1.1 --- a/imip_store.py Tue Sep 08 00:23:49 2015 +0200
1.2 +++ b/imip_store.py Tue Sep 08 00:26:45 2015 +0200
1.3 @@ -629,6 +629,56 @@
1.4
1.5 release_freebusy = release_lock
1.6
1.7 + # Tentative free/busy periods related to countering.
1.8 +
1.9 + def get_freebusy_offers(self, user):
1.10 +
1.11 + "Get free/busy offers for the given 'user'."
1.12 +
1.13 + offers = []
1.14 + expired = []
1.15 + now = datetime.now()
1.16 +
1.17 + # Expire old offers and save the collection if modified.
1.18 +
1.19 + l = self.get_freebusy_for_update(user, "freebusy-offers")
1.20 + try:
1.21 + for fb in l:
1.22 + if fb.expires and get_datetime(fb.expires) <= now:
1.23 + expired.append(fb)
1.24 + else:
1.25 + offers.append(fb)
1.26 +
1.27 + if expired:
1.28 + self.set_freebusy_offers_in_update(user, offers)
1.29 +
1.30 + finally:
1.31 + self.release_freebusy(user)
1.32 +
1.33 + return offers
1.34 +
1.35 + def get_freebusy_offers_for_update(self, user):
1.36 +
1.37 + """
1.38 + Get free/busy offers for the given 'user', locking the table. Dependent
1.39 + code must release this lock regardless of it completing successfully.
1.40 + """
1.41 +
1.42 + self.acquire_lock(user)
1.43 + return self.get_freebusy_offers(user)
1.44 +
1.45 + def set_freebusy_offers(self, user, freebusy):
1.46 +
1.47 + "For the given 'user', set 'freebusy' offers."
1.48 +
1.49 + return self.set_freebusy(user, freebusy, "freebusy-offers")
1.50 +
1.51 + def set_freebusy_offers_in_update(self, user, freebusy):
1.52 +
1.53 + "For the given 'user', set 'freebusy' offers during a compound update."
1.54 +
1.55 + return self.set_freebusy_in_update(user, freebusy, "freebusy-offers")
1.56 +
1.57 # Object status details access.
1.58
1.59 def _get_requests(self, user, queue):