[CalendarServer-changes] [2863] CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/ scheduling

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 25 18:44:52 PDT 2008


Revision: 2863
          http://trac.macosforge.org/projects/calendarserver/changeset/2863
Author:   cdaboo at apple.com
Date:     2008-08-25 18:44:52 -0700 (Mon, 25 Aug 2008)
Log Message:
-----------
Make sure changes by one attendee are reflected to all other attendees.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/implicit.py
    CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/itip.py
    CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/processing.py
    CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/scheduler.py

Modified: CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/implicit.py	2008-08-25 23:06:05 UTC (rev 2862)
+++ CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/implicit.py	2008-08-26 01:44:52 UTC (rev 2863)
@@ -69,7 +69,7 @@
         self.calendar = calendar
         self.calendar_owner = (yield self.resource.owner(self.request))
         self.deleting = deleting
-
+.
         # When deleting we MUST have the calendar as the actual resource
         # will have been deleted by now
         assert deleting and calendar or not deleting
@@ -87,6 +87,31 @@
 
         returnValue(self.calendar)
 
+    def refreshAllAttendeesExceptSome(self, request, resource, calendar, attendees):
+        """
+        
+        @param request:
+        @type request:
+        @param attendee:
+        @type attendee:
+        @param calendar:
+        @type calendar:
+        """
+
+        self.request = request
+        self.resource = resource
+        self.calendar = calendar
+        self.calendar_owner = None
+        self.deleting = False
+        self.internal_request = True
+        self.except_attendees = attendees
+        
+        # Get some useful information from the calendar
+        self.extractCalendarData()
+        self.organizerPrincipal = self.resource.principalForCalendarUserAddress(self.organizer)
+        
+        return self.processRequests()
+
     def extractCalendarData(self):
         
         # Get the ORGANIZER and verify it is the same for all components
@@ -298,7 +323,7 @@
     
             # Do the PUT processing
             log.info("Implicit CANCEL - organizer: '%s' to attendee: '%s', UID: '%s', RIDs: '%s'" % (self.organizer, attendee, self.uid, rids))
-            response = (yield scheduler.doSchedulingViaPUT(self.organizer, (attendee,), itipmsg))
+            response = (yield scheduler.doSchedulingViaPUT(self.organizer, (attendee,), itipmsg, self.internal_request))
             self.handleSchedulingResponse(response, True)
             
     @inlineCallbacks
@@ -314,6 +339,10 @@
             if attendee in self.organizerPrincipal.calendarUserAddresses():
                 continue
 
+            # Don't send message to specified attendees
+            if attendee in self.except_attendees:
+                continue
+
             itipmsg = iTipGenerator.generateAttendeeRequest(self.calendar, (attendee,))
 
             # Send scheduling message
@@ -323,7 +352,7 @@
     
             # Do the PUT processing
             log.info("Implicit REQUEST - organizer: '%s' to attendee: '%s', UID: '%s'" % (self.organizer, attendee, self.uid,))
-            response = (yield scheduler.doSchedulingViaPUT(self.organizer, (attendee,), itipmsg))
+            response = (yield scheduler.doSchedulingViaPUT(self.organizer, (attendee,), itipmsg, self.internal_request))
             self.handleSchedulingResponse(response, True)
 
     def handleSchedulingResponse(self, response, is_organizer):
@@ -439,5 +468,5 @@
 
         # Do the PUT processing
         log.info("Implicit %s - attendee: '%s' to organizer: '%s', UID: '%s'" % (action, self.attendee, self.organizer, self.uid,))
-        response = (yield scheduler.doSchedulingViaPUT(self.attendee, (self.organizer,), itipmsg))
+        response = (yield scheduler.doSchedulingViaPUT(self.attendee, (self.organizer,), itipmsg, self.internal_request))
         self.handleSchedulingResponse(response, False)

Modified: CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/itip.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/itip.py	2008-08-25 23:06:05 UTC (rev 2862)
+++ CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/itip.py	2008-08-26 01:44:52 UTC (rev 2863)
@@ -217,8 +217,9 @@
         # Do the master first
         old_master = calendar.masterComponent()
         new_master = itip_message.masterComponent()
+        attendees = set()
         if new_master:
-            iTipProcessing.updateAttendeePartStat(new_master, old_master)
+            attendees.add(iTipProcessing.updateAttendeePartStat(new_master, old_master))
 
         # Now do all overridden ones
         for itip_component in itip_message.subcomponents():
@@ -238,9 +239,9 @@
                 match_component = calendar.deriveInstance(rid)
                 calendar.addComponent(match_component)
 
-            iTipProcessing.updateAttendeePartStat(itip_component, match_component)
+            attendees.add(iTipProcessing.updateAttendeePartStat(itip_component, match_component))
                 
-        return True
+        return True, attendees
 
     @staticmethod
     def updateAttendeePartStat(from_component, to_component):
