[CalendarServer-changes] [2749] CalendarServer/branches/users/sagen/mailgateway-implicit-2745/ twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 21 17:30:34 PDT 2008


Revision: 2749
          http://trac.macosforge.org/projects/calendarserver/changeset/2749
Author:   sagen at apple.com
Date:     2008-07-21 17:30:34 -0700 (Mon, 21 Jul 2008)
Log Message:
-----------
Checkpoint

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/mail.py
    CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/imip.py
    CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/scheduler.py

Modified: CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/mail.py
===================================================================
--- CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/mail.py	2008-07-21 23:16:45 UTC (rev 2748)
+++ CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/mail.py	2008-07-22 00:30:34 UTC (rev 2749)
@@ -27,6 +27,9 @@
 from twisted.python.usage import Options, UsageError
 from twisted.python.reflect import namedClass
 from twistedcaldav.log import LoggingMixIn
+from twistedcaldav import ical
+from twistedcaldav.scheduling.scheduler import IMIPScheduler
+from twistedcaldav.scheduling.cuaddress import LocalCalendarUser
 from twistedcaldav.config import config, parseConfig, defaultConfig
 from zope.interface import Interface, implements
 import email
@@ -252,6 +255,13 @@
         self.log_info(message)
         parsedMessage = email.message_from_string(message)
         # TODO: messages can be handed off here...
+        for part in parsedMessage.walk():
+            if part.get_content_type() == "text/calendar":
+                calBody = part.get_payload(decode=True)
+                calComponent = ical.Component.fromString(calBody)
+                scheduler = IMIPScheduler(None, None)
+                organizer = LocalCalendarUser("mailto:user01 at example.com", None)
+                scheduler.doSchedulingViaPUT(None, (organizer,), calComponent)
 
 
 #

Modified: CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/imip.py
===================================================================
--- CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/imip.py	2008-07-21 23:16:45 UTC (rev 2748)
+++ CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/imip.py	2008-07-22 00:30:34 UTC (rev 2749)
@@ -61,12 +61,25 @@
             if self.freebusy:
                 raise ValueError("iMIP VFREEBUSY REQUESTs not supported.")
 
-            message = self._generateTemplateMessage(self.scheduler.calendar)
-            fromAddr = self.scheduler.originator.cuaddr
-            if not fromAddr.startswith("mailto:"):
+            # Copy the ical component because we need to substitute the
+            # calendar server's sepcial email address for ORGANIZER
+            itip = self.scheduler.calendar.duplicate( )
+            itip.getOrganizerProperty().setValue("mailto:SERVER_ADDRESS+TOKEN at HOST.NAME")
+            # TODO: generate +address token
+            # TODO: grab server email address from config
+
+            message = self._generateTemplateMessage(itip)
+
+            # The email's From: will be the calendar server's address (without
+            # + addressing), while the Reply-To: will be the organizer's email
+            # address.
+            cuAddr = self.scheduler.originator.cuaddr
+            if not cuAddr.startswith("mailto:"):
                 raise ValueError("ORGANIZER address '%s' must be mailto: for iMIP operation." % (fromAddr,))
-            fromAddr = fromAddr[7:]
+            cuAddr = cuAddr[7:]
+            fromAddr = "SERVER_ADDRESS at HOST.NAME"
             message = message.replace("${fromaddress}", fromAddr)
+            message = message.replace("${replytoaddress}", cuAddr)
             
             for recipient in self.recipients:
                 try:
@@ -101,6 +114,7 @@
         writer = MimeWriter.MimeWriter(data)
     
         writer.addheader("From", "${fromaddress}")
+        writer.addheader("Reply-To", "${replytoaddress}")
         writer.addheader("To", "${toaddress}")
         writer.addheader("Date", rfc822date())
         writer.addheader("Subject", "DO NOT REPLY: calendar invitation test")

Modified: CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/scheduler.py	2008-07-21 23:16:45 UTC (rev 2748)
+++ CalendarServer/branches/users/sagen/mailgateway-implicit-2745/twistedcaldav/scheduling/scheduler.py	2008-07-22 00:30:34 UTC (rev 2749)
@@ -717,6 +717,31 @@
             log.err("Unknown iTIP METHOD for security checks: %s" % (self.calendar.propertyValue("METHOD"),))
             raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data")))
 
+
+class IMIPScheduler(Scheduler):
+
+    def checkAuthorization(self):
+        pass
+
+    def checkOriginator(self):
+        pass
+
+    def checkRecipients(self):
+        pass
+
+    def checkOrganizer(self):
+        pass
+
+    def checkOrganizerAsOriginator(self):
+        pass
+
+    def checkAttendeeAsOriginator(self):
+        pass
+
+    def securityChecks(self):
+        pass
+
+
 class ScheduleResponseResponse (Response):
     """
     ScheduleResponse L{Response} object.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080721/a5380032/attachment.html 


More information about the calendarserver-changes mailing list