1.1 --- a/imip_person.py Wed Oct 22 15:41:10 2014 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,192 +0,0 @@
1.4 -#!/usr/bin/env python
1.5 -
1.6 -"""
1.7 -Handlers for a person for whom scheduling is performed.
1.8 -"""
1.9 -
1.10 -from imiptools.content import Handler
1.11 -from vCalendar import to_node
1.12 -
1.13 -class Event(Handler):
1.14 -
1.15 - "An event handler."
1.16 -
1.17 - def add(self):
1.18 - pass
1.19 -
1.20 - def cancel(self):
1.21 - pass
1.22 -
1.23 - def counter(self):
1.24 -
1.25 - "Since this handler does not send requests, it will not handle replies."
1.26 -
1.27 - pass
1.28 -
1.29 - def declinecounter(self):
1.30 -
1.31 - """
1.32 - Since this handler does not send counter proposals, it will not handle
1.33 - replies to such proposals.
1.34 - """
1.35 -
1.36 - pass
1.37 -
1.38 - def publish(self):
1.39 - pass
1.40 -
1.41 - def refresh(self):
1.42 - pass
1.43 -
1.44 - def reply(self):
1.45 -
1.46 - "Since this handler does not send requests, it will not handle replies."
1.47 -
1.48 - pass
1.49 -
1.50 - def request(self):
1.51 -
1.52 - "Hold requests and notify the recipient."
1.53 -
1.54 - oa = self.require_organiser_and_attendees()
1.55 - if not oa:
1.56 - return None
1.57 -
1.58 - (organiser, organiser_attr), attendees = oa
1.59 -
1.60 - # Process each attendee separately.
1.61 -
1.62 - for attendee, attendee_attr in attendees.items():
1.63 -
1.64 - if not self.have_new_object(attendee, "VEVENT"):
1.65 - continue
1.66 -
1.67 - # Store the event and queue the request.
1.68 -
1.69 - self.store.set_event(attendee, self.uid, to_node(
1.70 - {"VEVENT" : [(self.details, {})]}
1.71 - ))
1.72 -
1.73 - self.store.queue_request(attendee, self.uid)
1.74 -
1.75 - # The message is now wrapped and passed on to the recipient.
1.76 -
1.77 -class Freebusy(Handler):
1.78 -
1.79 - "A free/busy handler."
1.80 -
1.81 - def publish(self):
1.82 - pass
1.83 -
1.84 - def reply(self):
1.85 -
1.86 - "Since this handler does not send requests, it will not handle replies."
1.87 -
1.88 - pass
1.89 -
1.90 - def request(self):
1.91 -
1.92 - """
1.93 - Respond to a request by preparing a reply containing free/busy
1.94 - information for each indicated attendee.
1.95 - """
1.96 -
1.97 - # NOTE: This is currently the same as the resource handler but should be
1.98 - # NOTE: subject to policy/preferences.
1.99 -
1.100 - oa = self.require_organiser_and_attendees()
1.101 - if not oa:
1.102 - return None
1.103 -
1.104 - (organiser, organiser_attr), attendees = oa
1.105 -
1.106 - # Construct an appropriate fragment.
1.107 -
1.108 - calendar = []
1.109 - cwrite = calendar.append
1.110 -
1.111 - # Get the details for each attendee.
1.112 -
1.113 - for attendee, attendee_attr in attendees.items():
1.114 - freebusy = self.store.get_freebusy(attendee)
1.115 -
1.116 - if freebusy:
1.117 - record = []
1.118 - rwrite = record.append
1.119 -
1.120 - rwrite(("ORGANIZER", organiser_attr, organiser))
1.121 - rwrite(("ATTENDEE", attendee_attr, attendee))
1.122 - rwrite(("UID", {}, self.uid))
1.123 -
1.124 - for start, end, uid in freebusy:
1.125 - rwrite(("FREEBUSY", {"FBTYPE" : "BUSY"}, [start, end]))
1.126 -
1.127 - cwrite(("VFREEBUSY", {}, record))
1.128 -
1.129 - # Return the reply.
1.130 -
1.131 - return calendar
1.132 -
1.133 -class Journal(Handler):
1.134 -
1.135 - "A journal entry handler."
1.136 -
1.137 - def add(self):
1.138 - pass
1.139 -
1.140 - def cancel(self):
1.141 - pass
1.142 -
1.143 - def publish(self):
1.144 - pass
1.145 -
1.146 -class Todo(Handler):
1.147 -
1.148 - "A to-do item handler."
1.149 -
1.150 - def add(self):
1.151 - pass
1.152 -
1.153 - def cancel(self):
1.154 - pass
1.155 -
1.156 - def counter(self):
1.157 -
1.158 - "Since this handler does not send requests, it will not handle replies."
1.159 -
1.160 - pass
1.161 -
1.162 - def declinecounter(self):
1.163 -
1.164 - """
1.165 - Since this handler does not send counter proposals, it will not handle
1.166 - replies to such proposals.
1.167 - """
1.168 -
1.169 - pass
1.170 -
1.171 - def publish(self):
1.172 - pass
1.173 -
1.174 - def refresh(self):
1.175 - pass
1.176 -
1.177 - def reply(self):
1.178 -
1.179 - "Since this handler does not send requests, it will not handle replies."
1.180 -
1.181 - pass
1.182 -
1.183 - def request(self):
1.184 - pass
1.185 -
1.186 -# Handler registry.
1.187 -
1.188 -handlers = [
1.189 - ("VFREEBUSY", Freebusy),
1.190 - ("VEVENT", Event),
1.191 - ("VTODO", Todo),
1.192 - ("VJOURNAL", Journal),
1.193 - ]
1.194 -
1.195 -# vim: tabstop=4 expandtab shiftwidth=4