[CalendarServer-changes] [8650] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Sat Feb 11 12:15:52 PST 2012


Revision: 8650
          http://trac.macosforge.org/projects/calendarserver/changeset/8650
Author:   cdaboo at apple.com
Date:     2012-02-11 12:15:52 -0800 (Sat, 11 Feb 2012)
Log Message:
-----------
Make sure that calendar color is copied over during direct share.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/customxml.py
    CalendarServer/trunk/twistedcaldav/sharing.py

Modified: CalendarServer/trunk/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/customxml.py	2012-02-11 20:13:58 UTC (rev 8649)
+++ CalendarServer/trunk/twistedcaldav/customxml.py	2012-02-11 20:15:52 UTC (rev 8650)
@@ -1103,6 +1103,14 @@
     name = "max-bytes"
 
 
+#
+# Client properties we might care about
+#
+
+class CalendarColor(davxml.WebDAVTextElement):
+    namespace = "http://apple.com/ns/ical/"
+    name = "calendar-color"
+
 ##
 # Extensions to davxml.ResourceType
 ##

Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py	2012-02-11 20:13:58 UTC (rev 8649)
+++ CalendarServer/trunk/twistedcaldav/sharing.py	2012-02-11 20:15:52 UTC (rev 8650)
@@ -1,6 +1,6 @@
 # -*- test-case-name: twistedcaldav.test.test_sharing -*-
 ##
-# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2012 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -1035,13 +1035,25 @@
             share = SharedCollectionRecord(shareUID, sharetype, hostUrl, str(uuid4()), displayname)
             yield self.sharesDB().addOrUpdateRecord(share)
         
-        # Set per-user displayname to whatever was given
+        # Get shared collection in non-share mode first
         sharedCollection = (yield request.locateResource(hostUrl))
         ownerPrincipal = (yield self.ownerPrincipal(request))
+
+        # For a direct share we will copy any calendar-color over using the owners view
+        color = None
+        if sharetype == SHARETYPE_DIRECT and not oldShare and sharedCollection.isCalendarCollection():
+            try:
+                color = (yield sharedCollection.readProperty(customxml.CalendarColor, request))
+            except HTTPError:
+                pass
+        
+        # Set per-user displayname or color to whatever was given
         sharedCollection.setVirtualShare(ownerPrincipal, share)
         if displayname:
             yield sharedCollection.writeProperty(davxml.DisplayName.fromString(displayname), request)
-        
+        if color:
+            yield sharedCollection.writeProperty(customxml.CalendarColor.fromString(color), request)
+
         # Calendars always start out transparent and with empty default alarms
         if not oldShare and sharedCollection.isCalendarCollection():
             yield sharedCollection.writeProperty(caldavxml.ScheduleCalendarTransp(caldavxml.Transparent()), request)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120211/e93dac2f/attachment-0001.html>


More information about the calendarserver-changes mailing list