@@ -264,6 +265,8 @@
         existing_attendee = to_component.getAttendeeProperty((attendee.value(),))
         if existing_attendee:
             existing_attendee.params().setdefault("PARTSTAT", [partstat])[0] = partstat
+            
+        return attendee.value()
 
     @staticmethod
     def transferAlarms(from_calendar, master_valarms, to_component, remove_matched=False):

Modified: CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/processing.py	2008-08-25 23:06:05 UTC (rev 2862)
+++ CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/processing.py	2008-08-26 01:44:52 UTC (rev 2863)
@@ -146,15 +146,16 @@
     @inlineCallbacks
     def doImplicitOrganizerUpdate(self):
         
-        # Check to see if this is a cancel of the entire event
-        if iTipProcessing.processReply(self.message, self.recipient_calendar):
+        # Check to see if this is a valid reply
+        result, processed_attendees = iTipProcessing.processReply(self.message, self.recipient_calendar)
+        if result:
  
             # Update the attendee's copy of the event
             log.debug("ImplicitProcessing - originator '%s' to recipient '%s' processing METHOD:REPLY, UID: '%s' - updating event" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
-            yield self.writeCalendarResource(self.recipient_calendar_collection_uri, self.recipient_calendar_collection, self.recipient_calendar_name, self.recipient_calendar)
+            recipient_calendar_resource = (yield self.writeCalendarResource(self.recipient_calendar_collection_uri, self.recipient_calendar_collection, self.recipient_calendar_name, self.recipient_calendar))
             result = (True, False,)
             
-            # TODO: Send out a request to all attendees to update them
+            self.updateAllAttendeesExceptSome(recipient_calendar_resource, processed_attendees)
 
         else:
             # Ignore scheduling message
@@ -162,6 +163,19 @@
 
         returnValue(result)
 
+    def updateAllAttendeesExceptSome(self, resource, attendees):
+        """
+        Send an update out to all attendees except the specified ones, to refresh the others due to a change
+        by that one.
+        
+        @param attendee: cu-addresses of attendees not to send to
+        @type attendee: C{set}
+        """
+        
+        from twistedcaldav.scheduling.implicit import ImplicitScheduler
+        scheduler = ImplicitScheduler()
+        scheduler.refreshAllAttendeesExceptSome(self.request, resource, self.recipient_calendar, attendees)
+
     @inlineCallbacks
     def doImplicitAttendee(self):
 

Modified: CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/scheduler.py	2008-08-25 23:06:05 UTC (rev 2862)
+++ CalendarServer/branches/users/cdaboo/implicit-2805/twistedcaldav/scheduling/scheduler.py	2008-08-26 01:44:52 UTC (rev 2863)
@@ -69,6 +69,7 @@
         self.excludeUID = None
         self.fakeTheResult = False
         self.method = "Unknown"
+        self.internal_request = False
     
     @inlineCallbacks
     def doSchedulingViaPOST(self):
@@ -90,7 +91,7 @@
         returnValue(result)
 
     @inlineCallbacks
-    def doSchedulingViaPUT(self, originator, recipients, calendar):
+    def doSchedulingViaPUT(self, originator, recipients, calendar, internal_request=False):
         """
         The implicit scheduling PUT operation.
         """
@@ -104,6 +105,7 @@
         self.originator = originator
         self.recipients = recipients
         self.calendar = calendar
+        self.internal_request = internal_request
 
         result = (yield self.doScheduling())
         returnValue(result)
@@ -370,7 +372,7 @@
 
     def checkAuthorization(self):
         # Must have an authenticated user
-        if self.resource.currentPrincipal(self.request) == davxml.Principal(davxml.Unauthenticated()):
+        if not self.internal_request and self.resource.currentPrincipal(self.request) == davxml.Principal(davxml.Unauthenticated()):
             log.err("Unauthenticated originators not allowed: %s" % (self.originator,))
             raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
 
@@ -392,11 +394,13 @@
                 log.err("Could not find inbox for originator: %s" % (self.originator,))
                 raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
         
-            # Verify that Originator matches the authenticated user.
-            authn_principal = self.resource.currentPrincipal(self.request)
-            if davxml.Principal(davxml.HRef(originatorPrincipal.principalURL())) != authn_principal:
-                log.err("Originator: %s does not match authorized user: %s" % (self.originator, authn_principal.children[0],))
-                raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+            # Verify that Originator matches the authenticated user, but not if this is a server
+            # generated request
+            if not self.internal_request:
+                authn_principal = self.resource.currentPrincipal(self.request)
+                if davxml.Principal(davxml.HRef(originatorPrincipal.principalURL())) != authn_principal:
+                    log.err("Originator: %s does not match authorized user: %s" % (self.originator, authn_principal.children[0],))
+                    raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
 
             self.originator = LocalCalendarUser(self.originator, originatorPrincipal)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080825/abdbca9e/attachment-0001.html 


More information about the calendarserver-changes mailing list