[CalendarServer-changes] [9842] CalendarServer/branches/users/gaya/inviteclean

source_changes at macosforge.org source_changes at macosforge.org
Sat Sep 22 20:36:01 PDT 2012


Revision: 9842
          http://trac.calendarserver.org//changeset/9842
Author:   gaya at apple.com
Date:     2012-09-22 20:36:01 -0700 (Sat, 22 Sep 2012)
Log Message:
-----------
update from trunk

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/inviteclean/HACKING
    CalendarServer/branches/users/gaya/inviteclean/README
    CalendarServer/branches/users/gaya/inviteclean/calendarserver/tap/caldav.py
    CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/httpTests.py
    CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/multiget.py
    CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/propfind.py
    CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/query.py
    CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/sync.py
    CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/sqlusage.py
    CalendarServer/branches/users/gaya/inviteclean/contrib/tools/readStats.py
    CalendarServer/branches/users/gaya/inviteclean/support/build.sh
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/customxml.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/ical.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/localization.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/mail.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/mkcol.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/stdconfig.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_localization.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py
    CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py

Added Paths:
-----------
    CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.txt
    CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.xml

Removed Paths:
-------------
    CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.txt
    CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.xml

Property Changed:
----------------
    CalendarServer/branches/users/gaya/inviteclean/


Property changes on: CalendarServer/branches/users/gaya/inviteclean
___________________________________________________________________
Modified: svn:mergeinfo
   - /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:9408-9805
   + /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:9408-9833

Modified: CalendarServer/branches/users/gaya/inviteclean/HACKING
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/HACKING	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/HACKING	2012-09-23 03:36:01 UTC (rev 9842)
@@ -52,7 +52,7 @@
 The source code to the Calendar and Contacts Server is available via
 Subversion at this repository URL:
 
-  http://svn.macosforge.org/repository/calendarserver/CalendarServer/trunk/
+  http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/
 
 You can also browse the repository directly using your web browser, or
 use WebDAV clients to browse the repository, such as Mac OS X's Finder

Modified: CalendarServer/branches/users/gaya/inviteclean/README
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/README	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/README	2012-09-23 03:36:01 UTC (rev 9842)
@@ -45,7 +45,7 @@
 
   ::
 
-    svn co http://svn.macosforge.org/repository/calendarserver/CalendarServer/trunk/ CalendarServer
+    svn co http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/ CalendarServer
 
 The server requires a number of libraries in order to operate, which
 will need to be placed as peers of the source directory.  The ``run``

Modified: CalendarServer/branches/users/gaya/inviteclean/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/calendarserver/tap/caldav.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/calendarserver/tap/caldav.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -405,7 +405,7 @@
                 access=os.W_OK,
                 create=(0750, config.UserName, config.GroupName),
             )
-        if config.DocumentRoot.startswith(config.ServerRoot + os.sep):
+        if config.DocumentRoot.startswith(config.DataRoot + os.sep):
             self.checkDirectory(
                 config.DocumentRoot,
                 "Document root",

Modified: CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/httpTests.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/httpTests.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/httpTests.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -30,14 +30,13 @@
             self.rows = rows
             self.timing = timing
         
-    def __init__(self, label, session, href, logFilePath):
+    def __init__(self, label, sessions, logFilePath):
         """
         @param label: label used to identify the test
         @type label: C{str}
         """
         self.label = label
-        self.session = session
-        self.baseHref = href
+        self.sessions = sessions
         self.logFilePath = logFilePath
         self.result = None
 

Modified: CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/multiget.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/multiget.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/multiget.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -26,15 +26,15 @@
     A multiget operation
     """
 
-    def __init__(self, label, session, href, logFilePath, count):
-        super(MultigetTest, self).__init__(label, session, href, logFilePath)
+    def __init__(self, label, sessions, logFilePath, count):
+        super(MultigetTest, self).__init__(label, sessions, logFilePath)
         self.count = count
     
     def doRequest(self):
         """
         Execute the actual HTTP request.
         """
-        hrefs = [joinURL(self.baseHref, "%d.ics" % (i+1,)) for i in range(self.count)]
+        hrefs = [joinURL(self.sessions[0].calendarHref, "%d.ics" % (i+1,)) for i in range(self.count)]
         props = (
             davxml.getetag,
             caldavxml.calendar_data,
@@ -42,12 +42,12 @@
         )
 
         # Create CalDAV multiget
-        request = Multiget(self.session, self.baseHref, hrefs, props)
+        request = Multiget(self.sessions[0], self.sessions[0].calendarHref, hrefs, props)
         result = ResponseDataString()
         request.setOutput(result)
     
         # Process it
-        self.session.runSession(request)
+        self.sessions[0].runSession(request)
     
         # If its a 207 we want to parse the XML
         if request.getStatusCode() == statuscodes.MultiStatus:

Modified: CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/propfind.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/propfind.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/propfind.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -25,8 +25,8 @@
     A propfind operation
     """
 
-    def __init__(self, label, session, href, logFilePath, depth=1):
-        super(PropfindTest, self).__init__(label, session, href, logFilePath)
+    def __init__(self, label, sessions, logFilePath, depth=1):
+        super(PropfindTest, self).__init__(label, sessions, logFilePath)
         self.depth = headers.Depth1 if depth == 1 else headers.Depth0
     
     def doRequest(self):
@@ -39,12 +39,12 @@
         )
 
         # Create WebDAV propfind
-        request = PropFind(self.session, self.baseHref, self.depth, props)
+        request = PropFind(self.sessions[0], self.sessions[0].calendarHref, self.depth, props)
         result = ResponseDataString()
         request.setOutput(result)
     
         # Process it
-        self.session.runSession(request)
+        self.sessions[0].runSession(request)
     
         # If its a 207 we want to parse the XML
         if request.getStatusCode() == statuscodes.MultiStatus:

Modified: CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/query.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/query.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/query.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -60,8 +60,8 @@
     A sync operation
     """
 
-    def __init__(self, label, session, href, logFilePath, count):
-        super(QueryTest, self).__init__(label, session, href, logFilePath)
+    def __init__(self, label, sessions, logFilePath, count):
+        super(QueryTest, self).__init__(label, sessions, logFilePath)
         self.count = count
     
     def prepare(self):
@@ -74,8 +74,8 @@
         self.end = self.start.duplicate()
         self.end.offsetHours(1)
         for i in range(self.count):
-            href = joinURL(self.baseHref, "tr-query-%d.ics" % (i+1,))
-            self.session.writeData(URL(path=href), ICAL % (self.start.getText(), i+1,), "text/calendar")
+            href = joinURL(self.sessions[0].calendarHref, "tr-query-%d.ics" % (i+1,))
+            self.sessions[0].writeData(URL(path=href), ICAL % (self.start.getText(), i+1,), "text/calendar")
 
     def doRequest(self):
         """
@@ -87,12 +87,12 @@
         )
 
         # Create CalDAV query
-        request = QueryVEVENTTimeRange(self.session, self.baseHref, self.start.getText(), self.end.getText(), props)
+        request = QueryVEVENTTimeRange(self.sessions[0], self.sessions[0].calendarHref, self.start.getText(), self.end.getText(), props)
         result = ResponseDataString()
         request.setOutput(result)
     
         # Process it
-        self.session.runSession(request)
+        self.sessions[0].runSession(request)
     
         # If its a 207 we want to parse the XML
         if request.getStatusCode() == statuscodes.MultiStatus:
@@ -106,5 +106,5 @@
         """
         # Remove created resources
         for i in range(self.count):
-            href = joinURL(self.baseHref, "tr-query-%d.ics" % (i+1,))
-            self.session.deleteResource(URL(path=href))
+            href = joinURL(self.sessions[0].calendarHref, "tr-query-%d.ics" % (i+1,))
+            self.sessions[0].deleteResource(URL(path=href))

Modified: CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/sync.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/sync.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/requests/sync.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -58,8 +58,8 @@
     A sync operation
     """
 
-    def __init__(self, label, session, href, logFilePath, full, count):
-        super(SyncTest, self).__init__(label, session, href, logFilePath)
+    def __init__(self, label, sessions, logFilePath, full, count):
+        super(SyncTest, self).__init__(label, sessions, logFilePath)
         self.full = full
         self.count = count
         self.synctoken = ""
@@ -70,14 +70,14 @@
         """
         if not self.full:
             # Get current sync token
-            results, _ignore_bad = self.session.getProperties(URL(path=self.baseHref), (davxml.sync_token,))
+            results, _ignore_bad = self.sessions[0].getProperties(URL(path=self.sessions[0].calendarHref), (davxml.sync_token,))
             self.synctoken = results[davxml.sync_token]
             
             # Add resources to create required number of changes
             now = PyCalendarDateTime.getNowUTC()
             for i in range(self.count):
-                href = joinURL(self.baseHref, "sync-collection-%d.ics" % (i+1,))
-                self.session.writeData(URL(path=href), ICAL % (now.getYear() + 1, i+1,), "text/calendar")
+                href = joinURL(self.sessions[0].calendarHref, "sync-collection-%d.ics" % (i+1,))
+                self.sessions[0].writeData(URL(path=href), ICAL % (now.getYear() + 1, i+1,), "text/calendar")
 
     def doRequest(self):
         """
@@ -89,7 +89,7 @@
         )
 
         # Run sync collection
-        self.session.syncCollection(URL(path=self.baseHref), self.synctoken, props)
+        self.sessions[0].syncCollection(URL(path=self.sessions[0].calendarHref), self.synctoken, props)
 
     def cleanup(self):
         """
@@ -98,5 +98,5 @@
         if not self.full:
             # Remove created resources
             for i in range(self.count):
-                href = joinURL(self.baseHref, "sync-collection-%d.ics" % (i+1,))
-                self.session.deleteResource(URL(path=href))
+                href = joinURL(self.sessions[0].calendarHref, "sync-collection-%d.ics" % (i+1,))
+                self.sessions[0].deleteResource(URL(path=href))

Modified: CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/sqlusage.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/sqlusage.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/contrib/performance/sqlusage/sqlusage.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -19,13 +19,16 @@
 from caldavclientlibrary.protocol.url import URL
 from caldavclientlibrary.protocol.webdav.definitions import davxml
 from calendarserver.tools import tables
+from contrib.performance.sqlusage.requests.invite import InviteTest
 from contrib.performance.sqlusage.requests.multiget import MultigetTest
 from contrib.performance.sqlusage.requests.propfind import PropfindTest
+from contrib.performance.sqlusage.requests.put import PutTest
 from contrib.performance.sqlusage.requests.query import QueryTest
 from contrib.performance.sqlusage.requests.sync import SyncTest
 from pycalendar.datetime import PyCalendarDateTime
 from twext.web2.dav.util import joinURL
 import getopt
+import itertools
 import sys
 
 """
@@ -37,7 +40,7 @@
 with calendar size can be plotted. 
 """
 
-EVENT_COUNTS = (0, 1, 5, 10, 25, 50, 75, 100, 200, 300, 400, 500, 1000, 2000, 3000, 4000, 5000)
+EVENT_COUNTS = (0, 1, 5, 10, 50, 100, 500, 1000, 5000)
 
 ICAL = """BEGIN:VCALENDAR
 CALSCALE:GREGORIAN
@@ -72,48 +75,63 @@
 END:VCALENDAR
 """.replace("\n", "\r\n")
 
+class SQLUsageSession(CalDAVSession):
+    
+    def __init__(self, server, port=None, ssl=False, user="", pswd="", principal=None, root=None, logging=False):
+
+        super(SQLUsageSession, self).__init__(server, port, ssl, user, pswd, principal, root, logging)
+        self.homeHref = "/calendars/users/%s/" % (self.user,)
+        self.calendarHref = "/calendars/users/%s/calendar/" % (self.user,)
+        self.inboxHref = "/calendars/users/%s/inbox/" % (self.user,)
+        
+
 class SQLUsage(object):
     
-    def __init__(self, server, port, user, pswd, logFilePath):
+    def __init__(self, server, port, users, pswds, logFilePath):
         self.server = server
         self.port = port
-        self.user = user
-        self.pswd = pswd
+        self.users = users
+        self.pswds = pswds
         self.logFilePath = logFilePath
         self.requestLabels = []
         self.results = {}
         self.currentCount = 0
-        
-        self.userhref = "/calendars/users/%s/" % (self.user,)
 
-    def runLoop(self):
+    def runLoop(self, counts):
         
-        # Make the session
-        session = CalDAVSession(self.server, self.port, user=self.user, pswd=self.pswd, root="/")
+        # Make the sessions
+        sessions = [
+            SQLUsageSession(self.server, self.port, user=user, pswd=pswd, root="/")
+            for user, pswd in itertools.izip(self.users, self.pswds)
+        ]
 
         # Set of requests to execute
         requests = [
-            MultigetTest("multiget-1", session, joinURL(self.userhref, "calendar/"), self.logFilePath, 1),
-            MultigetTest("multiget-50", session, joinURL(self.userhref, "calendar/"), self.logFilePath, 50),
-            PropfindTest("propfind-cal", session, joinURL(self.userhref, "calendar/"), self.logFilePath, 1),
-            SyncTest("sync-full", session, joinURL(self.userhref, "calendar/"), self.logFilePath, True, 0),
-            SyncTest("sync-1", session, joinURL(self.userhref, "calendar/"), self.logFilePath, False, 1),
-            QueryTest("query-1", session, joinURL(self.userhref, "calendar/"), self.logFilePath, 1),
-            QueryTest("query-10", session, joinURL(self.userhref, "calendar/"), self.logFilePath, 10),
+            MultigetTest("multiget-1", sessions, self.logFilePath, 1),
+            MultigetTest("multiget-50", sessions, self.logFilePath, 50),
+            PropfindTest("propfind-cal", sessions, self.logFilePath, 1),
+            SyncTest("sync-full", sessions, self.logFilePath, True, 0),
+            SyncTest("sync-1", sessions, self.logFilePath, False, 1),
+            QueryTest("query-1", sessions, self.logFilePath, 1),
+            QueryTest("query-10", sessions, self.logFilePath, 10),
+            PutTest("put", sessions, self.logFilePath),
+            InviteTest("invite", sessions, self.logFilePath),
         ]
         self.requestLabels = [request.label for request in requests]
 
         # Warm-up server by doing calendar home and calendar propfinds
         props = (davxml.resourcetype,)
-        session.getPropertiesOnHierarchy(URL(path=self.userhref), props)
-        session.getPropertiesOnHierarchy(URL(path=joinURL(self.userhref, "calendar/")), props)
+        for session in sessions:
+            session.getPropertiesOnHierarchy(URL(path=session.homeHref), props)
+            session.getPropertiesOnHierarchy(URL(path=session.calendarHref), props)
         
         # Now loop over sets of events
-        for count in EVENT_COUNTS:
+        for count in counts:
             print "Testing count = %d" % (count,)
-            self.ensureEvents(session, count)
+            self.ensureEvents(sessions[0], sessions[0].calendarHref, count)
             result = {}
             for request in requests:
+                print "  Test = %s" % (request.label,)
                 result[request.label] = request.execute()
             self.results[count] = result
     
@@ -121,26 +139,26 @@
         
         self._printReport("SQL Statement Count", "count", "%d")
         self._printReport("SQL Rows Returned", "rows", "%d")
-        self._printReport("SQL Time", "timing", "%.3f")
+        self._printReport("SQL Time", "timing", "%.1f")
             
     def _printReport(self, title, attr, colFormat):
         table = tables.Table()
         
         print title
-        headers = ["Events"] + sorted([label for label in self.requestLabels])
+        headers = ["Events"] + self.requestLabels
         table.addHeader(headers)
         formats = [tables.Table.ColumnFormat("%d", tables.Table.ColumnFormat.RIGHT_JUSTIFY)] + \
             [tables.Table.ColumnFormat(colFormat, tables.Table.ColumnFormat.RIGHT_JUSTIFY)] * len(self.requestLabels)
         table.setDefaultColumnFormats(formats)
         for k in sorted(self.results.keys()):
-            row = [k] + [getattr(self.results[k][item], attr) for item in sorted(self.results[k].keys())]
+            row = [k] + [getattr(self.results[k][item], attr) for item in self.requestLabels]
             table.addRow(row)
         os = StringIO()
         table.printTable(os=os)
         print os.getvalue()
         print
             
-    def ensureEvents(self, session, n):
+    def ensureEvents(self, session, calendarhref, n):
         """
         Make sure the required number of events are present in the calendar.
     
@@ -150,7 +168,7 @@
         now = PyCalendarDateTime.getNowUTC()
         for i in range(n - self.currentCount):
             index = self.currentCount + i + 1
-            href = joinURL(self.userhref, "calendar", "%d.ics" % (index,))
+            href = joinURL(calendarhref, "%d.ics" % (index,))
             session.writeData(URL(path=href), ICAL % (now.getYear() + 1, index,), "text/calendar")
             
         self.currentCount = n
@@ -166,6 +184,7 @@
     --port         Server port
     --user         User name
     --pswd         Password
+    --counts       Comma-separated list of event counts to test
 
 Arguments:
     FILE           File name for sqlstats.log to analyze.
@@ -183,11 +202,12 @@
     
     server = "localhost"
     port = 8008
-    user = "user01"
-    pswd = "user01"
+    users = ("user01", "user02",)
+    pswds = ("user01", "user02",)
     file = "sqlstats.logs"
+    counts = EVENT_COUNTS
 
-    options, args = getopt.getopt(sys.argv[1:], "h", ["server", "port", "user", "pswd",])
+    options, args = getopt.getopt(sys.argv[1:], "h", ["server=", "port=", "user=", "pswd=", "counts=",])
 
     for option, value in options:
         if option == "-h":
@@ -197,9 +217,11 @@
         elif option == "--port":
             port = int(value)
         elif option == "--user":
-            user = value
+            users = value.split(",")
         elif option == "--pswd":
-            pswd = value
+            pswds = value.split(",")
+        elif option == "--counts":
+            counts = [int(i) for i in value.split(",")]
         else:
             usage("Unrecognized option: %s" % (option,))
 
@@ -209,6 +231,6 @@
     elif len(args) != 0:
         usage("Must zero or one file arguments")
 
-    sql = SQLUsage(server, port, user, pswd, file)
-    sql.runLoop()
+    sql = SQLUsage(server, port, users, pswds, file)
+    sql.runLoop(counts)
     sql.report()

Modified: CalendarServer/branches/users/gaya/inviteclean/contrib/tools/readStats.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/contrib/tools/readStats.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/contrib/tools/readStats.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -30,23 +30,42 @@
 def safeDivision(value, total, factor=1):
     return value * factor / total if total else 0
 
-def readSock(sockname):
-    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-    s.connect(sockname)
-    data = ""
-    while True:
-        d = s.recv(1024)
-        if d:
-            data += d
-        else:
-            break
-    s.close()
+def readSock(sockname, useTCP):
+    try:
+        s = socket.socket(socket.AF_INET if useTCP else socket.AF_UNIX, socket.SOCK_STREAM)
+        s.connect(sockname)
+        data = ""
+        while True:
+            d = s.recv(1024)
+            if d:
+                data += d
+            else:
+                break
+        s.close()
+        data = json.loads(data)
+    except socket.error:
+        data = {"Failed": "Unable to read statistics from server: %s" % (sockname,)}
+    data["Server"] = sockname
     return data
 
-def printStats(data):
+def printStats(stats):
+    if len(stats) == 1 and False:
+        if "Failed" in stats[0]:
+            printFailedStats(stats[0]["Failed"]) 
+        else:
+            try:
+                printStat(stats[0])
+            except KeyError, e:
+                printFailedStats("Unable to find key '%s' in statistics from server socket" % (e,))
+                sys.exit(1)
+            
+    else:
+        printMultipleStats(stats)
+        
+def printStat(stats):
     
-    stats = json.loads(data)
     print "- " * 40
+    print "Server: %s" % (stats["Server"],)
     print datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
     print "Service Uptime: %s" % (datetime.timedelta(seconds=(int(time.time() - stats["System"]["start time"]))),)
     if stats["System"]["cpu count"] > 0:
@@ -66,6 +85,42 @@
     printRequestSummary(stats)
     printHistogramSummary(stats["5 Minutes"])
 
+def printMultipleStats(stats):
+
+    labels = serverLabels(stats)
+ 
+    print "- " * 40
+    print "Servers: %s" % (", ".join(labels),)
+
+    print datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
+
+    times = []
+    for stat in stats:
+        try:
+            t = str(datetime.timedelta(seconds=int(time.time() - stat["System"]["start time"])))
+        except KeyError:
+            t = "-"
+        times.append(t)
+    print "Service Uptime: %s" % (", ".join(times),)
+
+    cpus = []
+    memories = []
+    for stat in stats:
+        if stat["System"]["cpu count"] > 0:
+            cpus.append("%.1f%%" % (stat["System"]["cpu use"],))
+            memories.append("%.1f%%" % (stat["System"]["memory percent"],))
+        else:
+            cpus.append("-")
+            memories("-")
+    print "Current CPU: %s" % (", ".join(cpus),)
+    print "Current Memory Used: %s" % (", ".join(memories),)
+    print
+    printMultiRequestSummary(stats, labels, ("5 Minutes", 5*60,))
+    printMultiHistogramSummary(stats, "5 Minutes")
+
+def serverLabels(stats):
+    return [str(stat["Server"]) for stat in stats]
+
 def printFailedStats(message):
     
     print "- " * 40
@@ -114,6 +169,57 @@
     table.printTable(os=os)
     print os.getvalue()
 
+def printMultiRequestSummary(stats, labels, index):
+    table = tables.Table()
+    table.addHeader(
+        ("Server", "Requests", "Av. Requests", "Av. Response", "Av. Response", "Max. Response",    "Slot",     "CPU", "500's"),
+    )
+    table.addHeader(
+        (      "",         "",   "per second",         "(ms)", "no write(ms)",          "(ms)", "Average", "Average",      ""),
+    )
+    table.setDefaultColumnFormats(
+       (
+            tables.Table.ColumnFormat("%s", tables.Table.ColumnFormat.LEFT_JUSTIFY), 
+            tables.Table.ColumnFormat("%d", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.1f", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.1f", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.1f", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.1f", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.2f", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.1f%%", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%d", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+        )
+    )
+    
+    key, seconds = index
+    totals = ["Overall:", 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0]
+    for ctr, stat in enumerate(stats):
+
+        stat = stat[key]
+        
+        col = []
+        col.append(labels[ctr])
+        col.append(stat["requests"])
+        col.append(safeDivision(float(stat["requests"]), seconds))
+        col.append(safeDivision(stat["t"], stat["requests"]))
+        col.append(safeDivision(stat["t"] - stat["t-resp-wr"], stat["requests"]))
+        col.append(stat["T-MAX"])
+        col.append(safeDivision(float(stat["slots"]), stat["requests"]))
+        col.append(safeDivision(stat["cpu"], stat["requests"]))
+        col.append(stat["500"])
+        table.addRow(col)
+        for item in xrange(1, len(col)):
+            totals[item] += col[item]
+    
+    for item in (2, 3, 4, 6, 7):
+        totals[item] /= len(stats)
+    
+    table.addFooter(totals)
+
+    os = StringIO()
+    table.printTable(os=os)
+    print os.getvalue()
+
 def printHistogramSummary(stat):
     
     print "5 minute average response histogram"
@@ -152,7 +258,58 @@
     table.printTable(os=os)
     print os.getvalue()
     
+def printMultiHistogramSummary(stats, index):
     
+    # Totals first
+    keys = ("requests", "<10ms", "10ms<->100ms", "100ms<->1s", "1s<->10s", "10s<->30s", "30s<->60s", ">60s", "Over 1s", "Over 10s",)
+    totals = {
+        "T"        : dict([(k, 0) for k in keys]),
+        "T-RESP-WR": dict([(k, 0) for k in keys]),
+    }
+    
+    for stat in stats:
+        for i in ("T", "T-RESP-WR",):
+            totals[i][keys[0]] += stat[index][keys[0]]
+            for k in keys[1:]:
+                totals[i][k] += stat[index][i][k]
+
+    print "5 minute average response histogram"
+    table = tables.Table()
+    table.addHeader(
+        ("", "<10ms", "10ms<->100ms", "100ms<->1s", "1s<->10s", "10s<->30s", "30s<->60s", ">60s",  "Over 1s", "Over 10s"),
+    )
+    table.setDefaultColumnFormats(
+       (
+            tables.Table.ColumnFormat("%s", tables.Table.ColumnFormat.CENTER_JUSTIFY), 
+            tables.Table.ColumnFormat("%d (%.1f%%)", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%d (%.1f%%)", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%d (%.1f%%)", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%d (%.1f%%)", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%d (%.1f%%)", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%d (%.1f%%)", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%d (%.1f%%)", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.1f%%", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+            tables.Table.ColumnFormat("%.1f%%", tables.Table.ColumnFormat.RIGHT_JUSTIFY),
+        )
+    )
+    for i in ("T", "T-RESP-WR",):
+        table.addRow((
+            "Overall Response" if i == "T" else "Response without Write",
+            (totals[i]["<10ms"], safeDivision(totals[i]["<10ms"], totals[i]["requests"], 100.0)),
+            (totals[i]["10ms<->100ms"], safeDivision(totals[i]["10ms<->100ms"], totals[i]["requests"], 100.0)),
+            (totals[i]["100ms<->1s"], safeDivision(totals[i]["100ms<->1s"], totals[i]["requests"], 100.0)),
+            (totals[i]["1s<->10s"], safeDivision(totals[i]["1s<->10s"], totals[i]["requests"], 100.0)),
+            (totals[i]["10s<->30s"], safeDivision(totals[i]["10s<->30s"], totals[i]["requests"], 100.0)),
+            (totals[i]["30s<->60s"], safeDivision(totals[i]["30s<->60s"], totals[i]["requests"], 100.0)),
+            (totals[i][">60s"], safeDivision(totals[i][">60s"], totals[i]["requests"], 100.0)),
+            safeDivision(totals[i]["Over 1s"], totals[i]["requests"], 100.0),
+            safeDivision(totals[i]["Over 10s"], totals[i]["requests"], 100.0),
+        ))
+    os = StringIO()
+    table.printTable(os=os)
+    print os.getvalue()
+    
+    
 def usage(error_msg=None):
     if error_msg:
         print error_msg
@@ -162,6 +319,7 @@
     -h            Print this help and exit
     -s            Name of local socket to read from
     -t            Delay in seconds between each sample [10 seconds]
+    --tcp host:port Use TCP connection with host:port
 
 Description:
     This utility will print a summary of statistics read from a
@@ -177,25 +335,22 @@
 if __name__ == '__main__':
     
     delay = 10
-    sockname = "data/Logs/state/caldavd-stats.sock"
+    servers = ("data/Logs/state/caldavd-stats.sock",)
+    useTCP = False
 
-    options, args = getopt.getopt(sys.argv[1:], "hs:t:", [])
+    options, args = getopt.getopt(sys.argv[1:], "hs:t:", ["tcp=",])
 
     for option, value in options:
         if option == "-h":
             usage()
         elif option == "-s":
-            sockname = value
+            servers = value.split(",")
         elif option == "-t":
             delay = int(value)
+        elif option == "--tcp":
+            servers = [(host, int(port),) for host, port in [server.split(":") for server in value.split(",")]]
+            useTCP = True
 
     while True:
-        try:
-            printStats(readSock(sockname))
-        except socket.error:
-            printFailedStats("Unable to read statistics from server socket: %s" % (sockname,))
-        except KeyError, e:
-            printFailedStats("Unable to find key '%s' in statistics from server socket" % (e,))
-            sys.exit(1)
-
+        printStats([readSock(server, useTCP) for server in servers])
         time.sleep(delay)

Deleted: CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.txt
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.txt	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.txt	2012-09-23 03:36:01 UTC (rev 9842)
@@ -1,1736 +0,0 @@
-
-
-
-Calendar Server Extension                                       C. Daboo
-                                                                 E. York
-                                                              Apple Inc.
-                                                         October 6, 2010
-
-
-                Shared and Published Calendars in CalDAV
-
-Abstract
-
-   This specification defines an extension to CalDAV that enables the
-   sharing of calendars between users on a CalDAV server.
-
-
-Table of Contents
-
-   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
-   2.  Conventions Used in This Document  . . . . . . . . . . . . . .  3
-   3.  Overview . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
-   4.  Notifications  . . . . . . . . . . . . . . . . . . . . . . . .  5
-     4.1.  Additional Principal Properties  . . . . . . . . . . . . .  5
-       4.1.1.  CS:notification-URL Property . . . . . . . . . . . . .  6
-     4.2.  Properties on Notification Resources . . . . . . . . . . .  6
-       4.2.1.  CS:notificationtype Property . . . . . . . . . . . . .  6
-   5.  Shared Calendaring . . . . . . . . . . . . . . . . . . . . . .  7
-     5.1.  Feature Discovery  . . . . . . . . . . . . . . . . . . . .  7
-     5.2.  Additional Properties for Calendars  . . . . . . . . . . .  7
-       5.2.1.  DAV:resourcetype Property  . . . . . . . . . . . . . .  7
-       5.2.2.  CS:invite Property . . . . . . . . . . . . . . . . . .  8
-       5.2.3.  CS:allowed-sharing-modes Property  . . . . . . . . . .  8
-       5.2.4.  CS:shared-url Property . . . . . . . . . . . . . . . .  9
-     5.3.  Sharer Actions on Shared Calendars . . . . . . . . . . . .  9
-       5.3.1.  Creating a Shared Calendar . . . . . . . . . . . . . .  9
-         5.3.1.1.  Example: Successful MKCALENDAR Request . . . . . . 10
-         5.3.1.2.  Example: Successful Extended MKCOL Request . . . . 10
-       5.3.2.  Sharing an Existing Calendar . . . . . . . . . . . . . 11
-         5.3.2.1.  Example: Successful PROPPATCH Request  . . . . . . 11
-       5.3.3.  Manipulating Sharees of a Shared Calendar  . . . . . . 12
-         5.3.3.1.  Example: Successful Sharee Add Request . . . . . . 13
-         5.3.3.2.  Example: Successful Multiple Sharee Change
-                   Request  . . . . . . . . . . . . . . . . . . . . . 14
-     5.4.  Sharee Actions on Shared Calendars . . . . . . . . . . . . 15
-       5.4.1.  Replying to a Sharing Invite . . . . . . . . . . . . . 15
-       5.4.2.  Removing a Shared Calendar . . . . . . . . . . . . . . 16
-     5.5.  General Considerations . . . . . . . . . . . . . . . . . . 16
-       5.5.1.  Access Levels  . . . . . . . . . . . . . . . . . . . . 16
-       5.5.2.  Allowing or Disallowing Sharing  . . . . . . . . . . . 16
-       5.5.3.  Per-user WebDAV Properties . . . . . . . . . . . . . . 17
-
-
-
-Daboo & York                                                    [Page 1]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-       5.5.4.  Per-user Calendar Data . . . . . . . . . . . . . . . . 17
-       5.5.5.  Scheduling . . . . . . . . . . . . . . . . . . . . . . 18
-   6.  XML Element Definitions  . . . . . . . . . . . . . . . . . . . 19
-     6.1.  CS:shared-owner  . . . . . . . . . . . . . . . . . . . . . 19
-     6.2.  CS:shared  . . . . . . . . . . . . . . . . . . . . . . . . 20
-     6.3.  CS:can-be-shared . . . . . . . . . . . . . . . . . . . . . 20
-     6.4.  CS:can-be-published  . . . . . . . . . . . . . . . . . . . 21
-     6.5.  CS:user  . . . . . . . . . . . . . . . . . . . . . . . . . 21
-     6.6.  CS:invite-noresponse . . . . . . . . . . . . . . . . . . . 21
-     6.7.  CS:invite-deleted  . . . . . . . . . . . . . . . . . . . . 22
-     6.8.  CS:invite-accepted . . . . . . . . . . . . . . . . . . . . 22
-     6.9.  CS:invite-declined . . . . . . . . . . . . . . . . . . . . 22
-     6.10. CS:invite-invalid  . . . . . . . . . . . . . . . . . . . . 23
-     6.11. CS:access  . . . . . . . . . . . . . . . . . . . . . . . . 23
-     6.12. CS:read  . . . . . . . . . . . . . . . . . . . . . . . . . 24
-     6.13. CS:read-write  . . . . . . . . . . . . . . . . . . . . . . 24
-     6.14. CS:summary . . . . . . . . . . . . . . . . . . . . . . . . 24
-     6.15. CS:invite-notification . . . . . . . . . . . . . . . . . . 25
-     6.16. CS:uid . . . . . . . . . . . . . . . . . . . . . . . . . . 25
-     6.17. CS:hosturl . . . . . . . . . . . . . . . . . . . . . . . . 25
-     6.18. CS:organizer . . . . . . . . . . . . . . . . . . . . . . . 26
-     6.19. CS:common-name . . . . . . . . . . . . . . . . . . . . . . 26
-     6.20. CS:invite-reply  . . . . . . . . . . . . . . . . . . . . . 26
-     6.21. CS:in-reply-to . . . . . . . . . . . . . . . . . . . . . . 27
-     6.22. CS:notification  . . . . . . . . . . . . . . . . . . . . . 27
-     6.23. CS:dtstamp . . . . . . . . . . . . . . . . . . . . . . . . 28
-     6.24. CS:share . . . . . . . . . . . . . . . . . . . . . . . . . 28
-     6.25. CS:set . . . . . . . . . . . . . . . . . . . . . . . . . . 28
-     6.26. CS:remove  . . . . . . . . . . . . . . . . . . . . . . . . 29
-     6.27. CS:shared-as . . . . . . . . . . . . . . . . . . . . . . . 29
-   7.  Security Considerations  . . . . . . . . . . . . . . . . . . . 29
-   8.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 29
-   9.  Acknowledgments  . . . . . . . . . . . . . . . . . . . . . . . 30
-   10. Normative References . . . . . . . . . . . . . . . . . . . . . 30
-   Appendix A.  Change History  . . . . . . . . . . . . . . . . . . . 30
-   Appendix B.  Change History  . . . . . . . . . . . . . . . . . . . 30
-   Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 31
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Daboo & York                                                    [Page 2]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-1.  Introduction
-
-   CalDAV [RFC4791] provides a way for calendar users to store calendar
-   data and exchange this data via scheduling operations.  Based on the
-   WebDAV [RFC4918] protocol, it also includes the ability to manage
-   access to calendar data via the WebDAV ACL [RFC3744] extension.
-
-   WebDAV ACL [RFC3744] provides a way to manage fine-grained access
-   controls on WebDAV resources.  Whilst this could be used directly to
-   manage sharing of calendars, experience has shown that client
-   developers are averse to using it due to its complexity.  Instead a
-   simpler process for sharing calendars is preferred.
-
-   This extension defines a way for individual calendar users to share
-   calendars with other users.  This is done via an "opt-in" process in
-   which a sharing invite is sent from the sharer to a sharee, allowing
-   the sharee to accept or decline.  If the sharee accepts the sharing
-   invite, the shared calendar is made available to them in their own
-   calendar home collection (i.e., alongside their own personal
-   calendars).  HTTP POST operations are used to manage the sharing
-   invitations and replies, and WebDAV properties are used to expose the
-   state of shared calendars.
-
-
-2.  Conventions Used in This Document
-
-   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
-   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
-   document are to be interpreted as described in [RFC2119].
-
-   When XML element types in the namespaces "DAV:" and
-   "urn:ietf:params:xml:ns:caldav" are referenced in this document
-   outside of the context of an XML fragment, the string "DAV:" and
-   "CALDAV:" will be prefixed to the element type names respectively.
-
-   The namespace "http://calendarserver.org/ns/" is used for XML
-   elements defined in this specification.  When XML element types in
-   that namespace are referenced in this document outside of the context
-   of an XML fragment, the string "CS:" will be prefixed to the element
-   type names.
-
-   Terms Used:
-
-   Sharer  A calendar user who is sharing a calendar with other calendar
-      users.
-
-
-
-
-
-
-Daboo & York                                                    [Page 3]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Sharee  A calendar user to whom a calendar has been shared.
-
-   Sharing Invite  A message sent by a sharer to a sharee to indicate
-      the status of a shared calendar.
-
-   Sharing Reply  A message sent by a sharee to a sharer to indicate the
-      status of a shared calendar.
-
-
-3.  Overview
-
-   This section provides a basic overview of this protocol by way of a
-   simple use case of a sharer sharing a calendar with a single sharee.
-
-   To share a calendar with another user, the sharer's client executes
-   an HTTP POST request against the calendar collection resource for the
-   calendar to be shared.  The POST request body will contain details of
-   the calendar user to whom the calendar is to be shared as well as the
-   access right to be granted to them.  If the request succeeds, a
-   notification is sent to the sharee with details of the calendar being
-   shared to them.
-
-   The sharer's client will show the notification to the sharee and
-   present them with the choice to accept or decline the invitation to
-   the shared calendar.  If the sharee chooses to decline, then nothing
-   changes for that sharee.  If the sharee chooses to accept, then the
-   server automatically creates a new calendar collection resource in
-   the sharee's calendar home collection, and ensures that calendar
-   provides a mapping to the actual shared calendar of the sharer.  Thus
-   the shared calendar is available to the sharee as just another
-   calendar in their calendar home.  The server enforces the appropriare
-   access privileges for the sharee.
-
-   At any time, the sharer can inspect properties on the calendar
-   collection being shared, and determine the accept/decline status of
-   each sharee.  Additional sharees can be added and existing ones
-   removed.  The access privileges for existing sharees can also be
-   changed.
-
-   Once a sharee has a shared calendar set to appear in their calendar
-   home collection, they can remove it and decline the sharing invite by
-   simply having their client issue an HTTP DELETE request on the shared
-   calendar collection.  That does not delete any calendar data, but
-   rather simply removes the "link" to the sharer's calendar collection
-   and sets the sharee's inviate status to declined.
-
-
-
-
-
-
-Daboo & York                                                    [Page 4]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-4.  Notifications
-
-   In order to facilitate the process of sharing invitations, this
-   specification defines a new generic notification mechanism for CalDAV
-   servers.  When this feature is available, a CS:notification-URL
-   (Section 4.1.1) property appears on principal resources for those
-   principals who are able to receive notifications.  That property
-   specifies a single DAV:href element whose content refers to a WebDAV
-   collection resource.  Notification "messages" are deposited into this
-   collection and can be retrieved by clients and acted on accordingly.
-
-   The notification collection referenced by the CS:notification-URL
-   (Section 4.1.1) property MUST have a DAV:resourcetype property with
-   DAV:collection and CS:notification (Section 6.22) child elements.
-
-   Notification "messages" are XML documents stored as resources in the
-   notification collection.  Each XML document contains a CS:
-   notification (Section 6.22) element as its root.  The root element
-   contains a CS:dtstamp (Section 6.23) element, and one additional
-   element which represents the type of notification being conveyed in
-   the message.  That child element will typically contain additional
-   content that describes the notification.
-
-   Each notification resource has a CS:notificationtype (Section 4.2.1)
-   property which contains as its single child element an empty element
-   that matches the child element of the notification resource XML
-   document root.  Any attributes on the child element in the XML
-   document are also present in the property child element.
-
-   Notifications are automatically generated by the server (perhaps in
-   response to a client action) with an appropriate resource stored in
-   the notifications collection of the user to whom the notification is
-   targeted.  Clients SHOULD monitor the notification collection looking
-   for new notification resources.  When doing so, clients SHOULD look
-   at the CS:notificationtype (Section 4.2.1) property to ensure that
-   the notification is of a type that the client can handle.  Once a
-   client has handled the notification in whatever way is appropriate it
-   SHOULD delete the notification resource.  Servers MAY delete
-   notification resources on their own if they determine that the
-   notifications are no longer relevant or valid.  Servers MAY coalesce
-   notifications as appropriate.
-
-4.1.  Additional Principal Properties
-
-   This section defines new properties for WebDAV principal resources as
-   defined in RFC3744 [RFC3744].  These properties are likely to be
-   protected but the server MAY allow them to be written by appropriate
-   users.
-
-
-
-Daboo & York                                                    [Page 5]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-4.1.1.  CS:notification-URL Property
-
-   Name:  notification-URL
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Identify the URL of the notification collection owned by
-      the associated principal resource.
-
-   Protected:  This property SHOULD be protected.
-
-   PROPFIND behavior:  This property SHOULD NOT be returned by a
-      PROPFIND allprop request (as defined in Section 14.2 of
-      [RFC4918]).
-
-   COPY/MOVE behavior:  This property value SHOULD be preserved in COPY
-      and MOVE operations.
-
-   Description:  This property is needed for a client to determine where
-      the notification collection of the current user is located so that
-      processing of notification messages can occur.  If not present,
-      then the associated calendar user is not enabled for notification
-      messages on the server.
-
-   Definition:
-
-   <!ELEMENT notification-URL (DAV:href)>
-
-4.2.  Properties on Notification Resources
-
-   The following new WebDAV properties are defined for notification
-   resources.
-
-4.2.1.  CS:notificationtype Property
-
-   Name:  notificationtype
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Identify the type of notification of the corresponding
-      resource.
-
-   Protected:  This property MUST be protected.
-
-   PROPFIND behavior:  This property SHOULD NOT be returned by a
-      PROPFIND allprop request (as defined in Section 14.2 of
-      [RFC4918]).
-
-
-
-
-Daboo & York                                                    [Page 6]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   COPY/MOVE behavior:  This property value MUST be preserved in COPY
-      and MOVE operations.
-
-   Description:  This property allows a client, via a PROPFIND Depth:1
-      request, to quickly find notification messages that the client can
-      handle in a notification collection.  The single child element is
-      the notification resource root element's child defining the
-      notification itself.  This element MUST be empty, though any
-      attributes on the element in the notification resource MUST be
-      present in the property element.
-
-   Definition:
-
-   <!ELEMENT notificationtype (invite-notification | invite-reply)>
-   <!-- Child elements are empty but will have appropriate attributes.
-        Any valid notification message child element can appear.-->
-
-
-5.  Shared Calendaring
-
-5.1.  Feature Discovery
-
-   A server that supports the features described in this document MUST
-   include "calendarserver-sharing" as a field in the DAV response
-   header from an OPTIONS request on any resource that supports these
-   features.
-
-5.2.  Additional Properties for Calendars
-
-   The following new or modified WebDAV properties are defined for
-   calendar collections and used to view or manipulate shared calendar
-   features.
-
-5.2.1.  DAV:resourcetype Property
-
-   Calendar collections that are shared have addition elements listed in
-   their DAV:resourcetype property in addition to DAV:collection and
-   CALDAV:calendar.
-
-   o  CS:shared-owner (Section 6.1): used to indicate that the calendar
-      is owned by the current user and is being shared by them.
-
-   o  CS:shared (Section 6.2): used to indicate that the calendar is
-      owned by another user and is being shared to the current user.
-
-
-
-
-
-
-
-Daboo & York                                                    [Page 7]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-5.2.2.  CS:invite Property
-
-   Name:  invite
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Used to show to whom a calendar has been shared.
-
-   Protected:  This property MUST be protected.
-
-   PROPFIND behavior:  This property SHOULD NOT be returned by a
-      PROPFIND allprop request (as defined in Section 14.2 of
-      [RFC4918]).
-
-   COPY/MOVE behavior:  This property value MUST be preserved in COPY
-      and MOVE operations.
-
-   Description:  This WebDAV property is present on a calendar
-      collection resource that has been shared by the owner.  It MUST
-      NOT appear on the calendar collection resources of the sharees of
-      the calendar.  It provides a list of users to whom the calendar
-      has been shared, along with the "status" of the sharing invites
-      sent to each user.
-
-   Definition:
-
-   <!ELEMENT invite (user*)>
-
-5.2.3.  CS:allowed-sharing-modes Property
-
-   Name:  allowed-sharing-modes
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Used to show which modes of sharing are supported on a
-      calendar collection.
-
-   Protected:  This property MUST be protected.
-
-   PROPFIND behavior:  This property SHOULD NOT be returned by a
-      PROPFIND allprop request (as defined in Section 14.2 of
-      [RFC4918]).
-
-   COPY/MOVE behavior:  This property value MUST be preserved in COPY
-      and MOVE operations.
-
-
-
-
-
-
-Daboo & York                                                    [Page 8]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Description:  This WebDAV property is present on a calendar
-      collection resource that can been shared or published.  It
-      provides a list of options indicating what sharing modes are
-      allowed as per Section 5.5.2.
-
-   Definition:
-
-   <!ELEMENT allowed-sharing-modes
-             (can-be-shared?, can-be-published?)>
-
-5.2.4.  CS:shared-url Property
-
-   Name:  shared-url
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Indicates the URL of the owner's copy of a shared calendar.
-
-   Protected:  This property MUST be protected.
-
-   PROPFIND behavior:  This property SHOULD NOT be returned by a
-      PROPFIND allprop request (as defined in Section 14.2 of
-      [RFC4918]).
-
-   COPY/MOVE behavior:  This property value MUST be preserved in COPY
-      and MOVE operations.
-
-   Description:  This WebDAV property is present on a shared calendar
-      collection resource that appears in a sharee's calendar home
-      collection.  Its content is a single DAV:href element whose value
-      is the URL of the sharer's calendar being shared.
-
-   Definition:
-
-   <!ELEMENT shared-url (DAV:href)>
-
-5.3.  Sharer Actions on Shared Calendars
-
-5.3.1.  Creating a Shared Calendar
-
-   To create a shared calendar, clients use the MKCALENDAR [RFC4791] or
-   extended MKCOL [RFC5689] requests, and include a DAV:resourcetype
-   property to be set upon creation.  That property MUST contain DAV:
-   collection, CALDAV:calendar and CS:shared-owner child elements to
-   enable sharing.
-
-
-
-
-
-
-Daboo & York                                                    [Page 9]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-5.3.1.1.  Example: Successful MKCALENDAR Request
-
-   This example shows how the MKCALENDAR request is used to create a
-   shared calendar collection.  The response body is empty as the
-   request completed successfully.
-
-   >> Request <<
-
-   MKCALENDAR /calendars/users/cyrus/shared/ HTTP/1.1
-   Host: calendar.example.com
-   Content-Type: application/xml; charset="utf-8"
-   Content-Length: xxxx
-
-   <?xml version="1.0" encoding="utf-8" ?>
-   <C:mkcalendar xmlns:D="DAV:"
-                 xmlns:C="urn:ietf:params:xml:ns:caldav"
-                 xmlns:CS="http://calendarserver.org/ns/">
-     <D:set>
-       <D:prop>
-         <D:resourcetype>
-           <D:collection/>
-           <C:calendar/>
-           <CS:shared-owner/>
-         </D:resourcetype>
-       </D:prop>
-     </D:set>
-   </C:mkcalendar>
-
-   >> Response <<
-
-   HTTP/1.1 201 Created
-   Cache-Control: no-cache
-   Date: Sat, 11 Nov 2006 09:32:12 GMT
-
-5.3.1.2.  Example: Successful Extended MKCOL Request
-
-   This example shows how the extended MKCOL request is used to create a
-   shared calendar collection.  The response body is empty as the
-   request completed successfully.
-
-
-
-
-
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 10]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   >> Request <<
-
-   MKCOL /calendars/users/cyrus/shared/ HTTP/1.1
-   Host: calendar.example.com
-   Content-Type: application/xml; charset="utf-8"
-   Content-Length: xxxx
-
-   <?xml version="1.0" encoding="utf-8" ?>
-   <D:mkcol xmlns:D="DAV:"
-                 xmlns:C="urn:ietf:params:xml:ns:caldav"
-                 xmlns:CS="http://calendarserver.org/ns/">
-     <D:set>
-       <D:prop>
-         <D:resourcetype>
-           <D:collection/>
-           <C:calendar/>
-           <CS:shared-owner/>
-         </D:resourcetype>
-       </D:prop>
-     </D:set>
-   </D:mkcol>
-
-   >> Response <<
-
-   HTTP/1.1 201 Created
-   Cache-Control: no-cache
-   Date: Sat, 11 Nov 2006 09:32:12 GMT
-
-5.3.2.  Sharing an Existing Calendar
-
-   Sharing an existing calendar can be accomplished in two ways.  One
-   option is to use a PROPPATCH request to set the DAV:resourcetype
-   property to include CS:shared-owner as a child element.  Another
-   option is to add sharee's directly to the calendar collection (as
-   described in Section 5.3.3) - that action MUST upgrade a non-shared
-   calendar to a shared calendar when it completes successfully,
-   assuming that such an upgrade is allowed as per Section 5.5.2.
-
-5.3.2.1.  Example: Successful PROPPATCH Request
-
-   This example shows how the PROPPATCH request is used to upgrade to a
-   shared calendar collection.
-
-
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 11]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   >> Request <<
-
-   PROPPATCH /calendars/users/cyrus/shared/ HTTP/1.1
-   Host: calendar.example.com
-   Content-Type: application/xml; charset="utf-8"
-   Content-Length: xxxx
-
-   <?xml version="1.0" encoding="utf-8" ?>
-   <D:propertyupdate xmlns:D="DAV:"
-                 xmlns:C="urn:ietf:params:xml:ns:caldav"
-                 xmlns:CS="http://calendarserver.org/ns/">
-     <D:set>
-       <D:prop>
-         <D:resourcetype>
-           <D:collection/>
-           <C:calendar/>
-           <CS:shared-owner/>
-         </D:resourcetype>
-       </D:prop>
-     </D:set>
-   </D:propertyupdate>
-
-   >> Response <<
-
-   HTTP/1.1 207 Multi-Status
-   Date: Sat, 11 Nov 2006 09:32:12 GMT
-   Content-Type: application/xml; charset="utf-8"
-   Content-Length: xxxx
-
-   <?xml version="1.0" encoding="utf-8" ?>
-   <D:multistatus xmlns:D="DAV:">
-     <D:response>
-       <D:href>/calendars/users/cyrus/shared/</D:href>
-       <D:propstat>
-         <D:prop>
-           <D:resourcetype/>
-         </D:prop>
-         <D:status>HTTP/1.1 200 OK</D:status>
-       </D:propstat>
-     </D:response>
-   </D:multistatus>
-
-5.3.3.  Manipulating Sharees of a Shared Calendar
-
-   The sharer of a shared calendar is able to manipulate the sharee list
-   by issuing a POST request targeted at the shared calendar collection
-   resource.  The POST request MUST contain an XML document as its body
-   with the root element being CS:share (Section 6.24).
-
-
-
-Daboo & York                                                   [Page 12]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   The CS:share (Section 6.24) element in the POST requests MUST contain
-   one or more CS:set (Section 6.25) or CS:remove (Section 6.26)
-   elements.  For each CS:set (Section 6.25) element, the server MUST
-   add the specified sharee access to the shared calendar.  For each CS:
-   remove (Section 6.26) element the server MUST remove the specified
-   sharee access from the shared calendar.  In each case the server MUST
-   send a notification message to any sharees whose status is changed
-   (added, modified or removed), indicating to them a change in status
-   for the shared calendar.  The server SHOULD NOT send notification
-   messages to sharees whose status is unchanged.
-
-   Sharee's are identified via a DAV:href element whose value is either
-   a principal-URL for a sharee hosted on the same server, a calendar
-   user address or email address.  In the case of the later two, the
-   sharee might not be a user on the same server - though in that case
-   how invitations are sent or access enabled is out of scope for this
-   specification.  A server MAY change the sharee's "address" to any
-   suitable alternative that it might prefer when returning the list of
-   sharees via the CS:invite property (Section 5.2.2).
-
-   The client MAY include a CS:common-name (Section 6.19) element in the
-   CS:set (Section 6.25) element.  When provided, the value represents
-   the common name for the sharee, and is returned in the list of
-   sharees via the CS:invite property (Section 5.2.2).  The server MAY
-   change this to a suitable alternative when it is able to match the
-   sharee to a known user.  If absent from the client request, the
-   server SHOULD add a CS:common-name when it is able to match the
-   sharee with a known user, and a common name for that user can be
-   determined.
-
-   When the sharee list on a shared calendar is changed, the server MUST
-   send notifications to each sharee to update them on their current
-   sharing status.  This is accomplished by sending a CS:invite-
-   notification (Section 6.15) notification to each sharee.
-
-5.3.3.1.  Example: Successful Sharee Add Request
-
-   This example shows how to add a single sharee (with calendar user
-   address "mailto:eric at example.com") to a shared calendar with CS:read-
-   write access.
-
-
-
-
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 13]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   >> Request <<
-
-   POST /calendars/users/cyrus/shared/ HTTP/1.1
-   Host: calendar.example.com
-   Content-Type: application/xml; charset="utf-8"
-   Content-Length: xxxx
-
-   <?xml version="1.0" encoding="utf-8" ?>
-   <CS:share xmlns:D="DAV:"
-                 xmlns:CS="http://calendarserver.org/ns/">
-     <CS:set>
-       <D:href>mailto:eric at example.com</D:href>
-       <CS:common-name>Eric York</CS:common-name>
-       <CS:summary>Shared workspace</CS:summary>
-       <CS:read-write />
-     </CS:set>
-   </CS:share>
-
-   >> Response <<
-
-   HTTP/1.1 200 OK
-   Cache-Control: no-cache
-   Date: Sat, 11 Nov 2006 09:32:12 GMT
-
-5.3.3.2.  Example: Successful Multiple Sharee Change Request
-
-   This example shows how multiple sharee's can be manipulated in a
-   single request.  The sharee with calendar user address
-   "mailto:eric at example.com" has their access downgraded to CS:read,
-   whilst another sharee is removed from the access list entirely.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 14]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   >> Request <<
-
-   POST /calendars/users/cyrus/shared/ HTTP/1.1
-   Host: calendar.example.com
-   Content-Type: application/xml; charset="utf-8"
-   Content-Length: xxxx
-
-   <?xml version="1.0" encoding="utf-8" ?>
-   <CS:share xmlns:D="DAV:"
-                 xmlns:CS="http://calendarserver.org/ns/">
-     <CS:set>
-       <D:href>mailto:eric at example.com</D:href>
-       <CS:summary>Shared workspace</CS:summary>
-       <CS:read-write />
-     </CS:set>
-     <CS:remove>
-       <D:href>mailto:wilfredo at example.com</D:href>
-     </CS:remove>
-   </CS:share>
-
-   >> Response <<
-
-   HTTP/1.1 200 OK
-   Cache-Control: no-cache
-   Date: Sat, 11 Nov 2006 09:32:12 GMT
-
-5.4.  Sharee Actions on Shared Calendars
-
-5.4.1.  Replying to a Sharing Invite
-
-   When a sharee is invited to a shared calendar they can accept or
-   decline the invite by issuing a POST request to the sharee's calendar
-   home collection resource.  The POST request MUST contain an XML
-   document as its body with the root element being CS:invite-reply
-   (Section 6.20).
-
-   The CS:invite-reply (Section 6.20) element in the POST request
-   specifies the sharee who is replying in the DAV:href element, the
-   accept or decline action via the CS:invite-accepted or CS:invite-
-   declined elements, the URL of the shared calendar in the CS:hosturl
-   element, the unique identifier of the invite to which it is a reply
-   in the CS:in-reply-to element, and an optional CS:summary element.
-
-   The response to a POST request that accepts a shared calendar invite
-   MUST be an XML document containing CS:shared-as (Section 6.27) as its
-   root element.  That root element contains a single DAV:href element
-   whose content is the URI of the shared calendar in the sharee's
-   calendar home created by the invite acceptance.
-
-
-
-Daboo & York                                                   [Page 15]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   When the sharee replies to an invite, the server SHOULD send a
-   notification to the sharer to update them on the change in the sharee
-   state.  This is accomplished by sending a CS:invite-reply
-   (Section 6.20) notification to the sharer.
-
-5.4.2.  Removing a Shared Calendar
-
-   To remove a shared calendar from a sharee's calendar home collection
-   a DELETE request is targeted at the shared calendar URI.  When such a
-   request is received the server MUST remove the shared calendar from
-   the sharee's calendar home and automatically update the sharee's
-   status in the sharer's calendar's CS:invite property.
-
-5.5.  General Considerations
-
-5.5.1.  Access Levels
-
-   Two levels of access ca be granted by a sharer to any sharee.  These
-   are governed by the CS:access element used in the CS:invite/CS:user
-   element that specifies a shared user invite.  CS:access contains a
-   single empty element that defines the type of access granted:
-
-   CS:read  When present this indicates that sharees can read calendar
-      data but cannot change it.
-
-   CS:read-write  When present this indicates that sharees can read and
-      write calendar data.
-
-5.5.2.  Allowing or Disallowing Sharing
-
-   Servers MAY support calendar sharing on a per-calendar basis - e.g.,
-   they could treat some calendars as always private (cannot be shared)
-   or always public (always shared).  As a result clients need a way to
-   determine which calendar could be shared so they can enable or
-   disable sharing options on a per-calendar basis.
-
-   This specification adds a CS:allowed-sharing-modes (Section 5.2.3)
-   WebDAV property which servers can return on calendar collection
-   resources.  This property contains XML elements that describe which
-   sharing or publishing capabilities can be supported by the
-   corresponding calendar collection:
-
-      CS:can-be-shared (Section 6.3): when present indicates that the
-      calendar collection can be shared.  When not present, the calendar
-      collection cannot be shared.
-
-      CS:can-be-published (Section 6.4): when present indicates that the
-      calendar collection can be published.  When not present, the
-
-
-
-Daboo & York                                                   [Page 16]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-      calendar collection cannot be published.
-
-   When not present on a calendar collection, sharing or publishing of
-   that calendar is not allowed.  Clients SHOULD NOT attempt to use
-   requests to enable sharing or publishing targeted at those calendar
-   collections.
-
-5.5.3.  Per-user WebDAV Properties
-
-   Servers MUST support "per-user" WebDAV properties on shared calendar
-   collections and MAY support them on calendar object resources within
-   shared calendar collections.  A "per-user" WebDAV property is one
-   whose value can be set and retrieved independently by each user with
-   appropriate access rights. e.g., user "A" changes the DAV:displayname
-   property on a shared calendar in their calendar home to "My
-   calendar", and user "B" changes the same property to "Shared" on the
-   same shared calendar in their calendar home.  When each user
-   retrieves the property value they will see their own last stored
-   value and not the value of the other user.
-
-   For shared calendars, the server MUST allow all users to write "per-
-   user" WebDAV properties on the shared calendar collection and MAY
-   allow property writes on calendar object resources within the shared
-   calendar collection.  This is required even in the case where the
-   sharee has been granted read access only (i.e., the ability to change
-   calendar data is disallowed).  This requirement ensures that sharees
-   can always change "personal" properties such as calendar colors and
-   display names.
-
-   Servers MUST treat the following properties as "per-user":
-
-      DAV:displayname
-
-      CALDAV:calendar-description
-
-      CALDAV:schedule-calendar-transp
-
-      ICAL:calendar-color
-
-   Servers MAY treat any dead property as per-user.
-
-   Servers MUST NOT treat live properties as per-user.
-
-5.5.4.  Per-user Calendar Data
-
-   Servers MUST support "per-user" calendar data in calendar object
-   resources stored in shared calendars.  This allows each sharee and
-   the sharer to store their own alarms and free busy transparency
-
-
-
-Daboo & York                                                   [Page 17]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   status without "interfering" with other users who also have access to
-   the same calendar object resources.
-
-   For calendaring object resources in shared calendar collections, the
-   server MUST treat the following iCalendar data objects as per-user:
-
-      TRANSP property
-
-      VALARM component
-
-   Servers MAY treat any non-standard X- iCalendar properties as per-
-   user.
-
-   When handling per-user data in recurring components, servers SHOULD
-   eliminate overridden instances when returning iCalendar data to
-   clients in the case where there are no differences between the
-   overridden component and the instance that could be derived from the
-   "master" recurrence component.  For example, consider a daily
-   recurring event, Monday through Friday, initially defined without any
-   overridden instances, that is in a shared calendar.  If user "A"
-   overrides the Tuesday instance and adds their own "VALARM" component
-   only, then when user "A" later retrieves the data again they would
-   see that overridden instance, but when user "B" does so, they would
-   not.  This ensures that each user sees the most "compact"
-   representation of the calendar data.
-
-5.5.5.  Scheduling
-
-   CalDAV Scheduling [I-D.desruisseaux-caldav-sched] defines how a
-   CalDAV server carries out scheduling operations when calendar object
-   resources are created, modified or deleted and include "ORGANIZER"
-   and "ATTENDEE" iCalendar properties.
-
-   When calendar object resources are created, modified or deleted in
-   shared calendars by sharees, the following restrictions apply:
-
-   1.  The "ORGANIZER" iCalendar property value in the iCalendar data
-       MUST match a calendar user address of the sharer (owner) of the
-       shared calendar.  The DAV:owner WebDAV property MUST be present
-       on a shared calendar and MUST provide a reference to a principal-
-       URL of the sharer (owner) of the shared calendar.  Clients can
-       use this value to determine what the allowed "ORGANIZER"
-       iCalendar property values are.  The server MUST reject any
-       attempt by a sharee to create an iCalendar component with an
-       "ORGANIZER" property value other than the sharer (owner) of the
-       shared calendar.
-
-
-
-
-
-Daboo & York                                                   [Page 18]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   2.  The server MUST reject any attempt by a sharee to MOVE a calendar
-       object resource in a shared calendar to some other collection.
-
-   3.  When a sharee is listed as an Attendee in a calendar object
-       resource in a shared calendar, and write access is granted, the
-       sharee is allowed to change not only iCalendar data related to
-       the Organizer, but also data related to the Attendee. i.e., a
-       sharee can change their own participation status on the
-       "ATTENDEE" iCalendar property referring to them.  Additionally,
-       if the sharee is not listed as an Attendee, and write access is
-       granted, the sharee can add themselves as an Attendee.
-
-   4.  The default calendar collection defined in Section 6.3 of
-       [I-D.desruisseaux-caldav-sched] MUST NOT be a calendar shared to
-       the corresponding calendar user.
-
-   Following are additional considerations for scheduling with shared
-   calendars:
-
-   1.  A scheduled iCalendar component could appear in more than one
-       calendar collection within a sharee's calendar home if the sharee
-       is an Attendee and the Organizer or other Attendees have shared a
-       calendar with the sharee that includes their copies of the
-       iCalendar component.  It is important to note that the scheduled
-       component in the shared calendar could have different access
-       rights than the one in the sharee's owned calendar.
-
-   2.  A scheduled iCalendar component appearing in a sharee's shared
-       calendar could include the sharee as an Attendee.  For recurring
-       events, it is possible for the sharee to only be listed as an
-       Attendee in some instances, as opposed to all.  Clients will need
-       to be aware of this when allowing sharee's to set their own
-       participation status.
-
-   In addition, when a shared calendar is first accepted by a sharee,
-   the server SHOULD set the CALDAV:schedule-calendar-transp property to
-   the value CALDAV:transparent to ensure newly accepted shared
-   calendars do not contribute to the sharee's freebusy time until the
-   sharee explicitly requests it.
-
-
-6.  XML Element Definitions
-
-6.1.  CS:shared-owner
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 19]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Name:  shared-owner
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Used to indicate that a calendar is being shared by the
-      owner.
-
-   Description:  This property appears in the DAV:resourcetype property
-      on the calendar collection resource shared by a sharer.  See
-      Section 5.2.
-
-   Definition:
-
-   <!ELEMENT shared-owner EMPTY>
-
-6.2.  CS:shared
-
-   Name:  shared
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Used to indicate that a calendar is being shared to a
-      sharee.
-
-   Description:  This property appears in the DAV:resourcetype property
-      on a calendar collection resource that is shared to a sharee and
-      appears in the sharee's calendar home collection.  See
-      Section 5.2.
-
-   Definition:
-
-   <!ELEMENT shared EMPTY>
-
-6.3.  CS:can-be-shared
-
-   Name:  can-be-shared
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Used to indicate that a calendar can be shared.
-
-   Description:  This element indicates that a calendar can be shared
-      with other users.  See Section 5.2.3
-
-   Definition:
-
-   <!ELEMENT can-be-shared EMPTY>
-
-
-
-
-Daboo & York                                                   [Page 20]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-6.4.  CS:can-be-published
-
-   Name:  can-be-published
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Used to indicate that a calendar can be published.
-
-   Description:  This element indicates that a calendar can be published
-      to anyone.  See Section 5.2.3
-
-   Definition:
-
-   <!ELEMENT can-be-published EMPTY>
-
-6.5.  CS:user
-
-   Name:  user
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Used to show status of sharing invites sent to sharees.
-
-   Description:  This element provides the "status" of a sharing invite
-      sent to a particular user.  See Section 5.2.2.
-
-   Definition:
-
-   <!ELEMENT user (DAV:href, common-name?, (invite-noresponse |
-                   invite-accepted | invite-declined | invite-invalid),
-                   access, summary?)>
-
-6.6.  CS:invite-noresponse
-
-   Name:  invite-noresponse
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Sharing invite status.
-
-   Description:  When used in a CS:user (Section 6.5) element, this
-      element is used to indicate that the sharee has never replied to
-      the corresponding sharing invite.  When used in a CS:invite-
-      notification (Section 6.15) element, this element is used to
-      indicate to the sharee that a sharing reply is needed.
-
-
-
-
-
-
-Daboo & York                                                   [Page 21]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Definition:
-
-   <!ELEMENT invite-noresponse EMPTY>
-
-6.7.  CS:invite-deleted
-
-   Name:  invite-deleted
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Sharing invite status.
-
-   Description:  When used in a CS:invite-notification (Section 6.15)
-      element, this element is used to indicate to the sharee that a
-      shared calendar has been unshared by the sharer.
-
-   Definition:
-
-   <!ELEMENT invite-deleted EMPTY>
-
-6.8.  CS:invite-accepted
-
-   Name:  invite-accepted
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Sharing invite status.
-
-   Description:  When used in a CS:user (Section 6.5) element, this
-      element is used to indicate that the sharee has accepted the
-      corresponding sharing invite.  When used in a CS:invite-
-      notification (Section 6.15) element, this element is used to
-      indicate to the sharee that the sharing invite is an update for
-      one they previously accepted.
-
-   Definition:
-
-   <!ELEMENT invite-accepted EMPTY>
-
-6.9.  CS:invite-declined
-
-   Name:  invite-declined
-
-   Namespace:  http://calendarserver.org/ns/
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 22]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Purpose:  Sharing invite status.
-
-   Description:  When used in a CS:user (Section 6.5) element, this
-      element is used to indicate that the sharee has declined the
-      corresponding sharing invite.  When used in a CS:invite-
-      notification (Section 6.15) element, this element is used to
-      indicate to the sharee that the sharing invite is an update for
-      one they previously declined.
-
-   Definition:
-
-   <!ELEMENT invite-declined EMPTY>
-
-6.10.  CS:invite-invalid
-
-   Name:  invite-invalid
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Sharing invite status.
-
-   Description:  When used in a CS:user (Section 6.5) element, this
-      element is used to indicate that the corresponding sharee is not a
-      valid calendar user known to the server.
-
-   Definition:
-
-   <!ELEMENT invite-invalid EMPTY>
-
-6.11.  CS:access
-
-   Name:  access
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Shared calendar access level.
-
-   Description:  When used in a CS:user (Section 6.5) element, this
-      element is used to indicate the sharing access level granted to
-      the corresponding sharee.
-
-   Definition:
-
-   <!ELEMENT invite-invalid (read | read-write)>
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 23]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-6.12.  CS:read
-
-   Name:  read
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Shared calendar access level privilege.
-
-   Description:  Indicates that the access level granted only allows
-      sharees to read data in the shared calendar (though they can write
-      per-user data (Section 5.5.4)).
-
-   Definition:
-
-   <!ELEMENT read EMPTY>
-
-6.13.  CS:read-write
-
-   Name:  read-write
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Shared calendar access level privilege.
-
-   Description:  Indicates that the access level granted allows sharees
-      to read and write all data in the shared calendar, with the
-      exception of components that would trigger scheduling.
-
-   Definition:
-
-   <!ELEMENT read-write EMPTY>
-
-6.14.  CS:summary
-
-   Name:  summary
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Summary or title of shared calendar.
-
-   Description:  A brief description of a shared calendar.  This can be
-      used by sharers to communicate the nature of a shared calendar to
-      sharees, as well as used by sharees to indicate back to the sharer
-      how each sharee is refering to the shared calendar.
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 24]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Definition:
-
-   <!ELEMENT summary (#PCDATA)>
-
-6.15.  CS:invite-notification
-
-   Name:  invite-notification
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  A notification used as a shared calendar invite.
-
-   Description:  Defines a notification message sent automatically by
-      the server when a sharer adds, changes or removes a sharee from a
-      shared calendar.  The DAV:href element specifies the calendar user
-      address of the sharee to whom the message was sent.
-
-   Definition:
-
-   <!ELEMENT invite-notification (uid, DAV:href,
-                                  (invite-noresponse | invite-deleted |
-                                   invite-accepted | invite-declined),
-                                  access, hosturl, organizer, summary?>
-
-6.16.  CS:uid
-
-   Name:  uid
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Unique identifier.
-
-   Description:  A unique identifier for an invitation to a shared
-      calendar.
-
-   Definition:
-
-   <!ELEMENT uid (#PCDATA)>
-
-6.17.  CS:hosturl
-
-   Name:  hosturl
-
-   Namespace:  http://calendarserver.org/ns/
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 25]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Purpose:  Identifies the source URL of a shared calendar.
-
-   Description:  Contains a single DAV:href element that refers to the
-      source of a shared calendar - i.e., the URL of the calendar shared
-      by the sharer.
-
-   Definition:
-
-   <!ELEMENT hosturl (DAV:href)>
-
-6.18.  CS:organizer
-
-   Name:  organizer
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Identifies the sharer of a shared calendar.
-
-   Description:  Contains a single DAV:href element that identifies the
-      calendar user address of the sharer of a shared calendar, and an
-      optional CS:common-name element that matches that user.
-
-   Definition:
-
-   <!ELEMENT organizer (DAV:href, CS:common-name?)>
-
-6.19.  CS:common-name
-
-   Name:  common-name
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  The common name of a sharer or sharee.
-
-   Description:  The common name is optionally provided by a client when
-      adding a sharee and optionally included (or modified) by the
-      server when returning results for sharers or sharees and in
-      notifications.
-
-   Definition:
-
-   <!ELEMENT common-name (#PCDATA)>
-
-6.20.  CS:invite-reply
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 26]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-   Name:  invite-reply
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  A notification used as a reply to a shared calendar invite.
-
-   Description:  Defines a notification message sent automatically by
-      the server when a sharee replies to a shared calendar invite.  The
-      DAV:href element specifies the calendar user address of the sharee
-      to whom the original invite message was sent.
-
-   Definition:
-
-   <!ELEMENT invite-reply (DAV:href,
-                           (invite-accepted | invite-declined),
-                           hosturl, in-reply-to, summary?>
-
-6.21.  CS:in-reply-to
-
-   Name:  in-reply-to
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Unique identifier.
-
-   Description:  Specifies the unique identifier of the inviate message
-      that this notification message is a reply to.
-
-   Definition:
-
-   <!ELEMENT in-reply-to (#PCDATA)>
-
-6.22.  CS:notification
-
-   Name:  notification
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Notification message root element.
-
-   Description:  The root element used in notification resources.
-
-   Definition:
-
-   <!ELEMENT notification (CS:dtstamp,
-                           (invite-notification | invite-reply)>
-   <!-- Any notification type element can appear after CS:dtstamp,
-        this specification defines only the two listed above -->
-
-
-
-Daboo & York                                                   [Page 27]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-6.23.  CS:dtstamp
-
-   Name:  dtstamp
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Date-time stamp.
-
-   Description:  Contains the date-time stamp corresponding to the
-      creation of a notification message.
-
-   Definition:
-
-   <!ELEMENT dtstamp (#PCDATA)>
-
-6.24.  CS:share
-
-   Name:  share
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Describes changes to sharees.
-
-   Description:  The root element used in POST requests on calendars by
-      sharers to manipulate the sharee list of a shared calendar.
-
-   Definition:
-
-   <!ELEMENT share (set | remove)*>
-
-6.25.  CS:set
-
-   Name:  set
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Sets access for a sharee.
-
-   Description:  Used to add or modify sharee access to a shared
-      calendar.  The specified access to the shared calendar is given to
-      the sharee.
-
-   Definition:
-
-   <!ELEMENT set (DAV:href, common-name?, summary?,
-                  (read | read-write)>
-
-
-
-
-
-Daboo & York                                                   [Page 28]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-6.26.  CS:remove
-
-   Name:  remove
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Removes access for a sharee.
-
-   Description:  Used to remove sharee access to a shared calendar.  All
-      access to the shared calendar is removed for the sharee.
-
-   Definition:
-
-   <!ELEMENT remove (DAV:href)>
-
-6.27.  CS:shared-as
-
-   Name:  shared-as
-
-   Namespace:  http://calendarserver.org/ns/
-
-   Purpose:  Identifies a shared calendar.
-
-   Description:  Returned by the server for a POST request by a sharee
-      accepting a shared calendar invite.  The DAV:href element
-      specifies the URI of the calendar created by the acceptance.
-
-   Definition:
-
-   <!ELEMENT shared-as (DAV:href)>
-
-
-7.  Security Considerations
-
-   Per-user WebDAV properties and iCalendar data MUST only be accessible
-   by the user that created them.
-
-   Alarms set by the sharer SHOULD NOT be propagated to sharees by
-   default.  Clients SHOULD NOT automatically enable triggering of
-   alarms on shared calendars that have just been accepted without
-   confirmation by the user.
-
-   TBD
-
-
-8.  IANA Considerations
-
-   This document does not require any actions on the part of IANA.
-
-
-
-Daboo & York                                                   [Page 29]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-9.  Acknowledgments
-
-   This specification is the result of discussions between the Apple
-   calendar server and client teams.
-
-
-10.  Normative References
-
-   [I-D.desruisseaux-caldav-sched]
-              Daboo, C. and B. Desruisseaux, "CalDAV Scheduling
-              Extensions to WebDAV", draft-desruisseaux-caldav-sched-08
-              (work in progress), August 2009.
-
-   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
-              Requirement Levels", BCP 14, RFC 2119, March 1997.
-
-   [RFC3744]  Clemm, G., Reschke, J., Sedlar, E., and J. Whitehead, "Web
-              Distributed Authoring and Versioning (WebDAV)
-              Access Control Protocol", RFC 3744, May 2004.
-
-   [RFC4791]  Daboo, C., Desruisseaux, B., and L. Dusseault,
-              "Calendaring Extensions to WebDAV (CalDAV)", RFC 4791,
-              March 2007.
-
-   [RFC4918]  Dusseault, L., "HTTP Extensions for Web Distributed
-              Authoring and Versioning (WebDAV)", RFC 4918, June 2007.
-
-   [RFC5689]  Daboo, C., "Extended MKCOL for Web Distributed Authoring
-              and Versioning (WebDAV)", RFC 5689, September 2009.
-
-
-Appendix A.  Change History
-
-   Changes in -02:
-
-   1.  Removed read-write-shared access mode - now a server that does
-       not support shared scheduling should advertise that via a DAV
-       header
-
-
-Appendix B.  Change History
-
-   Changes in -01:
-
-   1.  Added CS:shared-url property
-
-   2.  Clarified that notifications are only required to be sent when
-       sharee status is changed
-
-
-
-Daboo & York                                                   [Page 30]
-
-                      CalDAV Sharing and Publishing         October 2010
-
-
-Authors' Addresses
-
-   Cyrus Daboo
-   Apple Inc.
-   1 Infinite Loop
-   Cupertino, CA  95014
-   USA
-
-   Email: cyrus at daboo.name
-   URI:   http://www.apple.com/
-
-
-   Eric York
-   Apple Inc.
-   1 Infinite Loop
-   Cupertino, CA  95014
-   USA
-
-   Email:
-   URI:   http://www.apple.com/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Daboo & York                                                   [Page 31]
-

Deleted: CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.xml
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.xml	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing-02.xml	2012-09-23 03:36:01 UTC (rev 9842)
@@ -1,1111 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet type="text/xsl" href="../rfc2629.xslt"?>
-<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' [
-<!ENTITY rfc2119 PUBLIC '' 'bibxml/reference.RFC.2119.xml'>
-<!ENTITY rfc3744 PUBLIC '' 'bibxml/reference.RFC.3744.xml'>
-<!ENTITY rfc4791 PUBLIC '' 'bibxml/reference.RFC.4791.xml'>
-<!ENTITY rfc4918 PUBLIC '' 'bibxml/reference.RFC.4918.xml'>
-<!ENTITY rfc5689 PUBLIC '' 'bibxml/reference.RFC.5689.xml'>
-<!ENTITY I-D.desruisseaux-caldav-sched PUBLIC '' 'bibxml3/reference.I-D.desruisseaux-caldav-sched.xml'>
-]> 
-<?rfc toc="yes"?>
-<?rfc tocdepth="4"?>
-<?rfc strict="yes"?>
-<?rfc comments="yes"?>
-<?rfc inline="yes"?>
-<?rfc symrefs="yes"?>
-<?rfc sortrefs="yes"?>
-<?rfc compact="yes"?>
-<?rfc subcompact="no"?>
-<?rfc private="Calendar Server Extension"?>
-<rfc ipr="none" docName='caldav-sharing-02'>
-    <front>
-        <title abbrev="CalDAV Sharing and Publishing">Shared and Published Calendars in CalDAV</title> 
-        <author initials="C." surname="Daboo" fullname="Cyrus Daboo">
-            <organization abbrev="Apple Inc.">
-                Apple Inc.
-            </organization>
-            <address>
-                <postal>
-                    <street>1 Infinite Loop</street>
-                    <city>Cupertino</city>
-                    <region>CA</region>
-                    <code>95014</code> 
-                    <country>USA</country>
-                </postal>
-                <email>cyrus at daboo.name</email>
-                <uri>http://www.apple.com/</uri>
-            </address>
-        </author>
-        <author initials="E." surname="York" fullname="Eric York">
-            <organization abbrev="Apple Inc.">
-                Apple Inc.
-            </organization>
-            <address>
-                <postal>
-                    <street>1 Infinite Loop</street>
-                    <city>Cupertino</city>
-                    <region>CA</region>
-                    <code>95014</code> 
-                    <country>USA</country>
-                </postal>
-                <email></email>
-                <uri>http://www.apple.com/</uri>
-            </address>
-        </author>
-        <date/>
-        <abstract>
-            <t>
-                This specification defines an extension to CalDAV that enables the sharing of calendars between users on a CalDAV server.
-            </t>
-        </abstract>
-    </front>
-    <middle>
-        <section title='Introduction'>
-            <t>
-                <xref target="RFC4791">CalDAV</xref> provides a way for calendar users to store calendar data and exchange this data via scheduling operations. Based on the <xref target='RFC4918'>WebDAV</xref> protocol, it also includes the ability to manage access to calendar data via the <xref target='RFC3744'>WebDAV ACL</xref> extension.
-            </t>
-            <t>
-                <xref target='RFC3744'>WebDAV ACL</xref> provides a way to manage fine-grained access controls on WebDAV resources. Whilst this could be used directly to manage sharing of calendars, experience has shown that client developers are averse to using it due to its complexity. Instead a simpler process for sharing calendars is preferred.
-            </t>
-            <t>
-                This extension defines a way for individual calendar users to share calendars with other users. This is done via an "opt-in" process in which a sharing invite is sent from the sharer to a sharee, allowing the sharee to accept or decline. If the sharee accepts the sharing invite, the shared calendar is made available to them in their own calendar home collection (i.e., alongside their own personal calendars). HTTP POST operations are used to manage the sharing invitations and replies, and WebDAV properties are used to expose the state of shared calendars.
-            </t>
-        </section>
-
-        <!--<section title="Open Issues">
-            <t>
-                <list style="numbers">
-                    <t>
-                    </t>
-                </list>
-            </t>
-        </section>-->
-            
-        <section title='Conventions Used in This Document'>
-            <t>
-                The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target='RFC2119' />. 
-            </t>
-            <t>
-                When XML element types in the namespaces "DAV:" and "urn:ietf:params:xml:ns:caldav" are referenced in this document outside of the context of an XML fragment, the string "DAV:" and "CALDAV:" will be prefixed to the element type names respectively. 
-            </t>
-            <t>
-                The namespace "http://calendarserver.org/ns/" is used for XML elements defined in this specification.  When XML element types in that namespace are referenced in this document outside of the context of an XML fragment, the string "CS:" will be prefixed to the element type names. 
-            </t>
-            <t>Terms Used:
-                <list style='hanging'>
-                    <t hangText='Sharer'>A calendar user who is sharing a calendar with other calendar users.</t>
-                    <t hangText='Sharee'>A calendar user to whom a calendar has been shared.</t>
-                    <t hangText='Sharing Invite'>A message sent by a sharer to a sharee to indicate the status of a shared calendar.</t>
-                    <t hangText='Sharing Reply'>A message sent by a sharee to a sharer to indicate the status of a shared calendar.</t>
-                </list>
-            </t>
-        </section>
-         
-        <section title='Overview' anchor='overview'>
-            <t>
-                This section provides a basic overview of this protocol by way of a simple use case of a sharer sharing a calendar with a single sharee.
-            </t>
-            <t>
-                To share a calendar with another user, the sharer's client executes an HTTP POST request against the calendar collection resource for the calendar to be shared. The POST request body will contain details of the calendar user to whom the calendar is to be shared as well as the access right to be granted to them. If the request succeeds, a notification is sent to the sharee with details of the calendar being shared to them.
-            </t>
-            <t>
-                The sharer's client will show the notification to the sharee and present them with the choice to accept or decline the invitation to the shared calendar. If the sharee chooses to decline, then nothing changes for that sharee. If the sharee chooses to accept, then the server automatically creates a new calendar collection resource in the sharee's calendar home collection, and ensures that calendar provides a mapping to the actual shared calendar of the sharer. Thus the shared calendar is available to the sharee as just another calendar in their calendar home. The server enforces the appropriare access privileges for the sharee.
-            </t>
-            <t>
-                At any time, the sharer can inspect properties on the calendar collection being shared, and determine the accept/decline status of each sharee. Additional sharees can be added and existing ones removed. The access privileges for existing sharees can also be changed.
-            </t>
-            <t>
-            	Once a sharee has a shared calendar set to appear in their calendar home collection, they can remove it and decline the sharing invite by simply having their client issue an HTTP DELETE request on the shared calendar collection. That does not delete any calendar data, but rather simply removes the "link" to the sharer's calendar collection and sets the sharee's inviate status to declined.
-            </t>
-        </section>
-        
-        <section title="Notifications">
-            <t>
-                In order to facilitate the process of sharing invitations, this specification defines a new generic notification mechanism for CalDAV servers. When this feature is available, a <xref target="CS:notification-URL">CS:notification-URL</xref> property appears on principal resources for those principals who are able to receive notifications. That property specifies a single DAV:href element whose content refers to a WebDAV collection resource. Notification "messages" are deposited into this collection and can be retrieved by clients and acted on accordingly.
-            </t>
-            <t>
-                The notification collection referenced by the <xref target="CS:notification-URL">CS:notification-URL</xref> property MUST have a DAV:resourcetype property with DAV:collection and <xref target="CS:notification">CS:notification</xref> child elements. 
-            </t>
-            <t>
-                Notification "messages" are XML documents stored as resources in the notification collection. Each XML document contains a <xref target="CS:notification">CS:notification</xref> element as its root. The root element contains a <xref target="CS:dtstamp">CS:dtstamp</xref> element, and one additional element which represents the type of notification being conveyed in the message. That child element will typically contain additional content that describes the notification.
-            </t>
-            <t>
-                Each notification resource has a <xref target="CS:notificationtype">CS:notificationtype</xref> property which contains as its single child element an empty element that matches the child element of the notification resource XML document root. Any attributes on the child element in the XML document are also present in the property child element.
-            </t>
-            <t>
-                Notifications are automatically generated by the server (perhaps in response to a client action) with an appropriate resource stored in the notifications collection of the user to whom the notification is targeted. Clients SHOULD monitor the notification collection looking for new notification resources. When doing so, clients SHOULD look at the <xref target="CS:notificationtype">CS:notificationtype</xref> property to ensure that the notification is of a type that the client can handle. Once a client has handled the notification in whatever way is appropriate it SHOULD delete the notification resource. Servers MAY delete notification resources on their own if they determine that the notifications are no longer relevant or valid. Servers MAY coalesce notifications as appropriate.
-            </t>
-            <section title="Additional Principal Properties" anchor='principal-properties'>
-                <t>
-                    This section defines new properties for WebDAV principal resources as defined in <xref target="RFC3744">RFC3744</xref>. These properties are likely to be protected but the server MAY allow them to be written by appropriate users.
-                </t>
-                <section title="CS:notification-URL Property" anchor="CS:notification-URL">
-                  <t>
-                    <list style="hanging">
-                      <t hangText="Name:">notification-URL</t>
-                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                      <t hangText="Purpose:">Identify the URL of the notification collection owned by the associated principal resource.</t>
-                      <t hangText="Protected:">This property SHOULD be protected.</t>
-                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
-                      <t hangText="COPY/MOVE behavior:">This property value SHOULD be preserved in COPY and MOVE operations.</t>
-        
-                      <t hangText="Description:">This property is needed for a client to determine where the notification collection of the current user is located so that processing of notification messages can occur. If not present, then the associated calendar user is not enabled for notification messages on the server.</t>
-                      <t hangText="Definition:">
-                        <figure>
-                          <artwork><![CDATA[
-<!ELEMENT notification-URL (DAV:href)>]]></artwork>
-                        </figure>
-                      </t>
-                    </list>
-                  </t>
-                </section>
-            </section>
-            <section title="Properties on Notification Resources" anchor='notification-properties'>
-                <t>
-                    The following new WebDAV properties are defined for notification resources.
-                </t>
-                <section title="CS:notificationtype Property" anchor="CS:notificationtype">
-                  <t>
-                    <list style="hanging">
-                      <t hangText="Name:">notificationtype</t>
-                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                      <t hangText="Purpose:">Identify the type of notification of the corresponding resource.</t>
-                      <t hangText="Protected:">This property MUST be protected.</t>
-                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
-                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
-        
-                      <t hangText="Description:">This property allows a client, via a PROPFIND Depth:1 request, to quickly find notification messages that the client can handle in a notification collection. The single child element is the notification resource root element's child defining the notification itself. This element MUST be empty, though any attributes on the element in the notification resource MUST be present in the property element.</t>
-                      <t hangText="Definition:">
-                        <figure>
-                          <artwork><![CDATA[
-<!ELEMENT notificationtype (invite-notification | invite-reply)>
-<!-- Child elements are empty but will have appropriate attributes.
-     Any valid notification message child element can appear.-->]]></artwork>
-                        </figure>
-                      </t>
-                    </list>
-                  </t>
-                </section>
-            </section>
-        </section>
-
-        <section title="Shared Calendaring">
-            <section title="Feature Discovery">
-                <t>
-                    A server that supports the features described in this document MUST include "calendarserver-sharing" as a field in the DAV response header from an OPTIONS request on any resource that supports these features.
-                </t>
-            </section>
-            <section title="Additional Properties for Calendars" anchor='properties'>
-                <t>
-                    The following new or modified WebDAV properties are defined for calendar collections and used to view or manipulate shared calendar features.
-                </t>
-                <section title="DAV:resourcetype Property" anchor="DAV:resourcetype">
-                    <t>
-                        Calendar collections that are shared have addition elements listed in their DAV:resourcetype property in addition to DAV:collection and CALDAV:calendar.
-                        <list style="symbols">
-                            <t><xref target="CS:shared-owner">CS:shared-owner</xref>: used to indicate that the calendar is owned by the current user and is being shared by them.</t>
-                            <t><xref target="CS:shared">CS:shared</xref>: used to indicate that the calendar is owned by another user and is being shared to the current user.</t>
-                        </list>
-                    </t>
-                </section>
-                <section title="CS:invite Property" anchor="CS:invite">
-                  <t>
-                    <list style="hanging">
-                      <t hangText="Name:">invite</t>
-                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                      <t hangText="Purpose:">Used to show to whom a calendar has been shared.</t>
-                      <t hangText="Protected:">This property MUST be protected.</t>
-                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
-                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
-        
-                      <t hangText="Description:">This WebDAV property is present on a calendar collection resource that has been shared by the owner. It MUST NOT appear on the calendar collection resources of the sharees of the calendar. It provides a list of users to whom the calendar has been shared, along with the "status" of the sharing invites sent to each user.</t>
-                      <t hangText="Definition:">
-                        <figure>
-                          <artwork><![CDATA[
-<!ELEMENT invite (user*)>]]></artwork>
-                        </figure>
-                      </t>
-                    </list>
-                  </t>
-                </section>
-                <section title="CS:allowed-sharing-modes Property" anchor="CS:allowed-sharing-modes">
-                  <t>
-                    <list style="hanging">
-                      <t hangText="Name:">allowed-sharing-modes</t>
-                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                      <t hangText="Purpose:">Used to show which modes of sharing are supported on a calendar collection.</t>
-                      <t hangText="Protected:">This property MUST be protected.</t>
-                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
-                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
-        
-                      <t hangText="Description:">This WebDAV property is present on a calendar collection resource that can been shared or published. It provides a list of options indicating what sharing modes are allowed as per <xref target="allowed"/>.</t>
-                      <t hangText="Definition:">
-                        <figure>
-                          <artwork><![CDATA[
-<!ELEMENT allowed-sharing-modes
-          (can-be-shared?, can-be-published?)>]]></artwork>
-                        </figure>
-                      </t>
-                    </list>
-                  </t>
-                </section>
-                <section title="CS:shared-url Property" anchor="CS:shared-url">
-                  <t>
-                    <list style="hanging">
-                      <t hangText="Name:">shared-url</t>
-                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                      <t hangText="Purpose:">Indicates the URL of the owner's copy of a shared calendar.</t>
-                      <t hangText="Protected:">This property MUST be protected.</t>
-                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
-                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
-        
-                      <t hangText="Description:">This WebDAV property is present on a shared calendar collection resource that appears in a sharee's calendar home collection. Its content is a single DAV:href element whose value is the URL of the sharer's calendar being shared.</t>
-                      <t hangText="Definition:">
-                        <figure>
-                          <artwork><![CDATA[
-<!ELEMENT shared-url (DAV:href)>]]></artwork>
-                        </figure>
-                      </t>
-                    </list>
-                  </t>
-                </section>
-            </section>
-            <section title="Sharer Actions on Shared Calendars">
-                <section title="Creating a Shared Calendar">
-                    <t>
-                        To create a shared calendar, clients use the <xref target="RFC4791">MKCALENDAR</xref> or <xref target="RFC5689">extended MKCOL</xref> requests, and include a DAV:resourcetype property to be set upon creation. That property MUST contain DAV:collection, CALDAV:calendar and CS:shared-owner child elements to enable sharing.
-                    </t>
-                    <section title="Example: Successful MKCALENDAR Request">
-            
-                        <t>
-                          This example shows how the MKCALENDAR request is used to create a shared calendar collection. The response body is empty as the request completed successfully.
-                        </t>
-    
-                        <figure>
-                          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-MKCALENDAR /calendars/users/cyrus/shared/ HTTP/1.1
-Host: calendar.example.com
-Content-Type: application/xml; charset="utf-8"
-Content-Length: xxxx
-
-<?xml version="1.0" encoding="utf-8" ?>
-<C:mkcalendar xmlns:D="DAV:"
-              xmlns:C="urn:ietf:params:xml:ns:caldav"
-              xmlns:CS="http://calendarserver.org/ns/">
-  <D:set>
-    <D:prop>
-      <D:resourcetype>
-        <D:collection/>
-        <C:calendar/>
-        <CS:shared-owner/>
-      </D:resourcetype>
-    </D:prop>
-  </D:set>
-</C:mkcalendar>]]></artwork>
-                        </figure>
-                        <figure>
-                          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-HTTP/1.1 201 Created
-Cache-Control: no-cache
-Date: Sat, 11 Nov 2006 09:32:12 GMT]]></artwork>
-                        </figure>
-                    </section>
-                    <section title="Example: Successful Extended MKCOL Request">
-            
-                        <t>
-                          This example shows how the extended MKCOL request is used to create a shared calendar collection. The response body is empty as the request completed successfully.
-                        </t>
-    
-                        <figure>
-                          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-MKCOL /calendars/users/cyrus/shared/ HTTP/1.1
-Host: calendar.example.com
-Content-Type: application/xml; charset="utf-8"
-Content-Length: xxxx
-
-<?xml version="1.0" encoding="utf-8" ?>
-<D:mkcol xmlns:D="DAV:"
-              xmlns:C="urn:ietf:params:xml:ns:caldav"
-              xmlns:CS="http://calendarserver.org/ns/">
-  <D:set>
-    <D:prop>
-      <D:resourcetype>
-        <D:collection/>
-        <C:calendar/>
-        <CS:shared-owner/>
-      </D:resourcetype>
-    </D:prop>
-  </D:set>
-</D:mkcol>]]></artwork>
-                        </figure>
-                        <figure>
-                          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-HTTP/1.1 201 Created
-Cache-Control: no-cache
-Date: Sat, 11 Nov 2006 09:32:12 GMT]]></artwork>
-                        </figure>
-                    </section>
-                </section>
-                <section title="Sharing an Existing Calendar">
-                    <t>
-                        Sharing an existing calendar can be accomplished in two ways. One option is to use a PROPPATCH request to set the DAV:resourcetype property to include CS:shared-owner as a child element. Another option is to add sharee's directly to the calendar collection (as described in <xref target="sharee"/>) - that action MUST upgrade a non-shared calendar to a shared calendar when it completes successfully, assuming that such an upgrade is allowed as per <xref target="allowed"/>.
-                    </t>
-                    <section title="Example: Successful PROPPATCH Request">
-            
-                        <t>
-                          This example shows how the PROPPATCH request is used to upgrade to a shared calendar collection.
-                        </t>
-    
-                        <figure>
-                          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-PROPPATCH /calendars/users/cyrus/shared/ HTTP/1.1
-Host: calendar.example.com
-Content-Type: application/xml; charset="utf-8"
-Content-Length: xxxx
-
-<?xml version="1.0" encoding="utf-8" ?>
-<D:propertyupdate xmlns:D="DAV:"
-              xmlns:C="urn:ietf:params:xml:ns:caldav"
-              xmlns:CS="http://calendarserver.org/ns/">
-  <D:set>
-    <D:prop>
-      <D:resourcetype>
-        <D:collection/>
-        <C:calendar/>
-        <CS:shared-owner/>
-      </D:resourcetype>
-    </D:prop>
-  </D:set>
-</D:propertyupdate>]]></artwork>
-                        </figure>
-                        <figure>
-                          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-HTTP/1.1 207 Multi-Status
-Date: Sat, 11 Nov 2006 09:32:12 GMT
-Content-Type: application/xml; charset="utf-8"
-Content-Length: xxxx
-
-<?xml version="1.0" encoding="utf-8" ?>
-<D:multistatus xmlns:D="DAV:">
-  <D:response>
-    <D:href>/calendars/users/cyrus/shared/</D:href>
-    <D:propstat>
-      <D:prop>
-        <D:resourcetype/>
-      </D:prop>
-      <D:status>HTTP/1.1 200 OK</D:status>
-    </D:propstat>
-  </D:response>
-</D:multistatus>]]></artwork>
-                        </figure>
-                    </section>
-                </section>
-                <section title="Manipulating Sharees of a Shared Calendar" anchor="sharee">
-                    <t>
-                        The sharer of a shared calendar is able to manipulate the sharee list by issuing a POST request targeted at the shared calendar collection resource. The POST request MUST contain an XML document as its body with the root element being <xref target="CS:share">CS:share</xref>.
-                    </t>
-                    <t>
-                    	The <xref target="CS:share">CS:share</xref> element in the POST requests MUST contain one or more <xref target="CS:set">CS:set</xref> or <xref target="CS:remove">CS:remove</xref> elements. For each <xref target="CS:set">CS:set</xref> element, the server MUST add the specified sharee access to the shared calendar. For each <xref target="CS:remove">CS:remove</xref> element the server MUST remove the specified sharee access from the shared calendar. In each case the server MUST send a notification message to any sharees whose status is changed (added, modified or removed), indicating to them a change in status for the shared calendar. The server SHOULD NOT send notification messages to sharees whose status is unchanged.
-                    </t>
-                    <t>
-                    	Sharee's are identified via a DAV:href element whose value is either a principal-URL for a sharee hosted on the same server, a calendar user address or email address. In the case of the later two, the sharee might not be a user on the same server - though in that case how invitations are sent or access enabled is out of scope for this specification. A server MAY change the sharee's "address" to any suitable alternative that it might prefer when returning the list of sharees via the <xref target="CS:invite">CS:invite property</xref>.
-                    </t>
-                    <t>
-                    	The client MAY include a <xref target="CS:common-name">CS:common-name</xref> element in the <xref target="CS:set">CS:set</xref> element. When provided, the value represents the common name for the sharee, and is returned in the list of sharees via the <xref target="CS:invite">CS:invite property</xref>. The server MAY change this to a suitable alternative when it is able to match the sharee to a known user. If absent from the client request, the server SHOULD add a CS:common-name when it is able to match the sharee with a known user, and a common name for that user can be determined.
-                    </t>
-                    <t>
-                    	When the sharee list on a shared calendar is changed, the server MUST send notifications to each sharee to update them on their current sharing status. This is accomplished by sending a <xref target="CS:invite-notification">CS:invite-notification</xref> notification to each sharee.
-                    </t>
-                    <section title="Example: Successful Sharee Add Request">
-            
-                        <t>
-                          This example shows how to add a single sharee (with calendar user address "mailto:eric at example.com") to a shared calendar with CS:read-write access.
-                        </t>
-    
-                        <figure>
-                          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-POST /calendars/users/cyrus/shared/ HTTP/1.1
-Host: calendar.example.com
-Content-Type: application/xml; charset="utf-8"
-Content-Length: xxxx
-
-<?xml version="1.0" encoding="utf-8" ?>
-<CS:share xmlns:D="DAV:"
-              xmlns:CS="http://calendarserver.org/ns/">
-  <CS:set>
-    <D:href>mailto:eric at example.com</D:href>
-    <CS:common-name>Eric York</CS:common-name>
-    <CS:summary>Shared workspace</CS:summary>
-    <CS:read-write />
-  </CS:set>
-</CS:share>]]></artwork>
-                        </figure>
-                        <figure>
-                          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-HTTP/1.1 200 OK
-Cache-Control: no-cache
-Date: Sat, 11 Nov 2006 09:32:12 GMT]]></artwork>
-                        </figure>
-                    </section>
-                    <section title="Example: Successful Multiple Sharee Change Request">
-            
-                        <t>
-                          This example shows how multiple sharee's can be manipulated in a single request. The sharee with calendar user address "mailto:eric at example.com" has their access downgraded to CS:read, whilst another sharee is removed from the access list entirely.
-                        </t>
-    
-                        <figure>
-                          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-POST /calendars/users/cyrus/shared/ HTTP/1.1
-Host: calendar.example.com
-Content-Type: application/xml; charset="utf-8"
-Content-Length: xxxx
-
-<?xml version="1.0" encoding="utf-8" ?>
-<CS:share xmlns:D="DAV:"
-              xmlns:CS="http://calendarserver.org/ns/">
-  <CS:set>
-    <D:href>mailto:eric at example.com</D:href>
-    <CS:summary>Shared workspace</CS:summary>
-    <CS:read-write />
-  </CS:set>
-  <CS:remove>
-    <D:href>mailto:wilfredo at example.com</D:href>
-  </CS:remove>
-</CS:share>]]></artwork>
-                        </figure>
-                        <figure>
-                          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
-                          <artwork><![CDATA[
-HTTP/1.1 200 OK
-Cache-Control: no-cache
-Date: Sat, 11 Nov 2006 09:32:12 GMT]]></artwork>
-                        </figure>
-                    </section>
-                </section>
-            </section>
-            <section title="Sharee Actions on Shared Calendars">
-                <section title="Replying to a Sharing Invite">
-                	<t>
-                		When a sharee is invited to a shared calendar they can accept or decline the invite by issuing a POST request to the sharee's calendar home collection resource. The POST request MUST contain an XML document as its body with the root element being <xref target="CS:invite-reply">CS:invite-reply</xref>.
-                	</t>
-                	<t>
-                		The <xref target="CS:invite-reply">CS:invite-reply</xref> element in the POST request specifies the sharee who is replying in the DAV:href element, the accept or decline action via the CS:invite-accepted or CS:invite-declined elements, the URL of the shared calendar in the CS:hosturl element, the unique identifier of the invite to which it is a reply in the CS:in-reply-to element, and an optional CS:summary element.
-                	</t>
-                	<t>
-                		The response to a POST request that accepts a shared calendar invite MUST be an XML document containing <xref target="CS:shared-as">CS:shared-as</xref> as its root element. That root element contains a single DAV:href element whose content is the URI of the shared calendar in the sharee's calendar home created by the invite acceptance.
-                	</t>
-                	<t>
-                        When the sharee replies to an invite, the server SHOULD send a notification to the sharer to update them on the change in the sharee state.  This is accomplished by sending a <xref target="CS:invite-reply">CS:invite-reply</xref> notification to the sharer.
-                	</t>
-                </section>
-                <section title="Removing a Shared Calendar">
-                	<t>
-                		To remove a shared calendar from a sharee's calendar home collection a DELETE request is targeted at the shared calendar URI. When such a request is received the server MUST remove the shared calendar from the sharee's calendar home and automatically update the sharee's status in the sharer's calendar's CS:invite property.
-                	</t>
-                </section>
-            </section>
-            <section title="General Considerations">
-                <section title="Access Levels">
-                	<t>
-                		Two levels of access ca be granted by a sharer to any sharee. These are governed by the CS:access element used in the CS:invite/CS:user element that specifies a shared user invite. CS:access contains a single empty element that defines the type of access granted:
-                		<list style="hanging">
-                		<t hangText="CS:read">
-                		    When present this indicates that sharees can read calendar data but cannot change it.
-                		</t>
-                		<t hangText="CS:read-write">
-                		    When present this indicates that sharees can read and write calendar data.
-                		</t>
-                		</list>
-                	</t>
-                </section>
-                <section title="Allowing or Disallowing Sharing" anchor="allowed">
-                	<t>
-                		Servers MAY support calendar sharing on a per-calendar basis - e.g., they could treat some calendars as always private (cannot be shared) or always public (always shared). As a result clients need a way to determine which calendar could be shared so they can enable or disable sharing options on a per-calendar basis.
-                	</t>
-                	<t>
-                		This specification adds a <xref target="CS:allowed-sharing-modes">CS:allowed-sharing-modes</xref> WebDAV property which servers can return on calendar collection resources. This property contains XML elements that describe which sharing or publishing capabilities can be supported by the corresponding calendar collection:
-                		<list>
-							<t><xref target="CS:can-be-shared">CS:can-be-shared</xref>: when present indicates that the calendar collection can be shared. When not present, the calendar collection cannot be shared.</t>
-							<t><xref target="CS:can-be-published">CS:can-be-published</xref>: when present indicates that the calendar collection can be published. When not present, the calendar collection cannot be published.</t>
-						</list>                		
-                	</t>
-                	<t>
-                		When not present on a calendar collection, sharing or publishing of that calendar is not allowed. Clients SHOULD NOT attempt to use requests to enable sharing or publishing targeted at those calendar collections.
-                	</t>
-                </section>
-                <section title="Per-user WebDAV Properties">
-                	<t>
-                		Servers MUST support "per-user" WebDAV properties on shared calendar collections and MAY support them on calendar object resources within shared calendar collections. A "per-user" WebDAV property is one whose value can be set and retrieved independently by each user with appropriate access rights. e.g., user "A" changes the DAV:displayname property on a shared calendar in their calendar home to "My calendar", and user "B" changes the same property to "Shared" on the same shared calendar in their calendar home. When each user retrieves the property value they will see their own last stored value and not the value of the other user.
-                	</t>
-                	<t>
-                		For shared calendars, the server MUST allow all users to write "per-user" WebDAV properties on the shared calendar collection and MAY allow property writes on calendar object resources within the shared calendar collection. This is required even in the case where the sharee has been granted read access only (i.e., the ability to change calendar data is disallowed). This requirement ensures that sharees can always change "personal" properties such as calendar colors and display names.
-                	</t>
-                	<t>
-                		Servers MUST treat the following properties as "per-user":
-                		<list>
-                			<t>DAV:displayname</t>
-                			<t>CALDAV:calendar-description</t>
-                			<t>CALDAV:schedule-calendar-transp</t>
-                			<t>ICAL:calendar-color</t>
-                		</list>
-                	</t>
-                	<t>
-                		Servers MAY treat any dead property as per-user.
-                	</t>
-                	<t>
-                		Servers MUST NOT treat live properties as per-user.
-                	</t>
-                </section>
-                <section title="Per-user Calendar Data" anchor="per-user-data">
-                	<t>
-                		Servers MUST support "per-user" calendar data in calendar object resources stored in shared calendars. This allows each sharee and the sharer to store their own alarms and free busy transparency status without "interfering" with other users who also have access to the same calendar object resources.
-                	</t>
-                	<t>
-                		For calendaring object resources in shared calendar collections, the server MUST treat the following iCalendar data objects as per-user:
-                		<list>
-                			<t>TRANSP property</t>
-                			<t>VALARM component</t>
-                		</list>
-                	</t>
-                	<t>
-                		Servers MAY treat any non-standard X- iCalendar properties as per-user.
-                	</t>
-                	<t>
-                		When handling per-user data in recurring components, servers SHOULD eliminate overridden instances when returning iCalendar data to clients in the case where there are no differences between the overridden component and the instance that could be derived from the "master" recurrence component. For example, consider a daily recurring event, Monday through Friday, initially defined without any overridden instances, that is in a shared calendar. If user "A" overrides the Tuesday instance and adds their own "VALARM" component only, then when user "A" later retrieves the data again they would see that overridden instance, but when user "B" does so, they would not. This ensures that each user sees the most "compact" representation of the calendar data.
-                	</t>
-                </section>
-                <section title="Scheduling">
-                	<t>
-                		<xref target="I-D.desruisseaux-caldav-sched">CalDAV Scheduling</xref> defines how a CalDAV server carries out scheduling operations when calendar object resources are created, modified or deleted and include "ORGANIZER" and "ATTENDEE" iCalendar properties.
-                	</t>
-                	<t>
-                		When calendar object resources are created, modified or deleted in shared calendars by sharees, the following restrictions apply:
-                		<list style="numbers">
-                			<t>The "ORGANIZER" iCalendar property value in the iCalendar data MUST match a calendar user address of the sharer (owner) of the shared calendar. The DAV:owner WebDAV property MUST be present on a shared calendar and MUST provide a reference to a principal-URL of the sharer (owner) of the shared calendar. Clients can use this value to determine what the allowed "ORGANIZER" iCalendar property values are. The server MUST reject any attempt by a sharee to create an iCalendar component with an "ORGANIZER" property value other than the sharer (owner) of the shared calendar.</t>
-                			<t>The server MUST reject any attempt by a sharee to MOVE a calendar object resource in a shared calendar to some other collection.</t>
-                			<t>When a sharee is listed as an Attendee in a calendar object resource in a shared calendar, and write access is granted, the sharee is allowed to change not only iCalendar data related to the Organizer, but also data related to the Attendee. i.e., a sharee can change their own participation status on the "ATTENDEE" iCalendar property referring to them. Additionally, if the sharee is not listed as an Attendee, and write access is granted, the sharee can add themselves as an Attendee.</t>
-                			<t>The default calendar collection defined in Section 6.3 of <xref target="I-D.desruisseaux-caldav-sched"/> MUST NOT be a calendar shared to the corresponding calendar user.</t>
-                		</list>
-                	</t>
-                	<t>
-                		Following are additional considerations for scheduling with shared calendars:
-                		<list style="numbers">
-                			<t>A scheduled iCalendar component could appear in more than one calendar collection within a sharee's calendar home if the sharee is an Attendee and the Organizer or other Attendees have shared a calendar with the sharee that includes their copies of the iCalendar component. It is important to note that the scheduled component in the shared calendar could have different access rights than the one in the sharee's owned calendar.</t>
-                			<t>A scheduled iCalendar component appearing in a sharee's shared calendar could include the sharee as an Attendee. For recurring events, it is possible for the sharee to only be listed as an Attendee in some instances, as opposed to all. Clients will need to be aware of this when allowing sharee's to set their own participation status.</t>
-                		</list>
-                	</t>
-                	<t>
-                		In addition, when a shared calendar is first accepted by a sharee, the server SHOULD set the CALDAV:schedule-calendar-transp property to the value CALDAV:transparent to ensure newly accepted shared calendars do not contribute to the sharee's freebusy time until the sharee explicitly requests it.
-                	</t>
-                </section>
-            </section>
-        </section>
-
-        <section title='XML Element Definitions'>
-            <section title="CS:shared-owner" anchor="CS:shared-owner">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">shared-owner</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Used to indicate that a calendar is being shared by the owner.</t>
-                    <t hangText="Description:">This property appears in the DAV:resourcetype property on the calendar collection resource shared by a sharer. See <xref target="properties"/>.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT shared-owner EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:shared" anchor="CS:shared">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">shared</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Used to indicate that a calendar is being shared to a sharee.</t>
-                    <t hangText="Description:">This property appears in the DAV:resourcetype property on a calendar collection resource that is shared to a sharee and appears in the sharee's calendar home collection. See <xref target="properties"/>.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT shared EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:can-be-shared" anchor="CS:can-be-shared">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">can-be-shared</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Used to indicate that a calendar can be shared.</t>
-                    <t hangText="Description:">This element indicates that a calendar can be shared with other users. See <xref target="CS:allowed-sharing-modes"/></t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT can-be-shared EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:can-be-published" anchor="CS:can-be-published">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">can-be-published</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Used to indicate that a calendar can be published.</t>
-                    <t hangText="Description:">This element indicates that a calendar can be published to anyone. See <xref target="CS:allowed-sharing-modes"/></t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT can-be-published EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:user" anchor="CS:user">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">user</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Used to show status of sharing invites sent to sharees.</t>
-                    <t hangText="Description:">This element provides the "status" of a sharing invite sent to a particular user. See <xref target="CS:invite"/>.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT user (DAV:href, common-name?, (invite-noresponse |
-                invite-accepted | invite-declined | invite-invalid),
-                access, summary?)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:invite-noresponse">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">invite-noresponse</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Sharing invite status.</t>
-                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the sharee has never replied to the corresponding sharing invite. When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that a sharing reply is needed.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-noresponse EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:invite-deleted">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">invite-deleted</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Sharing invite status.</t>
-                    <t hangText="Description:">When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that a shared calendar has been unshared by the sharer.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-deleted EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:invite-accepted">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">invite-accepted</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Sharing invite status.</t>
-                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the sharee has accepted the corresponding sharing invite. When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that the sharing invite is an update for one they previously accepted.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-accepted EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:invite-declined">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">invite-declined</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Sharing invite status.</t>
-                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the sharee has declined the corresponding sharing invite. When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that the sharing invite is an update for one they previously declined.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-declined EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:invite-invalid">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">invite-invalid</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Sharing invite status.</t>
-                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the corresponding sharee is not a valid calendar user known to the server.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-invalid EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:access">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">access</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Shared calendar access level.</t>
-                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate the sharing access level granted to the corresponding sharee.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-invalid (read | read-write)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:read">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">read</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Shared calendar access level privilege.</t>
-                    <t hangText="Description:">Indicates that the access level granted only allows sharees to read data in the shared calendar (though they can write <xref target="per-user-data">per-user data</xref>).</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT read EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:read-write">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">read-write</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Shared calendar access level privilege.</t>
-                    <t hangText="Description:">Indicates that the access level granted allows sharees to read and write all data in the shared calendar, with the exception of components that would trigger scheduling.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT read-write EMPTY>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:summary">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">summary</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Summary or title of shared calendar.</t>
-                    <t hangText="Description:">A brief description of a shared calendar. This can be used by sharers to communicate the nature of a shared calendar to sharees, as well as used by sharees to indicate back to the sharer how each sharee is refering to the shared calendar.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT summary (#PCDATA)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:invite-notification" anchor="CS:invite-notification">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">invite-notification</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">A notification used as a shared calendar invite.</t>
-                    <t hangText="Description:">Defines a notification message sent automatically by the server when a sharer adds, changes or removes a sharee from a shared calendar. The DAV:href element specifies the calendar user address of the sharee to whom the message was sent.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-notification (uid, DAV:href,
-                               (invite-noresponse | invite-deleted |
-                                invite-accepted | invite-declined),
-                               access, hosturl, organizer, summary?>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:uid">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">uid</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Unique identifier.</t>
-                    <t hangText="Description:">A unique identifier for an invitation to a shared calendar.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT uid (#PCDATA)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:hosturl">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">hosturl</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Identifies the source URL of a shared calendar.</t>
-                    <t hangText="Description:">Contains a single DAV:href element that refers to the source of a shared calendar - i.e., the URL of the calendar shared by the sharer.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT hosturl (DAV:href)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:organizer">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">organizer</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Identifies the sharer of a shared calendar.</t>
-                    <t hangText="Description:">Contains a single DAV:href element that identifies the calendar user address of the sharer of a shared calendar, and an optional CS:common-name element that matches that user.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT organizer (DAV:href, CS:common-name?)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:common-name" anchor="CS:common-name">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">common-name</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">The common name of a sharer or sharee.</t>
-                    <t hangText="Description:">The common name is optionally provided by a client when adding a sharee and optionally included (or modified) by the server when returning results for sharers or sharees and in notifications.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT common-name (#PCDATA)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:invite-reply" anchor="CS:invite-reply">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">invite-reply</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">A notification used as a reply to a shared calendar invite.</t>
-                    <t hangText="Description:">Defines a notification message sent automatically by the server when a sharee replies to a shared calendar invite. The DAV:href element specifies the calendar user address of the sharee to whom the original invite message was sent.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT invite-reply (DAV:href,
-                        (invite-accepted | invite-declined),
-                        hosturl, in-reply-to, summary?>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:in-reply-to">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">in-reply-to</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Unique identifier.</t>
-                    <t hangText="Description:">Specifies the unique identifier of the inviate message that this notification message is a reply to.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT in-reply-to (#PCDATA)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:notification" anchor="CS:notification">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">notification</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Notification message root element.</t>
-                    <t hangText="Description:">The root element used in notification resources.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT notification (CS:dtstamp,
-                        (invite-notification | invite-reply)>
-<!-- Any notification type element can appear after CS:dtstamp,
-     this specification defines only the two listed above -->]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:dtstamp" anchor="CS:dtstamp">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">dtstamp</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Date-time stamp.</t>
-                    <t hangText="Description:">Contains the date-time stamp corresponding to the creation of a notification message.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT dtstamp (#PCDATA)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:share" anchor="CS:share">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">share</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Describes changes to sharees.</t>
-                    <t hangText="Description:">The root element used in POST requests on calendars by sharers to manipulate the sharee list of a shared calendar.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT share (set | remove)*>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:set" anchor="CS:set">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">set</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Sets access for a sharee.</t>
-                    <t hangText="Description:">Used to add or modify sharee access to a shared calendar. The specified access to the shared calendar is given to the sharee.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT set (DAV:href, common-name?, summary?,
-               (read | read-write)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:remove" anchor="CS:remove">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">remove</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Removes access for a sharee.</t>
-                    <t hangText="Description:">Used to remove sharee access to a shared calendar. All access to the shared calendar is removed for the sharee.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT remove (DAV:href)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-            <section title="CS:shared-as" anchor="CS:shared-as">
-                <t>
-                  <list style="hanging">
-                    <t hangText="Name:">shared-as</t>
-                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
-                    <t hangText="Purpose:">Identifies a shared calendar.</t>
-                    <t hangText="Description:">Returned by the server for a POST request by a sharee accepting a shared calendar invite. The DAV:href element specifies the URI of the calendar created by the acceptance.</t>
-                    <t hangText="Definition:">
-                      <figure>
-                        <artwork><![CDATA[
-<!ELEMENT shared-as (DAV:href)>]]></artwork>
-                      </figure>
-                    </t>
-                  </list>
-                </t>
-            </section>
-        </section>
-
-        <section title='Security Considerations'>
-            <t>
-                Per-user WebDAV properties and iCalendar data MUST only be accessible by the user that created them.
-            </t>
-            <t>
-                Alarms set by the sharer SHOULD NOT be propagated to sharees by default. Clients SHOULD NOT automatically enable triggering of alarms on shared calendars that have just been accepted without confirmation by the user.
-            </t>
-            <t>
-            	TBD
-            </t>
-        </section>
-        <section title='IANA Considerations'>
-            <t>
-                This document does not require any actions on the part of IANA.
-            </t>
-        </section>
-        <section title='Acknowledgments'>
-            <t>
-                This specification is the result of discussions between the Apple calendar server and client teams.
-            </t>
-        </section>
-    </middle>
-    <back>
-        <references title='Normative References'>
-            &rfc2119;
-            &rfc3744;
-            &rfc4791;
-            &rfc4918;
-            &rfc5689;
-            &I-D.desruisseaux-caldav-sched; 
-        </references>
-<!--
-<references title='Informative References'>
-</references>
--->
-        <section title='Change History'>
-            <t>Changes in -02:
-                <list style='numbers'>
-                    <t>Removed read-write-shared access mode - now a server that does not support shared scheduling should advertise that via a DAV header</t>
-                </list>
-            </t>
-        </section>
-        <section title='Change History'>
-            <t>Changes in -01:
-                <list style='numbers'>
-                    <t>Added CS:shared-url property</t>
-                    <t>Clarified that notifications are only required to be sent when sharee status is changed</t>
-                </list>
-            </t>
-        </section>
-    </back>
-</rfc>

Copied: CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.txt (from rev 9833, CalendarServer/trunk/doc/Extensions/caldav-sharing.txt)
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.txt	                        (rev 0)
+++ CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.txt	2012-09-23 03:36:01 UTC (rev 9842)
@@ -0,0 +1,1624 @@
+
+
+
+Calendar Server Extension                                       C. Daboo
+                                                                 E. York
+                                                              Apple Inc.
+                                                      September 19, 2012
+
+
+                Shared and Published Calendars in CalDAV
+
+Abstract
+
+   This specification defines an extension to CalDAV that enables the
+   sharing of calendars between users on a CalDAV server.
+
+
+Table of Contents
+
+   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
+   2.  Conventions Used in This Document  . . . . . . . . . . . . . .  3
+   3.  Overview . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
+   4.  Notifications  . . . . . . . . . . . . . . . . . . . . . . . .  5
+     4.1.  Additional Principal Properties  . . . . . . . . . . . . .  5
+       4.1.1.  CS:notification-URL Property . . . . . . . . . . . . .  6
+     4.2.  Properties on Notification Resources . . . . . . . . . . .  6
+       4.2.1.  CS:notificationtype Property . . . . . . . . . . . . .  6
+   5.  Shared Calendaring . . . . . . . . . . . . . . . . . . . . . .  7
+     5.1.  Feature Discovery  . . . . . . . . . . . . . . . . . . . .  7
+     5.2.  Additional Properties for Calendars  . . . . . . . . . . .  7
+       5.2.1.  DAV:resourcetype Property  . . . . . . . . . . . . . .  7
+       5.2.2.  CS:invite Property . . . . . . . . . . . . . . . . . .  8
+       5.2.3.  CS:allowed-sharing-modes Property  . . . . . . . . . .  8
+       5.2.4.  CS:shared-url Property . . . . . . . . . . . . . . . .  9
+     5.3.  Sharer Actions on Shared Calendars . . . . . . . . . . . .  9
+       5.3.1.  Sharing or Unsharing a Calendar  . . . . . . . . . . .  9
+       5.3.2.  Manipulating Sharees of a Shared Calendar  . . . . . . 10
+         5.3.2.1.  Example: Successful Sharee Add Request . . . . . . 11
+         5.3.2.2.  Example: Successful Multiple Sharee Change
+                   Request  . . . . . . . . . . . . . . . . . . . . . 11
+     5.4.  Sharee Actions on Shared Calendars . . . . . . . . . . . . 12
+       5.4.1.  Replying to a Sharing Invite . . . . . . . . . . . . . 12
+       5.4.2.  Removing a Shared Calendar . . . . . . . . . . . . . . 13
+     5.5.  General Considerations . . . . . . . . . . . . . . . . . . 13
+       5.5.1.  Access Levels  . . . . . . . . . . . . . . . . . . . . 13
+       5.5.2.  Allowing or Disallowing Sharing  . . . . . . . . . . . 13
+       5.5.3.  Per-user WebDAV Properties . . . . . . . . . . . . . . 14
+       5.5.4.  Per-user Calendar Data . . . . . . . . . . . . . . . . 14
+       5.5.5.  Scheduling . . . . . . . . . . . . . . . . . . . . . . 15
+   6.  XML Element Definitions  . . . . . . . . . . . . . . . . . . . 16
+     6.1.  CS:shared-owner  . . . . . . . . . . . . . . . . . . . . . 16
+
+
+
+Daboo & York                                                    [Page 1]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+     6.2.  CS:shared  . . . . . . . . . . . . . . . . . . . . . . . . 17
+     6.3.  CS:can-be-shared . . . . . . . . . . . . . . . . . . . . . 17
+     6.4.  CS:can-be-published  . . . . . . . . . . . . . . . . . . . 18
+     6.5.  CS:user  . . . . . . . . . . . . . . . . . . . . . . . . . 18
+     6.6.  CS:invite-noresponse . . . . . . . . . . . . . . . . . . . 18
+     6.7.  CS:invite-deleted  . . . . . . . . . . . . . . . . . . . . 19
+     6.8.  CS:invite-accepted . . . . . . . . . . . . . . . . . . . . 19
+     6.9.  CS:invite-declined . . . . . . . . . . . . . . . . . . . . 19
+     6.10. CS:invite-invalid  . . . . . . . . . . . . . . . . . . . . 20
+     6.11. CS:access  . . . . . . . . . . . . . . . . . . . . . . . . 20
+     6.12. CS:read  . . . . . . . . . . . . . . . . . . . . . . . . . 21
+     6.13. CS:read-write  . . . . . . . . . . . . . . . . . . . . . . 21
+     6.14. CS:summary . . . . . . . . . . . . . . . . . . . . . . . . 21
+     6.15. CS:invite-notification . . . . . . . . . . . . . . . . . . 22
+     6.16. CS:uid . . . . . . . . . . . . . . . . . . . . . . . . . . 22
+     6.17. CS:hosturl . . . . . . . . . . . . . . . . . . . . . . . . 23
+     6.18. CS:organizer . . . . . . . . . . . . . . . . . . . . . . . 23
+     6.19. CS:common-name . . . . . . . . . . . . . . . . . . . . . . 23
+     6.20. CS:first-name  . . . . . . . . . . . . . . . . . . . . . . 24
+     6.21. CS:last-name . . . . . . . . . . . . . . . . . . . . . . . 24
+     6.22. CS:invite-reply  . . . . . . . . . . . . . . . . . . . . . 24
+     6.23. CS:in-reply-to . . . . . . . . . . . . . . . . . . . . . . 25
+     6.24. CS:notification  . . . . . . . . . . . . . . . . . . . . . 25
+     6.25. CS:dtstamp . . . . . . . . . . . . . . . . . . . . . . . . 26
+     6.26. CS:share . . . . . . . . . . . . . . . . . . . . . . . . . 26
+     6.27. CS:set . . . . . . . . . . . . . . . . . . . . . . . . . . 26
+     6.28. CS:remove  . . . . . . . . . . . . . . . . . . . . . . . . 27
+     6.29. CS:shared-as . . . . . . . . . . . . . . . . . . . . . . . 27
+   7.  Security Considerations  . . . . . . . . . . . . . . . . . . . 27
+   8.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 27
+   9.  Acknowledgments  . . . . . . . . . . . . . . . . . . . . . . . 28
+   10. Normative References . . . . . . . . . . . . . . . . . . . . . 28
+   Appendix A.  Change History  . . . . . . . . . . . . . . . . . . . 28
+   Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Daboo & York                                                    [Page 2]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+1.  Introduction
+
+   CalDAV [RFC4791] provides a way for calendar users to store calendar
+   data and exchange this data via scheduling operations.  Based on the
+   WebDAV [RFC4918] protocol, it also includes the ability to manage
+   access to calendar data via the WebDAV ACL [RFC3744] extension.
+
+   WebDAV ACL [RFC3744] provides a way to manage fine-grained access
+   controls on WebDAV resources.  Whilst this could be used directly to
+   manage sharing of calendars, experience has shown that client
+   developers are averse to using it due to its complexity.  Instead a
+   simpler process for sharing calendars is preferred.
+
+   This extension defines a way for individual calendar users to share
+   calendars with other users.  This is done via an "opt-in" process in
+   which a sharing invite is sent from the sharer to a sharee, allowing
+   the sharee to accept or decline.  If the sharee accepts the sharing
+   invite, the shared calendar is made available to them in their own
+   calendar home collection (i.e., alongside their own personal
+   calendars).  HTTP POST operations are used to manage the sharing
+   invitations and replies, and WebDAV properties are used to expose the
+   state of shared calendars.
+
+
+2.  Conventions Used in This Document
+
+   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
+   document are to be interpreted as described in [RFC2119].
+
+   When XML element types in the namespaces "DAV:" and
+   "urn:ietf:params:xml:ns:caldav" are referenced in this document
+   outside of the context of an XML fragment, the string "DAV:" and
+   "CALDAV:" will be prefixed to the element type names respectively.
+
+   The namespace "http://calendarserver.org/ns/" is used for XML
+   elements defined in this specification.  When XML element types in
+   that namespace are referenced in this document outside of the context
+   of an XML fragment, the string "CS:" will be prefixed to the element
+   type names.
+
+   Terms Used:
+
+   Sharer  A calendar user who is sharing a calendar with other calendar
+      users.
+
+
+
+
+
+
+Daboo & York                                                    [Page 3]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Sharee  A calendar user to whom a calendar has been shared.
+
+   Sharing Invite  A message sent by a sharer to a sharee to indicate
+      the status of a shared calendar.
+
+   Sharing Reply  A message sent by a sharee to a sharer to indicate the
+      status of a shared calendar.
+
+
+3.  Overview
+
+   This section provides a basic overview of this protocol by way of a
+   simple use case of a sharer sharing a calendar with a single sharee.
+
+   To share a calendar with another user, the sharer's client executes
+   an HTTP POST request against the calendar collection resource for the
+   calendar to be shared.  The POST request body will contain details of
+   the calendar user to whom the calendar is to be shared as well as the
+   access right to be granted to them.  If the request succeeds, a
+   notification is sent to the sharee with details of the calendar being
+   shared to them.
+
+   The sharer's client will show the notification to the sharee and
+   present them with the choice to accept or decline the invitation to
+   the shared calendar.  If the sharee chooses to decline, then nothing
+   changes for that sharee.  If the sharee chooses to accept, then the
+   server automatically creates a new calendar collection resource in
+   the sharee's calendar home collection, and ensures that calendar
+   provides a mapping to the actual shared calendar of the sharer.  Thus
+   the shared calendar is available to the sharee as just another
+   calendar in their calendar home.  The server enforces the appropriare
+   access privileges for the sharee.
+
+   At any time, the sharer can inspect properties on the calendar
+   collection being shared, and determine the accept/decline status of
+   each sharee.  Additional sharees can be added and existing ones
+   removed.  The access privileges for existing sharees can also be
+   changed.
+
+   Once a sharee has a shared calendar set to appear in their calendar
+   home collection, they can remove it and decline the sharing invite by
+   simply having their client issue an HTTP DELETE request on the shared
+   calendar collection.  That does not delete any calendar data, but
+   rather simply removes the "link" to the sharer's calendar collection
+   and sets the sharee's inviate status to declined.
+
+
+
+
+
+
+Daboo & York                                                    [Page 4]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+4.  Notifications
+
+   In order to facilitate the process of sharing invitations, this
+   specification defines a new generic notification mechanism for CalDAV
+   servers.  When this feature is available, a CS:notification-URL
+   (Section 4.1.1) property appears on principal resources for those
+   principals who are able to receive notifications.  That property
+   specifies a single DAV:href element whose content refers to a WebDAV
+   collection resource.  Notification "messages" are deposited into this
+   collection and can be retrieved by clients and acted on accordingly.
+
+   The notification collection referenced by the CS:notification-URL
+   (Section 4.1.1) property MUST have a DAV:resourcetype property with
+   DAV:collection and CS:notification (Section 6.24) child elements.
+
+   Notification "messages" are XML documents stored as resources in the
+   notification collection.  Each XML document contains a CS:
+   notification (Section 6.24) element as its root.  The root element
+   contains a CS:dtstamp (Section 6.25) element, and one additional
+   element which represents the type of notification being conveyed in
+   the message.  That child element will typically contain additional
+   content that describes the notification.
+
+   Each notification resource has a CS:notificationtype (Section 4.2.1)
+   property which contains as its single child element an empty element
+   that matches the child element of the notification resource XML
+   document root.  Any attributes on the child element in the XML
+   document are also present in the property child element.
+
+   Notifications are automatically generated by the server (perhaps in
+   response to a client action) with an appropriate resource stored in
+   the notifications collection of the user to whom the notification is
+   targeted.  Clients SHOULD monitor the notification collection looking
+   for new notification resources.  When doing so, clients SHOULD look
+   at the CS:notificationtype (Section 4.2.1) property to ensure that
+   the notification is of a type that the client can handle.  Once a
+   client has handled the notification in whatever way is appropriate it
+   SHOULD delete the notification resource.  Servers MAY delete
+   notification resources on their own if they determine that the
+   notifications are no longer relevant or valid.  Servers MAY coalesce
+   notifications as appropriate.
+
+4.1.  Additional Principal Properties
+
+   This section defines new properties for WebDAV principal resources as
+   defined in RFC3744 [RFC3744].  These properties are likely to be
+   protected but the server MAY allow them to be written by appropriate
+   users.
+
+
+
+Daboo & York                                                    [Page 5]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+4.1.1.  CS:notification-URL Property
+
+   Name:  notification-URL
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Identify the URL of the notification collection owned by
+      the associated principal resource.
+
+   Protected:  This property SHOULD be protected.
+
+   PROPFIND behavior:  This property SHOULD NOT be returned by a
+      PROPFIND allprop request (as defined in Section 14.2 of
+      [RFC4918]).
+
+   COPY/MOVE behavior:  This property value SHOULD be preserved in COPY
+      and MOVE operations.
+
+   Description:  This property is needed for a client to determine where
+      the notification collection of the current user is located so that
+      processing of notification messages can occur.  If not present,
+      then the associated calendar user is not enabled for notification
+      messages on the server.
+
+   Definition:
+
+   <!ELEMENT notification-URL (DAV:href)>
+
+4.2.  Properties on Notification Resources
+
+   The following new WebDAV properties are defined for notification
+   resources.
+
+4.2.1.  CS:notificationtype Property
+
+   Name:  notificationtype
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Identify the type of notification of the corresponding
+      resource.
+
+   Protected:  This property MUST be protected.
+
+   PROPFIND behavior:  This property SHOULD NOT be returned by a
+      PROPFIND allprop request (as defined in Section 14.2 of
+      [RFC4918]).
+
+
+
+
+Daboo & York                                                    [Page 6]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   COPY/MOVE behavior:  This property value MUST be preserved in COPY
+      and MOVE operations.
+
+   Description:  This property allows a client, via a PROPFIND Depth:1
+      request, to quickly find notification messages that the client can
+      handle in a notification collection.  The single child element is
+      the notification resource root element's child defining the
+      notification itself.  This element MUST be empty, though any
+      attributes on the element in the notification resource MUST be
+      present in the property element.
+
+   Definition:
+
+   <!ELEMENT notificationtype (invite-notification | invite-reply)>
+   <!-- Child elements are empty but will have appropriate attributes.
+        Any valid notification message child element can appear.-->
+
+
+5.  Shared Calendaring
+
+5.1.  Feature Discovery
+
+   A server that supports the features described in this document MUST
+   include "calendarserver-sharing" as a field in the DAV response
+   header from an OPTIONS request on any resource that supports these
+   features.
+
+5.2.  Additional Properties for Calendars
+
+   The following new or modified WebDAV properties are defined for
+   calendar collections and used to view or manipulate shared calendar
+   features.
+
+5.2.1.  DAV:resourcetype Property
+
+   Calendar collections that are shared have addition elements listed in
+   their DAV:resourcetype property in addition to DAV:collection and
+   CALDAV:calendar.
+
+   o  CS:shared-owner (Section 6.1): used to indicate that the calendar
+      is owned by the current user and is being shared by them.
+
+   o  CS:shared (Section 6.2): used to indicate that the calendar is
+      owned by another user and is being shared to the current user.
+
+
+
+
+
+
+
+Daboo & York                                                    [Page 7]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+5.2.2.  CS:invite Property
+
+   Name:  invite
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Used to show to whom a calendar has been shared.
+
+   Protected:  This property MUST be protected.
+
+   PROPFIND behavior:  This property SHOULD NOT be returned by a
+      PROPFIND allprop request (as defined in Section 14.2 of
+      [RFC4918]).
+
+   COPY/MOVE behavior:  This property value MUST be preserved in COPY
+      and MOVE operations.
+
+   Description:  This WebDAV property is present on a calendar
+      collection resource that has been shared by the owner, or on the
+      calendar collection resources of the sharees of the calendar.  It
+      provides a list of users to whom the calendar has been shared,
+      along with the "status" of the sharing invites sent to each user.
+      In addition, servers SHOULD include a CS:organizer XML element on
+      calendar collection resources of the sharees to provide clients
+      with a fast way to determine who the sharer is.  A server's local
+      privacy policy may prevent sharees from knowing about other
+      sharees on a shared calendar.  If that is so server will not
+      include CS:user XML elements for other sharees.
+
+   Definition:
+
+   <!ELEMENT invite (organizer?, user*)>
+
+5.2.3.  CS:allowed-sharing-modes Property
+
+   Name:  allowed-sharing-modes
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Used to show which modes of sharing are supported on a
+      calendar collection.
+
+   Protected:  This property MUST be protected.
+
+   PROPFIND behavior:  This property SHOULD NOT be returned by a
+      PROPFIND allprop request (as defined in Section 14.2 of
+      [RFC4918]).
+
+
+
+
+Daboo & York                                                    [Page 8]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   COPY/MOVE behavior:  This property value MUST be preserved in COPY
+      and MOVE operations.
+
+   Description:  This WebDAV property is present on a calendar
+      collection resource that can been shared or published.  It
+      provides a list of options indicating what sharing modes are
+      allowed as per Section 5.5.2.
+
+   Definition:
+
+   <!ELEMENT allowed-sharing-modes
+             (can-be-shared?, can-be-published?)>
+
+5.2.4.  CS:shared-url Property
+
+   Name:  shared-url
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Indicates the URL of the owner's copy of a shared calendar.
+
+   Protected:  This property MUST be protected.
+
+   PROPFIND behavior:  This property SHOULD NOT be returned by a
+      PROPFIND allprop request (as defined in Section 14.2 of
+      [RFC4918]).
+
+   COPY/MOVE behavior:  This property value MUST be preserved in COPY
+      and MOVE operations.
+
+   Description:  This WebDAV property is present on a shared calendar
+      collection resource that appears in a sharee's calendar home
+      collection.  Its content is a single DAV:href element whose value
+      is the URL of the sharer's calendar being shared.
+
+   Definition:
+
+   <!ELEMENT shared-url (DAV:href)>
+
+5.3.  Sharer Actions on Shared Calendars
+
+5.3.1.  Sharing or Unsharing a Calendar
+
+   To update an existing calendar to be shared, the sharer simply adds
+   one or more sharees to the calendar collection as per Section 5.3.2.
+   The server MUST update the DAV:resourcetype property on the calendar
+   collection to ensure it contains a CS:shared-owner XML element to
+   indicate the calendar collection is now shared.
+
+
+
+Daboo & York                                                    [Page 9]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   To unshare a calendar, the sharer simply removes all sharees to the
+   CS:invite property of the calendar collection as per Section 5.3.2.
+   The server MUST update the DAV:resourcetype property on the calendar
+   collection to ensure it does not contain a CS:shared-owner XML
+   element to indicate the calendar collection is not shared.
+
+5.3.2.  Manipulating Sharees of a Shared Calendar
+
+   The sharer of a shared calendar is able to manipulate the sharee list
+   by issuing a POST request targeted at the calendar collection
+   resource.  The POST request MUST contain an XML document as its body
+   with the root element being CS:share (Section 6.26).
+
+   The CS:share (Section 6.26) element in the POST requests MUST contain
+   one or more CS:set (Section 6.27) or CS:remove (Section 6.28)
+   elements.  For each CS:set (Section 6.27) element, the server MUST
+   add the specified sharee access to the calendar.  For each CS:remove
+   (Section 6.28) element the server MUST remove the specified sharee
+   access from the shared calendar.  In each case the server MUST send a
+   notification message to any sharees whose status is changed (added,
+   modified or removed), indicating to them a change in status for the
+   shared calendar.  The server SHOULD NOT send notification messages to
+   sharees whose status is unchanged.
+
+   Sharee's are identified via a DAV:href element whose value is either
+   a principal-URL for a sharee hosted on the same server, a calendar
+   user address or email address.  In the case of the later two, the
+   sharee might not be a user on the same server - though in that case
+   how invitations are sent or access enabled is out of scope for this
+   specification.  A server MAY change the sharee's "address" to any
+   suitable alternative that it might prefer when returning the list of
+   sharees via the CS:invite property (Section 5.2.2).
+
+   The client MAY include a CS:common-name (Section 6.19) element in the
+   CS:set (Section 6.27) element.  When provided, the value represents
+   the common name for the sharee, and is returned in the list of
+   sharees via the CS:invite property (Section 5.2.2).  The server MAY
+   change this to a suitable alternative when it is able to match the
+   sharee to a known user.  If absent from the client request, the
+   server SHOULD add a CS:common-name when it is able to match the
+   sharee with a known user, and a common name for that user can be
+   determined.
+
+   When the sharee list on a shared calendar is changed, the server MUST
+   send notifications to each sharee to update them on their current
+   sharing status.  This is accomplished by sending a CS:invite-
+   notification (Section 6.15) notification to each sharee.
+
+
+
+
+Daboo & York                                                   [Page 10]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+5.3.2.1.  Example: Successful Sharee Add Request
+
+   This example shows how to add a single sharee (with calendar user
+   address "mailto:eric at example.com") to a shared calendar with CS:read-
+   write access.
+
+   >> Request <<
+
+   POST /calendars/users/cyrus/shared/ HTTP/1.1
+   Host: calendar.example.com
+   Content-Type: application/xml; charset="utf-8"
+   Content-Length: xxxx
+
+   <?xml version="1.0" encoding="utf-8" ?>
+   <CS:share xmlns:D="DAV:"
+                 xmlns:CS="http://calendarserver.org/ns/">
+     <CS:set>
+       <D:href>mailto:eric at example.com</D:href>
+       <CS:common-name>Eric York</CS:common-name>
+       <CS:summary>Shared workspace</CS:summary>
+       <CS:read-write />
+     </CS:set>
+   </CS:share>
+
+   >> Response <<
+
+   HTTP/1.1 200 OK
+   Cache-Control: no-cache
+   Date: Sat, 11 Nov 2006 09:32:12 GMT
+
+5.3.2.2.  Example: Successful Multiple Sharee Change Request
+
+   This example shows how multiple sharee's can be manipulated in a
+   single request.  The sharee with calendar user address
+   "mailto:eric at example.com" has their access downgraded to CS:read,
+   whilst another sharee is removed from the access list entirely.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Daboo & York                                                   [Page 11]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   >> Request <<
+
+   POST /calendars/users/cyrus/shared/ HTTP/1.1
+   Host: calendar.example.com
+   Content-Type: application/xml; charset="utf-8"
+   Content-Length: xxxx
+
+   <?xml version="1.0" encoding="utf-8" ?>
+   <CS:share xmlns:D="DAV:"
+                 xmlns:CS="http://calendarserver.org/ns/">
+     <CS:set>
+       <D:href>mailto:eric at example.com</D:href>
+       <CS:summary>Shared workspace</CS:summary>
+       <CS:read-write />
+     </CS:set>
+     <CS:remove>
+       <D:href>mailto:wilfredo at example.com</D:href>
+     </CS:remove>
+   </CS:share>
+
+   >> Response <<
+
+   HTTP/1.1 200 OK
+   Cache-Control: no-cache
+   Date: Sat, 11 Nov 2006 09:32:12 GMT
+
+5.4.  Sharee Actions on Shared Calendars
+
+5.4.1.  Replying to a Sharing Invite
+
+   When a sharee is invited to a shared calendar they can accept or
+   decline the invite by issuing a POST request to the sharee's calendar
+   home collection resource.  The POST request MUST contain an XML
+   document as its body with the root element being CS:invite-reply
+   (Section 6.22).
+
+   The CS:invite-reply (Section 6.22) element in the POST request
+   specifies the sharee who is replying in the DAV:href element, the
+   accept or decline action via the CS:invite-accepted or CS:invite-
+   declined elements, the URL of the shared calendar in the CS:hosturl
+   element, the unique identifier of the invite to which it is a reply
+   in the CS:in-reply-to element, and an optional CS:summary element.
+
+   The response to a POST request that accepts a shared calendar invite
+   MUST be an XML document containing CS:shared-as (Section 6.29) as its
+   root element.  That root element contains a single DAV:href element
+   whose content is the URI of the shared calendar in the sharee's
+   calendar home created by the invite acceptance.
+
+
+
+Daboo & York                                                   [Page 12]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   When the sharee replies to an invite, the server SHOULD send a
+   notification to the sharer to update them on the change in the sharee
+   state.  This is accomplished by sending a CS:invite-reply
+   (Section 6.22) notification to the sharer.
+
+5.4.2.  Removing a Shared Calendar
+
+   To remove a shared calendar from a sharee's calendar home collection
+   a DELETE request is targeted at the shared calendar URI.  When such a
+   request is received the server MUST remove the shared calendar from
+   the sharee's calendar home and automatically update the sharee's
+   status in the sharer's calendar's CS:invite property.
+
+5.5.  General Considerations
+
+5.5.1.  Access Levels
+
+   Two levels of access ca be granted by a sharer to any sharee.  These
+   are governed by the CS:access element used in the CS:invite/CS:user
+   element that specifies a shared user invite.  CS:access contains a
+   single empty element that defines the type of access granted:
+
+   CS:read  When present this indicates that sharees can read calendar
+      data but cannot change it.
+
+   CS:read-write  When present this indicates that sharees can read and
+      write calendar data.
+
+5.5.2.  Allowing or Disallowing Sharing
+
+   Servers MAY support calendar sharing on a per-calendar basis - e.g.,
+   they could treat some calendars as always private (cannot be shared)
+   or always public (always shared).  As a result clients need a way to
+   determine which calendar could be shared so they can enable or
+   disable sharing options on a per-calendar basis.
+
+   This specification adds a CS:allowed-sharing-modes (Section 5.2.3)
+   WebDAV property which servers can return on calendar collection
+   resources.  This property contains XML elements that describe which
+   sharing or publishing capabilities can be supported by the
+   corresponding calendar collection:
+
+      CS:can-be-shared (Section 6.3): when present indicates that the
+      calendar collection can be shared.  When not present, the calendar
+      collection cannot be shared.
+
+      CS:can-be-published (Section 6.4): when present indicates that the
+      calendar collection can be published.  When not present, the
+
+
+
+Daboo & York                                                   [Page 13]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+      calendar collection cannot be published.
+
+   When not present on a calendar collection, sharing or publishing of
+   that calendar is not allowed.  Clients SHOULD NOT attempt to use
+   requests to enable sharing or publishing targeted at those calendar
+   collections.
+
+5.5.3.  Per-user WebDAV Properties
+
+   Servers MUST support "per-user" WebDAV properties on shared calendar
+   collections and MAY support them on calendar object resources within
+   shared calendar collections.  A "per-user" WebDAV property is one
+   whose value can be set and retrieved independently by each user with
+   appropriate access rights. e.g., user "A" changes the DAV:displayname
+   property on a shared calendar in their calendar home to "My
+   calendar", and user "B" changes the same property to "Shared" on the
+   same shared calendar in their calendar home.  When each user
+   retrieves the property value they will see their own last stored
+   value and not the value of the other user.
+
+   For shared calendars, the server MUST allow all users to write "per-
+   user" WebDAV properties on the shared calendar collection and MAY
+   allow property writes on calendar object resources within the shared
+   calendar collection.  This is required even in the case where the
+   sharee has been granted read access only (i.e., the ability to change
+   calendar data is disallowed).  This requirement ensures that sharees
+   can always change "personal" properties such as calendar colors and
+   display names.
+
+   Servers MUST treat the following properties as "per-user":
+
+      DAV:displayname
+
+      CALDAV:calendar-description
+
+      CALDAV:schedule-calendar-transp
+
+      ICAL:calendar-color
+
+   Servers MAY treat any dead property as per-user.
+
+   Servers MUST NOT treat live properties as per-user.
+
+5.5.4.  Per-user Calendar Data
+
+   Servers MUST support "per-user" calendar data in calendar object
+   resources stored in shared calendars.  This allows each sharee and
+   the sharer to store their own alarms and free busy transparency
+
+
+
+Daboo & York                                                   [Page 14]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   status without "interfering" with other users who also have access to
+   the same calendar object resources.
+
+   For calendaring object resources in shared calendar collections, the
+   server MUST treat the following iCalendar data objects as per-user:
+
+      TRANSP property
+
+      VALARM component
+
+   Servers MAY treat any non-standard X- iCalendar properties as per-
+   user.
+
+   When handling per-user data in recurring components, servers SHOULD
+   eliminate overridden instances when returning iCalendar data to
+   clients in the case where there are no differences between the
+   overridden component and the instance that could be derived from the
+   "master" recurrence component.  For example, consider a daily
+   recurring event, Monday through Friday, initially defined without any
+   overridden instances, that is in a shared calendar.  If user "A"
+   overrides the Tuesday instance and adds their own "VALARM" component
+   only, then when user "A" later retrieves the data again they would
+   see that overridden instance, but when user "B" does so, they would
+   not.  This ensures that each user sees the most "compact"
+   representation of the calendar data.
+
+5.5.5.  Scheduling
+
+   CalDAV Scheduling [RFC6638] defines how a CalDAV server carries out
+   scheduling operations when calendar object resources are created,
+   modified or deleted and include "ORGANIZER" and "ATTENDEE" iCalendar
+   properties.
+
+   When calendar object resources are created, modified or deleted in
+   shared calendars by sharees, the following restrictions apply:
+
+   1.  The "ORGANIZER" iCalendar property value in the iCalendar data
+       MUST match a calendar user address of the sharer (owner) of the
+       shared calendar.  The DAV:owner WebDAV property MUST be present
+       on a shared calendar and MUST provide a reference to a principal-
+       URL of the sharer (owner) of the shared calendar.  Clients can
+       use this value to determine what the allowed "ORGANIZER"
+       iCalendar property values are.  The server MUST reject any
+       attempt by a sharee to create an iCalendar component with an
+       "ORGANIZER" property value other than the sharer (owner) of the
+       shared calendar.
+
+
+
+
+
+Daboo & York                                                   [Page 15]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   2.  The server MUST reject any attempt by a sharee to MOVE a calendar
+       object resource in a shared calendar to some other collection.
+
+   3.  When a sharee is listed as an Attendee in a calendar object
+       resource in a shared calendar, and write access is granted, the
+       sharee is allowed to change not only iCalendar data related to
+       the Organizer, but also data related to the Attendee. i.e., a
+       sharee can change their own participation status on the
+       "ATTENDEE" iCalendar property referring to them.  Additionally,
+       if the sharee is not listed as an Attendee, and write access is
+       granted, the sharee can add themselves as an Attendee.
+
+   4.  The default calendar collection defined in Section 6.3 of
+       [RFC6638] MUST NOT be a calendar shared to the corresponding
+       calendar user.
+
+   Following are additional considerations for scheduling with shared
+   calendars:
+
+   1.  A scheduled iCalendar component could appear in more than one
+       calendar collection within a sharee's calendar home if the sharee
+       is an Attendee and the Organizer or other Attendees have shared a
+       calendar with the sharee that includes their copies of the
+       iCalendar component.  It is important to note that the scheduled
+       component in the shared calendar could have different access
+       rights than the one in the sharee's owned calendar.
+
+   2.  A scheduled iCalendar component appearing in a sharee's shared
+       calendar could include the sharee as an Attendee.  For recurring
+       events, it is possible for the sharee to only be listed as an
+       Attendee in some instances, as opposed to all.  Clients will need
+       to be aware of this when allowing sharee's to set their own
+       participation status.
+
+   In addition, when a shared calendar is first accepted by a sharee,
+   the server SHOULD set the CALDAV:schedule-calendar-transp property to
+   the value CALDAV:transparent to ensure newly accepted shared
+   calendars do not contribute to the sharee's freebusy time until the
+   sharee explicitly requests it.
+
+
+6.  XML Element Definitions
+
+6.1.  CS:shared-owner
+
+
+
+
+
+
+
+Daboo & York                                                   [Page 16]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Name:  shared-owner
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Used to indicate that a calendar is being shared by the
+      owner.
+
+   Description:  This property appears in the DAV:resourcetype property
+      on the calendar collection resource shared by a sharer.  See
+      Section 5.2.
+
+   Definition:
+
+   <!ELEMENT shared-owner EMPTY>
+
+6.2.  CS:shared
+
+   Name:  shared
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Used to indicate that a calendar is being shared to a
+      sharee.
+
+   Description:  This property appears in the DAV:resourcetype property
+      on a calendar collection resource that is shared to a sharee and
+      appears in the sharee's calendar home collection.  See
+      Section 5.2.
+
+   Definition:
+
+   <!ELEMENT shared EMPTY>
+
+6.3.  CS:can-be-shared
+
+   Name:  can-be-shared
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Used to indicate that a calendar can be shared.
+
+   Description:  This element indicates that a calendar can be shared
+      with other users.  See Section 5.2.3
+
+   Definition:
+
+   <!ELEMENT can-be-shared EMPTY>
+
+
+
+
+Daboo & York                                                   [Page 17]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+6.4.  CS:can-be-published
+
+   Name:  can-be-published
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Used to indicate that a calendar can be published.
+
+   Description:  This element indicates that a calendar can be published
+      to anyone.  See Section 5.2.3
+
+   Definition:
+
+   <!ELEMENT can-be-published EMPTY>
+
+6.5.  CS:user
+
+   Name:  user
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Used to show status of sharing invites sent to sharees.
+
+   Description:  This element provides the "status" of a sharing invite
+      sent to a particular user.  See Section 5.2.2.
+
+   Definition:
+
+   <!ELEMENT user (DAV:href, common-name?, (invite-noresponse |
+                   invite-accepted | invite-declined | invite-invalid),
+                   access, summary?)>
+
+6.6.  CS:invite-noresponse
+
+   Name:  invite-noresponse
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Sharing invite status.
+
+   Description:  When used in a CS:user (Section 6.5) element, this
+      element is used to indicate that the sharee has never replied to
+      the corresponding sharing invite.  When used in a CS:invite-
+      notification (Section 6.15) element, this element is used to
+      indicate to the sharee that a sharing reply is needed.
+
+
+
+
+
+
+Daboo & York                                                   [Page 18]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Definition:
+
+   <!ELEMENT invite-noresponse EMPTY>
+
+6.7.  CS:invite-deleted
+
+   Name:  invite-deleted
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Sharing invite status.
+
+   Description:  When used in a CS:invite-notification (Section 6.15)
+      element, this element is used to indicate to the sharee that a
+      shared calendar has been unshared by the sharer.
+
+   Definition:
+
+   <!ELEMENT invite-deleted EMPTY>
+
+6.8.  CS:invite-accepted
+
+   Name:  invite-accepted
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Sharing invite status.
+
+   Description:  When used in a CS:user (Section 6.5) element, this
+      element is used to indicate that the sharee has accepted the
+      corresponding sharing invite.  When used in a CS:invite-
+      notification (Section 6.15) element, this element is used to
+      indicate to the sharee that the sharing invite is an update for
+      one they previously accepted.
+
+   Definition:
+
+   <!ELEMENT invite-accepted EMPTY>
+
+6.9.  CS:invite-declined
+
+   Name:  invite-declined
+
+   Namespace:  http://calendarserver.org/ns/
+
+
+
+
+
+
+
+Daboo & York                                                   [Page 19]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Purpose:  Sharing invite status.
+
+   Description:  When used in a CS:user (Section 6.5) element, this
+      element is used to indicate that the sharee has declined the
+      corresponding sharing invite.  When used in a CS:invite-
+      notification (Section 6.15) element, this element is used to
+      indicate to the sharee that the sharing invite is an update for
+      one they previously declined.
+
+   Definition:
+
+   <!ELEMENT invite-declined EMPTY>
+
+6.10.  CS:invite-invalid
+
+   Name:  invite-invalid
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Sharing invite status.
+
+   Description:  When used in a CS:user (Section 6.5) element, this
+      element is used to indicate that the corresponding sharee is not a
+      valid calendar user known to the server.
+
+   Definition:
+
+   <!ELEMENT invite-invalid EMPTY>
+
+6.11.  CS:access
+
+   Name:  access
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Shared calendar access level.
+
+   Description:  When used in a CS:user (Section 6.5) element, this
+      element is used to indicate the sharing access level granted to
+      the corresponding sharee.
+
+   Definition:
+
+   <!ELEMENT access (read | read-write)>
+
+
+
+
+
+
+
+Daboo & York                                                   [Page 20]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+6.12.  CS:read
+
+   Name:  read
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Shared calendar access level privilege.
+
+   Description:  Indicates that the access level granted only allows
+      sharees to read data in the shared calendar (though they can write
+      per-user data (Section 5.5.4)).
+
+   Definition:
+
+   <!ELEMENT read EMPTY>
+
+6.13.  CS:read-write
+
+   Name:  read-write
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Shared calendar access level privilege.
+
+   Description:  Indicates that the access level granted allows sharees
+      to read and write all data in the shared calendar, with the
+      exception of components that would trigger scheduling.
+
+   Definition:
+
+   <!ELEMENT read-write EMPTY>
+
+6.14.  CS:summary
+
+   Name:  summary
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Summary or title of shared calendar.
+
+   Description:  A brief description of a shared calendar.  This can be
+      used by sharers to communicate the nature of a shared calendar to
+      sharees, as well as used by sharees to indicate back to the sharer
+      how each sharee is refering to the shared calendar.
+
+
+
+
+
+
+
+Daboo & York                                                   [Page 21]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Definition:
+
+   <!ELEMENT summary (#PCDATA)>
+
+6.15.  CS:invite-notification
+
+   Name:  invite-notification
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  A notification used as a shared calendar invite.
+
+   Description:  Defines a notification message sent automatically by
+      the server when a sharer adds, changes or removes a sharee from a
+      shared calendar.  The DAV:href element specifies the calendar user
+      address of the sharee to whom the message was sent.  The CALDAV:
+      supported-calendar-component-set is a copy of the matching WebDAV
+      property on the sharers calendar collection, to allow clients to
+      know what restrictions might apply to the shared calendar before
+      accepting it.
+
+   Definition:
+
+   <!ELEMENT invite-notification (
+               uid, DAV:href,
+               (invite-noresponse | invite-deleted |
+               invite-accepted | invite-declined),
+               access, hosturl, organizer,
+               summary?,
+               CALDAV:supported-calendar-component-set?>
+
+6.16.  CS:uid
+
+   Name:  uid
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Unique identifier.
+
+   Description:  A unique identifier for an invitation to a shared
+      calendar.
+
+   Definition:
+
+   <!ELEMENT uid (#PCDATA)>
+
+
+
+
+
+
+Daboo & York                                                   [Page 22]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+6.17.  CS:hosturl
+
+   Name:  hosturl
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Identifies the source URL of a shared calendar.
+
+   Description:  Contains a single DAV:href element that refers to the
+      source of a shared calendar - i.e., the URL of the calendar shared
+      by the sharer.
+
+   Definition:
+
+   <!ELEMENT hosturl (DAV:href)>
+
+6.18.  CS:organizer
+
+   Name:  organizer
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Identifies the sharer of a shared calendar.
+
+   Description:  Contains a single DAV:href element that identifies the
+      calendar user address of the sharer of a shared calendar, and an
+      optional CS:common-name element that matches that user, and an
+      option CS:first-name, CS:last-name pair of elements that match
+      that user.  In some cases servers might have directory information
+      that includes only the common name, or only the first or last
+      name, and it is better to expose those directly to the client
+      as-is rather than to try and split or combine the attributes to
+      synthesize one set or the other.
+
+   Definition:
+
+   <!ELEMENT organizer (DAV:href,
+                        CS:common-name?,
+                        (CS:first-name, CS:last-name)?)>
+
+6.19.  CS:common-name
+
+   Name:  common-name
+
+   Namespace:  http://calendarserver.org/ns/
+
+
+
+
+
+
+Daboo & York                                                   [Page 23]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Purpose:  The common name of a sharer or sharee.
+
+   Description:  The common name is optionally provided by a client when
+      adding a sharee and optionally included (or modified) by the
+      server when returning results for sharers or sharees and in
+      notifications.
+
+   Definition:
+
+   <!ELEMENT common-name (#PCDATA)>
+
+6.20.  CS:first-name
+
+   Name:  first-name
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  The first name of a sharer or sharee.
+
+   Description:  The first name is optionally included by the server
+      when returning results for sharers or sharees and in
+      notifications.
+
+   Definition:
+
+   <!ELEMENT first-name (#PCDATA)>
+
+6.21.  CS:last-name
+
+   Name:  last-name
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  The last name of a sharer or sharee.
+
+   Description:  The last name is optionally included by the server when
+      returning results for sharers or sharees and in notifications.
+
+   Definition:
+
+   <!ELEMENT last-name (#PCDATA)>
+
+6.22.  CS:invite-reply
+
+
+
+
+
+
+
+
+Daboo & York                                                   [Page 24]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Name:  invite-reply
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  A notification used as a reply to a shared calendar invite.
+
+   Description:  Defines a notification message sent automatically by
+      the server when a sharee replies to a shared calendar invite.  The
+      DAV:href element specifies the calendar user address of the sharee
+      to whom the original invite message was sent.
+
+   Definition:
+
+   <!ELEMENT invite-reply (DAV:href,
+                           (invite-accepted | invite-declined),
+                           hosturl, in-reply-to, summary?>
+
+6.23.  CS:in-reply-to
+
+   Name:  in-reply-to
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Unique identifier.
+
+   Description:  Specifies the unique identifier of the inviate message
+      that this notification message is a reply to.
+
+   Definition:
+
+   <!ELEMENT in-reply-to (#PCDATA)>
+
+6.24.  CS:notification
+
+   Name:  notification
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Notification message root element.
+
+   Description:  The root element used in notification resources.
+
+   Definition:
+
+   <!ELEMENT notification (CS:dtstamp,
+                           (invite-notification | invite-reply)>
+   <!-- Any notification type element can appear after CS:dtstamp,
+        this specification defines only the two listed above -->
+
+
+
+Daboo & York                                                   [Page 25]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+6.25.  CS:dtstamp
+
+   Name:  dtstamp
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Date-time stamp.
+
+   Description:  Contains the date-time stamp corresponding to the
+      creation of a notification message.
+
+   Definition:
+
+   <!ELEMENT dtstamp (#PCDATA)>
+
+6.26.  CS:share
+
+   Name:  share
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Describes changes to sharees.
+
+   Description:  The root element used in POST requests on calendars by
+      sharers to manipulate the sharee list of a shared calendar.
+
+   Definition:
+
+   <!ELEMENT share (set | remove)*>
+
+6.27.  CS:set
+
+   Name:  set
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Sets access for a sharee.
+
+   Description:  Used to add or modify sharee access to a shared
+      calendar.  The specified access to the shared calendar is given to
+      the sharee.
+
+   Definition:
+
+   <!ELEMENT set (DAV:href, common-name?, summary?,
+                  (read | read-write)>
+
+
+
+
+
+Daboo & York                                                   [Page 26]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+6.28.  CS:remove
+
+   Name:  remove
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Removes access for a sharee.
+
+   Description:  Used to remove sharee access to a shared calendar.  All
+      access to the shared calendar is removed for the sharee.
+
+   Definition:
+
+   <!ELEMENT remove (DAV:href)>
+
+6.29.  CS:shared-as
+
+   Name:  shared-as
+
+   Namespace:  http://calendarserver.org/ns/
+
+   Purpose:  Identifies a shared calendar.
+
+   Description:  Returned by the server for a POST request by a sharee
+      accepting a shared calendar invite.  The DAV:href element
+      specifies the URI of the calendar created by the acceptance.
+
+   Definition:
+
+   <!ELEMENT shared-as (DAV:href)>
+
+
+7.  Security Considerations
+
+   Per-user WebDAV properties and iCalendar data MUST only be accessible
+   by the user that created them.
+
+   Alarms set by the sharer SHOULD NOT be propagated to sharees by
+   default.  Clients SHOULD NOT automatically enable triggering of
+   alarms on shared calendars that have just been accepted without
+   confirmation by the user.
+
+   TBD
+
+
+8.  IANA Considerations
+
+   This document does not require any actions on the part of IANA.
+
+
+
+Daboo & York                                                   [Page 27]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+9.  Acknowledgments
+
+   This specification is the result of discussions between the Apple
+   calendar server and client teams.
+
+
+10.  Normative References
+
+   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
+              Requirement Levels", BCP 14, RFC 2119, March 1997.
+
+   [RFC3744]  Clemm, G., Reschke, J., Sedlar, E., and J. Whitehead, "Web
+              Distributed Authoring and Versioning (WebDAV)
+              Access Control Protocol", RFC 3744, May 2004.
+
+   [RFC4791]  Daboo, C., Desruisseaux, B., and L. Dusseault,
+              "Calendaring Extensions to WebDAV (CalDAV)", RFC 4791,
+              March 2007.
+
+   [RFC4918]  Dusseault, L., "HTTP Extensions for Web Distributed
+              Authoring and Versioning (WebDAV)", RFC 4918, June 2007.
+
+   [RFC6638]  Daboo, C. and B. Desruisseaux, "Scheduling Extensions to
+              CalDAV", RFC 6638, June 2012.
+
+
+Appendix A.  Change History
+
+   Changes in -03:
+
+   1.  Fixed access element DTD.
+
+   2.  Remove MKxxx and PROPPATCH mechanism for upgrading/downgrading
+       shared state on a calendar collection.  Instead the server
+       implicitly sets the state based on whether there are any sharees
+       or not..
+
+   3.  Added CS:first-name and CS:last-name optional element to CS:
+       organizer.
+
+   4.  Added CALDAV:supported-calendar-component-set optional element to
+       CS:invite-notification.
+
+   Changes in -02:
+
+   1.  Removed read-write-shared access mode - now a server that does
+       not support shared scheduling should advertise that via a DAV
+       header
+
+
+
+Daboo & York                                                   [Page 28]
+
+                      CalDAV Sharing and Publishing       September 2012
+
+
+   Changes in -01:
+
+   1.  Added CS:shared-url property
+
+   2.  Clarified that notifications are only required to be sent when
+       sharee status is changed
+
+
+Authors' Addresses
+
+   Cyrus Daboo
+   Apple Inc.
+   1 Infinite Loop
+   Cupertino, CA  95014
+   USA
+
+   Email: cyrus at daboo.name
+   URI:   http://www.apple.com/
+
+
+   Eric York
+   Apple Inc.
+   1 Infinite Loop
+   Cupertino, CA  95014
+   USA
+
+   Email:
+   URI:   http://www.apple.com/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Daboo & York                                                   [Page 29]
+

Copied: CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.xml (from rev 9833, CalendarServer/trunk/doc/Extensions/caldav-sharing.xml)
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.xml	                        (rev 0)
+++ CalendarServer/branches/users/gaya/inviteclean/doc/Extensions/caldav-sharing.xml	2012-09-23 03:36:01 UTC (rev 9842)
@@ -0,0 +1,1025 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="../rfc2629.xslt"?>
+<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' [
+<!ENTITY rfc2119 PUBLIC '' 'bibxml/reference.RFC.2119.xml'>
+<!ENTITY rfc3744 PUBLIC '' 'bibxml/reference.RFC.3744.xml'>
+<!ENTITY rfc4791 PUBLIC '' 'bibxml/reference.RFC.4791.xml'>
+<!ENTITY rfc4918 PUBLIC '' 'bibxml/reference.RFC.4918.xml'>
+<!ENTITY rfc6638 PUBLIC '' 'bibxml/reference.RFC.6638.xml'>
+]> 
+<?rfc toc="yes"?>
+<?rfc tocdepth="4"?>
+<?rfc strict="yes"?>
+<?rfc comments="yes"?>
+<?rfc inline="yes"?>
+<?rfc symrefs="yes"?>
+<?rfc sortrefs="yes"?>
+<?rfc compact="yes"?>
+<?rfc subcompact="no"?>
+<?rfc private="Calendar Server Extension"?>
+<rfc ipr="none" docName='caldav-sharing-03'>
+    <front>
+        <title abbrev="CalDAV Sharing and Publishing">Shared and Published Calendars in CalDAV</title> 
+        <author initials="C." surname="Daboo" fullname="Cyrus Daboo">
+            <organization abbrev="Apple Inc.">
+                Apple Inc.
+            </organization>
+            <address>
+                <postal>
+                    <street>1 Infinite Loop</street>
+                    <city>Cupertino</city>
+                    <region>CA</region>
+                    <code>95014</code> 
+                    <country>USA</country>
+                </postal>
+                <email>cyrus at daboo.name</email>
+                <uri>http://www.apple.com/</uri>
+            </address>
+        </author>
+        <author initials="E." surname="York" fullname="Eric York">
+            <organization abbrev="Apple Inc.">
+                Apple Inc.
+            </organization>
+            <address>
+                <postal>
+                    <street>1 Infinite Loop</street>
+                    <city>Cupertino</city>
+                    <region>CA</region>
+                    <code>95014</code> 
+                    <country>USA</country>
+                </postal>
+                <email></email>
+                <uri>http://www.apple.com/</uri>
+            </address>
+        </author>
+        <date/>
+        <abstract>
+            <t>
+                This specification defines an extension to CalDAV that enables the sharing of calendars between users on a CalDAV server.
+            </t>
+        </abstract>
+    </front>
+    <middle>
+        <section title='Introduction'>
+            <t>
+                <xref target="RFC4791">CalDAV</xref> provides a way for calendar users to store calendar data and exchange this data via scheduling operations. Based on the <xref target='RFC4918'>WebDAV</xref> protocol, it also includes the ability to manage access to calendar data via the <xref target='RFC3744'>WebDAV ACL</xref> extension.
+            </t>
+            <t>
+                <xref target='RFC3744'>WebDAV ACL</xref> provides a way to manage fine-grained access controls on WebDAV resources. Whilst this could be used directly to manage sharing of calendars, experience has shown that client developers are averse to using it due to its complexity. Instead a simpler process for sharing calendars is preferred.
+            </t>
+            <t>
+                This extension defines a way for individual calendar users to share calendars with other users. This is done via an "opt-in" process in which a sharing invite is sent from the sharer to a sharee, allowing the sharee to accept or decline. If the sharee accepts the sharing invite, the shared calendar is made available to them in their own calendar home collection (i.e., alongside their own personal calendars). HTTP POST operations are used to manage the sharing invitations and replies, and WebDAV properties are used to expose the state of shared calendars.
+            </t>
+        </section>
+
+        <!--<section title="Open Issues">
+            <t>
+                <list style="numbers">
+                    <t>
+                    </t>
+                </list>
+            </t>
+        </section>-->
+            
+        <section title='Conventions Used in This Document'>
+            <t>
+                The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target='RFC2119' />. 
+            </t>
+            <t>
+                When XML element types in the namespaces "DAV:" and "urn:ietf:params:xml:ns:caldav" are referenced in this document outside of the context of an XML fragment, the string "DAV:" and "CALDAV:" will be prefixed to the element type names respectively. 
+            </t>
+            <t>
+                The namespace "http://calendarserver.org/ns/" is used for XML elements defined in this specification.  When XML element types in that namespace are referenced in this document outside of the context of an XML fragment, the string "CS:" will be prefixed to the element type names. 
+            </t>
+            <t>Terms Used:
+                <list style='hanging'>
+                    <t hangText='Sharer'>A calendar user who is sharing a calendar with other calendar users.</t>
+                    <t hangText='Sharee'>A calendar user to whom a calendar has been shared.</t>
+                    <t hangText='Sharing Invite'>A message sent by a sharer to a sharee to indicate the status of a shared calendar.</t>
+                    <t hangText='Sharing Reply'>A message sent by a sharee to a sharer to indicate the status of a shared calendar.</t>
+                </list>
+            </t>
+        </section>
+         
+        <section title='Overview' anchor='overview'>
+            <t>
+                This section provides a basic overview of this protocol by way of a simple use case of a sharer sharing a calendar with a single sharee.
+            </t>
+            <t>
+                To share a calendar with another user, the sharer's client executes an HTTP POST request against the calendar collection resource for the calendar to be shared. The POST request body will contain details of the calendar user to whom the calendar is to be shared as well as the access right to be granted to them. If the request succeeds, a notification is sent to the sharee with details of the calendar being shared to them.
+            </t>
+            <t>
+                The sharer's client will show the notification to the sharee and present them with the choice to accept or decline the invitation to the shared calendar. If the sharee chooses to decline, then nothing changes for that sharee. If the sharee chooses to accept, then the server automatically creates a new calendar collection resource in the sharee's calendar home collection, and ensures that calendar provides a mapping to the actual shared calendar of the sharer. Thus the shared calendar is available to the sharee as just another calendar in their calendar home. The server enforces the appropriare access privileges for the sharee.
+            </t>
+            <t>
+                At any time, the sharer can inspect properties on the calendar collection being shared, and determine the accept/decline status of each sharee. Additional sharees can be added and existing ones removed. The access privileges for existing sharees can also be changed.
+            </t>
+            <t>
+                Once a sharee has a shared calendar set to appear in their calendar home collection, they can remove it and decline the sharing invite by simply having their client issue an HTTP DELETE request on the shared calendar collection. That does not delete any calendar data, but rather simply removes the "link" to the sharer's calendar collection and sets the sharee's inviate status to declined.
+            </t>
+        </section>
+        
+        <section title="Notifications">
+            <t>
+                In order to facilitate the process of sharing invitations, this specification defines a new generic notification mechanism for CalDAV servers. When this feature is available, a <xref target="CS:notification-URL">CS:notification-URL</xref> property appears on principal resources for those principals who are able to receive notifications. That property specifies a single DAV:href element whose content refers to a WebDAV collection resource. Notification "messages" are deposited into this collection and can be retrieved by clients and acted on accordingly.
+            </t>
+            <t>
+                The notification collection referenced by the <xref target="CS:notification-URL">CS:notification-URL</xref> property MUST have a DAV:resourcetype property with DAV:collection and <xref target="CS:notification">CS:notification</xref> child elements. 
+            </t>
+            <t>
+                Notification "messages" are XML documents stored as resources in the notification collection. Each XML document contains a <xref target="CS:notification">CS:notification</xref> element as its root. The root element contains a <xref target="CS:dtstamp">CS:dtstamp</xref> element, and one additional element which represents the type of notification being conveyed in the message. That child element will typically contain additional content that describes the notification.
+            </t>
+            <t>
+                Each notification resource has a <xref target="CS:notificationtype">CS:notificationtype</xref> property which contains as its single child element an empty element that matches the child element of the notification resource XML document root. Any attributes on the child element in the XML document are also present in the property child element.
+            </t>
+            <t>
+                Notifications are automatically generated by the server (perhaps in response to a client action) with an appropriate resource stored in the notifications collection of the user to whom the notification is targeted. Clients SHOULD monitor the notification collection looking for new notification resources. When doing so, clients SHOULD look at the <xref target="CS:notificationtype">CS:notificationtype</xref> property to ensure that the notification is of a type that the client can handle. Once a client has handled the notification in whatever way is appropriate it SHOULD delete the notification resource. Servers MAY delete notification resources on their own if they determine that the notifications are no longer relevant or valid. Servers MAY coalesce notifications as appropriate.
+            </t>
+            <section title="Additional Principal Properties" anchor='principal-properties'>
+                <t>
+                    This section defines new properties for WebDAV principal resources as defined in <xref target="RFC3744">RFC3744</xref>. These properties are likely to be protected but the server MAY allow them to be written by appropriate users.
+                </t>
+                <section title="CS:notification-URL Property" anchor="CS:notification-URL">
+                  <t>
+                    <list style="hanging">
+                      <t hangText="Name:">notification-URL</t>
+                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                      <t hangText="Purpose:">Identify the URL of the notification collection owned by the associated principal resource.</t>
+                      <t hangText="Protected:">This property SHOULD be protected.</t>
+                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
+                      <t hangText="COPY/MOVE behavior:">This property value SHOULD be preserved in COPY and MOVE operations.</t>
+        
+                      <t hangText="Description:">This property is needed for a client to determine where the notification collection of the current user is located so that processing of notification messages can occur. If not present, then the associated calendar user is not enabled for notification messages on the server.</t>
+                      <t hangText="Definition:">
+                        <figure>
+                          <artwork><![CDATA[
+<!ELEMENT notification-URL (DAV:href)>]]></artwork>
+                        </figure>
+                      </t>
+                    </list>
+                  </t>
+                </section>
+            </section>
+            <section title="Properties on Notification Resources" anchor='notification-properties'>
+                <t>
+                    The following new WebDAV properties are defined for notification resources.
+                </t>
+                <section title="CS:notificationtype Property" anchor="CS:notificationtype">
+                  <t>
+                    <list style="hanging">
+                      <t hangText="Name:">notificationtype</t>
+                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                      <t hangText="Purpose:">Identify the type of notification of the corresponding resource.</t>
+                      <t hangText="Protected:">This property MUST be protected.</t>
+                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
+                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
+        
+                      <t hangText="Description:">This property allows a client, via a PROPFIND Depth:1 request, to quickly find notification messages that the client can handle in a notification collection. The single child element is the notification resource root element's child defining the notification itself. This element MUST be empty, though any attributes on the element in the notification resource MUST be present in the property element.</t>
+                      <t hangText="Definition:">
+                        <figure>
+                          <artwork><![CDATA[
+<!ELEMENT notificationtype (invite-notification | invite-reply)>
+<!-- Child elements are empty but will have appropriate attributes.
+     Any valid notification message child element can appear.-->]]></artwork>
+                        </figure>
+                      </t>
+                    </list>
+                  </t>
+                </section>
+            </section>
+        </section>
+
+        <section title="Shared Calendaring">
+            <section title="Feature Discovery">
+                <t>
+                    A server that supports the features described in this document MUST include "calendarserver-sharing" as a field in the DAV response header from an OPTIONS request on any resource that supports these features.
+                </t>
+            </section>
+            <section title="Additional Properties for Calendars" anchor='properties'>
+                <t>
+                    The following new or modified WebDAV properties are defined for calendar collections and used to view or manipulate shared calendar features.
+                </t>
+                <section title="DAV:resourcetype Property" anchor="DAV:resourcetype">
+                    <t>
+                        Calendar collections that are shared have addition elements listed in their DAV:resourcetype property in addition to DAV:collection and CALDAV:calendar.
+                        <list style="symbols">
+                            <t><xref target="CS:shared-owner">CS:shared-owner</xref>: used to indicate that the calendar is owned by the current user and is being shared by them.</t>
+                            <t><xref target="CS:shared">CS:shared</xref>: used to indicate that the calendar is owned by another user and is being shared to the current user.</t>
+                        </list>
+                    </t>
+                </section>
+                <section title="CS:invite Property" anchor="CS:invite">
+                  <t>
+                    <list style="hanging">
+                      <t hangText="Name:">invite</t>
+                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                      <t hangText="Purpose:">Used to show to whom a calendar has been shared.</t>
+                      <t hangText="Protected:">This property MUST be protected.</t>
+                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
+                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
+        
+                      <t hangText="Description:">This WebDAV property is present on a calendar collection resource that has been shared by the owner, or on the calendar collection resources of the sharees of the calendar. It provides a list of users to whom the calendar has been shared, along with the "status" of the sharing invites sent to each user. In addition, servers SHOULD include a CS:organizer XML element on calendar collection resources of the sharees to provide clients with a fast way to determine who the sharer is. A server's local privacy policy may prevent sharees from knowing about other sharees on a shared calendar. If that is so server will not include CS:user XML elements for other sharees.</t>
+                      <t hangText="Definition:">
+                        <figure>
+                          <artwork><![CDATA[
+<!ELEMENT invite (organizer?, user*)>]]></artwork>
+                        </figure>
+                      </t>
+                    </list>
+                  </t>
+                </section>
+                <section title="CS:allowed-sharing-modes Property" anchor="CS:allowed-sharing-modes">
+                  <t>
+                    <list style="hanging">
+                      <t hangText="Name:">allowed-sharing-modes</t>
+                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                      <t hangText="Purpose:">Used to show which modes of sharing are supported on a calendar collection.</t>
+                      <t hangText="Protected:">This property MUST be protected.</t>
+                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
+                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
+        
+                      <t hangText="Description:">This WebDAV property is present on a calendar collection resource that can been shared or published. It provides a list of options indicating what sharing modes are allowed as per <xref target="allowed"/>.</t>
+                      <t hangText="Definition:">
+                        <figure>
+                          <artwork><![CDATA[
+<!ELEMENT allowed-sharing-modes
+          (can-be-shared?, can-be-published?)>]]></artwork>
+                        </figure>
+                      </t>
+                    </list>
+                  </t>
+                </section>
+                <section title="CS:shared-url Property" anchor="CS:shared-url">
+                  <t>
+                    <list style="hanging">
+                      <t hangText="Name:">shared-url</t>
+                      <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                      <t hangText="Purpose:">Indicates the URL of the owner's copy of a shared calendar.</t>
+                      <t hangText="Protected:">This property MUST be protected.</t>
+                      <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
+                      <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>
+        
+                      <t hangText="Description:">This WebDAV property is present on a shared calendar collection resource that appears in a sharee's calendar home collection. Its content is a single DAV:href element whose value is the URL of the sharer's calendar being shared.</t>
+                      <t hangText="Definition:">
+                        <figure>
+                          <artwork><![CDATA[
+<!ELEMENT shared-url (DAV:href)>]]></artwork>
+                        </figure>
+                      </t>
+                    </list>
+                  </t>
+                </section>
+            </section>
+            <section title="Sharer Actions on Shared Calendars">
+                <section title="Sharing or Unsharing a Calendar">
+                    <t>
+                        To update an existing calendar to be shared, the sharer simply adds one or more sharees to the calendar collection as per <xref target="sharee"/>. The server MUST update the DAV:resourcetype property on the calendar collection to ensure it contains a CS:shared-owner XML element to indicate the calendar collection is now shared.
+                    </t>
+                    <t>
+                        To unshare a calendar, the sharer simply removes all sharees to the CS:invite property of the calendar collection as per <xref target="sharee"/>. The server MUST update the DAV:resourcetype property on the calendar collection to ensure it does not contain a CS:shared-owner XML element to indicate the calendar collection is not shared.
+                    </t>
+                </section>
+                <section title="Manipulating Sharees of a Shared Calendar" anchor="sharee">
+                    <t>
+                        The sharer of a shared calendar is able to manipulate the sharee list by issuing a POST request targeted at the calendar collection resource. The POST request MUST contain an XML document as its body with the root element being <xref target="CS:share">CS:share</xref>.
+                    </t>
+                    <t>
+                        The <xref target="CS:share">CS:share</xref> element in the POST requests MUST contain one or more <xref target="CS:set">CS:set</xref> or <xref target="CS:remove">CS:remove</xref> elements. For each <xref target="CS:set">CS:set</xref> element, the server MUST add the specified sharee access to the calendar. For each <xref target="CS:remove">CS:remove</xref> element the server MUST remove the specified sharee access from the shared calendar. In each case the server MUST send a notification message to any sharees whose status is changed (added, modified or removed), indicating to them a change in status for the shared calendar. The server SHOULD NOT send notification messages to sharees whose status is unchanged.
+                    </t>
+                    <t>
+                        Sharee's are identified via a DAV:href element whose value is either a principal-URL for a sharee hosted on the same server, a calendar user address or email address. In the case of the later two, the sharee might not be a user on the same server - though in that case how invitations are sent or access enabled is out of scope for this specification. A server MAY change the sharee's "address" to any suitable alternative that it might prefer when returning the list of sharees via the <xref target="CS:invite">CS:invite property</xref>.
+                    </t>
+                    <t>
+                        The client MAY include a <xref target="CS:common-name">CS:common-name</xref> element in the <xref target="CS:set">CS:set</xref> element. When provided, the value represents the common name for the sharee, and is returned in the list of sharees via the <xref target="CS:invite">CS:invite property</xref>. The server MAY change this to a suitable alternative when it is able to match the sharee to a known user. If absent from the client request, the server SHOULD add a CS:common-name when it is able to match the sharee with a known user, and a common name for that user can be determined.
+                    </t>
+                    <t>
+                        When the sharee list on a shared calendar is changed, the server MUST send notifications to each sharee to update them on their current sharing status. This is accomplished by sending a <xref target="CS:invite-notification">CS:invite-notification</xref> notification to each sharee.
+                    </t>
+                    <section title="Example: Successful Sharee Add Request">
+            
+                        <t>
+                          This example shows how to add a single sharee (with calendar user address "mailto:eric at example.com") to a shared calendar with CS:read-write access.
+                        </t>
+    
+                        <figure>
+                          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
+                          <artwork><![CDATA[
+POST /calendars/users/cyrus/shared/ HTTP/1.1
+Host: calendar.example.com
+Content-Type: application/xml; charset="utf-8"
+Content-Length: xxxx
+
+<?xml version="1.0" encoding="utf-8" ?>
+<CS:share xmlns:D="DAV:"
+              xmlns:CS="http://calendarserver.org/ns/">
+  <CS:set>
+    <D:href>mailto:eric at example.com</D:href>
+    <CS:common-name>Eric York</CS:common-name>
+    <CS:summary>Shared workspace</CS:summary>
+    <CS:read-write />
+  </CS:set>
+</CS:share>]]></artwork>
+                        </figure>
+                        <figure>
+                          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
+                          <artwork><![CDATA[
+HTTP/1.1 200 OK
+Cache-Control: no-cache
+Date: Sat, 11 Nov 2006 09:32:12 GMT]]></artwork>
+                        </figure>
+                    </section>
+                    <section title="Example: Successful Multiple Sharee Change Request">
+            
+                        <t>
+                          This example shows how multiple sharee's can be manipulated in a single request. The sharee with calendar user address "mailto:eric at example.com" has their access downgraded to CS:read, whilst another sharee is removed from the access list entirely.
+                        </t>
+    
+                        <figure>
+                          <preamble>&gt;&gt; Request &lt;&lt;</preamble>
+                          <artwork><![CDATA[
+POST /calendars/users/cyrus/shared/ HTTP/1.1
+Host: calendar.example.com
+Content-Type: application/xml; charset="utf-8"
+Content-Length: xxxx
+
+<?xml version="1.0" encoding="utf-8" ?>
+<CS:share xmlns:D="DAV:"
+              xmlns:CS="http://calendarserver.org/ns/">
+  <CS:set>
+    <D:href>mailto:eric at example.com</D:href>
+    <CS:summary>Shared workspace</CS:summary>
+    <CS:read-write />
+  </CS:set>
+  <CS:remove>
+    <D:href>mailto:wilfredo at example.com</D:href>
+  </CS:remove>
+</CS:share>]]></artwork>
+                        </figure>
+                        <figure>
+                          <preamble>&gt;&gt; Response &lt;&lt;</preamble>
+                          <artwork><![CDATA[
+HTTP/1.1 200 OK
+Cache-Control: no-cache
+Date: Sat, 11 Nov 2006 09:32:12 GMT]]></artwork>
+                        </figure>
+                    </section>
+                </section>
+            </section>
+            <section title="Sharee Actions on Shared Calendars">
+                <section title="Replying to a Sharing Invite">
+                    <t>
+                        When a sharee is invited to a shared calendar they can accept or decline the invite by issuing a POST request to the sharee's calendar home collection resource. The POST request MUST contain an XML document as its body with the root element being <xref target="CS:invite-reply">CS:invite-reply</xref>.
+                    </t>
+                    <t>
+                        The <xref target="CS:invite-reply">CS:invite-reply</xref> element in the POST request specifies the sharee who is replying in the DAV:href element, the accept or decline action via the CS:invite-accepted or CS:invite-declined elements, the URL of the shared calendar in the CS:hosturl element, the unique identifier of the invite to which it is a reply in the CS:in-reply-to element, and an optional CS:summary element.
+                    </t>
+                    <t>
+                        The response to a POST request that accepts a shared calendar invite MUST be an XML document containing <xref target="CS:shared-as">CS:shared-as</xref> as its root element. That root element contains a single DAV:href element whose content is the URI of the shared calendar in the sharee's calendar home created by the invite acceptance.
+                    </t>
+                    <t>
+                        When the sharee replies to an invite, the server SHOULD send a notification to the sharer to update them on the change in the sharee state.  This is accomplished by sending a <xref target="CS:invite-reply">CS:invite-reply</xref> notification to the sharer.
+                    </t>
+                </section>
+                <section title="Removing a Shared Calendar">
+                    <t>
+                        To remove a shared calendar from a sharee's calendar home collection a DELETE request is targeted at the shared calendar URI. When such a request is received the server MUST remove the shared calendar from the sharee's calendar home and automatically update the sharee's status in the sharer's calendar's CS:invite property.
+                    </t>
+                </section>
+            </section>
+            <section title="General Considerations">
+                <section title="Access Levels">
+                    <t>
+                        Two levels of access ca be granted by a sharer to any sharee. These are governed by the CS:access element used in the CS:invite/CS:user element that specifies a shared user invite. CS:access contains a single empty element that defines the type of access granted:
+                        <list style="hanging">
+                        <t hangText="CS:read">
+                            When present this indicates that sharees can read calendar data but cannot change it.
+                        </t>
+                        <t hangText="CS:read-write">
+                            When present this indicates that sharees can read and write calendar data.
+                        </t>
+                        </list>
+                    </t>
+                </section>
+                <section title="Allowing or Disallowing Sharing" anchor="allowed">
+                    <t>
+                        Servers MAY support calendar sharing on a per-calendar basis - e.g., they could treat some calendars as always private (cannot be shared) or always public (always shared). As a result clients need a way to determine which calendar could be shared so they can enable or disable sharing options on a per-calendar basis.
+                    </t>
+                    <t>
+                        This specification adds a <xref target="CS:allowed-sharing-modes">CS:allowed-sharing-modes</xref> WebDAV property which servers can return on calendar collection resources. This property contains XML elements that describe which sharing or publishing capabilities can be supported by the corresponding calendar collection:
+                        <list>
+                            <t><xref target="CS:can-be-shared">CS:can-be-shared</xref>: when present indicates that the calendar collection can be shared. When not present, the calendar collection cannot be shared.</t>
+                            <t><xref target="CS:can-be-published">CS:can-be-published</xref>: when present indicates that the calendar collection can be published. When not present, the calendar collection cannot be published.</t>
+                        </list>                     
+                    </t>
+                    <t>
+                        When not present on a calendar collection, sharing or publishing of that calendar is not allowed. Clients SHOULD NOT attempt to use requests to enable sharing or publishing targeted at those calendar collections.
+                    </t>
+                </section>
+                <section title="Per-user WebDAV Properties">
+                    <t>
+                        Servers MUST support "per-user" WebDAV properties on shared calendar collections and MAY support them on calendar object resources within shared calendar collections. A "per-user" WebDAV property is one whose value can be set and retrieved independently by each user with appropriate access rights. e.g., user "A" changes the DAV:displayname property on a shared calendar in their calendar home to "My calendar", and user "B" changes the same property to "Shared" on the same shared calendar in their calendar home. When each user retrieves the property value they will see their own last stored value and not the value of the other user.
+                    </t>
+                    <t>
+                        For shared calendars, the server MUST allow all users to write "per-user" WebDAV properties on the shared calendar collection and MAY allow property writes on calendar object resources within the shared calendar collection. This is required even in the case where the sharee has been granted read access only (i.e., the ability to change calendar data is disallowed). This requirement ensures that sharees can always change "personal" properties such as calendar colors and display names.
+                    </t>
+                    <t>
+                        Servers MUST treat the following properties as "per-user":
+                        <list>
+                            <t>DAV:displayname</t>
+                            <t>CALDAV:calendar-description</t>
+                            <t>CALDAV:schedule-calendar-transp</t>
+                            <t>ICAL:calendar-color</t>
+                        </list>
+                    </t>
+                    <t>
+                        Servers MAY treat any dead property as per-user.
+                    </t>
+                    <t>
+                        Servers MUST NOT treat live properties as per-user.
+                    </t>
+                </section>
+                <section title="Per-user Calendar Data" anchor="per-user-data">
+                    <t>
+                        Servers MUST support "per-user" calendar data in calendar object resources stored in shared calendars. This allows each sharee and the sharer to store their own alarms and free busy transparency status without "interfering" with other users who also have access to the same calendar object resources.
+                    </t>
+                    <t>
+                        For calendaring object resources in shared calendar collections, the server MUST treat the following iCalendar data objects as per-user:
+                        <list>
+                            <t>TRANSP property</t>
+                            <t>VALARM component</t>
+                        </list>
+                    </t>
+                    <t>
+                        Servers MAY treat any non-standard X- iCalendar properties as per-user.
+                    </t>
+                    <t>
+                        When handling per-user data in recurring components, servers SHOULD eliminate overridden instances when returning iCalendar data to clients in the case where there are no differences between the overridden component and the instance that could be derived from the "master" recurrence component. For example, consider a daily recurring event, Monday through Friday, initially defined without any overridden instances, that is in a shared calendar. If user "A" overrides the Tuesday instance and adds their own "VALARM" component only, then when user "A" later retrieves the data again they would see that overridden instance, but when user "B" does so, they would not. This ensures that each user sees the most "compact" representation of the calendar data.
+                    </t>
+                </section>
+                <section title="Scheduling">
+                    <t>
+                        <xref target="RFC6638">CalDAV Scheduling</xref> defines how a CalDAV server carries out scheduling operations when calendar object resources are created, modified or deleted and include "ORGANIZER" and "ATTENDEE" iCalendar properties.
+                    </t>
+                    <t>
+                        When calendar object resources are created, modified or deleted in shared calendars by sharees, the following restrictions apply:
+                        <list style="numbers">
+                            <t>The "ORGANIZER" iCalendar property value in the iCalendar data MUST match a calendar user address of the sharer (owner) of the shared calendar. The DAV:owner WebDAV property MUST be present on a shared calendar and MUST provide a reference to a principal-URL of the sharer (owner) of the shared calendar. Clients can use this value to determine what the allowed "ORGANIZER" iCalendar property values are. The server MUST reject any attempt by a sharee to create an iCalendar component with an "ORGANIZER" property value other than the sharer (owner) of the shared calendar.</t>
+                            <t>The server MUST reject any attempt by a sharee to MOVE a calendar object resource in a shared calendar to some other collection.</t>
+                            <t>When a sharee is listed as an Attendee in a calendar object resource in a shared calendar, and write access is granted, the sharee is allowed to change not only iCalendar data related to the Organizer, but also data related to the Attendee. i.e., a sharee can change their own participation status on the "ATTENDEE" iCalendar property referring to them. Additionally, if the sharee is not listed as an Attendee, and write access is granted, the sharee can add themselves as an Attendee.</t>
+                            <t>The default calendar collection defined in Section 6.3 of <xref target="RFC6638"/> MUST NOT be a calendar shared to the corresponding calendar user.</t>
+                        </list>
+                    </t>
+                    <t>
+                        Following are additional considerations for scheduling with shared calendars:
+                        <list style="numbers">
+                            <t>A scheduled iCalendar component could appear in more than one calendar collection within a sharee's calendar home if the sharee is an Attendee and the Organizer or other Attendees have shared a calendar with the sharee that includes their copies of the iCalendar component. It is important to note that the scheduled component in the shared calendar could have different access rights than the one in the sharee's owned calendar.</t>
+                            <t>A scheduled iCalendar component appearing in a sharee's shared calendar could include the sharee as an Attendee. For recurring events, it is possible for the sharee to only be listed as an Attendee in some instances, as opposed to all. Clients will need to be aware of this when allowing sharee's to set their own participation status.</t>
+                        </list>
+                    </t>
+                    <t>
+                        In addition, when a shared calendar is first accepted by a sharee, the server SHOULD set the CALDAV:schedule-calendar-transp property to the value CALDAV:transparent to ensure newly accepted shared calendars do not contribute to the sharee's freebusy time until the sharee explicitly requests it.
+                    </t>
+                </section>
+            </section>
+        </section>
+
+        <section title='XML Element Definitions'>
+            <section title="CS:shared-owner" anchor="CS:shared-owner">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">shared-owner</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Used to indicate that a calendar is being shared by the owner.</t>
+                    <t hangText="Description:">This property appears in the DAV:resourcetype property on the calendar collection resource shared by a sharer. See <xref target="properties"/>.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT shared-owner EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:shared" anchor="CS:shared">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">shared</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Used to indicate that a calendar is being shared to a sharee.</t>
+                    <t hangText="Description:">This property appears in the DAV:resourcetype property on a calendar collection resource that is shared to a sharee and appears in the sharee's calendar home collection. See <xref target="properties"/>.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT shared EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:can-be-shared" anchor="CS:can-be-shared">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">can-be-shared</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Used to indicate that a calendar can be shared.</t>
+                    <t hangText="Description:">This element indicates that a calendar can be shared with other users. See <xref target="CS:allowed-sharing-modes"/></t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT can-be-shared EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:can-be-published" anchor="CS:can-be-published">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">can-be-published</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Used to indicate that a calendar can be published.</t>
+                    <t hangText="Description:">This element indicates that a calendar can be published to anyone. See <xref target="CS:allowed-sharing-modes"/></t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT can-be-published EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:user" anchor="CS:user">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">user</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Used to show status of sharing invites sent to sharees.</t>
+                    <t hangText="Description:">This element provides the "status" of a sharing invite sent to a particular user. See <xref target="CS:invite"/>.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT user (DAV:href, common-name?, (invite-noresponse |
+                invite-accepted | invite-declined | invite-invalid),
+                access, summary?)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:invite-noresponse">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">invite-noresponse</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Sharing invite status.</t>
+                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the sharee has never replied to the corresponding sharing invite. When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that a sharing reply is needed.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT invite-noresponse EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:invite-deleted">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">invite-deleted</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Sharing invite status.</t>
+                    <t hangText="Description:">When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that a shared calendar has been unshared by the sharer.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT invite-deleted EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:invite-accepted">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">invite-accepted</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Sharing invite status.</t>
+                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the sharee has accepted the corresponding sharing invite. When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that the sharing invite is an update for one they previously accepted.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT invite-accepted EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:invite-declined">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">invite-declined</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Sharing invite status.</t>
+                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the sharee has declined the corresponding sharing invite. When used in a <xref target="CS:invite-notification">CS:invite-notification</xref> element, this element is used to indicate to the sharee that the sharing invite is an update for one they previously declined.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT invite-declined EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:invite-invalid">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">invite-invalid</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Sharing invite status.</t>
+                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate that the corresponding sharee is not a valid calendar user known to the server.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT invite-invalid EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:access">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">access</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Shared calendar access level.</t>
+                    <t hangText="Description:">When used in a <xref target="CS:user">CS:user</xref> element, this element is used to indicate the sharing access level granted to the corresponding sharee.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT access (read | read-write)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:read">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">read</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Shared calendar access level privilege.</t>
+                    <t hangText="Description:">Indicates that the access level granted only allows sharees to read data in the shared calendar (though they can write <xref target="per-user-data">per-user data</xref>).</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT read EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:read-write">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">read-write</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Shared calendar access level privilege.</t>
+                    <t hangText="Description:">Indicates that the access level granted allows sharees to read and write all data in the shared calendar, with the exception of components that would trigger scheduling.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT read-write EMPTY>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:summary">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">summary</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Summary or title of shared calendar.</t>
+                    <t hangText="Description:">A brief description of a shared calendar. This can be used by sharers to communicate the nature of a shared calendar to sharees, as well as used by sharees to indicate back to the sharer how each sharee is refering to the shared calendar.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT summary (#PCDATA)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:invite-notification" anchor="CS:invite-notification">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">invite-notification</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">A notification used as a shared calendar invite.</t>
+                    <t hangText="Description:">Defines a notification message sent automatically by the server when a sharer adds, changes or removes a sharee from a shared calendar. The DAV:href element specifies the calendar user address of the sharee to whom the message was sent. The CALDAV:supported-calendar-component-set is a copy of the matching WebDAV property on the sharers calendar collection, to allow clients to know what restrictions might apply to the shared calendar before accepting it.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT invite-notification (
+            uid, DAV:href,
+            (invite-noresponse | invite-deleted |
+            invite-accepted | invite-declined),
+            access, hosturl, organizer,
+            summary?,
+            CALDAV:supported-calendar-component-set?>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:uid">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">uid</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Unique identifier.</t>
+                    <t hangText="Description:">A unique identifier for an invitation to a shared calendar.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT uid (#PCDATA)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:hosturl">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">hosturl</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Identifies the source URL of a shared calendar.</t>
+                    <t hangText="Description:">Contains a single DAV:href element that refers to the source of a shared calendar - i.e., the URL of the calendar shared by the sharer.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT hosturl (DAV:href)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:organizer">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">organizer</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Identifies the sharer of a shared calendar.</t>
+                    <t hangText="Description:">Contains a single DAV:href element that identifies the calendar user address of the sharer of a shared calendar, and an optional CS:common-name element that matches that user, and an option CS:first-name, CS:last-name pair of elements that match that user. In some cases servers might have directory information that includes only the common name, or only the first or last name, and it is better to expose those directly to the client as-is rather than to try and split or combine the attributes to synthesize one set or the other.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT organizer (DAV:href,
+                     CS:common-name?,
+                     (CS:first-name, CS:last-name)?)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:common-name" anchor="CS:common-name">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">common-name</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">The common name of a sharer or sharee.</t>
+                    <t hangText="Description:">The common name is optionally provided by a client when adding a sharee and optionally included (or modified) by the server when returning results for sharers or sharees and in notifications.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT common-name (#PCDATA)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:first-name" anchor="CS:first-name">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">first-name</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">The first name of a sharer or sharee.</t>
+                    <t hangText="Description:">The first name is optionally included by the server when returning results for sharers or sharees and in notifications.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT first-name (#PCDATA)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:last-name" anchor="CS:last-name">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">last-name</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">The last name of a sharer or sharee.</t>
+                    <t hangText="Description:">The last name is optionally included by the server when returning results for sharers or sharees and in notifications.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT last-name (#PCDATA)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:invite-reply" anchor="CS:invite-reply">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">invite-reply</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">A notification used as a reply to a shared calendar invite.</t>
+                    <t hangText="Description:">Defines a notification message sent automatically by the server when a sharee replies to a shared calendar invite. The DAV:href element specifies the calendar user address of the sharee to whom the original invite message was sent.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT invite-reply (DAV:href,
+                        (invite-accepted | invite-declined),
+                        hosturl, in-reply-to, summary?>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:in-reply-to">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">in-reply-to</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Unique identifier.</t>
+                    <t hangText="Description:">Specifies the unique identifier of the inviate message that this notification message is a reply to.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT in-reply-to (#PCDATA)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:notification" anchor="CS:notification">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">notification</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Notification message root element.</t>
+                    <t hangText="Description:">The root element used in notification resources.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT notification (CS:dtstamp,
+                        (invite-notification | invite-reply)>
+<!-- Any notification type element can appear after CS:dtstamp,
+     this specification defines only the two listed above -->]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:dtstamp" anchor="CS:dtstamp">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">dtstamp</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Date-time stamp.</t>
+                    <t hangText="Description:">Contains the date-time stamp corresponding to the creation of a notification message.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT dtstamp (#PCDATA)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:share" anchor="CS:share">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">share</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Describes changes to sharees.</t>
+                    <t hangText="Description:">The root element used in POST requests on calendars by sharers to manipulate the sharee list of a shared calendar.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT share (set | remove)*>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:set" anchor="CS:set">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">set</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Sets access for a sharee.</t>
+                    <t hangText="Description:">Used to add or modify sharee access to a shared calendar. The specified access to the shared calendar is given to the sharee.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT set (DAV:href, common-name?, summary?,
+               (read | read-write)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:remove" anchor="CS:remove">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">remove</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Removes access for a sharee.</t>
+                    <t hangText="Description:">Used to remove sharee access to a shared calendar. All access to the shared calendar is removed for the sharee.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT remove (DAV:href)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+            <section title="CS:shared-as" anchor="CS:shared-as">
+                <t>
+                  <list style="hanging">
+                    <t hangText="Name:">shared-as</t>
+                    <t hangText="Namespace:">http://calendarserver.org/ns/</t>
+                    <t hangText="Purpose:">Identifies a shared calendar.</t>
+                    <t hangText="Description:">Returned by the server for a POST request by a sharee accepting a shared calendar invite. The DAV:href element specifies the URI of the calendar created by the acceptance.</t>
+                    <t hangText="Definition:">
+                      <figure>
+                        <artwork><![CDATA[
+<!ELEMENT shared-as (DAV:href)>]]></artwork>
+                      </figure>
+                    </t>
+                  </list>
+                </t>
+            </section>
+        </section>
+
+        <section title='Security Considerations'>
+            <t>
+                Per-user WebDAV properties and iCalendar data MUST only be accessible by the user that created them.
+            </t>
+            <t>
+                Alarms set by the sharer SHOULD NOT be propagated to sharees by default. Clients SHOULD NOT automatically enable triggering of alarms on shared calendars that have just been accepted without confirmation by the user.
+            </t>
+            <t>
+                TBD
+            </t>
+        </section>
+        <section title='IANA Considerations'>
+            <t>
+                This document does not require any actions on the part of IANA.
+            </t>
+        </section>
+        <section title='Acknowledgments'>
+            <t>
+                This specification is the result of discussions between the Apple calendar server and client teams.
+            </t>
+        </section>
+    </middle>
+    <back>
+        <references title='Normative References'>
+            &rfc2119;
+            &rfc3744;
+            &rfc4791;
+            &rfc4918;
+            &rfc6638; 
+        </references>
+<!--
+<references title='Informative References'>
+</references>
+-->
+        <section title='Change History'>
+            <t>Changes in -03:
+                <list style='numbers'>
+                    <t>Fixed access element DTD.</t>
+                    <t>Remove MKxxx and PROPPATCH mechanism for upgrading/downgrading shared state on a calendar collection. Instead the server implicitly sets the state based on whether there are any sharees or not..</t>
+                    <t>Added CS:first-name and CS:last-name optional element to CS:organizer.</t>
+                    <t>Added CALDAV:supported-calendar-component-set optional element to CS:invite-notification.</t>
+                </list>
+            </t>
+            <t>Changes in -02:
+                <list style='numbers'>
+                    <t>Removed read-write-shared access mode - now a server that does not support shared scheduling should advertise that via a DAV header</t>
+                </list>
+            </t>
+            <t>Changes in -01:
+                <list style='numbers'>
+                    <t>Added CS:shared-url property</t>
+                    <t>Clarified that notifications are only required to be sent when sharee status is changed</t>
+                </list>
+            </t>
+        </section>
+    </back>
+</rfc>

Modified: CalendarServer/branches/users/gaya/inviteclean/support/build.sh
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/support/build.sh	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/support/build.sh	2012-09-23 03:36:01 UTC (rev 9842)
@@ -235,7 +235,7 @@
         # Try getting a copy from calendarserver.org.
         #
         local tmp="$(mktemp "/tmp/${cache_basename}.XXXXX")";
-        curl -L "http://${pkg_host}${pkg_path}/${cache_basename}" -o "${tmp}";
+        curl -L "http://${pkg_host}${pkg_path}/${cache_basename}" -o "${tmp}" || true;
         echo "";
         if [ ! -s "${tmp}" ] || grep '<title>404 Not Found</title>' "${tmp}" > /dev/null; then
           rm -f "${tmp}";

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/customxml.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/customxml.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -31,6 +31,7 @@
 from txdav.xml.element import ResourceType, Collection, Principal
 
 from twistedcaldav import caldavxml, carddavxml
+from twistedcaldav.caldavxml import caldav_namespace
 from twistedcaldav.ical import Component as iComponent
 
 from pycalendar.datetime import PyCalendarDateTime
@@ -82,6 +83,7 @@
         return str(self)
 
 
+
 @registerElement
 class TwistedCalendarAccessProperty (WebDAVTextElement):
     """
@@ -95,42 +97,46 @@
         return str(self)
 
 
+
 @registerElement
 class TwistedSchedulingObjectResource (WebDAVTextElement):
     """
-    Indicates that the resource is a scheduling object resource.    
+    Indicates that the resource is a scheduling object resource.
     """
     namespace = twisted_private_namespace
     name = "scheduling-object-resource"
     hidden = True
 
 
+
 @registerElement
 class TwistedScheduleMatchETags(WebDAVElement):
     """
-    List of ETags that can be used for a "weak" If-Match comparison.    
+    List of ETags that can be used for a "weak" If-Match comparison.
     """
     namespace = twisted_private_namespace
     name = "scheduling-match-etags"
     hidden = True
 
-    allowed_children = { (dav_namespace, "getetag"): (0, None) }
+    allowed_children = {(dav_namespace, "getetag"): (0, None)}
 
 
+
 @registerElement
 class TwistedCalendarHasPrivateCommentsProperty (WebDAVEmptyElement):
     """
     Indicates that a calendar resource has private comments.
-    
+
     NB This MUST be a private property as we don't want to expose the presence of private comments
     in private events.
-    
+
     """
     namespace = twisted_private_namespace
     name = "calendar-has-private-comments"
     hidden = True
 
 
+
 @registerElement
 class CalendarProxyRead (WebDAVEmptyElement):
     """
@@ -141,6 +147,7 @@
     name = "calendar-proxy-read"
 
 
+
 @registerElement
 class CalendarProxyWrite (WebDAVEmptyElement):
     """
@@ -151,6 +158,7 @@
     name = "calendar-proxy-write"
 
 
+
 @registerElement
 class CalendarProxyReadFor (WebDAVElement):
     """
@@ -162,9 +170,10 @@
     hidden = True
     protected = True
 
-    allowed_children = { (dav_namespace, "href"): (0, None) }
+    allowed_children = {(dav_namespace, "href"): (0, None)}
 
 
+
 @registerElement
 class CalendarProxyWriteFor (WebDAVElement):
     """
@@ -176,9 +185,10 @@
     hidden = True
     protected = True
 
-    allowed_children = { (dav_namespace, "href"): (0, None) }
+    allowed_children = {(dav_namespace, "href"): (0, None)}
 
 
+
 @registerElement
 class DropBoxHome (WebDAVEmptyElement):
     """
@@ -189,6 +199,7 @@
     name = "dropbox-home"
 
 
+
 @registerElement
 class DropBox (WebDAVEmptyElement):
     """
@@ -199,6 +210,7 @@
     name = "dropbox"
 
 
+
 @registerElement
 class DropBoxHomeURL (WebDAVElement):
     """
@@ -210,9 +222,10 @@
     hidden = True
     protected = True
 
-    allowed_children = { (dav_namespace, "href"): (0, 1) }
+    allowed_children = {(dav_namespace, "href"): (0, 1)}
 
 
+
 @registerElement
 class GETCTag (WebDAVTextElement):
     """
@@ -223,6 +236,7 @@
     protected = True
 
 
+
 @registerElement
 class CalendarAvailability (WebDAVTextElement):
     """
@@ -239,6 +253,7 @@
         """
         return iComponent.fromString(str(self))
 
+
     def valid(self):
         """
         Determine whether the content of this element is a valid single VAVAILABILITY component,
@@ -246,7 +261,7 @@
 
         @return: True if valid, False if not.
         """
-        
+
         try:
             calendar = self.calendar()
             if calendar is None:
@@ -269,6 +284,7 @@
         return found
 
 
+
 @registerElement
 class MaxCollections (WebDAVTextElement):
     """
@@ -280,6 +296,7 @@
     protected = True
 
 
+
 @registerElement
 class MaxResources (WebDAVTextElement):
     """
@@ -291,6 +308,7 @@
     protected = True
 
 
+
 @registerElement
 class Timezones (WebDAVEmptyElement):
     """
@@ -301,6 +319,7 @@
     name = "timezones"
 
 
+
 @registerElement
 class TZIDs (WebDAVElement):
     """
@@ -308,9 +327,10 @@
     """
     namespace = calendarserver_namespace
     name = "tzids"
-    allowed_children = { (calendarserver_namespace, "tzid" ): (0, None) }
+    allowed_children = {(calendarserver_namespace, "tzid"): (0, None)}
 
 
+
 @registerElement
 class TZID (WebDAVTextElement):
     """
@@ -320,6 +340,7 @@
     name = "tzid"
 
 
+
 @registerElement
 class TZData (WebDAVElement):
     """
@@ -327,9 +348,10 @@
     """
     namespace = calendarserver_namespace
     name = "tzdata"
-    allowed_children = { (calendarserver_namespace, "observance" ): (0, None) }
+    allowed_children = {(calendarserver_namespace, "observance"): (0, None)}
 
 
+
 @registerElement
 class Observance (WebDAVElement):
     """
@@ -338,11 +360,12 @@
     namespace = calendarserver_namespace
     name = "observance"
     allowed_children = {
-        (calendarserver_namespace, "onset" )     : (1, 1),
-        (calendarserver_namespace, "utc-offset" ): (1, 1),
+        (calendarserver_namespace, "onset")     : (1, 1),
+        (calendarserver_namespace, "utc-offset"): (1, 1),
     }
 
 
+
 @registerElement
 class Onset (WebDAVTextElement):
     """
@@ -352,6 +375,7 @@
     name = "onset"
 
 
+
 @registerElement
 class UTCOffset (WebDAVTextElement):
     """
@@ -361,6 +385,7 @@
     name = "utc-offset"
 
 
+
 @registerElement
 class PubSubPushTransportsProperty (WebDAVTextElement):
     """
@@ -376,6 +401,7 @@
     }
 
 
+
 @registerElement
 class PubSubTransportProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
@@ -394,15 +420,17 @@
     }
 
 
+
 @registerElement
 class PubSubSubscriptionProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
     name = "subscription-url"
     protected = True
     hidden = True
-    allowed_children = { (dav_namespace, "href"): (0, 1) }
+    allowed_children = {(dav_namespace, "href"): (0, 1)}
 
 
+
 @registerElement
 class PubSubAPSBundleIDProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
@@ -411,6 +439,7 @@
     hidden = True
 
 
+
 @registerElement
 class PubSubAPSEnvironmentProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
@@ -419,6 +448,7 @@
     hidden = True
 
 
+
 @registerElement
 class PubSubAPSRefreshIntervalProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
@@ -427,6 +457,7 @@
     hidden = True
 
 
+
 @registerElement
 class PubSubXMPPPushKeyProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
@@ -435,6 +466,7 @@
     hidden = True
 
 
+
 @registerElement
 class PubSubXMPPURIProperty (WebDAVTextElement):
     """
@@ -447,6 +479,7 @@
     hidden = True
 
 
+
 @registerElement
 class PubSubHeartbeatProperty (WebDAVElement):
     """
@@ -458,11 +491,12 @@
     protected = True
     hidden = True
     allowed_children = {
-        (calendarserver_namespace, "xmpp-heartbeat-uri" )     : (1, 1),
-        (calendarserver_namespace, "xmpp-heartbeat-minutes" ) : (1, 1),
+        (calendarserver_namespace, "xmpp-heartbeat-uri")     : (1, 1),
+        (calendarserver_namespace, "xmpp-heartbeat-minutes") : (1, 1),
     }
 
 
+
 @registerElement
 class PubSubHeartbeatURIProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
@@ -471,6 +505,7 @@
     hidden = True
 
 
+
 @registerElement
 class PubSubHeartbeatMinutesProperty (WebDAVTextElement):
     namespace = calendarserver_namespace
@@ -479,6 +514,7 @@
     hidden = True
 
 
+
 @registerElement
 class PubSubXMPPServerProperty (WebDAVTextElement):
     """
@@ -507,10 +543,11 @@
     namespace = calendarserver_namespace
     name = "limit"
     allowed_children = {
-        (calendarserver_namespace, "nresults" )  : (1, 1),
+        (calendarserver_namespace, "nresults")  : (1, 1),
     }
 
 
+
 @registerElement
 class NResults (WebDAVTextElement):
     """
@@ -520,6 +557,7 @@
     name = "nresults"
 
 
+
 @registerElement
 class FirstNameProperty (WebDAVTextElement):
     """
@@ -531,6 +569,7 @@
     hidden = True
 
 
+
 @registerElement
 class LastNameProperty (WebDAVTextElement):
     """
@@ -542,6 +581,7 @@
     hidden = True
 
 
+
 @registerElement
 class EmailAddressProperty (WebDAVTextElement):
     """
@@ -553,6 +593,7 @@
     hidden = True
 
 
+
 @registerElement
 class EmailAddressSet (WebDAVElement):
     """
@@ -562,9 +603,10 @@
     name = "email-address-set"
     hidden = True
 
-    allowed_children = { (calendarserver_namespace, "email-address"): (0, None) }
+    allowed_children = {(calendarserver_namespace, "email-address"): (0, None)}
 
 
+
 @registerElement
 class ExpandedGroupMemberSet (WebDAVElement):
     """
@@ -575,9 +617,10 @@
     protected = True
     hidden = True
 
-    allowed_children = { (dav_namespace, "href"): (0, None) }
+    allowed_children = {(dav_namespace, "href"): (0, None)}
 
 
+
 @registerElement
 class ExpandedGroupMembership (WebDAVElement):
     """
@@ -588,9 +631,10 @@
     protected = True
     hidden = True
 
-    allowed_children = { (dav_namespace, "href"): (0, None) }
+    allowed_children = {(dav_namespace, "href"): (0, None)}
 
 
+
 @registerElement
 class IScheduleInbox (WebDAVEmptyElement):
     """
@@ -601,6 +645,7 @@
     name = "ischedule-inbox"
 
 
+
 @registerElement
 class FreeBusyURL (WebDAVEmptyElement):
     """
@@ -611,6 +656,7 @@
     name = "free-busy-url"
 
 
+
 @registerElement
 class ScheduleChanges (WebDAVElement):
     """
@@ -621,11 +667,12 @@
     protected = True
     hidden = True
     allowed_children = {
-        (calendarserver_namespace, "dtstamp" )     : (0, 1), # Have to allow 0 as element is empty in PROPFIND requests
-        (calendarserver_namespace, "action" )      : (0, 1), # Have to allow 0 as element is empty in PROPFIND requests
+        (calendarserver_namespace, "dtstamp")     : (0, 1), # Have to allow 0 as element is empty in PROPFIND requests
+        (calendarserver_namespace, "action")      : (0, 1), # Have to allow 0 as element is empty in PROPFIND requests
     }
 
 
+
 @registerElement
 class ScheduleDefaultTasksURL (WebDAVElement):
     """
@@ -634,9 +681,10 @@
     namespace = calendarserver_namespace
     name = "schedule-default-tasks-URL"
 
-    allowed_children = { (dav_namespace, "href"): (0, 1) }
+    allowed_children = {(dav_namespace, "href"): (0, 1)}
 
 
+
 @registerElement
 class DTStamp (WebDAVTextElement):
     """
@@ -650,6 +698,7 @@
         self.children = (PCDATAElement(PyCalendarDateTime.getNowUTC().getText()),)
 
 
+
 @registerElement
 class Action (WebDAVElement):
     """
@@ -658,13 +707,14 @@
     namespace = calendarserver_namespace
     name = "action"
     allowed_children = {
-        (calendarserver_namespace, "create" ) : (0, 1),
-        (calendarserver_namespace, "update" ) : (0, 1),
-        (calendarserver_namespace, "cancel" ) : (0, 1),
-        (calendarserver_namespace, "reply" )  : (0, 1),
+        (calendarserver_namespace, "create") : (0, 1),
+        (calendarserver_namespace, "update") : (0, 1),
+        (calendarserver_namespace, "cancel") : (0, 1),
+        (calendarserver_namespace, "reply")  : (0, 1),
     }
 
 
+
 @registerElement
 class Create (WebDAVEmptyElement):
     """
@@ -674,6 +724,7 @@
     name = "create"
 
 
+
 @registerElement
 class Update (WebDAVElement):
     """
@@ -682,10 +733,11 @@
     namespace = calendarserver_namespace
     name = "update"
     allowed_children = {
-        (calendarserver_namespace, "recurrence" ) : (1, None),
+        (calendarserver_namespace, "recurrence") : (1, None),
     }
 
 
+
 @registerElement
 class Cancel (WebDAVElement):
     """
@@ -694,10 +746,11 @@
     namespace = calendarserver_namespace
     name = "cancel"
     allowed_children = {
-        (calendarserver_namespace, "recurrence" ) : (0, 1),
+        (calendarserver_namespace, "recurrence") : (0, 1),
     }
 
 
+
 @registerElement
 class Reply (WebDAVElement):
     """
@@ -706,11 +759,12 @@
     namespace = calendarserver_namespace
     name = "reply"
     allowed_children = {
-        (calendarserver_namespace, "attendee" )        : (1, 1),
-        (calendarserver_namespace, "recurrence" )      : (1, None),
+        (calendarserver_namespace, "attendee")        : (1, 1),
+        (calendarserver_namespace, "recurrence")      : (1, None),
     }
 
 
+
 @registerElement
 class Recurrence (WebDAVElement):
     """
@@ -719,12 +773,13 @@
     namespace = calendarserver_namespace
     name = "recurrence"
     allowed_children = {
-        (calendarserver_namespace, "master" )       : (0, 1),
-        (calendarserver_namespace, "recurrenceid" ) : (0, None),
-        (calendarserver_namespace, "changes" )      : (0, 1),
+        (calendarserver_namespace, "master")       : (0, 1),
+        (calendarserver_namespace, "recurrenceid") : (0, None),
+        (calendarserver_namespace, "changes")      : (0, 1),
     }
 
 
+
 @registerElement
 class Master (WebDAVEmptyElement):
     """
@@ -734,6 +789,7 @@
     name = "master"
 
 
+
 @registerElement
 class RecurrenceID (WebDAVTextElement):
     """
@@ -743,6 +799,7 @@
     name = "recurrenceid"
 
 
+
 @registerElement
 class Changes (WebDAVElement):
     """
@@ -751,10 +808,11 @@
     namespace = calendarserver_namespace
     name = "changes"
     allowed_children = {
-        (calendarserver_namespace, "changed-property" )  : (0, None),
+        (calendarserver_namespace, "changed-property")  : (0, None),
     }
 
 
+
 @registerElement
 class ChangedProperty (WebDAVElement):
     """
@@ -764,7 +822,7 @@
     name = "changed-property"
 
     allowed_children = {
-        (calendarserver_namespace, "changed-parameter" )  : (0, None),
+        (calendarserver_namespace, "changed-parameter")  : (0, None),
     }
 
     allowed_attributes = {
@@ -772,6 +830,7 @@
     }
 
 
+
 @registerElement
 class ChangedParameter (WebDAVEmptyElement):
     """
@@ -785,6 +844,7 @@
     }
 
 
+
 @registerElement
 class Attendee (WebDAVTextElement):
     """
@@ -794,6 +854,7 @@
     name = "attendee"
 
 
+
 @registerElement
 class RecordType (WebDAVTextElement):
     """
@@ -805,6 +866,7 @@
     hidden = True
 
 
+
 @registerElement
 class AutoSchedule (WebDAVTextElement):
     """
@@ -814,6 +876,7 @@
     name = "auto-schedule"
 
 
+
 @registerElement
 class AutoScheduleMode (WebDAVTextElement):
     """
@@ -823,6 +886,7 @@
     name = "auto-schedule-mode"
 
 
+
 ##
 # Sharing
 ##
@@ -836,6 +900,7 @@
     name = "read"
 
 
+
 @registerElement
 class ReadWriteAccess (WebDAVEmptyElement):
     """
@@ -845,18 +910,21 @@
     name = "read-write"
 
 
+
 @registerElement
 class UID (WebDAVTextElement):
     namespace = calendarserver_namespace
     name = "uid"
 
 
+
 @registerElement
 class InReplyTo (WebDAVTextElement):
     namespace = calendarserver_namespace
     name = "in-reply-to"
 
 
+
 @registerElement
 class SharedOwner (WebDAVEmptyElement):
     """
@@ -866,6 +934,7 @@
     name = "shared-owner"
 
 
+
 @registerElement
 class Shared (WebDAVEmptyElement):
     """
@@ -875,6 +944,7 @@
     name = "shared"
 
 
+
 @registerElement
 class Subscribed (WebDAVEmptyElement):
     """
@@ -884,6 +954,7 @@
     name = "subscribed"
 
 
+
 @registerElement
 class SharedURL (WebDAVTextElement):
     """
@@ -895,6 +966,7 @@
     hidden = True
 
 
+
 @registerElement
 class SharedAs (WebDAVElement):
     """
@@ -908,6 +980,7 @@
     }
 
 
+
 @registerElement
 class SharedAcceptEmailNotification (WebDAVTextElement):
     """
@@ -917,6 +990,7 @@
     name = "shared-accept-email-notification"
 
 
+
 @registerElement
 class Birthday (WebDAVEmptyElement):
     """
@@ -926,6 +1000,7 @@
     name = "birthday"
 
 
+
 @registerElement
 class AllowedSharingModes (WebDAVElement):
     namespace = calendarserver_namespace
@@ -939,18 +1014,21 @@
     }
 
 
+
 @registerElement
 class CanBeShared (WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "can-be-shared"
 
 
+
 @registerElement
 class CanBePublished (WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "can-be-published"
 
 
+
 @registerElement
 class InviteShare (WebDAVElement):
     namespace = calendarserver_namespace
@@ -962,6 +1040,7 @@
     }
 
 
+
 @registerElement
 class InviteSet (WebDAVElement):
     namespace = calendarserver_namespace
@@ -977,6 +1056,7 @@
     }
 
 
+
 @registerElement
 class InviteRemove (WebDAVElement):
     namespace = calendarserver_namespace
@@ -990,6 +1070,7 @@
     }
 
 
+
 @registerElement
 class InviteUser (WebDAVElement):
     namespace = calendarserver_namespace
@@ -1009,6 +1090,7 @@
     }
 
 
+
 @registerElement
 class InviteAccess (WebDAVElement):
     namespace = calendarserver_namespace
@@ -1021,6 +1103,7 @@
     }
 
 
+
 @registerElement
 class Invite (WebDAVElement):
     namespace = calendarserver_namespace
@@ -1032,42 +1115,49 @@
     }
 
 
+
 @registerElement
 class InviteSummary (WebDAVTextElement):
     namespace = calendarserver_namespace
     name = "summary"
 
 
+
 @registerElement
 class InviteStatusNoResponse (WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "invite-noresponse"
 
 
+
 @registerElement
 class InviteStatusDeleted (WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "invite-deleted"
 
 
+
 @registerElement
 class InviteStatusAccepted (WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "invite-accepted"
 
 
+
 @registerElement
 class InviteStatusDeclined (WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "invite-declined"
 
 
+
 @registerElement
 class InviteStatusInvalid (WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "invite-invalid"
 
 
+
 @registerElement
 class HostURL (WebDAVElement):
     """
@@ -1081,6 +1171,7 @@
     }
 
 
+
 @registerElement
 class Organizer (WebDAVElement):
     """
@@ -1095,6 +1186,7 @@
     }
 
 
+
 @registerElement
 class CommonName (WebDAVTextElement):
     """
@@ -1104,6 +1196,7 @@
     name = "common-name"
 
 
+
 @registerElement
 class InviteNotification (WebDAVElement):
     namespace = calendarserver_namespace
@@ -1120,6 +1213,7 @@
         (calendarserver_namespace, "hosturl")           : (0, 1),
         (calendarserver_namespace, "organizer")         : (0, 1),
         (calendarserver_namespace, "summary")           : (0, 1),
+        (caldav_namespace, "supported-calendar-component-set") : (0, 1),
     }
 
     allowed_attributes = {
@@ -1127,6 +1221,7 @@
     }
 
 
+
 @registerElement
 class InviteReply (WebDAVElement):
     namespace = calendarserver_namespace
@@ -1145,6 +1240,7 @@
     }
 
 
+
 @registerElement
 class ResourceUpdateNotification (WebDAVElement):
     namespace = calendarserver_namespace
@@ -1159,24 +1255,28 @@
     }
 
 
+
 @registerElement
 class ResourceUpdateAdded(WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "resource-added-notification"
 
 
+
 @registerElement
 class ResourceUpdateUpdated(WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "resource-updated-notification"
 
 
+
 @registerElement
 class ResourceUpdateDeleted(WebDAVEmptyElement):
     namespace = calendarserver_namespace
     name = "resource-deleted-notification"
 
 
+
 @registerElement
 class SharedCalendarUpdateNotification (WebDAVElement):
     namespace = calendarserver_namespace
@@ -1190,6 +1290,8 @@
         (calendarserver_namespace, "invite-declined")   : (0, 1),
     }
 
+
+
 ##
 # Notifications
 ##
@@ -1211,6 +1313,7 @@
     }
 
 
+
 @registerElement
 class NotificationURL (WebDAVElement):
     """
@@ -1226,6 +1329,7 @@
     }
 
 
+
 @registerElement
 class NotificationType (WebDAVElement):
     """
@@ -1242,6 +1346,7 @@
     }
 
 
+
 @registerElement
 class Link (WebDAVEmptyElement):
     """
@@ -1263,6 +1368,7 @@
     }
 
 
+
 @registerElement
 class Resource (WebDAVElement):
     namespace = mm_namespace
@@ -1270,13 +1376,14 @@
 
     allowed_children = {
         (dav_namespace, "href")     : (0, 1),
-        (mm_namespace,  "if-match") : (0, 1),
+        (mm_namespace, "if-match") : (0, 1),
         (dav_namespace, "set")      : (0, 1),
         (dav_namespace, "remove")   : (0, 1),
-        (mm_namespace,  "delete")   : (0, 1),
+        (mm_namespace, "delete")   : (0, 1),
     }
 
 
+
 @registerElement
 class IfMatch (WebDAVElement):
     namespace = mm_namespace
@@ -1287,6 +1394,7 @@
     }
 
 
+
 @registerElement
 class Delete (WebDAVEmptyElement):
     namespace = mm_namespace
@@ -1307,6 +1415,7 @@
     }
 
 
+
 @registerElement
 class Simple (WebDAVElement):
     namespace = mm_namespace
@@ -1320,6 +1429,7 @@
     }
 
 
+
 @registerElement
 class CRUD (WebDAVElement):
     namespace = mm_namespace
@@ -1333,18 +1443,21 @@
     }
 
 
+
 @registerElement
 class MaxBulkResources (WebDAVTextElement):
     namespace = mm_namespace
     name = "max-resources"
 
 
+
 @registerElement
 class MaxBulkBytes (WebDAVTextElement):
     namespace = mm_namespace
     name = "max-bytes"
 
 
+
 #
 # Client properties we might care about
 #
@@ -1354,6 +1467,8 @@
     namespace = "http://apple.com/ns/ical/"
     name = "calendar-color"
 
+
+
 #
 # calendarserver-principal-search REPORT
 #
@@ -1366,6 +1481,8 @@
     namespace = calendarserver_namespace
     name = "search-token"
 
+
+
 @registerElement
 class CalendarServerPrincipalSearch (WebDAVElement):
 
@@ -1373,21 +1490,21 @@
     name = "calendarserver-principal-search"
 
     allowed_children = {
-        (calendarserver_namespace, "search-token"          ): (0, None),
-        (calendarserver_namespace, "limit"                 ): (0, 1),
-        (dav_namespace, "prop"                             ): (0, 1),
+        (calendarserver_namespace, "search-token"): (0, None),
+        (calendarserver_namespace, "limit"): (0, 1),
+        (dav_namespace, "prop"): (0, 1),
         (dav_namespace, "apply-to-principal-collection-set"): (0, 1),
     }
-    allowed_attributes = { "context" : False }
+    allowed_attributes = {"context": False}
 
 ##
 # Extensions to ResourceType
 ##
 
 ResourceType.dropboxhome = ResourceType(Collection(), DropBoxHome())
-ResourceType.dropbox     = ResourceType(Collection(), DropBox())
+ResourceType.dropbox = ResourceType(Collection(), DropBox())
 
-ResourceType.calendarproxyread  = ResourceType(Principal(), Collection(), CalendarProxyRead())
+ResourceType.calendarproxyread = ResourceType(Principal(), Collection(), CalendarProxyRead())
 ResourceType.calendarproxywrite = ResourceType(Principal(), Collection(), CalendarProxyWrite())
 
 ResourceType.timezones = ResourceType(Timezones())
@@ -1398,8 +1515,8 @@
 
 ResourceType.notification = ResourceType(Collection(), Notification())
 
-ResourceType.sharedownercalendar = ResourceType(Collection(), caldavxml.Calendar(),     SharedOwner())
-ResourceType.sharedcalendar      = ResourceType(Collection(), caldavxml.Calendar(),     Shared())
-ResourceType.sharedaddressbook   = ResourceType(Collection(), carddavxml.AddressBook(), Shared())
+ResourceType.sharedownercalendar = ResourceType(Collection(), caldavxml.Calendar(), SharedOwner())
+ResourceType.sharedcalendar = ResourceType(Collection(), caldavxml.Calendar(), Shared())
+ResourceType.sharedaddressbook = ResourceType(Collection(), carddavxml.AddressBook(), Shared())
 
 ResourceType.link = ResourceType(Link())

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/ical.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/ical.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/ical.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -39,7 +39,7 @@
 from twext.web2.dav.util import allDataFromStream
 
 from twistedcaldav.config import config
-from twistedcaldav.dateops import timeRangesOverlap, normalizeForIndex, differenceDateTime,\
+from twistedcaldav.dateops import timeRangesOverlap, normalizeForIndex, differenceDateTime, \
     normalizeForExpand
 from twistedcaldav.instance import InstanceList
 from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
@@ -76,66 +76,66 @@
 # Structure: propname: (<default value>, <parameter defaults dict>)
 
 normalizeProps = {
-    "CALSCALE":     ("GREGORIAN", {"VALUE": "TEXT"}),
-    "METHOD":       (None, {"VALUE": "TEXT"}),
-    "PRODID":       (None, {"VALUE": "TEXT"}),
-    "VERSION":      (None, {"VALUE": "TEXT"}),
-    "ATTACH":       (None, {"VALUE": "URI"}),
-    "CATEGORIES":   (None, {"VALUE": "TEXT"}),
-    "CLASS":        (None, {"VALUE": "TEXT"}),
-    "COMMENT":      (None, {"VALUE": "TEXT"}),
-    "DESCRIPTION":  (None, {"VALUE": "TEXT"}),
-    "GEO":          (None, {"VALUE": "FLOAT"}),
-    "LOCATION":     (None, {"VALUE": "TEXT"}),
+    "CALSCALE": ("GREGORIAN", {"VALUE": "TEXT"}),
+    "METHOD": (None, {"VALUE": "TEXT"}),
+    "PRODID": (None, {"VALUE": "TEXT"}),
+    "VERSION": (None, {"VALUE": "TEXT"}),
+    "ATTACH": (None, {"VALUE": "URI"}),
+    "CATEGORIES": (None, {"VALUE": "TEXT"}),
+    "CLASS": (None, {"VALUE": "TEXT"}),
+    "COMMENT": (None, {"VALUE": "TEXT"}),
+    "DESCRIPTION": (None, {"VALUE": "TEXT"}),
+    "GEO": (None, {"VALUE": "FLOAT"}),
+    "LOCATION": (None, {"VALUE": "TEXT"}),
     "PERCENT-COMPLETE": (None, {"VALUE": "INTEGER"}),
-    "PRIORITY":     (0, {"VALUE": "INTEGER"}),
-    "RESOURCES":    (None, {"VALUE": "TEXT"}),
-    "STATUS":       (None, {"VALUE": "TEXT"}),
-    "SUMMARY":      (None, {"VALUE": "TEXT"}),
-    "COMPLETED":    (None, {"VALUE": "DATE-TIME"}),
-    "DTEND":        (None, {"VALUE": "DATE-TIME"}),
-    "DUE":          (None, {"VALUE": "DATE-TIME"}),
-    "DTSTART":      (None, {"VALUE": "DATE-TIME"}),
-    "DURATION":     (None, {"VALUE": "DURATION"}),
-    "FREEBUSY":     (None, {"VALUE": "PERIOD"}),
-    "TRANSP":       ("OPAQUE", {"VALUE": "TEXT"}),
-    "TZID":         (None, {"VALUE": "TEXT"}),
-    "TZNAME":       (None, {"VALUE": "TEXT"}),
+    "PRIORITY": (0, {"VALUE": "INTEGER"}),
+    "RESOURCES": (None, {"VALUE": "TEXT"}),
+    "STATUS": (None, {"VALUE": "TEXT"}),
+    "SUMMARY": (None, {"VALUE": "TEXT"}),
+    "COMPLETED": (None, {"VALUE": "DATE-TIME"}),
+    "DTEND": (None, {"VALUE": "DATE-TIME"}),
+    "DUE": (None, {"VALUE": "DATE-TIME"}),
+    "DTSTART": (None, {"VALUE": "DATE-TIME"}),
+    "DURATION": (None, {"VALUE": "DURATION"}),
+    "FREEBUSY": (None, {"VALUE": "PERIOD"}),
+    "TRANSP": ("OPAQUE", {"VALUE": "TEXT"}),
+    "TZID": (None, {"VALUE": "TEXT"}),
+    "TZNAME": (None, {"VALUE": "TEXT"}),
     "TZOFFSETFROM": (None, {"VALUE": "UTC-OFFSET"}),
-    "TZOFFSETTO":   (None, {"VALUE": "UTC-OFFSET"}),
-    "TZURL":        (None, {"VALUE": "URI"}),
-    "ATTENDEE":     (None, {
-        "VALUE":          "CAL-ADDRESS",
-        "CUTYPE":         "INDIVIDUAL",
-        "ROLE":           "REQ-PARTICIPANT",
-        "PARTSTAT":       "NEEDS-ACTION",
-        "RSVP":           "FALSE",
+    "TZOFFSETTO": (None, {"VALUE": "UTC-OFFSET"}),
+    "TZURL": (None, {"VALUE": "URI"}),
+    "ATTENDEE": (None, {
+        "VALUE": "CAL-ADDRESS",
+        "CUTYPE": "INDIVIDUAL",
+        "ROLE": "REQ-PARTICIPANT",
+        "PARTSTAT": "NEEDS-ACTION",
+        "RSVP": "FALSE",
         "SCHEDULE-AGENT": "SERVER",
     }),
-    "CONTACT":      (None, {"VALUE": "TEXT"}),
-    "ORGANIZER":    (None, {"VALUE": "CAL-ADDRESS"}),
+    "CONTACT": (None, {"VALUE": "TEXT"}),
+    "ORGANIZER": (None, {"VALUE": "CAL-ADDRESS"}),
     "RECURRENCE-ID": (None, {"VALUE": "DATE-TIME"}),
-    "RELATED-TO":   (None, {"VALUE": "TEXT"}),
-    "URL":          (None, {"VALUE": "URI"}),
-    "UID":          (None, {"VALUE": "TEXT"}),
-    "EXDATE":       (None, {"VALUE": "DATE-TIME"}),
-    "EXRULE":       (None, {"VALUE": "RECUR"}),
-    "RDATE":        (None, {"VALUE": "DATE-TIME"}),
-    "RRULE":        (None, {"VALUE": "RECUR"}),
-    "ACTION":       (None, {"VALUE": "TEXT"}),
-    "REPEAT":       (0, {"VALUE": "INTEGER"}),
-    "TRIGGER":      (None, {"VALUE": "DURATION"}),
-    "CREATED":      (None, {"VALUE": "DATE-TIME"}),
-    "DTSTAMP":      (None, {"VALUE": "DATE-TIME"}),
+    "RELATED-TO": (None, {"VALUE": "TEXT"}),
+    "URL": (None, {"VALUE": "URI"}),
+    "UID": (None, {"VALUE": "TEXT"}),
+    "EXDATE": (None, {"VALUE": "DATE-TIME"}),
+    "EXRULE": (None, {"VALUE": "RECUR"}),
+    "RDATE": (None, {"VALUE": "DATE-TIME"}),
+    "RRULE": (None, {"VALUE": "RECUR"}),
+    "ACTION": (None, {"VALUE": "TEXT"}),
+    "REPEAT": (0, {"VALUE": "INTEGER"}),
+    "TRIGGER": (None, {"VALUE": "DURATION"}),
+    "CREATED": (None, {"VALUE": "DATE-TIME"}),
+    "DTSTAMP": (None, {"VALUE": "DATE-TIME"}),
     "LAST-MODIFIED": (None, {"VALUE": "DATE-TIME"}),
-    "SEQUENCE":     (0, {"VALUE": "INTEGER"}),
+    "SEQUENCE": (0, {"VALUE": "INTEGER"}),
     "REQUEST-STATUS": (None, {"VALUE": "TEXT"}),
 }
 
 # transformations to apply to property values
 normalizePropsValue = {
-    "ATTENDEE":     normalizeCUAddr,
-    "ORGANIZER":    normalizeCUAddr,
+    "ATTENDEE": normalizeCUAddr,
+    "ORGANIZER": normalizeCUAddr,
 }
 
 ignoredComponents = ("VTIMEZONE", "X-CALENDARSERVER-PERUSER",)
@@ -147,6 +147,8 @@
 class InvalidICalendarDataError(ValueError):
     pass
 
+
+
 class Property (object):
     """
     iCalendar Property
@@ -176,30 +178,53 @@
 
         self._parent = parent
 
-    def __str__(self): return str(self._pycalendar)
-    def __repr__(self): return "<%s: %r: %r>" % (self.__class__.__name__, self.name(), self.value())
 
+    def __str__(self):
+        return str(self._pycalendar)
+
+
+    def __repr__(self):
+        return "<%s: %r: %r>" % (self.__class__.__name__, self.name(), self.value())
+
+
     def __hash__(self):
         return hash(str(self))
 
-    def __ne__(self, other): return not self.__eq__(other)
+
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
+
     def __eq__(self, other):
-        if not isinstance(other, Property): return False
+        if not isinstance(other, Property):
+            return False
         return self._pycalendar == other._pycalendar
 
-    def __gt__(self, other): return not (self.__eq__(other) or self.__lt__(other))
+
+    def __gt__(self, other):
+        return not (self.__eq__(other) or self.__lt__(other))
+
+
     def __lt__(self, other):
         my_name = self.name()
         other_name = other.name()
 
-        if my_name < other_name: return True
-        if my_name > other_name: return False
+        if my_name < other_name:
+            return True
+        if my_name > other_name:
+            return False
 
         return self.value() < other.value()
 
-    def __ge__(self, other): return self.__eq__(other) or self.__gt__(other)
-    def __le__(self, other): return self.__eq__(other) or self.__lt__(other)
 
+    def __ge__(self, other):
+        return self.__eq__(other) or self.__gt__(other)
+
+
+    def __le__(self, other):
+        return self.__eq__(other) or self.__lt__(other)
+
+
     def duplicate(self):
         """
         Duplicate this object and all its contents.
@@ -208,21 +233,30 @@
         # FIXME: does the parent need to be set in this case?
         return Property(None, None, None, pycalendar=self._pycalendar.duplicate())
 
-    def name(self): return self._pycalendar.getName()
 
-    def value(self): return self._pycalendar.getValue().getValue()
+    def name(self):
+        return self._pycalendar.getName()
 
-    def strvalue(self): return str(self._pycalendar.getValue())
 
+    def value(self):
+        return self._pycalendar.getValue().getValue()
+
+
+    def strvalue(self):
+        return str(self._pycalendar.getValue())
+
+
     def _markAsDirty(self):
         parent = getattr(self, "_parent", None)
         if parent is not None:
             parent._markAsDirty()
 
+
     def setValue(self, value):
         self._pycalendar.setValue(value)
         self._markAsDirty()
 
+
     def parameterNames(self):
         """
         Returns a set containing parameter names for this property.
@@ -233,6 +267,7 @@
                 result.add(pyattr.getName())
         return result
 
+
     def parameterValue(self, name, default=None):
         """
         Returns a single value for the given parameter.  Raises
@@ -243,21 +278,26 @@
         except KeyError:
             return default
 
+
     def hasParameter(self, paramname):
         return self._pycalendar.hasAttribute(paramname)
 
+
     def setParameter(self, paramname, paramvalue):
         self._pycalendar.replaceAttribute(PyCalendarAttribute(paramname, paramvalue))
         self._markAsDirty()
 
+
     def removeParameter(self, paramname):
         self._pycalendar.removeAttributes(paramname)
         self._markAsDirty()
 
+
     def removeAllParameters(self):
         self._pycalendar.setAttributes({})
         self._markAsDirty()
 
+
     def removeParameterValue(self, paramname, paramvalue):
 
         paramname = paramname.upper()
@@ -270,6 +310,7 @@
                                 self._pycalendar.removeAttributes(paramname)
         self._markAsDirty()
 
+
     def containsTimeRange(self, start, end, defaulttz=None):
         """
         Determines whether this property contains a date/date-time within the specified
@@ -288,25 +329,26 @@
         allowedNames = ["COMPLETED", "CREATED", "DTSTAMP", "LAST-MODIFIED"]
         if self.name() not in allowedNames:
             return False
-        
+
         # get date/date-time value
         dt = self._pycalendar.getValue().getValue()
         assert isinstance(dt, PyCalendarDateTime), "Not a date/date-time value: %r" % (self,)
-        
+
         return timeRangesOverlap(dt, None, start, end, defaulttz)
 
 
+
 class Component (object):
     """
     X{iCalendar} component.
     """
 
     # Private Event access levels.
-    ACCESS_PROPERTY     = "X-CALENDARSERVER-ACCESS"
-    ACCESS_PUBLIC       = "PUBLIC"
-    ACCESS_PRIVATE      = "PRIVATE"
+    ACCESS_PROPERTY = "X-CALENDARSERVER-ACCESS"
+    ACCESS_PUBLIC = "PUBLIC"
+    ACCESS_PRIVATE = "PRIVATE"
     ACCESS_CONFIDENTIAL = "CONFIDENTIAL"
-    ACCESS_RESTRICTED   = "RESTRICTED"
+    ACCESS_RESTRICTED = "RESTRICTED"
 
     accessMap = {
         "PUBLIC"       : ACCESS_PUBLIC,
@@ -317,10 +359,10 @@
 
     confidentialPropertiesMap = {
         "VCALENDAR": ("PRODID", "VERSION", "CALSCALE", ACCESS_PROPERTY),
-        "VEVENT":    ("UID", "RECURRENCE-ID", "SEQUENCE", "DTSTAMP", "STATUS", "TRANSP", "DTSTART", "DTEND", "DURATION", "RRULE", "RDATE", "EXRULE", "EXDATE", ),
-        "VTODO":     ("UID", "RECURRENCE-ID", "SEQUENCE", "DTSTAMP", "STATUS", "DTSTART", "COMPLETED", "DUE", "DURATION", "RRULE", "RDATE", "EXRULE", "EXDATE", ),
-        "VJOURNAL":  ("UID", "RECURRENCE-ID", "SEQUENCE", "DTSTAMP", "STATUS", "DTSTART", "RRULE", "RDATE", "EXRULE", "EXDATE", ),
-        "VFREEBUSY": ("UID", "DTSTAMP", "DTSTART", "DTEND", "DURATION", "FREEBUSY", ),
+        "VEVENT": ("UID", "RECURRENCE-ID", "SEQUENCE", "DTSTAMP", "STATUS", "TRANSP", "DTSTART", "DTEND", "DURATION", "RRULE", "RDATE", "EXRULE", "EXDATE",),
+        "VTODO": ("UID", "RECURRENCE-ID", "SEQUENCE", "DTSTAMP", "STATUS", "DTSTART", "COMPLETED", "DUE", "DURATION", "RRULE", "RDATE", "EXRULE", "EXDATE",),
+        "VJOURNAL": ("UID", "RECURRENCE-ID", "SEQUENCE", "DTSTAMP", "STATUS", "DTSTART", "RRULE", "RDATE", "EXRULE", "EXDATE",),
+        "VFREEBUSY": ("UID", "DTSTAMP", "DTSTART", "DTEND", "DURATION", "FREEBUSY",),
         "VTIMEZONE": None,
     }
     extraRestrictedProperties = ("SUMMARY", "LOCATION",)
@@ -335,6 +377,7 @@
         """
         return clazz.fromString(string)
 
+
     @classmethod
     def allFromStream(clazz, stream):
         """
@@ -342,6 +385,7 @@
         """
         return clazz.fromStream(stream)
 
+
     @classmethod
     def fromString(clazz, string):
         """
@@ -355,13 +399,14 @@
         else:
             # Valid utf-8 please
             string.decode("utf-8")
-        
+
         # No BOMs please
         if string[:3] == codecs.BOM_UTF8:
             string = string[3:]
 
         return clazz.fromStream(StringIO.StringIO(string))
 
+
     @classmethod
     def fromStream(clazz, stream):
         """
@@ -382,6 +427,7 @@
             raise InvalidICalendarDataError("%s\n%s" % (errmsg, stream.read(),))
         return clazz(None, pycalendar=cal)
 
+
     @classmethod
     def fromIStream(clazz, stream):
         """
@@ -396,7 +442,8 @@
         #   A better solution would parse directly and incrementally from the
         #   request stream.
         #
-        def parse(data): return clazz.fromString(data)
+        def parse(data):
+            return clazz.fromString(data)
         return allDataFromStream(IStream(stream), parse)
 
 
@@ -437,11 +484,11 @@
 
             if "parent" in kwargs:
                 parent = kwargs["parent"]
-                
+
                 if parent is not None:
                     if not isinstance(parent, Component):
                         raise TypeError("Not a Component: %r" % (parent,))
-                    
+
                 self._parent = parent
             else:
                 self._parent = None
@@ -450,6 +497,7 @@
             self._pycalendar = PyCalendar(add_defaults=False) if name == "VCALENDAR" else PyCalendar.makeComponent(name, None)
             self._parent = None
 
+
     def __str__(self):
         """
         NB This does not automatically include timezones in VCALENDAR objects.
@@ -460,6 +508,7 @@
         self._cachedCopy = str(self._pycalendar)
         return self._cachedCopy
 
+
     def _markAsDirty(self):
         """
         Invalidate the cached copy of serialized icalendar data
@@ -469,38 +518,46 @@
         if parent is not None:
             parent._markAsDirty()
 
+
     def __repr__(self):
         return "<%s: %r>" % (self.__class__.__name__, str(self._pycalendar))
 
+
     def __hash__(self):
         return hash(str(self))
 
+
     def __ne__(self, other):
         return not self.__eq__(other)
 
+
     def __eq__(self, other):
         if not isinstance(other, Component):
             return False
         return self._pycalendar == other._pycalendar
 
+
     def getTextWithTimezones(self, includeTimezones):
         """
         Return text representation and include timezones if the option is on
         """
         assert self.name() == "VCALENDAR", "Must be a VCALENDAR: %r" % (self,)
-        
+
         return self._pycalendar.getText(includeTimezones=includeTimezones)
 
+
     # FIXME: Should this not be in __eq__?
     def same(self, other):
         return self._pycalendar == other._pycalendar
-    
+
+
     def name(self):
         """
         @return: the name of the iCalendar type of this component.
         """
         return self._pycalendar.getType()
 
+
     def mainType(self):
         """
         Determine the primary type of iCal component in this calendar.
@@ -508,7 +565,7 @@
         @raise: L{InvalidICalendarDataError} if there is more than one primary type.
         """
         assert self.name() == "VCALENDAR", "Must be a VCALENDAR: %r" % (self,)
-        
+
         mtype = None
         for component in self.subcomponents():
             if component.name() in ignoredComponents:
@@ -517,9 +574,10 @@
                 raise InvalidICalendarDataError("Component contains more than one type of primary type: %r" % (self,))
             else:
                 mtype = component.name()
-        
+
         return mtype
-    
+
+
     def mainComponent(self, allow_multiple=False):
         """
         Return the primary iCal component in this calendar.
@@ -527,7 +585,7 @@
         @raise: L{InvalidICalendarDataError} if there is more than one primary type.
         """
         assert self.name() == "VCALENDAR", "Must be a VCALENDAR: %r" % (self,)
-        
+
         result = None
         for component in self.subcomponents():
             if component.name() in ignoredComponents:
@@ -538,9 +596,10 @@
                 result = component
                 if allow_multiple:
                     break
-        
+
         return result
-    
+
+
     def masterComponent(self):
         """
         Return the master iCal component in this calendar.
@@ -548,15 +607,16 @@
             or C{None} if there isn't one.
         """
         assert self.name() == "VCALENDAR", "Must be a VCALENDAR: %r" % (self,)
-        
+
         for component in self.subcomponents():
             if component.name() in ignoredComponents:
                 continue
             if not component.hasProperty("RECURRENCE-ID"):
                 return component
-        
+
         return None
-    
+
+
     def overriddenComponent(self, recurrence_id):
         """
         Return the overridden iCal component in this calendar matching the supplied RECURRENCE-ID property.
@@ -568,7 +628,7 @@
             or C{None} if there isn't one.
         """
         assert self.name() == "VCALENDAR", "Must be a VCALENDAR: %r" % (self,)
-        
+
         if isinstance(recurrence_id, str):
             recurrence_id = PyCalendarDateTime.parseText(recurrence_id) if recurrence_id else None
 
@@ -580,21 +640,23 @@
                 return component
             elif rid is None and recurrence_id is None:
                 return component
-        
+
         return None
-    
+
+
     def accessLevel(self, default=ACCESS_PUBLIC):
         """
         Return the access level for this component.
         @return: the access level for the calendar data.
         """
         assert self.name() == "VCALENDAR", "Must be a VCALENDAR: %r" % (self,)
-        
+
         access = self.propertyValue(Component.ACCESS_PROPERTY)
         if access:
             access = access.upper()
         return Component.accessMap.get(access, default)
-    
+
+
     def duplicate(self):
         """
         Duplicate this object and all its contents.
@@ -604,7 +666,8 @@
         if hasattr(self, "noInstanceIndexing"):
             result.noInstanceIndexing = True
         return result
-        
+
+
     def subcomponents(self):
         """
         @return: an iterable of L{Component} objects, one for each subcomponent
@@ -615,6 +678,7 @@
             for c in self._pycalendar.getComponents()
         )
 
+
     def addComponent(self, component):
         """
         Adds a subcomponent to this component.
@@ -625,6 +689,7 @@
         component._parent = self
         self._markAsDirty()
 
+
     def removeComponent(self, component):
         """
         Removes a subcomponent from this component.
@@ -634,6 +699,7 @@
         component._parent = None
         self._markAsDirty()
 
+
     def hasProperty(self, name):
         """
         @param name: the name of the property whose existence is being tested.
@@ -641,6 +707,7 @@
         """
         return self._pycalendar.hasProperty(name)
 
+
     def getProperty(self, name):
         """
         Get one property from the property list.
@@ -649,10 +716,13 @@
         @raise: L{InvalidICalendarDataError} if there is more than one property of the given name.
         """
         properties = tuple(self.properties(name))
-        if len(properties) == 1: return properties[0]
-        if len(properties) > 1: raise InvalidICalendarDataError("More than one %s property in component %r" % (name, self))
+        if len(properties) == 1:
+            return properties[0]
+        if len(properties) > 1:
+            raise InvalidICalendarDataError("More than one %s property in component %r" % (name, self))
         return None
-        
+
+
     def properties(self, name=None):
         """
         @param name: if given and not C{None}, restricts the returned properties
@@ -671,6 +741,7 @@
             for p in properties
         )
 
+
     def propertyValue(self, name):
         properties = tuple(self.properties(name))
         if len(properties) == 1:
@@ -689,7 +760,8 @@
         """
         dtstart = self.propertyValue("DTSTART")
         return dtstart.duplicateAsUTC() if dtstart is not None else None
- 
+
+
     def getEndDateUTC(self):
         """
         Return the end date or date-time for the specified component,
@@ -707,6 +779,7 @@
 
         return dtend.duplicateAsUTC() if dtend is not None else None
 
+
     def getDueDateUTC(self):
         """
         Return the due date or date-time for the specified component
@@ -722,7 +795,8 @@
                 due = dtstart + duration
 
         return due.duplicateAsUTC() if due is not None else None
- 
+
+
     def getCompletedDateUTC(self):
         """
         Return the completed date or date-time for the specified component
@@ -732,7 +806,8 @@
         """
         completed = self.propertyValue("COMPLETED")
         return completed.duplicateAsUTC() if completed is not None else None
- 
+
+
     def getCreatedDateUTC(self):
         """
         Return the created date or date-time for the specified component
@@ -742,7 +817,8 @@
         """
         created = self.propertyValue("CREATED")
         return created.duplicateAsUTC() if created is not None else None
- 
+
+
     def getRecurrenceIDUTC(self):
         """
         Return the recurrence-id for the specified component.
@@ -751,7 +827,8 @@
         """
         rid = self.propertyValue("RECURRENCE-ID")
         return rid.duplicateAsUTC() if rid is not None else None
- 
+
+
     def getRange(self):
         """
         Determine whether a RANGE=THISANDFUTURE parameter is present
@@ -765,7 +842,8 @@
                 return (range == "THISANDFUTURE")
 
         return False
-    
+
+
     def getExdates(self):
         """
         Get the set of all EXDATEs in this (master) component.
@@ -776,6 +854,7 @@
                 exdates.add(exdate.getValue())
         return exdates
 
+
     def getTriggerDetails(self):
         """
         Return the trigger information for the specified alarm component.
@@ -787,24 +866,26 @@
             duration: the repeat duration if present, otherwise None
         """
         assert self.name() == "VALARM", "Component is not a VAlARM: %r" % (self,)
-        
+
         # The trigger value
         trigger = self.propertyValue("TRIGGER")
         if trigger is None:
             raise InvalidICalendarDataError("VALARM has no TRIGGER property: %r" % (self,))
-        
+
         # The related parameter
         related = self.getProperty("TRIGGER").parameterValue("RELATED")
         if related is None:
             related = True
         else:
             related = (related == "START")
-        
+
         # Repeat property
         repeat = self.propertyValue("REPEAT")
-        if repeat is None: repeat = 0
-        else: repeat = int(repeat)
-        
+        if repeat is None:
+            repeat = 0
+        else:
+            repeat = int(repeat)
+
         # Duration property
         duration = self.propertyValue("DURATION")
 
@@ -812,10 +893,12 @@
             raise InvalidICalendarDataError("VALARM has invalid REPEAT/DURATIOn properties: %r" % (self,))
 
         return (trigger, related, repeat, duration)
- 
+
+
     def getRecurrenceSet(self):
         return self._pycalendar.getRecurrenceSet()
 
+
     def getEffectiveStartEnd(self):
         # Get the start/end range needed for instance comparisons
 
@@ -831,12 +914,13 @@
         else:
             return None, None
 
+
     def getFBType(self):
-        
+
         # Only VEVENTs block time
-        if self.name() not in ("VEVENT", ):
+        if self.name() not in ("VEVENT",):
             return "FREE"
-        
+
         # Handle status
         status = self.propertyValue("STATUS")
         if status == "CANCELLED":
@@ -846,6 +930,7 @@
         else:
             return "BUSY"
 
+
     def addProperty(self, property):
         """
         Adds a property to this component.
@@ -856,6 +941,7 @@
         property._parent = self
         self._markAsDirty()
 
+
     def removeProperty(self, property):
         """
         Remove a property from this component.
@@ -866,17 +952,19 @@
         property._parent = None
         self._markAsDirty()
 
+
     def replaceProperty(self, property):
         """
         Add or replace a property in this component.
         @param property: the L{Property} to add or replace in this component.
         """
-        
+
         # Remove all existing ones first
         self._pycalendar.removeProperties(property.name())
         self.addProperty(property)
         self._markAsDirty()
 
+
     def timezoneIDs(self):
         """
         Returns the set of TZID parameter values appearing in any property in
@@ -890,35 +978,37 @@
             if tzid is not None:
                 result.add(tzid)
                 break
-        
+
         return result
-    
+
+
     def timezones(self):
         """
         Returns the set of TZID's for each VTIMEZONE component.
 
         @return: a set of strings, one for each unique TZID value.
         """
-        
+
         assert self.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
 
         results = set()
         for component in self.subcomponents():
             if component.name() == "VTIMEZONE":
                 results.add(component.propertyValue("TZID"))
-        
+
         return results
-    
+
+
     def truncateRecurrence(self, maximumCount):
         """
         Truncate RRULEs etc to make sure there are no more than the given number
         of instances.
- 
+
         @param maximumCount: the maximum number of instances to allow
         @type maximumCount: C{int}
         @return: a C{bool} indicating whether a change was made or not
         """
-        
+
         changed = False
         master = self.masterComponent()
         if master and master.isRecurring():
@@ -936,17 +1026,17 @@
                         start = master.getStartDateUTC()
                         diff = differenceDateTime(start, rrule.getUntil())
                         diff = diff.getDays() * 24 * 60 * 60 + diff.getSeconds()
-                        
+
                         period = {
-                            definitions.eRecurrence_YEARLY:   365 * 24 * 60 * 60,
-                            definitions.eRecurrence_MONTHLY:  30 * 24 * 60 * 60,
-                            definitions.eRecurrence_WEEKLY:   7 * 24 * 60 * 60,
-                            definitions.eRecurrence_DAILY:    1 * 24 * 60 * 60,
-                            definitions.eRecurrence_HOURLY:   60 * 60,
+                            definitions.eRecurrence_YEARLY: 365 * 24 * 60 * 60,
+                            definitions.eRecurrence_MONTHLY: 30 * 24 * 60 * 60,
+                            definitions.eRecurrence_WEEKLY: 7 * 24 * 60 * 60,
+                            definitions.eRecurrence_DAILY: 1 * 24 * 60 * 60,
+                            definitions.eRecurrence_HOURLY: 60 * 60,
                             definitions.eRecurrence_MINUTELY: 60,
                             definitions.eRecurrence_SECONDLY: 1
                         }[rrule.getFreq()] * rrule.getInterval()
-                        
+
                         if diff / period > maximumCount:
                             rrule.setUseUntil(False)
                             rrule.setUseCount(True)
@@ -965,6 +1055,7 @@
             self._markAsDirty()
         return changed
 
+
     def expand(self, start, end, timezone=None):
         """
         Expand the components into a set of new components, one for each
@@ -976,7 +1067,7 @@
         @param timezone: the L{Component} or L{PyCalendarTimezone} of the VTIMEZONE to use for floating/all-day.
         @return: the L{Component} for the new calendar with expanded instances.
         """
-        
+
         if timezone is not None and isinstance(timezone, Component):
             pytz = PyCalendarTimezone(tzid=timezone.propertyValue("TZID"))
         else:
@@ -989,7 +1080,7 @@
             calendar.removeProperty(property)
         for property in self.properties():
             calendar.addProperty(property)
-        
+
         # Expand the instances and add each one - use the normalizeForExpand date/time normalization method here
         # so that all-day date/times remain that way. However, when doing the timeRangesOverlap test below, we
         # Need to convert the all-days to floating (T000000) so that the timezone overlap calculation can be done
@@ -1001,9 +1092,10 @@
             if timeRangesOverlap(normalizeForIndex(instance.start), normalizeForIndex(instance.end), start, end, pytz):
                 calendar.addComponent(self.expandComponent(instance, first))
             first = False
-        
+
         return calendar
-    
+
+
     def expandComponent(self, instance, first):
         """
         Create an expanded component based on the instance provided.
@@ -1011,22 +1103,22 @@
         @param instance: an L{Instance} for the instance being expanded.
         @return: a new L{Component} for the expanded instance.
         """
-        
+
         # Duplicate the component from the instance
         newcomp = instance.component.duplicate()
- 
+
         # Strip out unwanted recurrence properties
         for property in tuple(newcomp.properties()):
             if property.name() in ["RRULE", "RDATE", "EXRULE", "EXDATE", "RECURRENCE-ID"]:
                 newcomp.removeProperty(property)
-        
+
         # Convert all datetime properties to UTC unless they are floating
         for property in newcomp.properties():
             value = property.value()
             if isinstance(value, PyCalendarDateTime) and value.local():
                 property.removeParameter("TZID")
                 property.setValue(value.duplicateAsUTC())
-        
+
         # Now reset DTSTART, DTEND/DURATION
         for property in newcomp.properties("DTSTART"):
             property.setValue(instance.start)
@@ -1034,32 +1126,33 @@
             property.setValue(instance.end)
         for property in newcomp.properties("DURATION"):
             property.setValue(instance.end - instance.start)
-        
+
         # Add RECURRENCE-ID if not master instance
         if not instance.isMasterInstance():
             newcomp.addProperty(Property("RECURRENCE-ID", instance.rid))
 
         return newcomp
 
+
     def cacheExpandedTimeRanges(self, limit, ignoreInvalidInstances=False):
         """
         Expand instances up to the specified limit and cache the results in this object
         so we can return cached results in the future. The limit value is the actual value
         that the requester needs, but we will cache an addition 365-days worth to give us some
         breathing room to return results for future instances.
- 
+
         @param limit: the max datetime to cache up to.
         @type limit: L{PyCalendarDateTime}
         """
-        
+
         # Checked for cached values first
         if hasattr(self, "cachedInstances"):
             cachedLimit = self.cachedInstances.limit
-            if cachedLimit is None or cachedLimit >= limit:
+            if cachedLimit is None or cachedLimit > limit:
                 # We have already fully expanded, or cached up to the requested time,
                 # so return cached instances
                 return self.cachedInstances
-        
+
         lookAheadLimit = limit + PyCalendarDuration(days=365)
         self.cachedInstances = self.expandTimeRanges(
             lookAheadLimit,
@@ -1067,6 +1160,7 @@
         )
         return self.cachedInstances
 
+
     def expandTimeRanges(self, limit, lowerLimit=None, ignoreInvalidInstances=False, normalizeFunction=normalizeForIndex):
         """
         Expand the set of recurrence instances for the components
@@ -1077,10 +1171,11 @@
         @param ignoreInvalidInstances: C{bool} whether to ignore instance errors.
         @return: a set of Instances for each recurrence in the set.
         """
-        
+
         componentSet = self.subcomponents()
         return self.expandSetTimeRanges(componentSet, limit, lowerLimit=lowerLimit, ignoreInvalidInstances=ignoreInvalidInstances, normalizeFunction=normalizeFunction)
-    
+
+
     def expandSetTimeRanges(self, componentSet, limit, lowerLimit=None, ignoreInvalidInstances=False, normalizeFunction=normalizeForIndex):
         """
         Expand the set of recurrence instances up to the specified date limit.
@@ -1105,16 +1200,17 @@
         @type normalizeFunction: C{function}
         @return: L{InstanceList} containing expanded L{Instance} for each recurrence in the set.
         """
-        
+
         # Set of instances to return
         instances = InstanceList(ignoreInvalidInstances=ignoreInvalidInstances, normalizeFunction=normalizeFunction)
         instances.expandTimeRanges(componentSet, limit, lowerLimit=lowerLimit)
         return instances
 
+
     def getComponentInstances(self):
         """
         Get the R-ID value for each component.
-        
+
         @return: a tuple of recurrence-ids
         """
 
@@ -1129,6 +1225,7 @@
             rid = self.getRecurrenceIDUTC()
             return (rid,)
 
+
     def isRecurring(self):
         """
         Check whether any recurrence properties are present in any component.
@@ -1144,7 +1241,8 @@
                 if self.hasProperty(propname):
                     return True
         return False
-        
+
+
     def isRecurringUnbounded(self):
         """
         Check for unbounded recurrence.
@@ -1157,7 +1255,8 @@
                 if not rrule.value().getUseCount() and not rrule.value().getUseUntil():
                     return True
         return False
-        
+
+
     def deriveInstance(self, rid, allowCancelled=False, newcomp=None):
         """
         Derive an instance from the master component that has the provided RECURRENCE-ID, but
@@ -1169,10 +1268,10 @@
         @type rid: L{PyCalendarDateTime}
         @param allowCancelled: whether to allow a STATUS:CANCELLED override
         @type allowCancelled: C{bool}
-        
+
         @return: L{Component} for newly derived instance, or None if not valid override
         """
-        
+
         if allowCancelled and newcomp is not None:
             raise ValueError("Cannot re-use master component with allowCancelled")
 
@@ -1200,7 +1299,7 @@
                     else:
                         # Cannot derive from an existing EXDATE
                         return None
-        
+
         # Check whether recurrence-id matches an RDATE - if so it is OK
         rdates = set()
         for rdate in master.properties("RDATE"):
@@ -1217,31 +1316,31 @@
             else:
                 # No RRULE and no match to an RDATE => error
                 return None
-        
+
         # If we were fed an already derived component, use that, otherwise make a new one
         if newcomp is None:
             newcomp = self.masterDerived()
-        
+
         # New DTSTART is the RECURRENCE-ID we are deriving but adjusted to the
         # original DTSTART's localtime
         dtstart = newcomp.getProperty("DTSTART")
         if newcomp.hasProperty("DTEND"):
             dtend = newcomp.getProperty("DTEND")
             oldduration = dtend.value() - dtstart.value()
-        
+
         newdtstartValue = rid.duplicate()
         if not dtstart.value().isDateOnly():
             if dtstart.value().local():
                 newdtstartValue.adjustTimezone(dtstart.value().getTimezone())
         else:
             newdtstartValue.setDateOnly(True)
-            
+
         dtstart.setValue(newdtstartValue)
         if newcomp.hasProperty("DTEND"):
             dtend.setValue(newdtstartValue + oldduration)
 
         newcomp.replaceProperty(Property("RECURRENCE-ID", dtstart.value(), params={}))
-        
+
         if didCancel:
             newcomp.replaceProperty(Property("STATUS", "CANCELLED"))
 
@@ -1249,13 +1348,14 @@
         newcomp._pycalendar.finalise()
 
         return newcomp
-    
+
+
     def masterDerived(self):
         """
         Generate a component from the master instance that can be fed repeatedly to
         deriveInstance in the case where the result of deriveInstance is not going
         to be inserted into the component. This provides an optimization for avoiding
-        unnecessary .duplicate() calls on the master for each deriveInstance. 
+        unnecessary .duplicate() calls on the master for each deriveInstance.
         """
 
         # Must have a master component
@@ -1270,19 +1370,20 @@
         for property in tuple(newcomp.properties()):
             if property.name() in ("RRULE", "RDATE", "EXRULE", "EXDATE", "RECURRENCE-ID",):
                 newcomp.removeProperty(property)
-        
+
         return newcomp
 
+
     def validInstances(self, rids, ignoreInvalidInstances=False):
         """
         Test whether the specified recurrence-ids are valid instances in this event.
 
         @param rid: recurrence-id values
         @type rid: iterable
-        
+
         @return: C{set} of valid rids
         """
-        
+
         valid = set()
         non_master_rids = [rid for rid in rids if rid is not None]
         if non_master_rids:
@@ -1297,6 +1398,7 @@
                 valid.add(rid)
         return valid
 
+
     def validInstance(self, rid, clear_cache=True, ignoreInvalidInstances=False):
         """
         Test whether the specified recurrence-id is a valid instance in this event.
@@ -1321,6 +1423,7 @@
         new_rids = set([instances[key].rid for key in instances])
         return rid in new_rids
 
+
     def resourceUID(self):
         """
         @return: the UID of the subcomponents in this component.
@@ -1337,6 +1440,7 @@
 
         return self._resource_uid
 
+
     def resourceType(self):
         """
         @return: the name of the iCalendar type of the subcomponents in this
@@ -1364,11 +1468,12 @@
 
         return self._resource_type
 
+
     def stripKnownTimezones(self):
         """
         Remove timezones that this server knows about
         """
-        
+
         changed = False
         for subcomponent in tuple(self.subcomponents()):
             if subcomponent.name() == "VTIMEZONE":
@@ -1385,6 +1490,7 @@
 
         return changed
 
+
     def validCalendarData(self, doFix=True, doRaise=True, validateRecurrences=False):
         """
         @return: tuple of fixed, unfixed issues
@@ -1413,7 +1519,7 @@
                 raise InvalidICalendarDataError("Calendar data had unfixable problems:\n  %s" % ("\n  ".join(unfixed),))
         if fixed:
             log.debug("Calendar data had fixable problems:\n  %s" % ("\n  ".join(fixed),))
-        
+
         return fixed, unfixed
 
 
@@ -1435,7 +1541,7 @@
 
                 # Remove all EXDATEs with a matching RECURRENCE-ID. Do this before we start
                 # processing of valid instances just in case the matching R-ID is also not valid and
-                # thus will need RDATE added. 
+                # thus will need RDATE added.
                 exdates = {}
                 for property in list(master.properties("EXDATE")):
                     for exdate in property.value():
@@ -1455,17 +1561,16 @@
                             fixed.append("Removed EXDATE for valid override: %s" % (rid,))
                         else:
                             unfixed.append("EXDATE for valid override: %s" % (rid,))
-                
+
                 # Get the set of all valid recurrence IDs
                 valid_rids = self.validInstances(all_rids, ignoreInvalidInstances=True)
-    
+
                 # Get the set of all RDATEs and add those to the valid set
                 rdates = []
                 for property in master.properties("RDATE"):
                     rdates.extend([_rdate.getValue() for _rdate in property.value()])
                 valid_rids.update(set(rdates))
 
-
                 # Remove EXDATEs predating master
                 dtstart = master.propertyValue("DTSTART")
                 if dtstart is not None:
@@ -1491,7 +1596,6 @@
                                 property.setValue(newValues)
                                 master.addProperty(property)
 
-
             else:
                 valid_rids = set()
 
@@ -1503,7 +1607,7 @@
                 brokenComponent = self.overriddenComponent(invalid_rid)
                 brokenRID = brokenComponent.propertyValue("RECURRENCE-ID")
                 if doFix:
-                    master.addProperty(Property("RDATE", [brokenRID,]))
+                    master.addProperty(Property("RDATE", [brokenRID, ]))
                     fixed.append("Added RDATE for invalid occurrence: %s" %
                         (brokenRID,))
                 else:
@@ -1511,9 +1615,10 @@
 
         return fixed, unfixed
 
+
     def validCalendarForCalDAV(self, methodAllowed):
         """
-        @param methodAllowed:     True if METHOD property is allowed, False otherwise.
+        @param methodAllowed: True if METHOD property is allowed, False otherwise.
         @raise InvalidICalendarDataError: if the given calendar component is not valid for
             use as a X{CalDAV} resource.
         """
@@ -1528,15 +1633,15 @@
         # Must not contain more than one type of iCalendar component, except for
         # the required timezone components, and component UIDs must match
         #
-        ctype            = None
-        component_id     = None
-        component_rids   = set()
-        timezone_refs    = set()
-        timezones        = set()
-        got_master       = False
+        ctype = None
+        component_id = None
+        component_rids = set()
+        timezone_refs = set()
+        timezones = set()
+        got_master = False
         #got_override     = False
         #master_recurring = False
-        
+
         for subcomponent in self.subcomponents():
             if subcomponent.name() == "VTIMEZONE":
                 timezones.add(subcomponent.propertyValue("TZID"))
@@ -1550,19 +1655,19 @@
                         msg = "Calendar resources may not contain more than one type of calendar component (%s and %s found)" % (ctype, subcomponent.name())
                         log.debug(msg)
                         raise InvalidICalendarDataError(msg)
-        
+
                 if ctype not in allowedComponents:
                     msg = "Component type: %s not allowed" % (ctype,)
                     log.debug(msg)
                     raise InvalidICalendarDataError(msg)
-                    
+
                 uid = subcomponent.propertyValue("UID")
                 if uid is None:
                     msg = "All components must have UIDs"
                     log.debug(msg)
                     raise InvalidICalendarDataError(msg)
                 rid = subcomponent.getRecurrenceIDUTC()
-                
+
                 # Verify that UIDs are the same
                 if component_id is None:
                     component_id = uid
@@ -1582,7 +1687,7 @@
                         # master_recurring = subcomponent.hasProperty("RRULE") or subcomponent.hasProperty("RDATE")
                 else:
                     pass # got_override = True
-                            
+
                 # Check that if an override is present then the master is recurring
                 # Leopard iCal sometimes does this for overridden instances that an Attendee receives and
                 # it creates a "fake" (invalid) master. We are going to skip this test here. Instead implicit
@@ -1594,8 +1699,8 @@
 #                    msg = "Calendar resources must have a recurring master component if there is an overridden one (%s)" % (subcomponent.propertyValue("UID"),)
 #                    log.debug(msg)
 #                    raise InvalidICalendarDataError(msg)
-                
-                # Check for duplicate RECURRENCE-IDs        
+
+                # Check for duplicate RECURRENCE-IDs
                 if rid in component_rids:
                     msg = "Calendar resources may not contain components with the same Recurrence-IDs (%s)" % (rid,)
                     log.debug(msg)
@@ -1604,7 +1709,7 @@
                     component_rids.add(rid)
 
                 timezone_refs.update(subcomponent.timezoneIDs())
-        
+
         #
         # Make sure required timezone components are present
         #
@@ -1614,7 +1719,7 @@
                     msg = "Timezone ID %s is referenced but not defined: %s" % (timezone_ref, self,)
                     log.debug(msg)
                     raise InvalidICalendarDataError(msg)
-        
+
         #
         # FIXME:
         #   This test is not part of the spec; it appears to be legal (but
@@ -1631,11 +1736,12 @@
         if len(s.translate(None, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F")) != len(s):
             raise InvalidICalendarDataError("iCalendar contains illegal control character")
 
+
     def validOrganizerForScheduling(self, doFix=True):
         """
-        Check that the ORGANIZER property is valid for scheduling 
+        Check that the ORGANIZER property is valid for scheduling
         """
-        
+
         organizers = self.getOrganizersByInstance()
         foundOrganizer = None
         foundRid = None
@@ -1653,7 +1759,7 @@
                     foundRid = rid
             else:
                 missingRids.add(rid)
-        
+
         # If there are some components without an ORGANIZER we will fix the data
         if foundOrganizer and missingRids:
             if doFix:
@@ -1666,6 +1772,7 @@
 
         return foundOrganizer
 
+
     def gettimezone(self):
         """
         Get the PyCalendarTimezone for a Timezone component.
@@ -1686,61 +1793,64 @@
     ##
     # iTIP stuff
     ##
-    
+
+
     def isValidMethod(self):
         """
         Verify that this calendar component has a valid iTIP METHOD property.
-        
+
         @return: True if valid, False if not
         """
-        
+
         try:
             method = self.propertyValue("METHOD")
             if method not in ("PUBLISH", "REQUEST", "REPLY", "ADD", "CANCEL", "REFRESH", "COUNTER", "DECLINECOUNTER"):
                 return False
         except InvalidICalendarDataError:
             return False
-        
+
         return True
 
+
     def isValidITIP(self):
         """
         Verify that this calendar component is valid according to iTIP.
-        
+
         @return: True if valid, False if not
         """
-        
+
         try:
             method = self.propertyValue("METHOD")
             if method not in ("PUBLISH", "REQUEST", "REPLY", "ADD", "CANCEL", "REFRESH", "COUNTER", "DECLINECOUNTER"):
                 return False
-            
+
             # First make sure components are all of the same time (excluding VTIMEZONE)
             self.validCalendarForCalDAV(methodAllowed=True)
-            
+
             # Next we could check the iTIP status for each type of method/component pair, however
             # we can also leave that up to the server except for the REQUEST/VFREEBUSY case which
             # the server will handle itself.
-            
+
             if (method == "REQUEST") and (self.mainType() == "VFREEBUSY"):
                 # TODO: verify REQUEST/VFREEBUSY as being OK
-                
+
                 # Only one VFREEBUSY (actually multiple X-'s are allowed but we will reject)
                 if len([c for c in self.subcomponents()]) != 1:
                     return False
 
         except InvalidICalendarDataError:
             return False
-        
+
         return True
-    
+
+
     def getOrganizer(self):
         """
         Get the organizer value. Works on either a VCALENDAR or on a component.
-        
+
         @return: the string value of the Organizer property, or None
         """
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
@@ -1755,13 +1865,14 @@
 
         return None
 
+
     def getOrganizersByInstance(self):
         """
         Get the organizer value for each instance.
-        
+
         @return: a list of tuples of (organizer value, recurrence-id)
         """
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             result = ()
@@ -1780,13 +1891,14 @@
 
         return ()
 
+
     def getOrganizerProperty(self):
         """
         Get the organizer value. Works on either a VCALENDAR or on a component.
-        
+
         @return: the string value of the Organizer property, or None
         """
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
@@ -1801,6 +1913,7 @@
 
         return None
 
+
     def getOrganizerScheduleAgent(self):
 
         is_server = False
@@ -1814,14 +1927,15 @@
 
         return is_server
 
+
     def getAttendees(self):
         """
         Get the attendee value. Works on either a VCALENDAR or on a component.
-        
+
         @param match: a C{list} of calendar user address strings to try and match.
         @return: a C{list} of the string values of the Attendee property, or None
         """
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
@@ -1833,17 +1947,18 @@
 
         return None
 
+
     def getAttendeesByInstance(self, makeUnique=False, onlyScheduleAgentServer=False):
         """
         Get the attendee values for each instance. Optionally remove duplicates.
-        
+
         @param makeUnique: if C{True} remove duplicate ATTENDEEs in each component
         @type makeUnique: C{bool}
         @param onlyScheduleAgentServer: if C{True} only return ATETNDEEs with SCHEDULE-AGENT=SERVER set
         @type onlyScheduleAgentServer: C{bool}
         @return: a list of tuples of (organizer value, recurrence-id)
         """
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             result = ()
@@ -1856,7 +1971,7 @@
             attendees = set()
             rid = self.getRecurrenceIDUTC()
             for attendee in tuple(self.properties("ATTENDEE")):
-                
+
                 if onlyScheduleAgentServer:
                     if attendee.hasParameter("SCHEDULE-AGENT"):
                         if attendee.parameterValue("SCHEDULE-AGENT") != "SERVER":
@@ -1870,19 +1985,20 @@
                     attendees.add(cuaddr)
             return result
 
+
     def getAttendeeProperty(self, match):
         """
         Get the attendees matching a value. Works on either a VCALENDAR or on a component.
-        
+
         @param match: a C{list} of calendar user address strings to try and match.
         @return: the matching Attendee property, or None
         """
-        
+
         # Need to normalize http/https cu addresses
         test = set()
         for item in match:
             test.add(normalizeCUAddr(item))
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
@@ -1898,14 +2014,15 @@
 
         return None
 
+
     def getAttendeeProperties(self, match):
         """
         Get all the attendees matching a value in each component. Works on a VCALENDAR component only.
-        
+
         @param match: a C{list} of calendar user address strings to try and match.
         @return: the string value of the Organizer property, or None
         """
-        
+
         assert self.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
 
         # Extract appropriate sub-component if this is a VCALENDAR
@@ -1918,6 +2035,7 @@
 
         return results
 
+
     def getAllAttendeeProperties(self):
         """
         Yield all attendees as Property objects.  Works on either a VCALENDAR or
@@ -1944,13 +2062,14 @@
             attendees.add(attendee)
         return attendees
 
+
     def getMaskUID(self):
         """
         Get the X-CALENDARSEREVR-MASK-UID value. Works on either a VCALENDAR or on a component.
-        
+
         @return: the string value of the X-CALENDARSEREVR-MASK-UID property, or None
         """
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
@@ -1965,13 +2084,14 @@
 
         return None
 
+
     def getExtendedFreeBusy(self):
         """
         Get the X-CALENDARSERVER-EXTENDED-FREEBUSY value. Works on either a VCALENDAR or on a component.
-        
+
         @return: the string value of the X-CALENDARSERVER-EXTENDED-FREEBUSY property, or None
         """
-        
+
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
@@ -1986,10 +2106,11 @@
 
         return None
 
+
     def setParameterToValueForPropertyWithValue(self, paramname, paramvalue, propname, propvalue):
         """
         Add or change the parameter to the specified value on the property having the specified value.
-        
+
         @param paramname: the parameter name
         @type paramname: C{str}
         @param paramvalue: the parameter value to set
@@ -1999,25 +2120,26 @@
         @param propvalue: the property value to test
         @type propvalue: C{str} or C{None}
         """
-        
+
         for component in self.subcomponents():
             if component.name() in ignoredComponents:
                 continue
             for property in component.properties(propname):
                 if propvalue is None or property.value() == propvalue:
                     property.setParameter(paramname, paramvalue)
-    
+
+
     def hasPropertyInAnyComponent(self, properties):
         """
         Test for the existence of one or more properties in any component.
-        
+
         @param properties: property name(s) to test for
         @type properties: C{list}, C{tuple} or C{str}
         """
 
         if isinstance(properties, str):
             properties = (properties,)
-            
+
         for property in properties:
             if self.hasProperty(property):
                 return True
@@ -2028,17 +2150,18 @@
 
         return False
 
+
     def getFirstPropertyInAnyComponent(self, properties):
         """
         Get the first of any set of properties in any component.
-        
+
         @param properties: property name(s) to test for
         @type properties: C{list}, C{tuple} or C{str}
         """
 
         if isinstance(properties, str):
             properties = (properties,)
-            
+
         for property in properties:
             props = tuple(self.properties(property))
             if props:
@@ -2051,15 +2174,16 @@
 
         return None
 
+
     def getAllPropertiesInAnyComponent(self, properties, depth=2):
         """
         Get the all of any set of properties in any component down to a
         specified depth.
-        
+
         @param properties: property name(s) to test for
         @type properties: C{list}, C{tuple} or C{str}
         @param depth: how deep to go in looking at sub-components:
-            0: do not go into sub-components, 1: go into one level of sub-components, 
+            0: do not go into sub-components, 1: go into one level of sub-components,
             2: two levels (which is effectively all the levels supported in iCalendar)
         @type depth: int
         """
@@ -2068,7 +2192,7 @@
 
         if isinstance(properties, str):
             properties = (properties,)
-            
+
         for property in properties:
             props = tuple(self.properties(property))
             if props:
@@ -2080,10 +2204,11 @@
 
         return results
 
+
     def hasPropertyValueInAllComponents(self, property):
         """
         Test for the existence of a property with a specific value in any sub-component.
-        
+
         @param property: property to test for
         @type property: L{Property}
         """
@@ -2097,6 +2222,7 @@
 
         return True
 
+
     def addPropertyToAllComponents(self, property):
         """
         Add a property to all top-level components except VTIMEZONE.
@@ -2104,28 +2230,30 @@
         @param property: the property to add
         @type property: L{Property}
         """
-        
+
         for component in self.subcomponents():
             if component.name() in ignoredComponents:
                 continue
             component.addProperty(property)
 
+
     def replacePropertyInAllComponents(self, property):
         """
         Replace a property in all components.
         @param property: the L{Property} to replace in this component.
         """
-        
+
         for component in self.subcomponents():
             if component.name() in ignoredComponents:
                 continue
             component.replaceProperty(property)
-    
+
+
     def transferProperties(self, from_calendar, properties):
         """
         Transfer specified properties from old calendar into all components
         of this calendar, synthesizing any for new overridden instances.
- 
+
         @param from_calendar: the old calendar to copy from
         @type from_calendar: L{Component}
         @param properties: the property names to copy over
@@ -2133,7 +2261,7 @@
         """
 
         assert from_calendar.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
-        
+
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
                 if component.name() in ignoredComponents:
@@ -2143,7 +2271,7 @@
             # Is there a matching component
             rid = self.getRecurrenceIDUTC()
             matched = from_calendar.overriddenComponent(rid)
-            
+
             # If no match found, we are processing a new overridden instance so copy from the original master
             if not matched:
                 matched = from_calendar.masterComponent()
@@ -2152,7 +2280,8 @@
                 for propname in properties:
                     for prop in matched.properties(propname):
                         self.addProperty(prop)
-            
+
+
     def attendeesView(self, attendees, onlyScheduleAgentServer=False):
         """
         Filter out any components that all attendees are not present in. Use EXDATEs
@@ -2160,7 +2289,7 @@
         """
 
         assert self.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
-            
+
         # Modify any components that reference the attendee, make note of the ones that don't
         remove_components = []
         master_component = None
@@ -2185,7 +2314,7 @@
                 master_component = component
                 if not found_all_attendees:
                     removed_master = True
-                
+
         # Now remove the unwanted components - but we may need to EXDATE the master
         exdates = []
         for component in remove_components:
@@ -2193,19 +2322,20 @@
             if rid is not None:
                 exdates.append(rid)
             self.removeComponent(component)
-            
+
         if not removed_master and master_component is not None:
             for exdate in exdates:
-                master_component.addProperty(Property("EXDATE", [exdate,]))
-    
+                master_component.addProperty(Property("EXDATE", [exdate, ]))
+
+
     def filterComponents(self, rids):
-        
+
         # If master is in rids do nothing
         if not rids or "" in rids:
             return True
-        
+
         assert self.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
-            
+
         # Remove components not in the list
         components = tuple(self.subcomponents())
         remaining = len(components)
@@ -2217,9 +2347,10 @@
             if (rid.getText() if rid else "") not in rids:
                 self.removeComponent(component)
                 remaining -= 1
-                
+
         return remaining != 0
-        
+
+
     def removeAllButOneAttendee(self, attendee):
         """
         Remove all ATTENDEE properties except for the one specified.
@@ -2231,7 +2362,8 @@
             if component.name() in ignoredComponents:
                 continue
             [component.removeProperty(p) for p in tuple(component.properties("ATTENDEE")) if p.value().lower() != attendee.lower()]
-    
+
+
     def hasAlarm(self):
         """
         Test whether the component has a VALARM as an immediate sub-component.
@@ -2243,20 +2375,21 @@
                 return True
         return False
 
+
     def addAlarms(self, alarm, ignoreActionNone=True):
         """
         Add an alarm to any VEVENT or VTODO subcomponents that do not already have any.
 
         @param alarm: the text for a VALARM component
         @type alarm: C{str}
-        
+
         @param ignoreActionNone: whether or not to skip ACTION:NONE alarms
         @type ignoreActionNone: C{bool}
-        
+
         @return: indicate whether a change was made
         @rtype: C{bool}
         """
-        
+
         # Create a fake component for the alarm text
         caldata = """BEGIN:VCALENDAR
 VERSION:2.0
@@ -2270,7 +2403,7 @@
 %sEND:VEVENT
 END:VCALENDAR
 """.replace("\n", "\r\n") % (alarm,)
-        
+
         try:
             calendar = Component.fromString(caldata)
             if calendar is None:
@@ -2297,9 +2430,10 @@
                     continue
                 component.addComponent(valarm.duplicate())
                 changed = True
-        
+
         return changed
 
+
     def removeAlarms(self):
         """
         Remove all Alarms components
@@ -2315,6 +2449,7 @@
                 if component.name() == "VALARM":
                     self.removeComponent(component)
 
+
     def hasDuplicateAlarms(self, doFix=False):
         """
         Test and optionally remove alarms that have the same ACTION and TRIGGER values in the same component.
@@ -2338,6 +2473,7 @@
                         action_trigger.add(item)
         return changed
 
+
     def filterProperties(self, remove=None, keep=None, do_subcomponents=True):
         """
         Remove all properties that do not match the provided set.
@@ -2349,11 +2485,12 @@
         else:
             if self.name() in ignoredComponents:
                 return
-            
+
             for p in tuple(self.properties()):
                 if (keep and p.name() not in keep) or (remove and p.name() in remove):
                     self.removeProperty(p)
-                
+
+
     def removeXComponents(self, keep_components=()):
         """
         Remove all X- components except the specified ones
@@ -2362,7 +2499,8 @@
         for component in tuple(self.subcomponents()):
             if component.name().startswith("X-") and component.name() not in keep_components:
                 self.removeComponent(component)
-            
+
+
     def removeXProperties(self, keep_properties=(), remove_x_parameters=True, do_subcomponents=True):
         """
         Remove all X- properties except the specified ones
@@ -2382,7 +2520,8 @@
                     for paramname in p.parameterNames():
                         if paramname.startswith("X-"):
                             p.removeParameter(paramname)
-            
+
+
     def removePropertyParameters(self, property, params):
         """
         Remove all specified property parameters
@@ -2399,6 +2538,7 @@
                 for param in params:
                     prop.removeParameter(param)
 
+
     def removePropertyParametersByValue(self, property, paramvalues):
         """
         Remove all specified property parameters
@@ -2415,10 +2555,11 @@
                 for param, value in paramvalues:
                     prop.removeParameterValue(param, value)
 
+
     def getITIPInfo(self):
         """
         Get property value details needed to synchronize iTIP components.
-        
+
         @return: C{tuple} of (uid, seq, dtstamp, r-id) some of which may be C{None} if property does not exist
         """
         try:
@@ -2429,46 +2570,48 @@
                 seq = int(seq)
             dtstamp = self.propertyValue("DTSTAMP")
             rid = self.propertyValue("RECURRENCE-ID")
-            
+
         except ValueError:
             return (None, None, None, None)
-        
+
         return (uid, seq, dtstamp, rid)
 
+
     @staticmethod
     def compareComponentsForITIP(component1, component2, use_dtstamp=True):
         """
         Compare synchronization information for two components to see if they match according to iTIP.
-    
+
         @param component1: first component to check.
         @type component1: L{Component}
         @param component2: second component to check.
         @type component2: L{Component}
         @param use_dtstamp: whether DTSTAMP is used in addition to SEQUENCE.
         @type component2: C{bool}
-        
+
         @return: 0, 1, -1 as per compareSyncInfo.
         """
         info1 = (None,) + Component.getITIPInfo(component1)
         info2 = (None,) + Component.getITIPInfo(component2)
         return Component.compareITIPInfo(info1, info2, use_dtstamp)
-    
+
+
     @staticmethod
     def compareITIPInfo(info1, info2, use_dtstamp=True):
         """
         Compare two synchronization information records.
-        
+
         @param info1: a C{tuple} as returned by L{getSyncInfo}.
         @param info2: a C{tuple} as returned by L{getSyncInfo}.
         @return: 1 if info1 > info2, 0 if info1 == info2, -1 if info1 < info2
         """
-        
+
         _ignore_name1, uid1, seq1, dtstamp1, _ignore_rid1 = info1
         _ignore_name2, uid2, seq2, dtstamp2, _ignore_rid2 = info2
-        
+
         # UIDs MUST match
         assert uid1 == uid2
-        
+
         # Look for sequence
         if (seq1 is not None) and (seq2 is not None):
             if seq1 > seq2:
@@ -2479,7 +2622,7 @@
             return 1
         elif (seq1 is None) and (seq2 is not None):
             return -1
-    
+
         # Look for DTSTAMP
         if use_dtstamp:
             if (dtstamp1 is not None) and (dtstamp2 is not None):
@@ -2491,15 +2634,16 @@
                 return 1
             elif (dtstamp1 is None) and (dtstamp2 is not None):
                 return -1
-    
+
         return 0
 
+
     def needsiTIPSequenceChange(self, oldcalendar):
         """
         Compare this calendar with the old one and indicate whether the current one has SEQUENCE
         that is always greater than the old.
         """
-        
+
         for component in self.subcomponents():
             if component.name() in ignoredComponents:
                 continue
@@ -2519,49 +2663,53 @@
 
         return False
 
+
     def bumpiTIPInfo(self, oldcalendar=None, doSequence=False):
         """
         Change DTSTAMP and optionally SEQUENCE on all components.
         """
-        
+
         if doSequence:
-            
+
+
             def maxSequence(calendar):
                 seqs = calendar.getAllPropertiesInAnyComponent("SEQUENCE", depth=1)
-                return max(seqs, key=lambda x:x.value()).value() if seqs else 0
+                return max(seqs, key=lambda x: x.value()).value() if seqs else 0
 
             # Determine value to bump to from old calendar (if exists) or self
-            newseq = maxSequence(oldcalendar if oldcalendar is not None else self) + 1                
-                
+            newseq = maxSequence(oldcalendar if oldcalendar is not None else self) + 1
+
             # Bump all components
             self.replacePropertyInAllComponents(Property("SEQUENCE", newseq))
-        
+
         self.replacePropertyInAllComponents(Property("DTSTAMP", PyCalendarDateTime.getNowUTC()))
-            
+
+
     def sequenceInSync(self, oldcalendar):
         """
         Make sure SEQUENCE does not decrease in any components.
         """
-        
-        
+
         def maxSequence(calendar):
             seqs = calendar.getAllPropertiesInAnyComponent("SEQUENCE", depth=1)
-            return max(seqs, key=lambda x:x.value()).value() if seqs else 0
+            return max(seqs, key=lambda x: x.value()).value() if seqs else 0
 
+
         def minSequence(calendar):
             seqs = calendar.getAllPropertiesInAnyComponent("SEQUENCE", depth=1)
-            return min(seqs, key=lambda x:x.value()).value() if seqs else 0
+            return min(seqs, key=lambda x: x.value()).value() if seqs else 0
 
         # Determine value to bump to from old calendar (if exists) or self
         oldseq = maxSequence(oldcalendar)
         currentseq = minSequence(self)
-            
+
         # Sync all components
         if oldseq and currentseq < oldseq:
             self.replacePropertyInAllComponents(Property("SEQUENCE", oldseq))
-            
+
+
     def normalizeAll(self):
-        
+
         # Normalize all properties
         for prop in tuple(self.properties()):
             result = normalizeProps.get(prop.name())
@@ -2571,13 +2719,13 @@
                 # Assume default VALUE is TEXT
                 default_value = None
                 default_params = {"VALUE": "TEXT"}
-            
+
             # Remove any default parameters
             for name in prop.parameterNames():
                 value = prop.parameterValue(name)
                 if value == default_params.get(name):
                     prop.removeParameter(name)
-            
+
             # If there are no parameters, remove the property if it has the default value
             if len(prop.parameterNames()) == 0:
                 if default_value is not None and prop.value() == default_value:
@@ -2596,29 +2744,30 @@
         for component in self.subcomponents():
             component.normalizeAll()
 
+
     def normalizeDateTimes(self):
         """
         Normalize various datetime properties into UTC and handle DTEND/DURATION variants in such
         a way that we can compare objects with slight differences.
-        
+
         Also normalize the RRULE value parts.
-        
+
         Strictly speaking we should not need to do this as clients should not be messing with
         these properties - i.e. they should round trip them. Unfortunately some do...
         """
-        
+
         # TODO: what about VJOURNAL and VTODO?
         if self.name() == "VEVENT":
-            
+
             # Basic time properties
             dtstart = self.getProperty("DTSTART")
             dtend = self.getProperty("DTEND")
             duration = self.getProperty("DURATION")
-            
+
             timeRange = PyCalendarPeriod(
-                start    = dtstart.value(),
-                end      = dtend.value()    if dtend is not None else None,
-                duration = duration.value() if duration is not None else None,
+                start=dtstart.value(),
+                end=dtend.value()    if dtend is not None else None,
+                duration=duration.value() if duration is not None else None,
             )
 
             # Have to fake the TZID value here when we convert date-times to UTC
@@ -2664,12 +2813,13 @@
 #                sortedValue = ";".join(["%s=%s" % (key, value,) for key, value in sorted(indexedTokens.iteritems(), key=lambda x:x[0])])
 #                rrule.setValue(sortedValue)
 
+
     def normalizePropertyValueLists(self, propname):
         """
         Convert properties that have a list of values into single properties, to make it easier
         to do comparisons between two ical objects.
         """
-        
+
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
                 if component.name() in ignoredComponents:
@@ -2680,13 +2830,14 @@
                 if type(prop.value()) is list and len(prop.value()) > 1:
                     self.removeProperty(prop)
                     for value in prop.value():
-                        self.addProperty(Property(propname, [value.getValue(),]))
+                        self.addProperty(Property(propname, [value.getValue(), ]))
 
+
     def normalizeAttachments(self):
         """
         Remove any ATTACH properties that relate to a dropbox.
         """
-        
+
         if self.name() == "VCALENDAR":
             for component in self.subcomponents():
                 if component.name() in ignoredComponents:
@@ -2703,6 +2854,7 @@
                     if dataValue.find(dropboxPrefix) != -1:
                         self.removeProperty(attachment)
 
+
     def normalizeCalendarUserAddresses(self, lookupFunction, principalFunction,
         toUUID=True):
         """
@@ -2817,20 +2969,21 @@
 
 
     def allPerUserUIDs(self):
-        
+
         results = set()
         for component in self.subcomponents():
             if component.name() == "X-CALENDARSERVER-PERUSER":
                 results.add(component.propertyValue("X-CALENDARSERVER-PERUSER-UID"))
         return results
 
+
     def perUserTransparency(self, rid):
-        
+
         # We will create a cache of all user/rid/transparency values as we will likely
         # be calling this a lot
         if not hasattr(self, "_perUserTransparency"):
             self._perUserTransparency = {}
-            
+
             # Do per-user data
             for component in self.subcomponents():
                 if component.name() == "X-CALENDARSERVER-PERUSER":
@@ -2838,24 +2991,24 @@
                     for subcomponent in component.subcomponents():
                         if subcomponent.name() == "X-CALENDARSERVER-PERINSTANCE":
                             instancerid = subcomponent.propertyValue("RECURRENCE-ID")
-                            transp = subcomponent.propertyValue("TRANSP") == "TRANSPARENT"                                
+                            transp = subcomponent.propertyValue("TRANSP") == "TRANSPARENT"
                             self._perUserTransparency.setdefault(uid, {})[instancerid] = transp
                 elif component.name() not in ignoredComponents:
                     instancerid = component.propertyValue("RECURRENCE-ID")
-                    transp = component.propertyValue("TRANSP") == "TRANSPARENT"                    
+                    transp = component.propertyValue("TRANSP") == "TRANSPARENT"
                     self._perUserTransparency.setdefault("", {})[instancerid] = transp
 
         # Now lookup in cache
         results = []
-        for uid, cachedRids in sorted(self._perUserTransparency.items(), key=lambda x:x[0]):
+        for uid, cachedRids in sorted(self._perUserTransparency.items(), key=lambda x: x[0]):
             lookupRid = rid
             if lookupRid not in cachedRids:
                 lookupRid = None
             if lookupRid in cachedRids:
                 results.append((uid, cachedRids[lookupRid],))
             else:
-                results.append((uid, False,))     
-        
+                results.append((uid, False,))
+
         return tuple(results)
 
 
@@ -2884,6 +3037,8 @@
         # Exists completely prior to limit
         return False
 
+
+
 ##
 # Timezones
 ##
@@ -2899,10 +3054,10 @@
     @type start: C{date}
     @param end: date for the end of the expansion.
     @type end: C{date}
-    
+
     @return: a C{list} of tuples of (C{datetime}, C{str})
     """
-    
+
     icalobj = Component.fromString(tzdata)
     tzcomp = None
     for comp in icalobj.subcomponents():
@@ -2913,9 +3068,9 @@
         raise InvalidICalendarDataError("No VTIMEZONE component in %s" % (tzdata,))
 
     tzexpanded = tzcomp._pycalendar.expandAll(start, end)
-    
+
     results = []
-    
+
     # Always need to ensure the start appears in the result
     start.setDateOnly(False)
     if tzexpanded:
@@ -2928,9 +3083,11 @@
             tzstart.getText(),
             PyCalendarUTCOffsetValue(tzoffsetto).getText(),
         ))
-    
+
     return results
 
+
+
 def tzexpandlocal(tzdata, start, end):
     """
     Expand a timezone to get onset(local)/utc-offset-from/utc-offset-to/name observance tuples within the specified
@@ -2942,10 +3099,10 @@
     @type start: C{date}
     @param end: date for the end of the expansion.
     @type end: C{date}
-    
+
     @return: a C{list} of tuples
     """
-    
+
     icalobj = Component(None, pycalendar=tzdata)
     tzcomp = None
     for comp in icalobj.subcomponents():
@@ -2956,9 +3113,9 @@
         raise InvalidICalendarDataError("No VTIMEZONE component in %s" % (tzdata,))
 
     tzexpanded = tzcomp._pycalendar.expandAll(start, end, with_name=True)
-    
+
     results = []
-    
+
     # Always need to ensure the start appears in the result
     start.setDateOnly(False)
     if tzexpanded:
@@ -2983,9 +3140,11 @@
             PyCalendarUTCOffsetValue(tzoffsetto).getText(),
             name,
         ))
-    
+
     return results
 
+
+
 ##
 # Utilities
 ##

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/localization.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/localization.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/localization.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -27,7 +27,7 @@
 
 try:
     from Foundation import (
-        NSPropertyListImmutable, NSPropertyListSerialization, NSData
+        NSPropertyListImmutable, NSPropertyListSerialization, NSData, NSLocale
     )
     foundationImported = True
 except ImportError:
@@ -474,3 +474,25 @@
 
     with open(dest, "wb") as outFile:
         outFile.write(result)
+
+
+def getLanguage(config):
+    """
+    If the language has been specified explicitly in the config, return it.  Otherwise
+    look it up via NSLocale on OS X.  Failing that, return "en"
+
+    @param config: The configuration object to examine
+    @type config: ConfigDict
+    @return: The two-letter language code -- on OS X the supported ones are:
+        de, en, es, fr, it, ja, ko, nl
+    @rtype: C{str}
+    """
+    if config.Localization.Language:
+        return config.Localization.Language
+
+    try:
+        language = NSLocale.preferredLanguages()[0]
+    except:
+        language = "en"
+
+    return language

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/mail.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/mail.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/mail.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -69,7 +69,7 @@
 from twistedcaldav.config import config
 from twistedcaldav.directory.util import transactionFromRequest
 from twistedcaldav.ical import Property
-from twistedcaldav.localization import translationTo, _
+from twistedcaldav.localization import translationTo, getLanguage, _
 from twistedcaldav.resource import CalDAVResource
 from twistedcaldav.schedule import deliverSchedulePrivilegeSet
 from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
@@ -98,9 +98,11 @@
 #
 class IMAPLogger(Logger):
     def emit(self, level, message, *args, **kwargs):
-        if not message.startswith("Unhandled unsolicited response: "):
-            super(Logger, self).emit(level, message, *args, **kwargs)
+        if message.startswith("Unhandled unsolicited response:"):
+            return
 
+        Logger.emit(self, level, message, *args, **kwargs)
+
 imap4.log = IMAPLogger()
 
 #
@@ -552,7 +554,7 @@
         calendar = (yield ical.Component.fromIStream(request.stream))
         originator = request.headers.getRawHeaders("originator")[0]
         recipient = request.headers.getRawHeaders("recipient")[0]
-        language = config.Localization.Language
+        language = getLanguage(config)
 
         if not (yield self.mailer.outbound(originator,
             recipient, calendar, language=language)):

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/mkcol.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/mkcol.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/mkcol.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -36,7 +36,7 @@
 
 from twistedcaldav import caldavxml, carddavxml, mkcolxml
 from twistedcaldav.config import config
-from twistedcaldav.resource import isAddressBookCollectionResource,\
+from twistedcaldav.resource import isAddressBookCollectionResource, \
     CalDAVResource
 from twistedcaldav.resource import isPseudoCalendarCollectionResource
 
@@ -77,7 +77,7 @@
 
     if config.EnableCalDAV:
         parent = (yield self._checkParents(request, isPseudoCalendarCollectionResource))
-    
+
         if parent is not None:
             raise HTTPError(StatusResponse(
                 responsecode.FORBIDDEN,
@@ -86,7 +86,7 @@
 
     if config.EnableCardDAV:
         parent = (yield self._checkParents(request, isAddressBookCollectionResource))
-    
+
         if parent is not None:
             raise HTTPError(StatusResponse(
                 responsecode.FORBIDDEN,
@@ -123,7 +123,7 @@
 
         errors = PropertyStatusResponseQueue("PROPPATCH", request.uri, responsecode.NO_CONTENT)
         got_an_error = False
-    
+
         set_supported_component_set = False
         if mkcol.children:
             # mkcol -> set -> prop -> property*
@@ -143,6 +143,7 @@
                                 rtype = "calendar"
                             elif property.childrenOfType(carddavxml.AddressBook):
                                 rtype = "addressbook"
+
             if not rtype:
                 error = "No {DAV:}resourcetype property in MKCOL request body: %s" % (mkcol,)
                 log.err(error)
@@ -151,14 +152,14 @@
                 error = "{DAV:}resourcetype property in MKCOL request body not supported: %s" % (mkcol,)
                 log.err(error)
                 raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, error))
-                
+
             # Make sure feature is enabled
             if (rtype == "calendar" and not config.EnableCalDAV or
                 rtype == "addressbook" and not config.EnableCardDAV):
                 error = "{DAV:}resourcetype property in MKCOL request body not supported: %s" % (mkcol,)
                 log.err(error)
                 raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, error))
-            
+
             # Now create the special collection
             if rtype == "calendar":
                 yield self.createCalendar(request)
@@ -166,19 +167,19 @@
                 yield self.createAddressBook(request)
 
             # Now handle other properties
-            for property in mkcol.children[0].children[0].children:
+            for property in properties:
                 try:
                     if rtype == "calendar" and property.qname() == (caldavxml.caldav_namespace, "supported-calendar-component-set"):
                         yield self.setSupportedComponentSet(property)
                         set_supported_component_set = True
-                    else:
+                    elif not isinstance(property, davxml.ResourceType):
                         yield self.writeProperty(property, request)
                 except HTTPError:
                     errors.add(Failure(), property)
                     got_an_error = True
                 else:
                     errors.add(responsecode.OK, property)
-    
+
         if got_an_error:
             # Clean up
             self.transactionError()
@@ -187,15 +188,14 @@
                     code=responsecode.FORBIDDEN,
                     stream=mkcolxml.MakeCollectionResponse(errors.response()).toxml()
             ))
-        
+
         # When calendar collections are single component only, default MKCALENDAR is VEVENT only
         if rtype == "calendar" and not set_supported_component_set and config.RestrictCalendarsToOneComponentType:
             yield self.setSupportedComponents(("VEVENT",))
 
         yield returnValue(responsecode.CREATED)
-    
+
     else:
         # No request body so it is a standard MKCOL
         result = yield super(CalDAVResource, self).http_MKCOL(request)
         returnValue(result)
-

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -48,7 +48,7 @@
 from twext.web2 import responsecode, http, http_headers
 from twext.web2.dav.auth import AuthenticationWrapper as SuperAuthenticationWrapper
 from twext.web2.dav.idav import IDAVPrincipalCollectionResource
-from twext.web2.dav.resource import AccessDeniedError, DAVPrincipalCollectionResource,\
+from twext.web2.dav.resource import AccessDeniedError, DAVPrincipalCollectionResource, \
     davPrivilegeSet
 from twext.web2.dav.resource import TwistedACLInheritable
 from twext.web2.dav.util import joinURL, parentForURL, normalizeURL
@@ -59,7 +59,7 @@
 
 from twistedcaldav import caldavxml, customxml
 from twistedcaldav import carddavxml
-from twistedcaldav.cache import PropfindCacheMixin, DisabledCacheNotifier,\
+from twistedcaldav.cache import PropfindCacheMixin, DisabledCacheNotifier, \
     CacheStoreNotifier
 from twistedcaldav.caldavxml import caldav_namespace
 from twistedcaldav.carddavxml import carddav_namespace
@@ -69,7 +69,7 @@
 from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
 from twistedcaldav.datafilters.privateevents import PrivateEventFilter
 from twistedcaldav.directory.internal import InternalDirectoryRecord
-from twistedcaldav.extensions import DAVResource, DAVPrincipalResource,\
+from twistedcaldav.extensions import DAVResource, DAVPrincipalResource, \
     DAVResourceWithChildrenMixin
 from twistedcaldav.ical import Component
 
@@ -113,6 +113,8 @@
             + config.CalDAVComplianceClasses
         )
 
+
+
 class ReadOnlyResourceMixIn (object):
     """
     Read only resource.
@@ -121,13 +123,31 @@
     def writeProperty(self, property, request):
         raise HTTPError(self.readOnlyResponse)
 
-    def http_ACL(self, request):       return responsecode.FORBIDDEN
-    def http_DELETE(self, request):    return responsecode.FORBIDDEN
-    def http_MKCOL(self, request):     return responsecode.FORBIDDEN
-    def http_MOVE(self, request):      return responsecode.FORBIDDEN
-    def http_PROPPATCH(self, request): return responsecode.FORBIDDEN
-    def http_PUT(self, request):       return responsecode.FORBIDDEN
 
+    def http_ACL(self, request):
+        return responsecode.FORBIDDEN
+
+
+    def http_DELETE(self, request):
+        return responsecode.FORBIDDEN
+
+
+    def http_MKCOL(self, request):
+        return responsecode.FORBIDDEN
+
+
+    def http_MOVE(self, request):
+        return responsecode.FORBIDDEN
+
+
+    def http_PROPPATCH(self, request):
+        return responsecode.FORBIDDEN
+
+
+    def http_PUT(self, request):
+        return responsecode.FORBIDDEN
+
+
     def http_MKCALENDAR(self, request):
         return ErrorResponse(
             responsecode.FORBIDDEN,
@@ -135,14 +155,19 @@
             "Resource is read-only",
         )
 
+
+
 class ReadOnlyNoCopyResourceMixIn (ReadOnlyResourceMixIn):
     """
     Read only resource that disallows COPY.
     """
 
-    def http_COPY(self, request): return responsecode.FORBIDDEN
+    def http_COPY(self, request):
+        return responsecode.FORBIDDEN
 
-def _calendarPrivilegeSet ():
+
+
+def _calendarPrivilegeSet():
     edited = False
 
     top_supported_privileges = []
@@ -197,6 +222,7 @@
     return fun
 
 
+
 class CalDAVResource (
         CalDAVComplianceMixIn, SharedCollectionMixin,
         DAVResourceWithChildrenMixin, DAVResource, LoggingMixIn
@@ -244,7 +270,7 @@
             # Render a monolithic iCalendar file
             if request.path[-1] != "/":
                 # Redirect to include trailing '/' in URI
-                return RedirectResponse(request.unparseURL(path=urllib.quote(urllib.unquote(request.path), safe=':/')+'/'))
+                return RedirectResponse(request.unparseURL(path=urllib.quote(urllib.unquote(request.path), safe=':/') + '/'))
 
             def _defer(data):
                 response = Response()
@@ -258,7 +284,6 @@
 
         return super(CalDAVResource, self).render(request)
 
-
     _associatedTransaction = None
     _transactionError = False
 
@@ -271,7 +296,7 @@
         @param transaction: the transaction to associate this resource and its
             children with.
 
-        @type transaction: L{txdav.caldav.idav.ITransaction} 
+        @type transaction: L{txdav.caldav.idav.ITransaction}
         """
         # FIXME: needs to reject association with transaction if it's already
         # got one (resources associated with a transaction are not reusable)
@@ -339,8 +364,8 @@
         """
         raise NotImplementedError("%s does not implement newStoreProperties" %
                                   (self,))
-        
-    
+
+
     def storeRemove(self, *a, **kw):
         """
         Remove this resource from storage.
@@ -355,36 +380,40 @@
 
         @param stream: The stream containing the data to be stored.
         @type stream: L{IStream}
-        
+
         @return: a L{Deferred} which fires with an HTTP response.
         @rtype: L{Deferred}
         """
-        raise NotImplementedError("%s does not implement storeStream"  %
+        raise NotImplementedError("%s does not implement storeStream" %
                                   (self,))
 
-    # End transitional new-store interface 
+    # End transitional new-store interface
 
+
     @updateCacheTokenOnCallback
     def http_PROPPATCH(self, request):
         return super(CalDAVResource, self).http_PROPPATCH(request)
 
+
     @updateCacheTokenOnCallback
     def http_DELETE(self, request):
         return super(CalDAVResource, self).http_DELETE(request)
 
+
     @updateCacheTokenOnCallback
     def http_ACL(self, request):
         return super(CalDAVResource, self).http_ACL(request)
 
+
     ##
     # WebDAV
     ##
 
     def liveProperties(self):
         baseProperties = (
-            element.Owner.qname(),               # Private Events needs this but it is also OK to return empty
+            element.Owner.qname(), # Private Events needs this but it is also OK to return empty
         )
-        
+
         if self.isPseudoCalendarCollection():
             baseProperties += (
                 caldavxml.SupportedCalendarComponentSet.qname(),
@@ -407,7 +436,7 @@
         if self.isCalendarCollection():
             baseProperties += (
                 element.ResourceID.qname(),
-                
+
                 # These are "live" properties in the sense of WebDAV, however "live" for twext actually means
                 # ones that are also always present, but the default alarm properties are allowed to be absent
                 # and are in fact stored in the property store.
@@ -440,13 +469,13 @@
             baseProperties += (
                 caldavxml.ScheduleTag.qname(),
             )
-            
+
         if config.EnableSyncReport and (element.Report(element.SyncCollection(),) in self.supportedReports()):
             baseProperties += (element.SyncToken.qname(),)
-            
+
         if config.EnableAddMember and (self.isCalendarCollection() or self.isAddressBookCollection()):
             baseProperties += (element.AddMember.qname(),)
-            
+
         if config.Sharing.Enabled:
             if config.Sharing.Calendars.Enabled and self.isCalendarCollection():
                 baseProperties += (
@@ -460,9 +489,10 @@
                     customxml.Invite.qname(),
                     customxml.AllowedSharingModes.qname(),
                 )
-                
+
         return super(CalDAVResource, self).liveProperties() + baseProperties
 
+
     def isShadowableProperty(self, qname):
         """
         Shadowable properties are ones on shared resources where a "default" exists until
@@ -474,6 +504,7 @@
             carddavxml.AddressBookDescription.qname(),
         )
 
+
     def isGlobalProperty(self, qname):
         """
         A global property is one that is the same for all users.
@@ -488,6 +519,7 @@
         else:
             return False
 
+
     @inlineCallbacks
     def hasProperty(self, property, request):
         """
@@ -514,7 +546,7 @@
         """
         Need to special case schedule-calendar-transp for backwards compatability.
         """
-        
+
         if type(property) is tuple:
             qname = property
         else:
@@ -523,10 +555,11 @@
         # Force calendar collections to always appear to have the property
         if qname == caldavxml.ScheduleCalendarTransp.qname() and self.isCalendarCollection():
             return succeed(True)
-        
+
         else:
             return super(CalDAVResource, self).hasProperty(property, request)
 
+
     @inlineCallbacks
     def readProperty(self, property, request):
         if type(property) is tuple:
@@ -552,7 +585,7 @@
                         returnValue(propVal)
 
                 returnValue(customxml.PubSubXMPPPushKeyProperty())
-        
+
         res = (yield self._readGlobalProperty(qname, property, request))
         returnValue(res)
 
@@ -661,7 +694,7 @@
 
         elif qname == customxml.Invite.qname():
             if config.Sharing.Enabled and (
-                config.Sharing.Calendars.Enabled and self.isCalendarCollection() or 
+                config.Sharing.Calendars.Enabled and self.isCalendarCollection() or
                 config.Sharing.AddressBooks.Enabled and self.isAddressBookCollection()
             ):
                 result = (yield self.inviteProperty(request))
@@ -675,7 +708,7 @@
 
         elif qname == customxml.SharedURL.qname():
             isShareeCollection = self.isShareeCollection()
-            
+
             if isShareeCollection:
                 returnValue(customxml.SharedURL(element.HRef.fromString(self._share.url())))
             else:
@@ -684,15 +717,17 @@
         result = (yield super(CalDAVResource, self).readProperty(property, request))
         returnValue(result)
 
+
     @inlineCallbacks
     def writeProperty(self, property, request):
         assert isinstance(property, element.WebDAVElement), (
             "%r is not a WebDAVElement instance" % (property,)
         )
- 
+
         res = (yield self._writeGlobalProperty(property, request))
         returnValue(res)
 
+
     @inlineCallbacks
     def _preProcessWriteProperty(self, property, request, isShare=False):
         if property.qname() == caldavxml.SupportedCalendarComponentSet.qname():
@@ -737,7 +772,7 @@
                     responsecode.FORBIDDEN,
                     "Property %s may only be set on calendar or home collection." % (property,)
                 ))
-                
+
             if not property.valid():
                 raise HTTPError(ErrorResponse(
                     responsecode.CONFLICT,
@@ -754,7 +789,7 @@
 
             # For backwards compatibility we need to sync this up with the calendar-free-busy-set on the inbox
             principal = (yield self.resourceOwnerPrincipal(request))
-            
+
             # Map owner to their inbox
             inboxURL = principal.scheduleInboxURL()
             if inboxURL:
@@ -762,62 +797,15 @@
                 myurl = (yield self.canonicalURL(request))
                 inbox.processFreeBusyCalendar(myurl, property.children[0] == caldavxml.Opaque())
 
+
     @inlineCallbacks
     def _writeGlobalProperty(self, property, request):
 
         yield self._preProcessWriteProperty(property, request)
-
-        if property.qname() == element.ResourceType.qname():
-            if self.isCalendarCollection() or self.isAddressBookCollection():
-                sawShare = [child for child in property.children if child.qname() == (calendarserver_namespace, "shared-owner")]
-                if sawShare:
-                    if self.isCalendarCollection() and not (config.Sharing.Enabled and config.Sharing.Calendars.Enabled):
-                        raise HTTPError(StatusResponse(
-                            responsecode.FORBIDDEN,
-                            "Cannot create shared calendars on this server.",
-                        ))
-                    elif self.isAddressBookCollection() and not (config.Sharing.Enabled and config.Sharing.AddressBooks.Enabled):
-                        raise HTTPError(StatusResponse(
-                            responsecode.FORBIDDEN,
-                            "Cannot create shared address books on this server.",
-                        ))
-
-                # Check if adding or removing share
-                shared = (yield self.isShared(request))
-                for child in property.children:
-                    if child.qname() == element.Collection.qname():
-                        break
-                else:
-                    raise HTTPError(StatusResponse(
-                        responsecode.FORBIDDEN,
-                        "Protected property %s may not be set." % (property.sname(),)
-                    ))
-                for child in property.children:
-                    if self.isCalendarCollection and child.qname() == caldavxml.Calendar.qname() or \
-                       self.isAddressBookCollection and child.qname() == carddavxml.AddressBook.qname():
-                        break
-                else:
-                    raise HTTPError(StatusResponse(
-                        responsecode.FORBIDDEN,
-                        "Protected property %s may not be set." % (property.sname(),)
-                    ))
-                sawShare = [child for child in property.children if child.qname() == (calendarserver_namespace, "shared-owner")]
-                if not shared and sawShare:
-                    # Owner is trying to share a collection
-                    self.upgradeToShare()
-                elif shared and not sawShare:
-                    # Remove share
-                    yield self.downgradeFromShare(request)
-                returnValue(None)
-            else:
-                # resourcetype cannot be changed but we will allow it to be set to the same value
-                currentType = self.resourceType()
-                if currentType == property:
-                    returnValue(None)
-
         result = (yield super(CalDAVResource, self).writeProperty(property, request))
         returnValue(result)
 
+
     ##
     # ACL
     ##
@@ -829,6 +817,7 @@
         """
         return ""
 
+
     def _set_accessMode(self, value):
         raise NotImplementedError
 
@@ -886,9 +875,10 @@
                 newacls.extend(acls.children)
 
                 acls = element.ACL(*newacls)
- 
+
         returnValue(acls)
 
+
     @inlineCallbacks
     def owner(self, request):
         """
@@ -906,6 +896,7 @@
         else:
             returnValue(None)
 
+
     @inlineCallbacks
     def ownerPrincipal(self, request):
         """
@@ -961,7 +952,7 @@
     def displayName(self):
         if self.isAddressBookCollection() and not self.hasDeadProperty((dav_namespace, "displayname")):
             return None
-        
+
         if 'record' in dir(self):
             if self.record.fullName:
                 return self.record.fullName
@@ -975,15 +966,18 @@
                 result = self.name()
             return result
 
+
     def name(self):
         return None
 
+
     def resourceID(self):
         if not self.hasDeadProperty(element.ResourceID.qname()):
             uuidval = uuid.uuid4()
             self.writeDeadProperty(element.ResourceID(element.HRef.fromString(uuidval.urn)))
         return str(self.readDeadProperty(element.ResourceID.qname()).children[0])
 
+
     ##
     # CalDAV
     ##
@@ -994,21 +988,25 @@
         """
         return self.isSpecialCollection(caldavxml.Calendar)
 
+
     def isAddressBookCollection(self):
         """
         See L{ICalDAVResource.isAddressBookCollection}.
         """
         return self.isSpecialCollection(carddavxml.AddressBook)
 
+
     def isNotificationCollection(self):
         """
         See L{ICalDAVResource.isNotificationCollection}.
         """
         return self.isSpecialCollection(customxml.Notification)
 
+
     def isDirectoryBackedAddressBookCollection(self):       # ATM - temporary fix? (this one worked)
         return False
 
+
     def isSpecialCollection(self, collectiontype):
         """
         See L{ICalDAVResource.isSpecialCollection}.
@@ -1024,18 +1022,22 @@
             return False
         return bool(resourcetype.childrenOfType(collectiontype))
 
+
     def isPseudoCalendarCollection(self):
         """
         See L{ICalDAVResource.isPseudoCalendarCollection}.
         """
         return self.isCalendarCollection()
 
+
     def findCalendarCollections(self, depth, request, callback, privileges=None):
         return self.findSpecialCollections(caldavxml.Calendar, depth, request, callback, privileges)
 
+
     def findAddressBookCollections(self, depth, request, callback, privileges=None):
         return self.findSpecialCollections(carddavxml.AddressBook, depth, request, callback, privileges)
 
+
     @inlineCallbacks
     def findSpecialCollectionsFaster(self, type, depth, request, callback, privileges=None):
         assert depth in ("0", "1", "infinity"), "Invalid depth: %s" % (depth,)
@@ -1053,13 +1055,13 @@
                             continue
                     if child.isSpecialCollection(type):
                         callback(child, childpath)
-                        
+
                     # No more regular collections. If we leave this in then dropbox is scanned at depth:infinity
                     # and that is very painful as it requires scanning all calendar resources too. Eventually we need
                     # to fix drop box and probably re-enable this for the generic case.
     #                elif child.isCollection():
     #                    if depth == "infinity":
-    #                        yield child.findSpecialCollectionsFaster(type, depth, request, callback, privileges)                
+    #                        yield child.findSpecialCollectionsFaster(type, depth, request, callback, privileges)
 
     findSpecialCollections = findSpecialCollectionsFaster
 
@@ -1071,7 +1073,7 @@
         @param request:
         @type request:
         """
-        
+
         # For backwards compatibility we need to sync this up with the calendar-free-busy-set on the inbox
         principal = (yield self.resourceOwnerPrincipal(request))
         inboxURL = principal.scheduleInboxURL()
@@ -1079,12 +1081,13 @@
             inbox = (yield request.locateResource(inboxURL))
             inbox.processFreeBusyCalendar(request.path, False)
 
+
     @inlineCallbacks
     def movedCalendar(self, request, defaultCalendarType, destination, destination_uri):
         """
         Calendar has been moved. Need to do some extra clean-up.
         """
-        
+
         # For backwards compatibility we need to sync this up with the calendar-free-busy-set on the inbox
         principal = (yield self.resourceOwnerPrincipal(request))
         inboxURL = principal.scheduleInboxURL()
@@ -1094,26 +1097,28 @@
             inbox = (yield request.locateResource(inboxURL))
             inbox.processFreeBusyCalendar(request.path, False)
             inbox.processFreeBusyCalendar(destination_uri, destination.isCalendarOpaque())
-            
+
             # Adjust the default calendar setting if necessary
             if defaultCalendarType is not None:
-                yield inbox.writeProperty(defaultCalendarType(element.HRef(destination_path)), request)               
+                yield inbox.writeProperty(defaultCalendarType(element.HRef(destination_path)), request)
 
+
     def isCalendarOpaque(self):
-        
+
         assert self.isCalendarCollection()
-        
+
         if self.hasDeadProperty((caldav_namespace, "schedule-calendar-transp")):
             property = self.readDeadProperty((caldav_namespace, "schedule-calendar-transp"))
             return property.children[0] == caldavxml.Opaque()
         else:
             return False
 
+
     @inlineCallbacks
     def isDefaultCalendar(self, request):
-        
+
         assert self.isCalendarCollection()
-        
+
         # Not allowed to delete the default calendar
         principal = (yield self.resourceOwnerPrincipal(request))
         inboxURL = principal.scheduleInboxURL()
@@ -1124,6 +1129,7 @@
 
         returnValue(None)
 
+
     @inlineCallbacks
     def iCalendarForUser(self, request):
 
@@ -1157,6 +1163,7 @@
                 return principal
         return None
 
+
     def principalForUID(self, principalUID):
         for principalCollection in self.principalCollections():
             principal = principalCollection.principalForUID(principalUID)
@@ -1170,19 +1177,20 @@
         """
         AddressBook has been moved. Need to do some extra clean-up.
         """
-        
+
         # Adjust the default addressbook setting if necessary
         if defaultAddressBook:
             principal = (yield self.resourceOwnerPrincipal(request))
             home = (yield principal.addressBookHome(request))
             (_ignore_scheme, _ignore_host, destination_path, _ignore_query, _ignore_fragment) = urlsplit(normalizeURL(destination_uri))
-            yield home.writeProperty(carddavxml.DefaultAddressBookURL(element.HRef(destination_path)), request)               
+            yield home.writeProperty(carddavxml.DefaultAddressBookURL(element.HRef(destination_path)), request)
 
+
     @inlineCallbacks
     def isDefaultAddressBook(self, request):
-        
+
         assert self.isAddressBookCollection()
-        
+
         # Not allowed to delete the default address book
         principal = (yield self.resourceOwnerPrincipal(request))
         home = (yield principal.addressBookHome(request))
@@ -1194,6 +1202,7 @@
 
         returnValue(False)
 
+
     @inlineCallbacks
     def vCard(self):
         """
@@ -1239,6 +1248,7 @@
             result.append(element.Report(element.SyncCollection(),))
         return result
 
+
     def writeNewACEs(self, newaces):
         """
         Write a new ACL to the resource's property store. We override this for calendar collections
@@ -1266,6 +1276,7 @@
         # Do inherited with possibly modified set of aces
         super(CalDAVResource, self).writeNewACEs(edited_aces)
 
+
     ##
     # Utilities
     ##
@@ -1278,15 +1289,16 @@
         """
         return request.locateResource(parentForURL(uri))
 
+
     @inlineCallbacks
     def canonicalURL(self, request):
-        
+
         if not hasattr(self, "_canonical_url"):
-    
+
             myurl = request.urlForResource(self)
             _ignore_scheme, _ignore_host, path, _ignore_query, _ignore_fragment = urlsplit(normalizeURL(myurl))
             lastpath = path.split("/")[-1]
-            
+
             parent = (yield request.locateResource(parentForURL(myurl)))
             if parent and isinstance(parent, CalDAVResource):
                 canonical_parent = (yield parent.canonicalURL(request))
@@ -1296,6 +1308,7 @@
 
         returnValue(self._canonical_url)
 
+
     ##
     # Quota
     ##
@@ -1305,18 +1318,20 @@
         Quota root only ever set on calendar homes.
         """
         return False
-    
+
+
     def quotaRoot(self, request):
         """
         Quota root only ever set on calendar homes.
         """
-        return None 
+        return None
 
+
     @inlineCallbacks
     def quotaRootResource(self, request):
         """
         Return the quota root for this resource.
-        
+
         @return: L{DAVResource} or C{None}
         """
 
@@ -1340,9 +1355,9 @@
 
         returnValue(result)
 
+
     # Collection sync stuff
 
-
     @inlineCallbacks
     def whatchanged(self, client_token, depth):
         current_token = (yield self.getSyncToken())
@@ -1355,7 +1370,7 @@
                     raise ValueError
                 caluuid, revision = client_token[6:].split("_", 1)
                 revision = int(revision)
-                
+
                 # Check client token validity
                 if caluuid != current_uuid:
                     raise ValueError
@@ -1381,25 +1396,29 @@
 
         returnValue((changed, removed, notallowed, current_token))
 
+
     def _indexWhatChanged(self, revision, depth):
         # Now handled directly by newstore
         raise NotImplementedError
 
+
     @inlineCallbacks
     def getSyncToken(self):
         """
         Return current sync-token value.
         """
-        
+
         internal_token = (yield self.getInternalSyncToken())
         returnValue("data:,%s" % (internal_token,))
 
+
     def getInternalSyncToken(self):
         """
         Return current internal sync-token value.
         """
         raise HTTPError(StatusResponse(responsecode.NOT_FOUND, "Property not supported"))
 
+
     #
     # Stuff from CalDAVFile
     #
@@ -1410,18 +1429,18 @@
         We override the base class to handle the special implicit scheduling weak ETag behavior
         for compatibility with old clients using If-Match.
         """
-        
+
         if config.Scheduling.CalDAV.ScheduleTagCompatibility:
-            
+
             if self.exists() and hasattr(self, "scheduleEtags"):
                 etags = self.scheduleEtags
                 if len(etags) > 1:
                     # This is almost verbatim from twext.web2.static.checkPreconditions
                     if request.method not in ("GET", "HEAD"):
-                        
+
                         # Always test against the current etag first just in case schedule-etags is out of sync
                         etag = (yield self.etag())
-                        etags = (etag, ) + tuple([http_headers.ETag(etag) for etag in etags])
+                        etags = (etag,) + tuple([http_headers.ETag(etag) for etag in etags])
 
                         # Loop over each tag and succeed if any one matches, else re-raise last exception
                         exists = self.exists()
@@ -1431,9 +1450,9 @@
                             try:
                                 http.checkPreconditions(
                                     request,
-                                    entityExists = exists,
-                                    etag = etag,
-                                    lastModified = last_modified,
+                                    entityExists=exists,
+                                    etag=etag,
+                                    lastModified=last_modified,
                                 )
                             except HTTPError, e:
                                 last_exception = e
@@ -1442,7 +1461,7 @@
                         else:
                             if last_exception:
                                 raise last_exception
-            
+
                     # Check per-method preconditions
                     method = getattr(self, "preconditions_" + request.method, None)
                     if method:
@@ -1453,6 +1472,7 @@
         result = (yield super(CalDAVResource, self).checkPreconditions(request))
         returnValue(result)
 
+
     @inlineCallbacks
     def createCalendar(self, request):
         """
@@ -1501,7 +1521,7 @@
                     customxml.MaxCollections(),
                     "Too many calendar collections",
                 ))
-                
+
         returnValue((yield self.createCalendarCollection()))
 
 
@@ -1519,9 +1539,7 @@
         """
         Only implemented by calendar collections; see storebridge.
         """
-        
 
-
     @inlineCallbacks
     def iCalendarFiltered(self, isowner, accessUID=None):
 
@@ -1596,9 +1614,10 @@
                     customxml.MaxCollections(),
                     "Too many address book collections",
                 ))
-                
+
         returnValue((yield self.createAddressBookCollection()))
 
+
     def createAddressBookCollection(self):
         """
         Internal API for creating an addressbook collection.
@@ -1608,9 +1627,10 @@
         """
         return fail(NotImplementedError())
 
+
     @inlineCallbacks
     def vCardRolledup(self, request):
-        # TODO: just catenate all the vCards together 
+        # TODO: just catenate all the vCards together
         yield fail(HTTPError((ErrorResponse(responsecode.BAD_REQUEST))))
 
 
@@ -1647,6 +1667,7 @@
 
         return super(CalDAVResource, self).supportedPrivileges(request)
 
+
     ##
     # Quota
     ##
@@ -1693,6 +1714,7 @@
 #            return succeed(self.fp.getsize())
         return succeed(0)
 
+
     ##
     # Utilities
     ##
@@ -1707,7 +1729,8 @@
         @return: True if the supplied URI is a child resource
                  False if not
         """
-        if uri is None: return False
+        if uri is None:
+            return False
 
         #
         # Parse the URI
@@ -1726,6 +1749,7 @@
 
         return path.startswith(parent) and (len(path) > len(parent)) and (not immediateChild or (path.find("/", len(parent)) == -1))
 
+
     @inlineCallbacks
     def _checkParents(self, request, test):
         """
@@ -1740,13 +1764,16 @@
 
         while True:
             parent_uri = parentForURL(parent_uri)
-            if not parent_uri: break
+            if not parent_uri:
+                break
 
             parent = yield request.locateResource(parent_uri)
 
             if test(parent):
                 returnValue(parent)
 
+
+
 class CalendarPrincipalCollectionResource (DAVPrincipalCollectionResource, CalDAVResource):
     """
     CalDAV principal collection.
@@ -1756,18 +1783,23 @@
     def isCollection(self):
         return True
 
+
     def isCalendarCollection(self):
         return False
 
+
     def isAddressBookCollection(self):
         return False
 
+
     def isDirectoryBackedAddressBookCollection(self):
         return False
 
+
     def principalForCalendarUserAddress(self, address):
         return None
 
+
     def supportedReports(self):
         """
         Principal collections are the only resources supporting the
@@ -1777,6 +1809,7 @@
         result.append(element.Report(element.PrincipalSearchPropertySet(),))
         return result
 
+
     def principalSearchPropertySet(self):
         return element.PrincipalSearchPropertySet(
             element.PrincipalSearchProperty(
@@ -1785,7 +1818,7 @@
                 ),
                 element.Description(
                     element.PCDATAElement("Display Name"),
-                    **{"xml:lang":"en"}
+                    **{"xml:lang": "en"}
                 ),
             ),
             element.PrincipalSearchProperty(
@@ -1794,11 +1827,13 @@
                 ),
                 element.Description(
                     element.PCDATAElement("Calendar User Addresses"),
-                    **{"xml:lang":"en"}
+                    **{"xml:lang": "en"}
                 ),
             ),
         )
 
+
+
 class CalendarPrincipalResource (CalDAVComplianceMixIn, DAVResourceWithChildrenMixin, DAVPrincipalResource):
     """
     CalDAV principal resource.
@@ -1808,22 +1843,22 @@
     implements(ICalendarPrincipalResource)
 
     def liveProperties(self):
-        
+
         baseProperties = ()
-        
+
         if self.calendarsEnabled():
             baseProperties += (
-                (caldav_namespace, "calendar-home-set"        ),
+                (caldav_namespace, "calendar-home-set"),
                 (caldav_namespace, "calendar-user-address-set"),
-                (caldav_namespace, "schedule-inbox-URL"       ),
-                (caldav_namespace, "schedule-outbox-URL"      ),
-                (caldav_namespace, "calendar-user-type"       ),
-                (calendarserver_namespace, "calendar-proxy-read-for"  ),
-                (calendarserver_namespace, "calendar-proxy-write-for" ),
-                (calendarserver_namespace, "auto-schedule" ),
-                (calendarserver_namespace, "auto-schedule-mode" ),
+                (caldav_namespace, "schedule-inbox-URL"),
+                (caldav_namespace, "schedule-outbox-URL"),
+                (caldav_namespace, "calendar-user-type"),
+                (calendarserver_namespace, "calendar-proxy-read-for"),
+                (calendarserver_namespace, "calendar-proxy-write-for"),
+                (calendarserver_namespace, "auto-schedule"),
+                (calendarserver_namespace, "auto-schedule-mode"),
             )
-        
+
         if self.addressBooksEnabled():
             baseProperties += (carddavxml.AddressBookHomeSet.qname(),)
             if self.directoryAddressBookEnabled():
@@ -1837,18 +1872,23 @@
 
         return super(CalendarPrincipalResource, self).liveProperties() + baseProperties
 
+
     def isCollection(self):
         return True
 
+
     def calendarsEnabled(self):
         return config.EnableCalDAV
 
+
     def addressBooksEnabled(self):
         return config.EnableCardDAV
 
+
     def directoryAddressBookEnabled(self):
         return config.DirectoryAddressBook.Enabled and config.EnableSearchAddressBook
 
+
     @inlineCallbacks
     def readProperty(self, property, request):
         if type(property) is tuple:
@@ -1934,6 +1974,7 @@
         result = (yield super(CalendarPrincipalResource, self).readProperty(property, request))
         returnValue(result)
 
+
     def calendarFreeBusyURIs(self, request):
         def gotInbox(inbox):
             if inbox is None:
@@ -1958,12 +1999,14 @@
         d.addCallback(gotInbox)
         return d
 
+
     def scheduleInbox(self, request):
         """
         @return: the deferred schedule inbox for this principal.
         """
         return request.locateResource(self.scheduleInboxURL())
 
+
     ##
     # Quota
     ##
@@ -1973,30 +2016,33 @@
         Quota root only ever set on calendar homes.
         """
         return False
-    
+
+
     def quotaRoot(self, request):
         """
         Quota root only ever set on calendar homes.
         """
         return None
 
+
+
 class DefaultAlarmPropertyMixin(object):
     """
     A mixin for use with calendar home and calendars to allow direct access to
     the default alarm properties in a more useful way that using readProperty.
     In particular it will handle inheritance of the property from the home if a
-    calendar does not explicitly have the property. 
+    calendar does not explicitly have the property.
     """
-    
+
     def getDefaultAlarm(self, vevent, timed):
-        
+
         if vevent:
             propname = caldavxml.DefaultAlarmVEventDateTime if timed else caldavxml.DefaultAlarmVEventDate
         else:
             propname = caldavxml.DefaultAlarmVToDoDateTime if timed else caldavxml.DefaultAlarmVToDoDate
-        
+
         if self.isCalendarCollection():
-            
+
             # Get from calendar or inherit from home
             try:
                 prop = self.deadProperties().get(propname.qname())
@@ -2013,6 +2059,8 @@
 
         return str(prop) if prop is not None else None
 
+
+
 class CommonHomeResource(PropfindCacheMixin, SharedHomeMixin, CalDAVResource):
     """
     Logic common to Calendar and Addressbook home resources.
@@ -2064,16 +2112,18 @@
     def _setupProvisions(self):
         pass
 
+
     def postCreateHome(self):
         pass
 
+
     def liveProperties(self):
 
         props = super(CommonHomeResource, self).liveProperties() + (
             (customxml.calendarserver_namespace, "push-transports"),
             (customxml.calendarserver_namespace, "pushkey"),
         )
-        
+
         if config.MaxCollectionsPerHome:
             props += (customxml.MaxCollections.qname(),)
 
@@ -2082,13 +2132,16 @@
     def url(self):
         return joinURL(self.parent.url(), self.name, "/")
 
+
     def canonicalURL(self, request):
         return succeed(self.url())
 
+
     def exists(self):
         # FIXME: tests
         return True
 
+
     def isCollection(self):
         return True
 
@@ -2121,9 +2174,10 @@
     def currentQuotaUse(self, request):
         """
         Get the quota use value
-        """  
+        """
         return maybeDeferred(self._newStoreHome.quotaUsedBytes)
 
+
     def supportedReports(self):
         result = super(CommonHomeResource, self).supportedReports()
         if config.EnableSyncReport and config.EnableSyncReportHome:
@@ -2131,6 +2185,7 @@
             result.append(element.Report(element.SyncCollection(),))
         return result
 
+
     def _mergeSyncTokens(self, hometoken, notificationtoken):
         """
         Merge two sync tokens, choosing the higher revision number of the two,
@@ -2142,6 +2197,7 @@
             hometoken = "%s_%s" % (homekey, notrev,)
         return hometoken
 
+
     def canShare(self):
         raise NotImplementedError
 
@@ -2154,16 +2210,17 @@
         """
         Override to pre-load children in certain collection types for better performance.
         """
-        
+
         if depth == "1":
             yield self._newStoreHome.loadChildren()
-        
+
         result = (yield super(CommonHomeResource, self).findChildrenFaster(
             depth, request, okcallback, badcallback, missingcallback, names, privileges, inherited_aces
         ))
-        
+
         returnValue(result)
-    
+
+
     @inlineCallbacks
     def makeChild(self, name):
         # Try built-in children first
@@ -2185,7 +2242,7 @@
 
         # get regular or shared child
         child = (yield self.makeRegularChild(name))
-        
+
         # add _share attribute if child is shared
         yield self.provisionShare(child)
 
@@ -2202,7 +2259,7 @@
             notifications,
             self,
             self._newStoreHome,
-            principalCollections = self.principalCollections(),
+            principalCollections=self.principalCollections(),
         )
         self.propagateTransaction(similar)
         returnValue(similar)
@@ -2348,6 +2405,7 @@
 
         returnValue((yield super(CommonHomeResource, self).readProperty(property, request)))
 
+
     ##
     # ACL
     ##
@@ -2355,12 +2413,15 @@
     def owner(self, request):
         return succeed(element.HRef(self.principalForRecord().principalURL()))
 
+
     def ownerPrincipal(self, request):
         return succeed(self.principalForRecord())
 
+
     def resourceOwnerPrincipal(self, request):
         return succeed(self.principalForRecord())
 
+
     def defaultAccessControlList(self):
         myPrincipal = self.principalForRecord()
 
@@ -2388,19 +2449,23 @@
 
         # Give all access to config.AdminPrincipals
         aces += config.AdminACEs
-        
+
         return element.ACL(*aces)
 
+
     def accessControlList(self, request, inheritance=True, expanding=False, inherited_aces=None):
         # Permissions here are fixed, and are not subject to inheritance rules, etc.
         return succeed(self.defaultAccessControlList())
 
+
     def principalCollections(self):
         return self.parent.principalCollections()
 
+
     def principalForRecord(self):
         raise NotImplementedError("Subclass must implement principalForRecord()")
 
+
     @inlineCallbacks
     def etag(self):
         """
@@ -2415,15 +2480,19 @@
         else:
             returnValue(None)
 
+
     def lastModified(self):
         return self._newStoreHome.modified() if self._newStoreHome else None
 
+
     def creationDate(self):
         return self._newStoreHome.created() if self._newStoreHome else None
 
+
     def notifierID(self, label="default"):
         self._newStoreHome.notifierID(label)
 
+
     def notifyChanged(self):
         return self._newStoreHome.notifyChanged()
 
@@ -2433,6 +2502,7 @@
     http_MOVE = None
 
 
+
 class CalendarHomeResource(DefaultAlarmPropertyMixin, CommonHomeResource):
     """
     Calendar home collection classmethod.
@@ -2451,11 +2521,11 @@
 
 
     def liveProperties(self):
-        
+
         existing = super(CalendarHomeResource, self).liveProperties()
         existing += (
             caldavxml.SupportedCalendarComponentSets.qname(),
-                
+
             # These are "live" properties in the sense of WebDAV, however "live" for twext actually means
             # ones that are also always present, but the default alarm properties are allowed to be absent
             # and are in fact stored in the property store.
@@ -2472,6 +2542,7 @@
         )
         return existing
 
+
     @inlineCallbacks
     def readProperty(self, property, request):
         if type(property) is tuple:
@@ -2496,10 +2567,11 @@
             else:
                 prop = caldavxml.SupportedCalendarComponentSets()
             returnValue(prop)
-            
+
         result = (yield super(CalendarHomeResource, self).readProperty(property, request))
         returnValue(result)
 
+
     def _setupProvisions(self):
 
         # Cache children which must be of a specific type
@@ -2554,19 +2626,21 @@
     def hasCalendarResourceUIDSomewhereElse(self, uid, ok_object, type):
         """
         Test if there are other child object resources with the specified UID.
-        
+
         Pass through direct to store.
         """
         return self._newStoreHome.hasCalendarResourceUIDSomewhereElse(uid, ok_object._newStoreObject, type)
 
+
     def getCalendarResourcesForUID(self, uid, allow_shared=False):
         """
         Return all child object resources with the specified UID.
-        
+
         Pass through direct to store.
         """
         return self._newStoreHome.getCalendarResourcesForUID(uid, allow_shared)
 
+
     def defaultAccessControlList(self):
         myPrincipal = self.principalForRecord()
 
@@ -2600,7 +2674,7 @@
 
         # Give all access to config.AdminPrincipals
         aces += config.AdminACEs
-        
+
         if config.EnableProxyPrincipals:
             # Server may be read only
             if config.EnableReadOnlyServer:
@@ -2685,6 +2759,7 @@
         returnValue((changed, deleted, notallowed))
 
 
+
 class AddressBookHomeResource (CommonHomeResource):
     """
     Address book home collection resource.
@@ -2703,11 +2778,12 @@
 
 
     def liveProperties(self):
-        
+
         return super(AddressBookHomeResource, self).liveProperties() + (
             carddavxml.DefaultAddressBookURL.qname(),
         )
 
+
     @inlineCallbacks
     def readProperty(self, property, request):
         if type(property) is tuple:
@@ -2725,15 +2801,16 @@
                 defaultAddressBook = str(defaultAddressBookProperty.children[0])
                 adbk = (yield request.locateResource(str(defaultAddressBook)))
                 if adbk is not None and isAddressBookCollectionResource(adbk) and adbk.exists() and not adbk.isShareeCollection():
-                    returnValue(defaultAddressBookProperty) 
-            
+                    returnValue(defaultAddressBookProperty)
+
             # Default is not valid - we have to try to pick one
             defaultAddressBookProperty = (yield self.pickNewDefaultAddressBook(request))
             returnValue(defaultAddressBookProperty)
-            
+
         result = (yield super(AddressBookHomeResource, self).readProperty(property, request))
         returnValue(result)
 
+
     @inlineCallbacks
     def writeProperty(self, property, request):
         assert isinstance(property, element.WebDAVElement)
@@ -2762,6 +2839,7 @@
 
         yield super(AddressBookHomeResource, self).writeProperty(property, request)
 
+
     def _setupProvisions(self):
 
         # Cache children which must be of a specific type
@@ -2772,12 +2850,15 @@
         if config.GlobalAddressBook.Enabled:
             self._provisionedLinks[config.GlobalAddressBook.Name] = "/addressbooks/public/global/addressbook/"
 
+
     def makeNewStore(self):
         return self._associatedTransaction.addressbookHomeWithUID(self.name, create=True), False     # Don't care about created
 
+
     def canShare(self):
         return config.Sharing.Enabled and config.Sharing.AddressBooks.Enabled and self.exists()
 
+
     @inlineCallbacks
     def makeRegularChild(self, name):
 
@@ -2814,7 +2895,7 @@
             addressbooks = yield self._newStoreHome.addressbooks()
             ownedAddressBooks = [addressbook for addressbook in addressbooks if addressbook.owned()]
             ownedAddressBooks.sort(key=lambda ab:ab.name())
-            
+
             # These are only unshared children
             # FIXME: the back-end should re-provision a default addressbook here.
             # Really, the dead property shouldn't be necessary, and this should
@@ -2839,6 +2920,7 @@
             element.HRef(defaultAddressBookURL))
         )
 
+
     @inlineCallbacks
     def getInternalSyncToken(self):
         # The newstore implementation supports this directly
@@ -2846,7 +2928,7 @@
 
         if config.Sharing.Enabled and config.Sharing.AddressBooks.Enabled and not config.Sharing.Calendars.Enabled:
             notifcationtoken = yield (yield self.getChild("notification")).getInternalSyncToken()
-            
+
             # Merge tokens
             adbkkey, adbkrev = adbktoken.split("_", 1)
             notrev = notifcationtoken.split("_", 1)[1]
@@ -2880,6 +2962,7 @@
         returnValue((changed, deleted, notallowed))
 
 
+
 class GlobalAddressBookResource (ReadOnlyResourceMixIn, CalDAVResource):
     """
     Global address book. All we care about is making sure permissions are setup.
@@ -2888,6 +2971,7 @@
     def resourceType(self):
         return element.ResourceType.sharedaddressbook #@UndefinedVariable
 
+
     def defaultAccessControlList(self):
 
         aces = (
@@ -2902,7 +2986,7 @@
                 TwistedACLInheritable(),
            ),
         )
-        
+
         if config.GlobalAddressBook.EnableAnonymousReadAccess:
             aces += (
                 element.ACE(
@@ -2916,11 +3000,13 @@
             )
         return element.ACL(*aces)
 
+
     def accessControlList(self, request, inheritance=True, expanding=False, inherited_aces=None):
         # Permissions here are fixed, and are not subject to inheritance rules, etc.
         return succeed(self.defaultAccessControlList())
 
 
+
 class AuthenticationWrapper(SuperAuthenticationWrapper):
 
     """ AuthenticationWrapper implementation which allows overriding
@@ -2938,6 +3024,7 @@
                 self.overrides[path] = dict([(factory.scheme, factory)
                     for factory in factories])
 
+
     def hook(self, req):
         """ Uses the default credentialFactories unless the request is for
             one of the overridden paths """
@@ -2949,11 +3036,11 @@
         req.credentialFactories = factories
 
 
+
 ##
 # Utilities
 ##
 
-
 def isCalendarCollectionResource(resource):
     try:
         resource = ICalDAVResource(resource)
@@ -2963,6 +3050,7 @@
         return resource.isCalendarCollection()
 
 
+
 def isPseudoCalendarCollectionResource(resource):
     try:
         resource = ICalDAVResource(resource)
@@ -2972,6 +3060,7 @@
         return resource.isPseudoCalendarCollection()
 
 
+
 def isAddressBookCollectionResource(resource):
     try:
         resource = ICalDAVResource(resource)
@@ -2979,4 +3068,3 @@
         return False
     else:
         return resource.isAddressBookCollection()
-

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -51,7 +51,7 @@
 import os
 import types
 
-#FIXME: Get rid of these imports
+# FIXME: Get rid of these imports
 from twistedcaldav.directory.util import TRANSACTION_KEY
 # circular import
 #from txdav.common.datastore.sql import ECALENDARTYPE, EADDRESSBOOKTYPE
@@ -69,7 +69,7 @@
         invites database.
         """
         if config.Sharing.Enabled:
-            
+
             def invitePropertyElement(invitation, includeUID=True):
 
                 userid = "urn:uuid:" + invitation.shareeUID()
@@ -86,16 +86,16 @@
             # See if this property is on the shared calendar
             isShared = yield self.isShared(request)
             if isShared:
-                yield self.validateInvites()
+                yield self.validateInvites(request)
                 invitations = yield self._allInvitations()
                 returnValue(customxml.Invite(
                     *[invitePropertyElement(invitation) for invitation in invitations]
                 ))
-                
+
             # See if it is on the sharee calendar
             if self.isShareeCollection():
                 original = (yield request.locateResource(self._share.url()))
-                yield original.validateInvites()
+                yield original.validateInvites(request)
                 invitations = yield original._allInvitations()
 
                 ownerPrincipal = (yield original.ownerPrincipal(request))
@@ -115,21 +115,21 @@
 
     def upgradeToShare(self):
         """ Upgrade this collection to a shared state """
-        
+
         # Change resourcetype
         rtype = self.resourceType()
         rtype = element.ResourceType(*(rtype.children + (customxml.SharedOwner(),)))
         self.writeDeadProperty(rtype)
-        
+
     @inlineCallbacks
     def downgradeFromShare(self, request):
-        
+
         # Change resource type (note this might be called after deleting a resource
         # so we have to cope with that)
         rtype = self.resourceType()
         rtype = element.ResourceType(*([child for child in rtype.children if child != customxml.SharedOwner()]))
         self.writeDeadProperty(rtype)
-        
+
         # Remove all invitees
         for invitation in (yield self._allInvitations()):
             yield self.uninviteFromShare(invitation, request)
@@ -146,7 +146,7 @@
                 (customxml.calendarserver_namespace, "valid-request"),
                 "Invalid share",
             ))
-        
+
         invitation = yield self._invitationForUID(inviteUID)
         if invitation is None or invitation.shareeUID() != shareeUID:
             raise HTTPError(ErrorResponse(
@@ -154,7 +154,7 @@
                 (customxml.calendarserver_namespace, "valid-request"),
                 "Invalid invitation uid: %s" % (inviteUID,),
             ))
-        
+
         # Only certain states are sharer controlled
         if invitation.state() in ("NEEDS-ACTION", "ACCEPTED", "DECLINED",):
             yield self._updateInvitation(invitation, state=state, summary=summary)
@@ -169,10 +169,10 @@
         @param request: the request triggering this action
         @type request: L{IRequest}
         """
-        
+
         # Need to have at least DAV:read to do this
         yield self.authorize(request, (element.Read(),))
-        
+
         # Find current principal
         authz_principal = self.currentPrincipal(request).children[0]
         if not isinstance(authz_principal, element.HRef):
@@ -189,7 +189,7 @@
                 "Current user principal not specified",
             ))
         sharee = (yield request.locateResource(principalURL))
-        
+
         # Check enabled for service
         from twistedcaldav.directory.principal import DirectoryCalendarPrincipalResource
         if not isinstance(sharee, DirectoryCalendarPrincipalResource):
@@ -198,7 +198,7 @@
                 (calendarserver_namespace, "invalid-principal"),
                 "Current user principal is not a calendar/addressbook enabled principal",
             ))
-        
+
         # Get the home collection
         if self.isCalendarCollection():
             shareeHomeResource = yield sharee.calendarHome(request)
@@ -210,7 +210,7 @@
                 (calendarserver_namespace, "invalid-principal"),
                 "No calendar/addressbook home for principal",
             ))
-            
+
         # TODO: Make sure principal is not sharing back to themselves
         hostURL = (yield self.canonicalURL(request))
         shareeHomeURL = shareeHomeResource.url()
@@ -247,7 +247,7 @@
 
     @inlineCallbacks
     def removeShareeCollection(self, request):
-        
+
         sharee = self.principalForUID(self._share.shareeUID())
 
         # Remove from sharee's calendar/address book home
@@ -271,7 +271,7 @@
         if isShareeCollection:
             rtype = element.ResourceType(
                 *(
-                    tuple([child for child in rtype.children if child.qname() != customxml.SharedOwner.qname()]) + 
+                    tuple([child for child in rtype.children if child.qname() != customxml.SharedOwner.qname()]) +
                     (customxml.Shared(),)
                 )
             )
@@ -282,7 +282,7 @@
         """
         Return the DAV:resourcetype stripped of any shared elements.
         """
-        
+
         if self.isCalendarCollection():
             return "calendar"
         elif self.isAddressBookCollection():
@@ -324,7 +324,7 @@
             # Invited shares use access mode from the invite
             # Get the access for self
             access = Invitation(self._newStoreObject).access()
-            
+
         userprivs = [
         ]
         if access in ("read-only", "read-write",):
@@ -391,22 +391,58 @@
 
         returnValue(element.ACL(*aces))
 
+
     @inlineCallbacks
-    def validateInvites(self):
+    def validUserIDForShare(self, userid, request=None):
         """
+        Test the user id to see if it is a valid identifier for sharing and
+        return a "normalized" form for our own use (e.g. convert mailto: to
+        urn:uuid).
+
+        @param userid: the userid to test
+        @type userid: C{str}
+
+        @return: C{str} of normalized userid or C{None} if
+            userid is not allowed.
+        """
+
+        # First try to resolve as a principal
+        principal = self.principalForCalendarUserAddress(userid)
+        if principal:
+            if request:
+                ownerPrincipal = (yield self.ownerPrincipal(request))
+                owner = ownerPrincipal.principalURL()
+                if owner == principal.principalURL():
+                    returnValue(None)
+            returnValue(principal.principalURL())
+
+        # TODO: we do not support external users right now so this is being hard-coded
+        # off in spite of the config option.
+        #elif config.Sharing.AllowExternalUsers:
+        #    return userid
+        else:
+            returnValue(None)
+
+
+    @inlineCallbacks
+    def validateInvites(self, request):
+        """
         Make sure each userid in an invite is valid - if not re-write status.
         """
+        #assert request
         invitations = yield self._allInvitations()
         for invitation in invitations:
-            if not self.principalForUID(invitation.shareeUID()) and invitation.state() != "INVALID":
-                yield self._updateInvitation(invitation, state="INVALID")
+            if invitation.state() != "INVALID":
+                if not (yield self.validUserIDForShare("urn:uuid:" + invitation.shareeUID(), request)):
+                    yield self._updateInvitation(invitation, state="INVALID")
 
+
     def inviteUserToShare(self, userid, cn, ace, summary, request):
         """ Send out in invite first, and then add this user to the share list
-            @param userid: 
+            @param userid:
             @param ace: Must be one of customxml.ReadWriteAccess or customxml.ReadAccess
         """
-        
+
         # TODO: Check if this collection is shared, and error out if it isn't
         resultIsList = True
         if type(userid) is not list:
@@ -414,13 +450,14 @@
             resultIsList = False
         if type(cn) is not list:
             cn = [cn]
-            
+
         dl = [self.inviteSingleUserToShare(user, cn, ace, summary, request) for user, cn in zip(userid, cn)]
         return self._processShareActionList(dl, resultIsList)
 
+
     def uninviteUserToShare(self, userid, ace, request):
         """ Send out in uninvite first, and then remove this user from the share list."""
-        
+
         # Do not validate the userid - we want to allow invalid users to be removed because they
         # may have been valid when added, but no longer valid now. Clients should be able to clear out
         # anything known to be invalid.
@@ -434,6 +471,7 @@
         dl = [self.uninviteSingleUserFromShare(user, ace, request) for user in userid]
         return self._processShareActionList(dl, resultIsList)
 
+
     def inviteUserUpdateToShare(self, userid, cn, aceOLD, aceNEW, summary, request):
 
         resultIsList = True
@@ -442,17 +480,18 @@
             resultIsList = False
         if type(cn) is not list:
             cn = [cn]
-            
+
         dl = [self.inviteSingleUserUpdateToShare(user, cn, aceOLD, aceNEW, summary, request) for user, cn in zip(userid, cn)]
         return self._processShareActionList(dl, resultIsList)
 
+
     def _processShareActionList(self, dl, resultIsList):
         def _defer(resultset):
             results = [result if success else False for success, result in resultset]
             return results if resultIsList else results[0]
         return DeferredList(dl).addCallback(_defer)
-        
 
+
     @inlineCallbacks
     def _createInvitation(self, shareeUID, access, summary,):
         '''
@@ -467,7 +506,7 @@
                                                     mode=invitationAccessToBindModeMap[access],
                                                     status=_BIND_STATUS_INVITED,
                                                     message=summary)
-        
+
         shareeHomeChild = yield shareeHome.invitedChildWithName(sharedName)
         invitation = Invitation(shareeHomeChild)
         returnValue(invitation)
@@ -498,10 +537,10 @@
             indirectAccceptedHomeChildren = [homeChild for homeChild in acceptedHomeChildren
                                              if homeChild.shareMode() != _BIND_MODE_DIRECT]
             invitedHomeChildren += indirectAccceptedHomeChildren
-        
+
         invitations = [Invitation(homeChild) for homeChild in invitedHomeChildren]
         invitations.sort(key=lambda invitation:invitation.shareeUID())
-        
+
         returnValue(invitations)
 
     @inlineCallbacks
@@ -526,19 +565,19 @@
             if invitation.uid() == uid:
                 returnValue(invitation)
         returnValue(None)
-            
 
 
+
     @inlineCallbacks
     def inviteSingleUserToShare(self, userid, cn, ace, summary, request):
-        
+
         # We currently only handle local users
         sharee = self.principalForCalendarUserAddress(userid)
         if not sharee:
             returnValue(False)
-        
+
         shareeUID = sharee.principalUID()
-        
+
         # Look for existing invite and update its fields or create new one
         invitation = yield self._invitationForShareeUID(shareeUID)
         if invitation:
@@ -575,7 +614,7 @@
 
     @inlineCallbacks
     def uninviteFromShare(self, invitation, request):
-        
+
         # Remove any shared calendar or address book
         sharee = self.principalForUID(invitation.shareeUID())
         if sharee:
@@ -590,20 +629,22 @@
                 yield self.removeInviteNotification(invitation, request)
             elif invitation:
                 yield self.sendInviteNotification(invitation, request, notificationState="DELETED")
-        
+
         # Direct shares for  with valid sharee principal will already be deleted
         yield self._newStoreObject.unshareWith(invitation._shareeHomeChild.viewerHome())
-    
-        returnValue(True)            
 
+        returnValue(True)
+
+
     def inviteSingleUserUpdateToShare(self, userid, commonName, acesOLD, aceNEW, summary, request):
-        
+
         # Just update existing
-        return self.inviteSingleUserToShare(userid, commonName, aceNEW, summary, request) 
+        return self.inviteSingleUserToShare(userid, commonName, aceNEW, summary, request)
 
+
     @inlineCallbacks
     def sendInviteNotification(self, invitation, request, notificationState=None):
-        
+
         ownerPrincipal = (yield self.ownerPrincipal(request))
         owner = ownerPrincipal.principalURL()
         ownerCN = ownerPrincipal.displayName()
@@ -613,18 +654,18 @@
         sharee = self.principalForUID(invitation.shareeUID())
         if sharee is None:
             raise ValueError("sharee is None but principalUID was valid before")
-        
+
         # We need to look up the resource so that the response cache notifier is properly initialized
         notificationResource = (yield request.locateResource(sharee.notificationURL()))
         notifications = notificationResource._newStoreNotifications
-        
+
         # Look for existing notification
         # oldnotification is not used don't query for it
         # oldnotification = (yield notifications.notificationObjectWithUID(invitation.uid()))
         # if oldnotification:
             # TODO: rollup changes?
         #    pass
-        
+
         # Generate invite XML
         userid = "urn:uuid:" + invitation.shareeUID()
         state = notificationState if notificationState else invitation.state()
@@ -650,20 +691,20 @@
                 **typeAttr
             ),
         ).toxml()
-        
+
         # Add to collections
         yield notifications.writeNotificationObject(invitation.uid(), xmltype, xmldata)
 
     @inlineCallbacks
     def removeInviteNotification(self, invitation, request):
-        
+
         # Locate notifications collection for user
         sharee = self.principalForUID(invitation.shareeUID())
         if sharee is None:
             raise ValueError("sharee is None but principalUID was valid before")
         notificationResource = (yield request.locateResource(sharee.notificationURL()))
         notifications = notificationResource._newStoreNotifications
-        
+
         # Add to collections
         yield notifications.removeNotificationObjectWithUID(invitation.uid())
 
@@ -672,7 +713,9 @@
         yield self.authorize(request, (element.Read(), element.Write()))
         result = (yield self._handleInvite(request, docroot))
         returnValue(result)
-    
+
+
+    @inlineCallbacks
     def _handleInvite(self, request, invitedoc):
         def _handleInviteSet(inviteset):
             userid = None
@@ -730,95 +773,98 @@
                 access = set(access)
             return (userid, access)
 
-        def _autoShare(isShared, request):
-            if not isShared:
-                self.upgradeToShare()
+        setDict, removeDict, updateinviteDict = {}, {}, {}
+        okusers = set()
+        badusers = set()
+        for item in invitedoc.children:
+            if isinstance(item, customxml.InviteSet):
+                userid, cn, access, summary = _handleInviteSet(item)
+                setDict[userid] = (cn, access, summary)
 
-        @inlineCallbacks
-        def _processInviteDoc(_, request):
-            setDict, removeDict, updateinviteDict = {}, {}, {}
+                # Validate each userid on add only
+                uid = (yield self.validUserIDForShare(userid, request))
+                (okusers if uid is not None else badusers).add(userid)
+            elif isinstance(item, customxml.InviteRemove):
+                userid, access = _handleInviteRemove(item)
+                removeDict[userid] = access
+
+                # Treat removed userids as valid as we will fail invalid ones silently
+                okusers.add(userid)
+
+        # Only make changes if all OK
+        if len(badusers) == 0:
             okusers = set()
             badusers = set()
-            for item in invitedoc.children:
-                if isinstance(item, customxml.InviteSet):
-                    userid, cn, access, summary = _handleInviteSet(item)
-                    setDict[userid] = (cn, access, summary)
-                
-                    # Validate each userid on add only
-                    (okusers if self.principalForCalendarUserAddress(userid) else badusers).add(userid)
-                elif isinstance(item, customxml.InviteRemove):
-                    userid, access = _handleInviteRemove(item)
-                    removeDict[userid] = access
-                    
-                    # Treat removed userids as valid as we will fail invalid ones silently
-                    okusers.add(userid)
+            # Special case removing and adding the same user and treat that as an add
+            sameUseridInRemoveAndSet = [u for u in removeDict.keys() if u in setDict]
+            for u in sameUseridInRemoveAndSet:
+                removeACL = removeDict[u]
+                cn, newACL, summary = setDict[u]
+                updateinviteDict[u] = (cn, removeACL, newACL, summary)
+                del removeDict[u]
+                del setDict[u]
+            for userid, access in removeDict.iteritems():
+                result = (yield self.uninviteUserToShare(userid, access, request))
+                # If result is False that means the user being removed was not
+                # actually invited, but let's not return an error in this case.
+                okusers.add(userid)
+            for userid, (cn, access, summary) in setDict.iteritems():
+                result = (yield self.inviteUserToShare(userid, cn, access, summary, request))
+                (okusers if result else badusers).add(userid)
+            for userid, (cn, removeACL, newACL, summary) in updateinviteDict.iteritems():
+                result = (yield self.inviteUserUpdateToShare(userid, cn, removeACL, newACL, summary, request))
+                (okusers if result else badusers).add(userid)
 
-            # Only make changes if all OK
-            if len(badusers) == 0:
-                okusers = set()
-                badusers = set()
-                # Special case removing and adding the same user and treat that as an add
-                sameUseridInRemoveAndSet = [u for u in removeDict.keys() if u in setDict]
-                for u in sameUseridInRemoveAndSet:
-                    removeACL = removeDict[u]
-                    cn, newACL, summary = setDict[u]
-                    updateinviteDict[u] = (cn, removeACL, newACL, summary)
-                    del removeDict[u]
-                    del setDict[u]
-                for userid, access in removeDict.iteritems():
-                    result = (yield self.uninviteUserToShare(userid, access, request))
-                    # If result is False that means the user being removed was not
-                    # actually invited, but let's not return an error in this case.
-                    okusers.add(userid)
-                for userid, (cn, access, summary) in setDict.iteritems():
-                    result = (yield self.inviteUserToShare(userid, cn, access, summary, request))
-                    (okusers if result else badusers).add(userid)
-                for userid, (cn, removeACL, newACL, summary) in updateinviteDict.iteritems():
-                    result = (yield self.inviteUserUpdateToShare(userid, cn, removeACL, newACL, summary, request))
-                    (okusers if result else badusers).add(userid)
+            # In this case bad items do not prevent ok items from being processed
+            ok_code = responsecode.OK
+        else:
+            # In this case a bad item causes all ok items not to be processed so failed dependency is returned
+            ok_code = responsecode.FAILED_DEPENDENCY
 
-                # In this case bad items do not prevent ok items from being processed
-                ok_code = responsecode.OK
-            else:
-                # In this case a bad item causes all ok items not to be processed so failed dependency is returned
-                ok_code = responsecode.FAILED_DEPENDENCY
+        # Do a final validation of the entire set of invites
+        numRecords = (yield self.validateInvites(request))
 
-            # Do a final validation of the entire set of invites
-            yield self.validateInvites()
-            
-            # Create the multistatus response - only needed if some are bad
-            if badusers:
-                xml_responses = []
-                xml_responses.extend([
-                    element.StatusResponse(element.HRef(userid), element.Status.fromResponseCode(ok_code))
-                    for userid in sorted(okusers)
-                ])
-                xml_responses.extend([
-                    element.StatusResponse(element.HRef(userid), element.Status.fromResponseCode(responsecode.FORBIDDEN))
-                    for userid in sorted(badusers)
-                ])
-            
-                #
-                # Return response
-                #
-                returnValue(MultiStatusResponse(xml_responses))
-            else:
-                returnValue(responsecode.OK)
+        # Set the sharing state on the collection
+        shared = (yield self.isShared(request))
+        if shared and numRecords == 0:
+            yield self.downgradeFromShare(request)
+        elif not shared and numRecords != 0:
+            self.upgradeToShare()
 
-        return self.isShared(request).addCallback(_autoShare, request).addCallback(_processInviteDoc, request)
+        # Create the multistatus response - only needed if some are bad
+        if badusers:
+            xml_responses = []
+            xml_responses.extend([
+                element.StatusResponse(element.HRef(userid), element.Status.fromResponseCode(ok_code))
+                for userid in sorted(okusers)
+            ])
+            xml_responses.extend([
+                element.StatusResponse(element.HRef(userid), element.Status.fromResponseCode(responsecode.FORBIDDEN))
+                for userid in sorted(badusers)
+            ])
 
+            #
+            # Return response
+            #
+            returnValue(MultiStatusResponse(xml_responses))
+        else:
+            returnValue(responsecode.OK)
+
+
     @inlineCallbacks
     def _xmlHandleInviteReply(self, request, docroot):
         yield self.authorize(request, (element.Read(), element.Write()))
         result = (yield self._handleInviteReply(request, docroot))
         returnValue(result)
-    
+
+
     def _handleInviteReply(self, request, docroot):
         raise NotImplementedError
 
+
     @inlineCallbacks
     def xmlRequestHandler(self, request):
-        
+
         # Need to read the data and get the root element first
         xmldata = (yield allDataFromStream(request.stream))
         try:
@@ -899,25 +945,25 @@
     """
     def __init__(self, shareeHomeChild):
         self._shareeHomeChild = shareeHomeChild
-    
+
     def uid(self):
         return self._shareeHomeChild.shareUID()
-    
+
     def shareeUID(self):
         return self._shareeHomeChild.viewerHome().uid()
-   
+
     def access(self):
         return invitationAccessFromBindModeMap.get(self._shareeHomeChild.shareMode())
-    
+
     def state(self):
         return invitationStateFromBindStatusMap.get(self._shareeHomeChild.shareStatus())
-   
+
     def summary(self):
         return self._shareeHomeChild.shareMessage()
 
 
 class LegacyInvite(object):
-    
+
     def __init__(self, inviteuid, userid, principalUID, common_name, access, state, summary):
         self.inviteuid = inviteuid
         self.principalUID = principalUID
@@ -927,7 +973,7 @@
 
 
 class InvitesDatabase(AbstractSQLDatabase, LoggingMixIn):
-    
+
     db_basename = db_prefix + "invites"
     schema_version = "1"
     db_type = "invites"
@@ -941,6 +987,7 @@
         db_filename = os.path.join(self.resource.fp.path, InvitesDatabase.db_basename)
         super(InvitesDatabase, self).__init__(db_filename, True, autocommit=True)
 
+
     def create(self):
         """
         Create the index and initialize it.
@@ -958,53 +1005,62 @@
     dbpath = property(get_dbpath, set_dbpath)
 
     def allRecords(self):
-        
+
         records = self._db_execute("select * from INVITE order by USERID")
         return [self._makeRecord(row) for row in (records if records is not None else ())]
-    
+
+
     def recordForUserID(self, userid):
-        
+
         row = self._db_execute("select * from INVITE where USERID = :1", userid)
         return self._makeRecord(row[0]) if row else None
-    
+
+
     def recordForPrincipalUID(self, principalUID):
-        
+
         row = self._db_execute("select * from INVITE where PRINCIPALUID = :1", principalUID)
         return self._makeRecord(row[0]) if row else None
-    
+
+
     def recordForInviteUID(self, inviteUID):
 
         row = self._db_execute("select * from INVITE where INVITEUID = :1", inviteUID)
         return self._makeRecord(row[0]) if row else None
-    
+
+
     def addOrUpdateRecord(self, record):
 
         self._db_execute("""insert or replace into INVITE (INVITEUID, USERID, PRINCIPALUID, NAME, ACCESS, STATE, SUMMARY)
             values (:1, :2, :3, :4, :5, :6, :7)
             """, record.inviteuid, "userid", record.principalUID, "name", record.access, record.state, record.summary,
         )
-    
+
+
     def removeRecordForInviteUID(self, inviteUID):
 
         self._db_execute("delete from INVITE where INVITEUID = :1", inviteUID)
-    
+
+
     def remove(self):
-        
+
         self._db_close()
         os.remove(self.dbpath)
 
+
     def _db_version(self):
         """
         @return: the schema version assigned to this index.
         """
         return InvitesDatabase.schema_version
 
+
     def _db_type(self):
         """
         @return: the collection type assigned to this index.
         """
         return InvitesDatabase.db_type
 
+
     def _db_init_data_tables(self, q):
         """
         Initialise the underlying database tables.
@@ -1050,6 +1106,7 @@
             """
         )
 
+
     def _db_upgrade_data_tables(self, q, old_version):
         """
         Upgrade the data from an older version of the DB.
@@ -1058,8 +1115,9 @@
         # Nothing to do as we have not changed the schema
         pass
 
+
     def _makeRecord(self, row):
-        
+
         return LegacyInvite(*[str(item) if type(item) == types.UnicodeType else item for item in row])
 
 class SharedHomeMixin(LinkFollowerMixIn):
@@ -1067,8 +1125,8 @@
     A mix-in for calendar/addressbook homes that defines the operations for
     manipulating a sharee's set of shared calendars.
     """
-    
-        
+
+
     @inlineCallbacks
     def provisionShare(self, child, request=None):
         share = yield self._shareForHomeChild(child._newStoreObject, request)
@@ -1080,51 +1138,51 @@
         # Try to find a matching share
         if not child or child.owned():
             returnValue(None)
-        
+
         sharerHomeChild = yield child.ownerHome().childWithID(child._resourceID)
-        
+
         # get the shared object's URL
         sharer = self.principalForUID(sharerHomeChild.viewerHome().uid())
-        
+
         if not request:
             # FIXEME:  Fake up a request that can be used to get the sharer home resource
             class _FakeRequest(object):pass
             fakeRequest = _FakeRequest()
             setattr(fakeRequest, TRANSACTION_KEY, self._newStoreHome._txn)
             request = fakeRequest
-        
+
         if self._newStoreHome._homeType == ECALENDARTYPE:
             sharerHomeCollection = yield sharer.calendarHome(request)
         elif self._newStoreHome._homeType == EADDRESSBOOKTYPE:
             sharerHomeCollection = yield sharer.addressBookHome(request)
-        
-        url = joinURL(sharerHomeCollection.url(), sharerHomeChild.name())        
+
+        url = joinURL(sharerHomeCollection.url(), sharerHomeChild.name())
         share = Share(shareeHomeChild=child, sharerHomeChild=sharerHomeChild, url=url)
 
         returnValue(share)
 
     @inlineCallbacks
     def _shareForUID(self, shareUID, request):
-        
+
         # since child.shareUID() == child.name() for indirect shares
         child = yield self._newStoreHome.childWithName(shareUID)
         if child:
             share = yield self._shareForHomeChild(child, request)
             if share and share.uid() == shareUID:
                 returnValue(share)
-        
+
         # find direct shares
         children = yield self._newStoreHome.children()
         for child in children:
             share = yield self._shareForHomeChild(child, request)
             if share and share.uid() == shareUID:
                 returnValue(share)
-                
+
         returnValue(None)
 
     @inlineCallbacks
     def acceptInviteShare(self, request, hostUrl, inviteUID, displayname=None):
-        
+
         # Check for old share
         oldShare = yield self._shareForUID(inviteUID, request)
 
@@ -1140,6 +1198,7 @@
         response = yield self._acceptShare(request, not oldShare, share, displayname)
         returnValue(response)
 
+
     @inlineCallbacks
     def acceptDirectShare(self, request, hostUrl, resourceUID, displayname=None):
 
@@ -1153,10 +1212,10 @@
                                                     mode=_BIND_MODE_DIRECT,
                                                     status=_BIND_STATUS_ACCEPTED,
                                                     message=displayname)
-            
+
             shareeHomeChild = yield self._newStoreHome.childWithName(sharedName)
             share = Share(shareeHomeChild=shareeHomeChild, sharerHomeChild=sharedCollection._newStoreObject, url=hostUrl)
-            
+
         response = yield self._acceptShare(request, not oldShare, share, displayname)
         returnValue(response)
 
@@ -1173,7 +1232,7 @@
                 color = (yield sharedCollection.readProperty(customxml.CalendarColor, request))
             except HTTPError:
                 pass
-            
+
         sharee = self.principalForUID(share.shareeUID())
         if sharedCollection.isCalendarCollection():
             shareeHomeResource = yield sharee.calendarHome(request)
@@ -1196,7 +1255,7 @@
             yield shareeCollection.writeProperty(caldavxml.DefaultAlarmVEventDate.fromString(""), request)
             yield shareeCollection.writeProperty(caldavxml.DefaultAlarmVToDoDateTime.fromString(""), request)
             yield shareeCollection.writeProperty(caldavxml.DefaultAlarmVToDoDate.fromString(""), request)
- 
+
         # Notify client of changes
         yield self.notifyChanged()
 
@@ -1210,7 +1269,9 @@
 
 
     def removeShare(self, request, share):
-        """ Remove a shared collection named in resourceName """
+        """
+        Remove a shared collection named in resourceName
+        """
 
         if share.direct():
             return self.removeDirectShare(request, share)
@@ -1220,7 +1281,10 @@
 
     @inlineCallbacks
     def removeShareByUID(self, request, shareUID):
-        """ Remove a shared collection but do not send a decline back """
+        """
+        Remove a shared collection but do not send a decline back. Return the
+        current display name of the shared collection.
+        """
 
         share = yield self._shareForUID(shareUID, request)
         if share:
@@ -1230,7 +1294,10 @@
 
     @inlineCallbacks
     def removeDirectShare(self, request, share):
-        """ Remove a shared collection but do not send a decline back """
+        """
+        Remove a shared collection but do not send a decline back. Return the
+        current display name of the shared collection.
+        """
 
         shareURL = joinURL(self.url(), share.name())
 
@@ -1242,7 +1309,7 @@
                 inbox = (yield request.locateResource(inboxURL))
                 inbox.processFreeBusyCalendar(shareURL, False)
 
-        
+
         if share.direct():
             yield share._sharerHomeChild.unshareWith(share._shareeHomeChild.viewerHome())
         else:
@@ -1256,15 +1323,16 @@
         yield self.removeShareByUID(request, inviteUID)
 
         yield self._changeShare(request, "DECLINED", hostUrl, inviteUID)
-        
+
         returnValue(Response(code=responsecode.NO_CONTENT))
 
+
     @inlineCallbacks
     def _changeShare(self, request, state, hostUrl, replytoUID, displayname=None):
         """
         Accept or decline an invite to a shared collection.
         """
-        
+
         # Change state in sharer invite
         ownerPrincipal = (yield self.ownerPrincipal(request))
         ownerPrincipalUID = ownerPrincipal.principalUID()
@@ -1276,12 +1344,13 @@
                 (customxml.calendarserver_namespace, "valid-request"),
                 "Invalid shared collection",
             ))
-            
+
         # Change the record
         yield sharedCollection.changeUserInviteState(request, replytoUID, ownerPrincipalUID, state, displayname)
 
         yield self.sendReply(request, ownerPrincipal, sharedCollection, state, hostUrl, replytoUID, displayname)
 
+
     @inlineCallbacks
     def sendReply(self, request, shareePrincipal, sharedCollection, state, hostUrl, replytoUID, displayname=None):
 
@@ -1322,10 +1391,11 @@
                 )
             ),
         ).toxml()
-        
+
         # Add to collections
         yield notifications.writeNotificationObject(notificationUID, xmltype, xmldata)
 
+
     def _handleInviteReply(self, request, invitereplydoc):
         """ Handle a user accepting or declining a sharing invite """
         hostUrl = None
@@ -1345,7 +1415,7 @@
                         hostUrl = str(hosturlItem)
             elif isinstance(item, customxml.InReplyTo):
                 replytoUID = str(item)
-        
+
         if accepted is None or hostUrl is None or replytoUID is None:
             raise HTTPError(ErrorResponse(
                 responsecode.FORBIDDEN,
@@ -1357,8 +1427,10 @@
         else:
             return self.declineShare(request, hostUrl, replytoUID)
 
+
+
 class SharedCollectionRecord(object):
-    
+
     def __init__(self, shareuid, sharetype, hosturl, localname, summary):
         self.shareuid = shareuid
         self.sharetype = sharetype
@@ -1367,32 +1439,32 @@
         self.summary = summary
 
 class Share(object):
-    
+
     def __init__(self, sharerHomeChild, shareeHomeChild, url):
         self._shareeHomeChild = shareeHomeChild
         self._sharerHomeChild = sharerHomeChild
         self._sharedResourceURL = url
-        
+
     @classmethod
     def directUID(cls, shareeHome, sharerHomeChild):
         return "Direct-%s-%s" % (shareeHome._resourceID, sharerHomeChild._resourceID,)
-        
+
     def uid(self):
         # Move to CommonHomeChild shareUID?
         if self._shareeHomeChild.shareMode() == _BIND_MODE_DIRECT:
             return self.directUID(shareeHome=self._shareeHomeChild.viewerHome(), sharerHomeChild=self._sharerHomeChild,)
         else:
             return self._shareeHomeChild.shareUID()
-    
+
     def direct(self):
         return self._shareeHomeChild.shareMode() == _BIND_MODE_DIRECT
-   
+
     def url(self):
         return self._sharedResourceURL
 
     def name(self):
         return self._shareeHomeChild.name()
-    
+
     def summary(self):
         return self._shareeHomeChild.shareMessage()
 
@@ -1400,12 +1472,12 @@
         return self._shareeHomeChild.viewerHome().uid()
 
 class SharedCollectionsDatabase(AbstractSQLDatabase, LoggingMixIn):
-    
+
     db_basename = db_prefix + "shares"
     schema_version = "1"
     db_type = "shares"
 
-    def __init__(self, resource):   
+    def __init__(self, resource):
         """
         @param resource: the L{CalDAVResource} resource for
             the shared collection. C{resource} must be a calendar/addressbook home collection.)
@@ -1422,7 +1494,6 @@
     def set_dbpath(self, newpath):
         pass
 
-
     dbpath = property(get_dbpath, set_dbpath)
 
 
@@ -1432,8 +1503,9 @@
         """
         self._db()
 
+
     def allRecords(self):
-        
+
         records = self._db_execute("select * from SHARES order by LOCALNAME")
         return [self._makeRecord(row) for row in (records if records is not None else ())]
 
@@ -1442,42 +1514,50 @@
 
         row = self._db_execute("select * from SHARES where SHAREUID = :1", shareUID)
         return self._makeRecord(row[0]) if row else None
-    
+
+
     def addOrUpdateRecord(self, record):
 
         self._db_execute("""insert or replace into SHARES (SHAREUID, SHARETYPE, HOSTURL, LOCALNAME, SUMMARY)
             values (:1, :2, :3, :4, :5)
             """, record.shareuid, record.sharetype, record.hosturl, record.localname, record.summary,
         )
-    
+
+
     def removeRecordForLocalName(self, localname):
 
         self._db_execute("delete from SHARES where LOCALNAME = :1", localname)
-    
+
+
     def removeRecordForShareUID(self, shareUID):
 
         self._db_execute("delete from SHARES where SHAREUID = :1", shareUID)
-    
+
+
     def remove(self):
-        
+
         self._db_close()
         os.remove(self.dbpath)
 
+
     def directShareID(self, shareeHome, sharerCollection):
         return "Direct-%s-%s" % (shareeHome.resourceID(), sharerCollection.resourceID(),)
 
+
     def _db_version(self):
         """
         @return: the schema version assigned to this index.
         """
         return SharedCollectionsDatabase.schema_version
 
+
     def _db_type(self):
         """
         @return: the collection type assigned to this index.
         """
         return SharedCollectionsDatabase.db_type
 
+
     def _db_init_data_tables(self, q):
         """
         Initialise the underlying database tables.
@@ -1519,6 +1599,7 @@
             """
         )
 
+
     def _db_upgrade_data_tables(self, q, old_version):
         """
         Upgrade the data from an older version of the DB.
@@ -1527,6 +1608,7 @@
         # Nothing to do as we have not changed the schema
         pass
 
+
     def _makeRecord(self, row):
-        
+
         return SharedCollectionRecord(*[str(item) if type(item) == types.UnicodeType else item for item in row])

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/stdconfig.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/stdconfig.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -810,7 +810,7 @@
     "Localization" : {
         "TranslationsDirectory" : "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/share/translations",
         "LocalesDirectory" : "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/share/locales",
-        "Language" : "en",
+        "Language" : "",
     },
 
 

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -1017,6 +1017,11 @@
         calendar.addProperty(VProperty("VERSION", "2.0"))
         calendar.addProperty(VProperty("PRODID", iCalendarProductID))
 
+        # Add a display name if available
+        displayName = self.displayName()
+        if displayName is not None:
+            calendar.addProperty(VProperty("X-WR-CALNAME", displayName))
+
         # Do some optimisation of access control calculation by determining any
         # inherited ACLs outside of the child resource loop and supply those to
         # the checkPrivileges on each child.

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_localization.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_localization.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_localization.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -16,9 +16,10 @@
 
 from __future__ import with_statement
 
-from twistedcaldav.localization import translationTo, _
+from twistedcaldav.localization import translationTo, getLanguage, _
 from twistedcaldav.ical import Component
 from twistedcaldav.test.util import TestCase
+from twistedcaldav.config import ConfigDict
 from pycalendar.datetime import PyCalendarDateTime
 
 import os
@@ -140,3 +141,10 @@
                 (u'11:05 (PDT) otay 18:15 (EDT)', u'4 ourshay 10 inutesmay'))
 
             self.assertEquals(t.monthAbbreviation(1), "ANJAY")
+
+    def test_getLanguage(self):
+        """
+        Test that getLanguage( ) examines config.
+        """
+
+        self.assertEquals(getLanguage(ConfigDict({"Localization" : {"Language" : "xyzzy"}})), "xyzzy")

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -38,9 +38,9 @@
 class SharingTests(HomeTestCase):
 
     class FakePrincipal(object):
-        
+
         class FakeRecord(object):
-            
+
             def __init__(self, name, cuaddr):
                 self.fullName = name
                 self.guid = name
@@ -53,24 +53,24 @@
                 name = cuaddr[9:]
             else:
                 name = cuaddr
-                
+
             self.path = "/principals/__uids__/%s" % (name,)
             self.homepath = "/calendars/__uids__/%s" % (name,)
             self.displayname = name.upper()
             self.record = self.FakeRecord(name, cuaddr)
-            
 
+
         def calendarHome(self, request):
             class FakeHome(object):
                 def removeShareByUID(self, request, uid):pass
             return FakeHome()
-        
+
         def principalURL(self):
             return self.path
-        
+
         def principalUID(self):
             return self.record.guid
-        
+
         def displayName(self):
             return self.displayname
 
@@ -88,7 +88,7 @@
         CalDAVResource.removeInviteNotification = lambda self, record, request: succeed(True)
 
         self.patch(CalDAVResource, "principalForCalendarUserAddress", lambda self, cuaddr: None if "bogus" in cuaddr else SharingTests.FakePrincipal(cuaddr))
-        self.patch(CalDAVResource, "principalForUID", lambda self, principalUID: SharingTests.FakePrincipal("urn:uuid:" + principalUID ))
+        self.patch(CalDAVResource, "principalForUID", lambda self, principalUID: SharingTests.FakePrincipal("urn:uuid:" + principalUID))
 
     def createDataStore(self):
         return self.calendarStore
@@ -105,7 +105,7 @@
 
 
     @inlineCallbacks
-    def _doPOST(self, body, resultcode = responsecode.OK):
+    def _doPOST(self, body, resultcode=responsecode.OK):
         request = SimpleRequest(self.site, "POST", "/calendar/")
         request.headers.setHeader("content-type", MimeType("text", "xml"))
         request.stream = MemoryStream(body)
@@ -115,7 +115,7 @@
         returnValue(response)
 
     def _clearUIDElementValue(self, xml):
-        
+
         for user in xml.children:
             for element in user.children:
                 if type(element) == customxml.UID:
@@ -137,7 +137,7 @@
         self.assertEquals(rtype, sharedOwnerType)
         propInvite = (yield self.resource.readProperty(customxml.Invite, request))
         self.assertEquals(propInvite, customxml.Invite())
-        
+
         isShared = (yield self.resource.isShared(request))
         self.assertTrue(isShared)
         isVShared = self.resource.isShareeCollection()
@@ -158,7 +158,7 @@
         self.assertEquals(rtype, sharedOwnerType)
         propInvite = (yield self.resource.readProperty(customxml.Invite, request))
         self.assertEquals(propInvite, customxml.Invite())
-        
+
         isShared = (yield self.resource.isShared(request))
         self.assertTrue(isShared)
         isVShared = self.resource.isShareeCollection()
@@ -179,7 +179,7 @@
         self.assertEquals(rtype, regularCalendarType)
         propInvite = (yield self.resource.readProperty(customxml.Invite, None))
         self.assertEquals(propInvite, None)
-        
+
         isShared = (yield self.resource.isShared(None))
         self.assertFalse(isShared)
         isVShared = self.resource.isShareeCollection()
@@ -187,7 +187,7 @@
 
     @inlineCallbacks
     def test_POSTaddInviteeAlreadyShared(self):
-        
+
         self.resource.upgradeToShare()
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
@@ -210,7 +210,7 @@
                 customxml.InviteStatusNoResponse(),
             )
         ))
-        
+
         isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
         isVShared = self.resource.isShareeCollection()
@@ -218,7 +218,7 @@
 
     @inlineCallbacks
     def test_POSTaddInviteeNotAlreadyShared(self):
-        
+
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
 <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
     <CS:set>
@@ -240,7 +240,7 @@
                 customxml.InviteStatusNoResponse(),
             )
         ))
-        
+
         isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
         isVShared = (yield self.resource.isShareeCollection())
@@ -248,7 +248,7 @@
 
     @inlineCallbacks
     def test_POSTupdateInvitee(self):
-        
+
         self.resource.upgradeToShare()
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
@@ -284,7 +284,7 @@
 
     @inlineCallbacks
     def test_POSTremoveInvitee(self):
-        
+
         self.resource.upgradeToShare()
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
@@ -310,7 +310,7 @@
 
     @inlineCallbacks
     def test_POSTaddMoreInvitees(self):
-        
+
         self.resource.upgradeToShare()
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
@@ -364,7 +364,7 @@
 
     @inlineCallbacks
     def test_POSTaddRemoveInvitees(self):
-        
+
         self.resource.upgradeToShare()
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
@@ -542,7 +542,7 @@
 
     @inlineCallbacks
     def test_POSTremoveInvalidInvitee(self):
-        
+
         self.resource.upgradeToShare()
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
@@ -579,7 +579,7 @@
                 customxml.InviteStatusInvalid(),
             )
         ))
-        
+
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
 <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
     <CS:remove>

Modified: CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py	2012-09-23 03:04:08 UTC (rev 9841)
+++ CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py	2012-09-23 03:36:01 UTC (rev 9842)
@@ -1958,11 +1958,11 @@
     _objectResourceClass = None
 
     _bindSchema              = None
-    _homeSchema 			 = None
-    _homeChildSchema 		 = None
+    _homeSchema              = None
+    _homeChildSchema          = None
     _homeChildMetaDataSchema = None
-    _revisionsSchema 		 = None
-    _objectSchema 			 = None
+    _revisionsSchema          = None
+    _objectSchema              = None
 
     _bindTable           = None
     _homeChildTable      = None
@@ -1985,9 +1985,9 @@
         self._name              = name
         self._resourceID        = resourceID
         self._bindMode          = mode
-        self._bindStatus 		= status
-        self._bindMessage 		= message
-        self._ownerHome 		= home if ownerHome is None else ownerHome
+        self._bindStatus         = status
+        self._bindMessage         = message
+        self._ownerHome         = home if ownerHome is None else ownerHome
         self._created           = None
         self._modified          = None
         self._objects           = {}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120922/93e92f89/attachment-0001.html>


More information about the calendarserver-changes mailing list