1.1 --- a/imiptools/content.py Thu Mar 05 15:26:50 2015 +0100
1.2 +++ b/imiptools/content.py Thu Mar 05 16:30:13 2015 +0100
1.3 @@ -28,7 +28,8 @@
1.4 is_new_object, uri_dict, uri_item, uri_values
1.5 from imiptools.dates import format_datetime, get_default_timezone, to_timezone
1.6 from imiptools.period import can_schedule, insert_period, remove_period, \
1.7 - remove_affected_period, update_freebusy
1.8 + remove_additional_periods, remove_affected_period, \
1.9 + update_freebusy
1.10 from imiptools.profile import Preferences
1.11 from socket import gethostname
1.12 import imip_store
1.13 @@ -172,15 +173,19 @@
1.14
1.15 remove_period(freebusy, self.uid, self.recurrenceid)
1.16
1.17 - def remove_freebusy_for_original_recurrence(self, freebusy):
1.18 + def remove_freebusy_for_recurrences(self, freebusy):
1.19
1.20 """
1.21 - Remove from 'freebusy' any specific recurrence from parent free/busy
1.22 - details for the current object.
1.23 + Remove from 'freebusy' any original recurrence from parent free/busy
1.24 + details for the current object, if the current object is a specific
1.25 + additional recurrence. Otherwise, remove all additional recurrence
1.26 + information.
1.27 """
1.28
1.29 if self.recurrenceid:
1.30 remove_affected_period(freebusy, self.uid, self.recurrenceid)
1.31 + else:
1.32 + remove_additional_periods(freebusy, self.uid)
1.33
1.34 def _update_freebusy(self, freebusy, periods, recurrenceid, transp=None):
1.35
1.36 @@ -242,12 +247,7 @@
1.37 self.update_freebusy_for_participant(freebusy, periods, participant_attr,
1.38 for_organiser and self.is_not_attendee(participant, self.obj))
1.39
1.40 - # Subtract any recurrences from the free/busy details of a parent
1.41 - # object.
1.42 -
1.43 - for recurrenceid in self.store.get_recurrences(user, self.uid):
1.44 - remove_affected_period(freebusy, self.uid, recurrenceid)
1.45 -
1.46 + self.remove_freebusy_for_recurrences(freebusy)
1.47 self.store.set_freebusy_for_other(user, freebusy, participant)
1.48
1.49 def update_freebusy_from_organiser(self, attendee, organiser_item):
2.1 --- a/imiptools/handlers/person.py Thu Mar 05 15:26:50 2015 +0100
2.2 +++ b/imiptools/handlers/person.py Thu Mar 05 16:30:13 2015 +0100
2.3 @@ -49,10 +49,15 @@
2.4 if not self.have_new_object(attendee):
2.5 continue
2.6
2.7 - # Set the complete event if not an additional occurrence.
2.8 + # Set the complete event or an additional occurrence.
2.9
2.10 self.store.set_event(attendee, self.uid, self.recurrenceid, self.obj.to_node())
2.11
2.12 + # Remove additional recurrences if handling a complete event.
2.13 +
2.14 + if not self.recurrenceid:
2.15 + self.store.remove_recurrences(attendee, self.uid)
2.16 +
2.17 # Queue any request.
2.18
2.19 if queue:
3.1 --- a/imiptools/handlers/person_outgoing.py Thu Mar 05 15:26:50 2015 +0100
3.2 +++ b/imiptools/handlers/person_outgoing.py Thu Mar 05 16:30:13 2015 +0100
3.3 @@ -62,6 +62,11 @@
3.4
3.5 self.store.set_event(identity, self.uid, self.recurrenceid, self.obj.to_node())
3.6
3.7 + # Remove additional recurrences if handling a complete event.
3.8 +
3.9 + if not self.recurrenceid:
3.10 + self.store.remove_recurrences(identity, self.uid)
3.11 +
3.12 else:
3.13 organiser_item, attendees = self.require_organiser_and_attendees(from_organiser)
3.14 self.merge_attendance(attendees, identity)
3.15 @@ -82,8 +87,7 @@
3.16
3.17 # Use the stored event in case the reply is incomplete, as is seen
3.18 # when Claws sends a REPLY for an object originally employing
3.19 - # recurrence information. Additionally, parent object details will
3.20 - # also be consulted if available.
3.21 + # recurrence information.
3.22
3.23 obj = self.get_object(identity)
3.24
3.25 @@ -95,12 +99,11 @@
3.26 self.update_freebusy_for_participant(freebusy, periods, attr,
3.27 from_organiser and self.is_not_attendee(identity, obj))
3.28
3.29 - # Subtract any recurrences from the free/busy details of a parent
3.30 - # object.
3.31 + # Remove either original recurrence or additional recurrence
3.32 + # details depending on whether an additional recurrence or a
3.33 + # complete event are being handled, respectively.
3.34
3.35 - for recurrenceid in self.store.get_recurrences(identity, self.uid):
3.36 - remove_affected_period(freebusy, self.uid, recurrenceid)
3.37 -
3.38 + self.remove_freebusy_for_recurrences(freebusy)
3.39 self.store.set_freebusy(identity, freebusy)
3.40
3.41 if self.publisher:
4.1 --- a/imiptools/handlers/resource.py Thu Mar 05 15:26:50 2015 +0100
4.2 +++ b/imiptools/handlers/resource.py Thu Mar 05 16:30:13 2015 +0100
4.3 @@ -88,6 +88,11 @@
4.4 event = self.obj.to_node()
4.5 self.store.set_event(attendee, self.uid, self.recurrenceid, event)
4.6
4.7 + # Remove additional recurrences if handling a complete event.
4.8 +
4.9 + if not self.recurrenceid:
4.10 + self.store.remove_recurrences(attendee, self.uid)
4.11 +
4.12 # Only update free/busy details if the event is scheduled.
4.13
4.14 if scheduled:
4.15 @@ -95,12 +100,11 @@
4.16 else:
4.17 self.remove_from_freebusy(freebusy)
4.18
4.19 - # Subtract any recurrences from the free/busy details of a parent
4.20 - # object.
4.21 + # Remove either original recurrence or additional recurrence
4.22 + # details depending on whether an additional recurrence or a
4.23 + # complete event are being handled, respectively.
4.24
4.25 - for recurrenceid in self.store.get_recurrences(attendee, self.uid):
4.26 - remove_affected_period(freebusy, self.uid, recurrenceid)
4.27 -
4.28 + self.remove_freebusy_for_recurrences(freebusy)
4.29 self.store.set_freebusy(attendee, freebusy)
4.30
4.31 if self.publisher:
5.1 --- a/imiptools/period.py Thu Mar 05 15:26:50 2015 +0100
5.2 +++ b/imiptools/period.py Thu Mar 05 16:30:13 2015 +0100
5.3 @@ -82,6 +82,21 @@
5.4 else:
5.5 i += 1
5.6
5.7 +def remove_additional_periods(freebusy, uid):
5.8 +
5.9 + """
5.10 + Remove from 'freebusy' all periods associated with 'uid' having a
5.11 + recurrence identifier indicating an additional or modified period.
5.12 + """
5.13 +
5.14 + i = 0
5.15 + while i < len(freebusy):
5.16 + t = freebusy[i]
5.17 + if len(t) >= 5 and t[2] == uid and t[4]:
5.18 + del freebusy[i]
5.19 + else:
5.20 + i += 1
5.21 +
5.22 def remove_affected_period(freebusy, uid, recurrenceid):
5.23
5.24 """