1.1 --- a/imip_store.py Wed Aug 12 18:23:24 2015 +0200
1.2 +++ b/imip_store.py Wed Aug 12 22:40:50 2015 +0200
1.3 @@ -348,6 +348,11 @@
1.4 """
1.5 Return a set of uncancelled events of the form (uid, recurrenceid)
1.6 providing free/busy details beyond the given datetime 'dt'.
1.7 +
1.8 + If 'dt' is not specified, all events previously found to provide
1.9 + details will be returned. Otherwise, if 'dt' is earlier than the
1.10 + datetime recorded for the known providers, None is returned, indicating
1.11 + that the list of providers must be recomputed.
1.12 """
1.13
1.14 filename = self.get_object_in_store(user, "freebusy-providers")
1.15 @@ -375,6 +380,25 @@
1.16
1.17 return t[1:]
1.18
1.19 + def set_freebusy_providers(self, user, dt, providers):
1.20 +
1.21 + """
1.22 + Define the uncancelled events providing free/busy details beyond the
1.23 + given datetime 'dt'.
1.24 + """
1.25 +
1.26 + t = [(format_datetime(dt),)]
1.27 +
1.28 + for obj in providers:
1.29 + t.append((obj.get_uid(), obj.get_recurrenceid() or ""))
1.30 +
1.31 + filename = self.get_object_in_store(user, "freebusy-providers")
1.32 + if not filename:
1.33 + return False
1.34 +
1.35 + self._set_table(user, filename, t)
1.36 + return True
1.37 +
1.38 # Free/busy period access.
1.39
1.40 def get_freebusy(self, user):
2.1 --- a/tools/make_freebusy.py Wed Aug 12 18:23:24 2015 +0200
2.2 +++ b/tools/make_freebusy.py Wed Aug 12 22:40:50 2015 +0200
2.3 @@ -24,7 +24,8 @@
2.4 from bisect import bisect_left
2.5 from codecs import getwriter
2.6 from imiptools.data import get_window_end, Object
2.7 -from imiptools.dates import get_default_timezone
2.8 +from imiptools.dates import get_default_timezone, to_utc_datetime
2.9 +from imiptools.period import insert_period
2.10 from imiptools.profile import Preferences
2.11 from imip_store import FileStore, FilePublisher
2.12 import sys
2.13 @@ -38,10 +39,11 @@
2.14 try:
2.15 user = sys.argv[1]
2.16 args = sys.argv[2:]
2.17 - participant = args and args[0] not in ("-n", "-s", "-v") and args[0] or user
2.18 + participant = args and args[0] not in ("-n", "-s", "-v", "-r") and args[0] or user
2.19 store_and_publish = "-s" in args
2.20 include_needs_action = "-n" in args
2.21 verbose = "-v" in args
2.22 + reset_updated_list = "-r" in args
2.23 except IndexError:
2.24 print >>sys.stderr, """\
2.25 Need a user and an optional participant (if different from the user),
2.26 @@ -67,7 +69,7 @@
2.27 # providing free/busy periods at the end of the given time window, or from
2.28 # a list of all events.
2.29
2.30 - all_events = store.get_freebusy_providers(user, window_end)
2.31 + all_events = not reset_updated_list and store.get_freebusy_providers(user, window_end)
2.32
2.33 if not all_events:
2.34 all_events = store.get_active_events(user)
2.35 @@ -100,11 +102,7 @@
2.36 if obj.get_participation(partstat, include_needs_action):
2.37 for p in obj.get_active_periods(recurrenceids, tzid, window_end):
2.38 fbp = obj.get_freebusy_period(p, partstat == "ORG")
2.39 - i = bisect_left(fb, fbp)
2.40 - if i == len(fb):
2.41 - fb.append(fbp)
2.42 - elif fb[i] != fbp:
2.43 - fb.insert(i, fbp)
2.44 + insert_period(fb, fbp)
2.45
2.46 # Store and publish the free/busy collection.
2.47
2.48 @@ -112,6 +110,7 @@
2.49 if user == participant:
2.50 store.set_freebusy(user, fb)
2.51 publisher.set_freebusy(user, fb)
2.52 + store.set_freebusy_providers(user, to_utc_datetime(window_end, tzid), [obj for obj in objs if obj.possibly_active_from(window_end, tzid)])
2.53 else:
2.54 store.set_freebusy_for_other(user, fb, participant)
2.55 else: