1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/conf/exim/010_exim4-config_people_outgoing Thu Oct 30 19:08:19 2014 +0100
1.3 @@ -0,0 +1,14 @@
1.4 +LDAP_PERSON_OUTGOING_QUERY = (&(|(mail=${quote_ldap:${sender_address_local_part}}@${sender_address_domain})(alias=${quote_ldap:${sender_address_local_part}}@${sender_address_domain}))(objectclass=kolabinetorgperson))
1.5 +
1.6 +people_outgoing:
1.7 + debug_print = "R: person_outgoing for $sender_address_local_part@$sender_address_domain"
1.8 + driver = accept
1.9 + unseen
1.10 + no_expn
1.11 + no_verify
1.12 + condition = ${if eq {}{${lookup ldap{ \
1.13 + user="$ldap_service_bind_dn" \
1.14 + pass=$ldap_service_password \
1.15 + ldap://$ldap_host:$ldap_port/$ldap_base_dn?mail?sub?LDAP_PERSON_OUTGOING_QUERY} \
1.16 + }}{no}{yes}}
1.17 + transport = people_outgoing_transport
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/conf/exim/30_exim4-config_people_outgoing Thu Oct 30 19:08:19 2014 +0100
2.3 @@ -0,0 +1,6 @@
2.4 +people_outgoing_transport:
2.5 + debug_print = "T: people_outgoing_transport for $local_part@$domain"
2.6 + driver = pipe
2.7 + command = /var/lib/imip-agent/imip_person_outgoing.py -O
2.8 + user = imip-agent
2.9 + initgroups = true
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/imip_person_outgoing.py Thu Oct 30 19:08:19 2014 +0100
3.3 @@ -0,0 +1,16 @@
3.4 +#!/usr/bin/env python
3.5 +
3.6 +from imiptools import Processor
3.7 +from imiptools.handlers import person_outgoing
3.8 +from imiptools.mail import Messenger
3.9 +
3.10 +Processor(
3.11 + person_outgoing.handlers,
3.12 + Messenger(
3.13 + "imip-agent@example.com",
3.14 + "Calendar system message",
3.15 + "This is a message from the calendar system."
3.16 + )
3.17 + )()
3.18 +
3.19 +# vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/imiptools/__init__.py Thu Oct 30 19:07:40 2014 +0100
4.2 +++ b/imiptools/__init__.py Thu Oct 30 19:08:19 2014 +0100
4.3 @@ -33,7 +33,7 @@
4.4 self.messenger = messenger or Messenger()
4.5 self.lmtp_socket = None
4.6
4.7 - def process(self, f, original_recipients, recipients):
4.8 + def process(self, f, original_recipients, recipients, outgoing_only):
4.9
4.10 """
4.11 Process content from the stream 'f' accompanied by the given
4.12 @@ -56,6 +56,12 @@
4.13 all_responses += handle_itip_part(part, senders, original_recipients, self.handlers, self.messenger)
4.14 handled = True
4.15
4.16 + # When processing outgoing messages, no replies or deliveries are
4.17 + # performed.
4.18 +
4.19 + if outgoing_only:
4.20 + return
4.21 +
4.22 # Pack any returned parts into a single message.
4.23
4.24 if all_responses:
4.25 @@ -109,11 +115,17 @@
4.26 recipients = []
4.27 senders = []
4.28 lmtp = []
4.29 + outgoing_only = False
4.30
4.31 l = []
4.32
4.33 for arg in args:
4.34
4.35 + # Detect outgoing processing mode.
4.36 +
4.37 + if arg == "-O":
4.38 + outgoing_only = True
4.39 +
4.40 # Switch to collecting recipients.
4.41
4.42 if arg == "-o":
4.43 @@ -140,7 +152,7 @@
4.44
4.45 self.messenger.sender = senders and senders[0] or self.messenger.sender
4.46 self.lmtp_socket = lmtp and lmtp[0] or None
4.47 - self.process(stream, original_recipients, recipients)
4.48 + self.process(stream, original_recipients, recipients, outgoing_only)
4.49
4.50 def __call__(self):
4.51
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/imiptools/handlers/person_outgoing.py Thu Oct 30 19:08:19 2014 +0100
5.3 @@ -0,0 +1,126 @@
5.4 +#!/usr/bin/env python
5.5 +
5.6 +"""
5.7 +Handlers for a person for whom scheduling is performed, inspecting outgoing
5.8 +messages to obtain scheduling done externally.
5.9 +"""
5.10 +
5.11 +from imiptools.content import Handler
5.12 +from vCalendar import to_node
5.13 +
5.14 +class PersonHandler(Handler):
5.15 +
5.16 + "Handling mechanisms specific to people."
5.17 +
5.18 + def _record(self, objtype, from_organiser=True, update_freebusy=False):
5.19 + identity = self.get_value(from_organiser and "ORGANIZER" or "ATTENDEE")
5.20 +
5.21 + # Store the object.
5.22 +
5.23 + self.store.set_event(identity, self.uid, to_node(
5.24 + {objtype : [(self.details, {})]}
5.25 + ))
5.26 +
5.27 + # Update free/busy information.
5.28 +
5.29 + if update_freebusy:
5.30 + periods = self.get_periods()
5.31 + freebusy = self.store.get_freebusy(identity) or []
5.32 + self.update_freebusy(freebusy, identity, periods)
5.33 + if self.publisher:
5.34 + self.publisher.set_freebusy(identity, freebusy)
5.35 +
5.36 + return True
5.37 +
5.38 +class Event(PersonHandler):
5.39 +
5.40 + "An event handler."
5.41 +
5.42 + def add(self):
5.43 + pass
5.44 +
5.45 + def cancel(self):
5.46 + pass
5.47 +
5.48 + def counter(self):
5.49 + pass
5.50 +
5.51 + def declinecounter(self):
5.52 + pass
5.53 +
5.54 + def publish(self):
5.55 + self._record("VEVENT", True, True)
5.56 +
5.57 + def refresh(self):
5.58 + self._record("VEVENT", True, True)
5.59 +
5.60 + def reply(self):
5.61 + self._record("VEVENT", False, False)
5.62 +
5.63 + def request(self):
5.64 + self._record("VEVENT", True, True)
5.65 +
5.66 +class Freebusy(PersonHandler):
5.67 +
5.68 + "A free/busy handler."
5.69 +
5.70 + def publish(self):
5.71 + pass
5.72 +
5.73 + def reply(self):
5.74 + pass
5.75 +
5.76 + def request(self):
5.77 + pass
5.78 +
5.79 +class Journal(PersonHandler):
5.80 +
5.81 + "A journal entry handler."
5.82 +
5.83 + def add(self):
5.84 + pass
5.85 +
5.86 + def cancel(self):
5.87 + pass
5.88 +
5.89 + def publish(self):
5.90 + self._record("VJOURNAL", True)
5.91 +
5.92 +class Todo(PersonHandler):
5.93 +
5.94 + "A to-do item handler."
5.95 +
5.96 + def add(self):
5.97 + pass
5.98 +
5.99 + def cancel(self):
5.100 + pass
5.101 +
5.102 + def counter(self):
5.103 + pass
5.104 +
5.105 + def declinecounter(self):
5.106 + pass
5.107 +
5.108 + def publish(self):
5.109 + self._record("VTODO", True)
5.110 +
5.111 + def refresh(self):
5.112 + self._record("VTODO", True)
5.113 +
5.114 + def reply(self):
5.115 + self._record("VTODO", False)
5.116 +
5.117 + def request(self):
5.118 + self._record("VTODO", True)
5.119 +
5.120 +# Handler registry.
5.121 +
5.122 +handlers = [
5.123 + ("VFREEBUSY", Freebusy),
5.124 + ("VEVENT", Event),
5.125 + ("VTODO", Todo),
5.126 + ("VJOURNAL", Journal),
5.127 + ]
5.128 +
5.129 +# vim: tabstop=4 expandtab shiftwidth=4