[CalendarServer-changes] [8032] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 30 11:45:45 PDT 2011


Revision: 8032
          http://trac.macosforge.org/projects/calendarserver/changeset/8032
Author:   cdaboo at apple.com
Date:     2011-08-30 11:45:44 -0700 (Tue, 30 Aug 2011)
Log Message:
-----------
Allow per-user auto-schedule (off by default).

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/principals.py
    CalendarServer/trunk/calendarserver/webadmin/resource.py
    CalendarServer/trunk/twistedcaldav/directory/principal.py
    CalendarServer/trunk/twistedcaldav/scheduling/caldav.py
    CalendarServer/trunk/twistedcaldav/scheduling/processing.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py

Modified: CalendarServer/trunk/calendarserver/tools/principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/principals.py	2011-08-26 20:36:19 UTC (rev 8031)
+++ CalendarServer/trunk/calendarserver/tools/principals.py	2011-08-30 18:45:44 UTC (rev 8032)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 ##
-# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
+# Copyright (c) 2006-2011 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@
     print ""
     print "  Principals are identified by one of the following:"
     print "    Type and shortname (eg.: users:wsanchez)"
-   #print "    A principal path (eg.: /principals/users/wsanchez/)"
+    #print "    A principal path (eg.: /principals/users/wsanchez/)"
     print "    A GUID (eg.: E415DBA7-40B5-49F5-A7CC-ACC81E4DEC79)"
     print ""
     print "options:"
@@ -674,8 +674,12 @@
 
 @inlineCallbacks
 def action_setAutoSchedule(principal, autoSchedule):
-    if autoSchedule and principal.record.recordType in ("users", "groups"):
+    if principal.record.recordType == "groups":
         print "Enabling auto-schedule for %s is not allowed." % (principal,)
