imip-agent

Change of imiptools/handlers/person_outgoing.py

140:33a8c753637c
imiptools/handlers/person_outgoing.py
     1.1 --- a/imiptools/handlers/person_outgoing.py	Thu Dec 18 22:18:53 2014 +0100
     1.2 +++ b/imiptools/handlers/person_outgoing.py	Thu Dec 18 23:24:56 2014 +0100
     1.3 @@ -12,17 +12,32 @@
     1.4  
     1.5      "Handling mechanisms specific to people."
     1.6  
     1.7 -    def _record(self, objtype, from_organiser=True, update_freebusy=False):
     1.8 +    def _get_identity(self, objtype, from_organiser=True):
     1.9  
    1.10 -        # Get the identity of interest in a usable form.
    1.11 +        """
    1.12 +        Get the identity of interest in a usable form for any unprocessed
    1.13 +        object.
    1.14 +        """
    1.15  
    1.16 -        identity, attr = uri_item(self.get_item(from_organiser and "ORGANIZER" or "ATTENDEE"))
    1.17 +        identity, attr = item = uri_item(self.get_item(from_organiser and "ORGANIZER" or "ATTENDEE"))
    1.18  
    1.19          # Check for event using UID.
    1.20  
    1.21          if not self.have_new_object(identity, objtype):
    1.22 +            return None
    1.23 +
    1.24 +        return item
    1.25 +
    1.26 +    def _record(self, objtype, from_organiser=True, update_freebusy=False):
    1.27 +
    1.28 +        "Record free/busy and object information."
    1.29 +
    1.30 +        item = self._get_identity(objtype, from_organiser)
    1.31 +        if not item:
    1.32              return False
    1.33  
    1.34 +        identity, attr = item
    1.35 +
    1.36          # Store the object.
    1.37  
    1.38          self.store.set_event(identity, self.uid, to_node(
    1.39 @@ -49,6 +64,21 @@
    1.40  
    1.41          return True
    1.42  
    1.43 +    def _remove(self, objtype, from_organiser=True):
    1.44 +
    1.45 +        "Remove free/busy information for any unprocessed object."
    1.46 +
    1.47 +        item = self._get_identity(objtype, from_organiser)
    1.48 +        if not item:
    1.49 +            return False
    1.50 +
    1.51 +        identity, attr = item
    1.52 +
    1.53 +        freebusy = self.store.get_freebusy(identity) or []
    1.54 +        self.remove_from_freebusy(freebusy, identity)
    1.55 +
    1.56 +        return True
    1.57 +
    1.58  class Event(PersonHandler):
    1.59  
    1.60      "An event handler."
    1.61 @@ -57,7 +87,7 @@
    1.62          pass
    1.63  
    1.64      def cancel(self):
    1.65 -        pass
    1.66 +        self._remove("VEVENT", True)
    1.67  
    1.68      def counter(self):
    1.69          pass
    1.70 @@ -98,7 +128,7 @@
    1.71          pass
    1.72  
    1.73      def cancel(self):
    1.74 -        pass
    1.75 +        self._remove("VJOURNAL", True)
    1.76  
    1.77      def publish(self):
    1.78          self._record("VJOURNAL", True)
    1.79 @@ -111,7 +141,7 @@
    1.80          pass
    1.81  
    1.82      def cancel(self):
    1.83 -        pass
    1.84 +        self._remove("VTODO", True)
    1.85  
    1.86      def counter(self):
    1.87          pass