1.1 --- a/imiptools/handlers/person_outgoing.py Tue May 19 23:40:57 2015 +0200
1.2 +++ b/imiptools/handlers/person_outgoing.py Wed May 20 13:41:23 2015 +0200
1.3 @@ -22,25 +22,27 @@
1.4
1.5 from imiptools.data import uri_dict, uri_item, uri_values
1.6 from imiptools.handlers import Handler
1.7 +from imiptools.handlers.common import Outgoing
1.8
1.9 -class PersonHandler(Handler):
1.10 +class PersonHandler(Handler, Outgoing):
1.11
1.12 "Handling mechanisms specific to people."
1.13
1.14 def set_identity(self, from_organiser=True):
1.15
1.16 """
1.17 - Set the current user for the current object.
1.18 + Set the current user for the current object. It is usually set when
1.19 + initialising the handler, using the recipient details, but outgoing
1.20 + messages do not reference the recipient in this way.
1.21 """
1.22
1.23 self.user, attr = uri_item(self.obj.get_item(from_organiser and "ORGANIZER" or "ATTENDEE"))
1.24
1.25 - def _record(self, from_organiser=True, update_freebusy=False):
1.26 + def _record(self, from_organiser=True):
1.27
1.28 """
1.29 Record details from the current object given a message originating
1.30 - from an organiser if 'from_organiser' is set to a true value, updating
1.31 - free/busy information if 'update_freebusy' is set to a true value.
1.32 + from an organiser if 'from_organiser' is set to a true value.
1.33 """
1.34
1.35 self.set_identity(from_organiser)
1.36 @@ -76,44 +78,16 @@
1.37
1.38 # Update free/busy information.
1.39
1.40 - if update_freebusy:
1.41 -
1.42 - freebusy = self.store.get_freebusy(self.user)
1.43 -
1.44 - # Use the stored event in case the reply is incomplete, as is seen
1.45 - # when Claws sends a REPLY for an object originally employing
1.46 - # recurrence information.
1.47 -
1.48 - obj = self.get_object()
1.49 - if not obj:
1.50 - return False # although this should not happen
1.51 -
1.52 - # If newer than any old version, discard old details from the
1.53 - # free/busy record and check for suitability.
1.54 -
1.55 - # Interpretation of periods can depend on the time zone.
1.56 -
1.57 - periods = obj.get_periods(self.get_tzid(), self.get_window_end())
1.58 -
1.59 - # Obtain the attendance attributes for this user, if available.
1.60 -
1.61 - attendees = uri_dict(self.obj.get_value_map("ATTENDEE"))
1.62 - self.update_freebusy_for_participant(freebusy, periods, attendees.get(self.user), from_organiser)
1.63 -
1.64 - # Remove original recurrence details replaced by additional
1.65 - # recurrences, as well as obsolete additional recurrences.
1.66 -
1.67 - self.remove_freebusy_for_recurrences(freebusy, self.store.get_recurrences(self.user, self.uid))
1.68 - self.store.set_freebusy(self.user, freebusy)
1.69 -
1.70 - if self.publisher and self.is_sharing():
1.71 - self.publisher.set_freebusy(self.user, freebusy)
1.72 + self.update_event_in_freebusy()
1.73
1.74 return True
1.75
1.76 - def _remove(self, from_organiser=True, update_freebusy=False):
1.77 + def _remove(self, from_organiser=True):
1.78
1.79 - "Remove free/busy information for any unprocessed object."
1.80 + """
1.81 + Remove details from the current object given a message originating
1.82 + from an organiser if 'from_organiser' is set to a true value.
1.83 + """
1.84
1.85 self.set_identity(from_organiser)
1.86
1.87 @@ -168,16 +142,8 @@
1.88
1.89 # Update free/busy information.
1.90
1.91 - if update_freebusy:
1.92 - freebusy = self.store.get_freebusy(self.user)
1.93 - self.remove_from_freebusy(freebusy)
1.94 - self.remove_freebusy_for_recurrences(freebusy)
1.95 -
1.96 - if cancel_entire_event or self.user in given_attendees:
1.97 - self.store.set_freebusy(self.user, freebusy)
1.98 -
1.99 - if self.publisher and self.is_sharing():
1.100 - self.publisher.set_freebusy(self.user, freebusy)
1.101 + if cancel_entire_event or self.user in given_attendees:
1.102 + self.remove_event_from_freebusy()
1.103
1.104 return True
1.105
1.106 @@ -189,7 +155,7 @@
1.107 pass
1.108
1.109 def cancel(self):
1.110 - self._remove(True, True)
1.111 + self._remove(True)
1.112
1.113 def counter(self):
1.114 pass
1.115 @@ -198,16 +164,16 @@
1.116 pass
1.117
1.118 def publish(self):
1.119 - self._record(True, True)
1.120 + self._record(True)
1.121
1.122 def refresh(self):
1.123 pass
1.124
1.125 def reply(self):
1.126 - self._record(False, True)
1.127 + self._record(False)
1.128
1.129 def request(self):
1.130 - self._record(True, True)
1.131 + self._record(True)
1.132
1.133 # Handler registry.
1.134