+        
+    elif principal.record.recordType == "users" and not config.Scheduling.Options.AllowUserAutoAccept:
+        print "Enabling auto-schedule for %s is not allowed." % (principal,)
+
     else:
         print "Setting auto-schedule to %s for %s" % (
             { True: "true", False: "false" }[autoSchedule],

Modified: CalendarServer/trunk/calendarserver/webadmin/resource.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/resource.py	2011-08-26 20:36:19 UTC (rev 8031)
+++ CalendarServer/trunk/calendarserver/webadmin/resource.py	2011-08-30 18:45:44 UTC (rev 8032)
@@ -1,6 +1,6 @@
 # -*- test-case-name: calendarserver.webadmin.test.test_resource -*-
 ##
-# Copyright (c) 2009-2010 Apple Inc. All rights reserved.
+# Copyright (c) 2009-2011 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -265,7 +265,9 @@
         Renderer which elides its tag for non-resource-type principals.
         """
         if (self.principalResource.record.recordType != "users" and
-            self.principalResource.record.recordType != "groups"):
+            self.principalResource.record.recordType != "groups" or
+            self.principalResource.record.recordType == "users" and
+            config.Scheduling.Options.AllowUserAutoAccept):
             return tag
         return ""
 
@@ -553,8 +555,10 @@
         if autoSchedule is not None and (autoSchedule == "true" or
                                          autoSchedule == "false"):
             if ( principal.record.recordType != "users" and
-                 principal.record.recordType != "groups"):
-                principal.setAutoSchedule(autoSchedule == "true")
+                 principal.record.recordType != "groups" or
+                 principal.record.recordType == "users" and
+                 config.Scheduling.Options.AllowUserAutoAccept):
+                (yield principal.setAutoSchedule(autoSchedule == "true"))
 
         # Update the proxies if specified.
         for proxyId in removeProxies:

Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py	2011-08-26 20:36:19 UTC (rev 8031)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py	2011-08-30 18:45:44 UTC (rev 8032)
@@ -205,7 +205,7 @@
         If property is a DAV property that maps to a directory field, return
         that field's name, otherwise return None
         """
-        field, converter, description, xmlClass = self._fieldMap.get(
+        field, converter, _ignore_description, _ignore_xmlClass = self._fieldMap.get(
             property.qname(), (None, None, None, None))
         if field is None:
             return (None, None)
@@ -215,7 +215,7 @@
 
     def principalSearchPropertySet(self):
         props = []
-        for field, converter, description, xmlClass in self._fieldMap.itervalues():
+        for _ignore_field, _ignore_converter, description, xmlClass in self._fieldMap.itervalues():
             props.append(
                 davxml.PrincipalSearchProperty(
                     davxml.PropertyContainer(
@@ -812,6 +812,9 @@
     def getAutoSchedule(self):
         return self.record.autoSchedule
 
+    def getCUType(self):
+        return self.record.getCUType()
+
     ##
     # Static
     ##

Modified: CalendarServer/trunk/twistedcaldav/scheduling/caldav.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/caldav.py	2011-08-26 20:36:19 UTC (rev 8031)
+++ CalendarServer/trunk/twistedcaldav/scheduling/caldav.py	2011-08-30 18:45:44 UTC (rev 8032)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2005-2010 Apple Inc. All rights reserved.
+# Copyright (c) 2005-2011 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -150,7 +150,7 @@
         # Do implicit scheduling message processing.
         try:
             processor = ImplicitProcessor()
-            _ignore_processed, autoprocessed, changes = (yield processor.doImplicitProcessing(
+            _ignore_processed, autoprocessed, store_inbox, changes = (yield processor.doImplicitProcessing(
                 self.scheduler.request,
                 self.scheduler.calendar,
                 self.scheduler.originator,
@@ -166,14 +166,7 @@
             responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=e.msg)
             returnValue(False)
 
-        if autoprocessed:
-            # No need to write the inbox item as it has already been auto-processed
-            responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.MESSAGE_DELIVERED)
-            if not hasattr(self.scheduler.request, "extendedLogItems"):
-                self.scheduler.request.extendedLogItems = {}
-            self.scheduler.request.extendedLogItems["itip.auto"] = self.scheduler.request.extendedLogItems.get("itip.auto", 0) + 1
-            returnValue(True)
-        else:
+        if store_inbox:
             # Copy calendar to inbox 
             try:
                 from twistedcaldav.method.put_common import StoreCalendarObjectResource
@@ -198,8 +191,6 @@
                 responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_AUTHORITY)
                 returnValue(False)
             else:
-                responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.MESSAGE_DELIVERED)
-    
                 # Store CALDAV:originator property
                 child.writeDeadProperty(caldavxml.Originator(davxml.HRef(self.scheduler.originator.cuaddr)))
             
@@ -209,9 +200,14 @@
                 # Store CS:schedule-changes property if present
                 if changes:
                     child.writeDeadProperty(changes)
-                    
-                returnValue(True)
-    
+
+        responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.MESSAGE_DELIVERED)
+        if autoprocessed:
+            if not hasattr(self.scheduler.request, "extendedLogItems"):
+                self.scheduler.request.extendedLogItems = {}
+            self.scheduler.request.extendedLogItems["itip.auto"] = self.scheduler.request.extendedLogItems.get("itip.auto", 0) + 1
+        returnValue(True)
+
     @inlineCallbacks
     def generateFreeBusyResponse(self, recipient, responses, organizerProp, organizerPrincipal, uid):
 

Modified: CalendarServer/trunk/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/processing.py	2011-08-26 20:36:19 UTC (rev 8031)
+++ CalendarServer/trunk/twistedcaldav/scheduling/processing.py	2011-08-30 18:45:44 UTC (rev 8032)
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005-2010 Apple Inc. All rights reserved.
+# Copyright (c) 2005-2011 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -152,7 +152,7 @@
         yield self.getRecipientsCopy()
         if self.recipient_calendar is None:
             log.debug("ImplicitProcessing - originator '%s' to recipient '%s' ignoring UID: '%s' - organizer has no copy" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
-            returnValue((True, True, None,))
+            returnValue((True, True, False, None,))
 
         # Handle new items differently than existing ones.
         if self.method == "REPLY":
@@ -160,7 +160,7 @@
         elif self.method == "REFRESH":
             # With implicit we ignore refreshes.
             # TODO: for iMIP etc we do need to handle them 
-            result = (True, True, None,)
+            result = (True, True, False, None,)
 
         returnValue(result)
 
@@ -206,11 +206,11 @@
             if partstatChanged:
                 yield self.queueAttendeeUpdate(recipient_calendar_resource, (attendeeReplying,))
 
-            result = (True, False, changes,)
+            result = (True, False, True, changes,)
 
         else:
             # Ignore scheduling message
-            result = (True, True, None,)
+            result = (True, True, False, None,)
 
         returnValue(result)
 
@@ -301,7 +301,7 @@
 
         # Handle new items differently than existing ones.
         if self.new_resource and self.method == "CANCEL":
-            result = (True, True, None)
+            result = (True, True, False, None)
         else:
             result = (yield self.doImplicitAttendeeUpdate())
         
@@ -327,10 +327,10 @@
             result = (yield self.doImplicitAttendeeCancel())
         elif self.method == "ADD":
             # TODO: implement ADD
-            result = (False, False, None)
+            result = (False, False, False, None)
         else:
             # NB We should never get here as we will have rejected unsupported METHODs earlier.
-            result = (True, True, None,)
+            result = (True, True, False, None,)
             
         returnValue(result)
 
@@ -355,6 +355,7 @@
 
             log.debug("ImplicitProcessing - originator '%s' to recipient '%s' processing METHOD:REQUEST, UID: '%s' - new processed" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
             autoprocessed = self.recipient.principal.getAutoSchedule()
+            store_inbox = not autoprocessed or self.recipient.principal.getCUType() == "INDIVIDUAL"
             new_calendar = iTipProcessing.processNewRequest(self.message, self.recipient.cuaddr, autoprocessing=autoprocessed)
             name =  md5(str(new_calendar) + str(time.time()) + defaultURL).hexdigest() + ".ics"
             
@@ -379,10 +380,11 @@
                     customxml.Create(),
                 ),
             )
-            result = (True, autoprocessed, changes,)
+            result = (True, autoprocessed, store_inbox, changes,)
         else:
             # Processing update to existing event
             autoprocessed = self.recipient.principal.getAutoSchedule()
+            store_inbox = not autoprocessed or self.recipient.principal.getCUType() == "INDIVIDUAL"
             new_calendar, rids = iTipProcessing.processRequest(self.message, self.recipient_calendar, self.recipient.cuaddr, autoprocessing=autoprocessed)
             if new_calendar:
      
@@ -427,13 +429,14 @@
                 # Refresh from another Attendee should not have Inbox item
                 if hasattr(self.request, "doing_attendee_refresh"):
                     autoprocessed = True
+                    store_inbox = False
 
-                result = (True, autoprocessed, changes,)
+                result = (True, autoprocessed, store_inbox, changes,)
                 
             else:
                 # Request needs to be ignored
                 log.debug("ImplicitProcessing - originator '%s' to recipient '%s' processing METHOD:REQUEST, UID: '%s' - ignoring" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
-                result = (True, True, None,)
+                result = (True, True, False, None,)
 
         returnValue(result)
 
@@ -447,8 +450,11 @@
             result = (True, True, None)
         else:
             # Need to check for auto-respond attendees. These need to suppress the inbox message
-            # if the cancel is processed.
-            autoprocessed = self.recipient.principal.getAutoSchedule()
+            # if the cancel is processed. However, if the principal is a user we always force the
+            # inbox item on them even if auto-schedule is true so that they get a notification
+            # of the cancel.
+            autoprocessed = self.recipient.principal.getAutoSchedule() and self.recipient.principal.getCUType() != "INDIVIDUAL"
+            store_inbox = not autoprocessed or self.recipient.principal.getCUType() == "INDIVIDUAL"
 
             # Check to see if this is a cancel of the entire event
             processed_message, delete_original, rids = iTipProcessing.processCancel(self.message, self.recipient_calendar, autoprocessing=autoprocessed)
@@ -466,7 +472,7 @@
                             customxml.Cancel(),
                         ),
                     )
-                    result = (True, autoprocessed, changes,)
+                    result = (True, autoprocessed, store_inbox, changes,)
                     
                 else:
          
@@ -485,10 +491,10 @@
                         customxml.DTStamp(),
                         customxml.Action(action),
                     )
-                    result = (True, autoprocessed, changes)
+                    result = (True, autoprocessed, store_inbox, changes)
             else:
                 log.debug("ImplicitProcessing - originator '%s' to recipient '%s' processing METHOD:CANCEL, UID: '%s' - ignoring" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
-                result = (True, True, None)
+                result = (True, True, False, None)
 
         returnValue(result)
 

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2011-08-26 20:36:19 UTC (rev 8031)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2011-08-30 18:45:44 UTC (rev 8032)
@@ -599,6 +599,7 @@
             "AllowGroupAsOrganizer"      : False, # Allow groups to be Organizers
             "AllowLocationAsOrganizer"   : False, # Allow locations to be Organizers
             "AllowResourceAsOrganizer"   : False, # Allow resources to be Organizers
+            "AllowUserAutoAccept"        : False, # Allow auto-accept for users
             "LimitFreeBusyAttendees"     : 30,    # Maximum number of attendees to request freebusy for
             "AttendeeRefreshInterval"    : 0,     # Time after an iTIP REPLY at which attendee refresh will trigger 
         }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110830/974e218b/attachment-0001.html>


More information about the calendarserver-changes mailing list