1.1 --- a/imiptools/handlers/common.py Wed Jan 28 01:04:24 2015 +0100
1.2 +++ b/imiptools/handlers/common.py Wed Jan 28 01:17:02 2015 +0100
1.3 @@ -21,22 +21,9 @@
1.4
1.5 from imiptools.content import to_part
1.6
1.7 -class CommonFreebusy:
1.8 -
1.9 - "Common free/busy mix-in."
1.10 -
1.11 - def request(self):
1.12 +class SupportFreebusy:
1.13
1.14 - """
1.15 - Respond to a request by preparing a reply containing free/busy
1.16 - information for each indicated attendee.
1.17 - """
1.18 -
1.19 - calendar = self.make_freebusy(from_organiser=False)
1.20 -
1.21 - # Return the reply.
1.22 -
1.23 - return [(True, to_part("REPLY", calendar))]
1.24 + "Support for free/busy publishing and sharing."
1.25
1.26 def make_freebusy_to_publish(self, from_organiser=True):
1.27
1.28 @@ -110,4 +97,21 @@
1.29
1.30 return calendar
1.31
1.32 +class CommonFreebusy(SupportFreebusy):
1.33 +
1.34 + "Common free/busy mix-in."
1.35 +
1.36 + def request(self):
1.37 +
1.38 + """
1.39 + Respond to a request by preparing a reply containing free/busy
1.40 + information for each indicated attendee.
1.41 + """
1.42 +
1.43 + calendar = self.make_freebusy(from_organiser=False)
1.44 +
1.45 + # Return the reply.
1.46 +
1.47 + return [(True, to_part("REPLY", calendar))]
1.48 +
1.49 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/imiptools/handlers/person.py Wed Jan 28 01:04:24 2015 +0100
2.2 +++ b/imiptools/handlers/person.py Wed Jan 28 01:17:02 2015 +0100
2.3 @@ -20,7 +20,7 @@
2.4 """
2.5
2.6 from imiptools.content import Handler, get_address, get_uri, to_part, uri_dict, uri_items
2.7 -from imiptools.handlers.common import CommonFreebusy
2.8 +from imiptools.handlers.common import CommonFreebusy, SupportFreebusy
2.9 from imiptools.profile import Preferences
2.10 from vCalendar import to_node
2.11
2.12 @@ -124,7 +124,7 @@
2.13 for sender, sender_attr in uri_items(self.get_items(from_organiser and "ORGANIZER" or "ATTENDEE")):
2.14 self.store.set_freebusy_for_other(get_uri(self.recipient), freebusy, sender)
2.15
2.16 -class Event(PersonHandler):
2.17 +class Event(PersonHandler, SupportFreebusy):
2.18
2.19 "An event handler."
2.20
2.21 @@ -179,7 +179,18 @@
2.22 "Hold requests and notify the recipient."
2.23
2.24 self._record_and_deliver("VEVENT", from_organiser=True, queue=True)
2.25 - return self.wrap("A request has been received.")
2.26 +
2.27 + # Produce free/busy information if configured to do so.
2.28 +
2.29 + preferences = Preferences(get_uri(self.recipient))
2.30 + if preferences.get("freebusy_sharing") == "share" and \
2.31 + preferences.get("freebusy_bundling") == "always":
2.32 +
2.33 + freebusy = self.make_freebusy_to_publish(from_organiser=False)
2.34 + else:
2.35 + freebusy = []
2.36 +
2.37 + return self.wrap("A request has been received.") + freebusy
2.38
2.39 class Freebusy(PersonHandler, CommonFreebusy):
2.40