[CalendarServer-changes] [3683] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 18 19:58:11 PST 2009
Revision: 3683
http://trac.macosforge.org/projects/calendarserver/changeset/3683
Author: cdaboo at apple.com
Date: 2009-02-18 19:58:10 -0800 (Wed, 18 Feb 2009)
Log Message:
-----------
Allow clients to manage dropbox attachments themselves with implicit scheduling.
Modified Paths:
--------------
CalendarServer/trunk/run
CalendarServer/trunk/twistedcaldav/ical.py
CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
CalendarServer/trunk/twistedcaldav/scheduling/itip.py
CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
Modified: CalendarServer/trunk/run
===================================================================
--- CalendarServer/trunk/run 2009-02-18 21:49:36 UTC (rev 3682)
+++ CalendarServer/trunk/run 2009-02-19 03:58:10 UTC (rev 3683)
@@ -707,7 +707,7 @@
caldavtester="${top}/CalDAVTester";
-svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 3671;
+svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 3682;
#
# PyFlakes
Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py 2009-02-18 21:49:36 UTC (rev 3682)
+++ CalendarServer/trunk/twistedcaldav/ical.py 2009-02-19 03:58:10 UTC (rev 3683)
@@ -1791,6 +1791,23 @@
for value in prop.value():
component.addProperty(Property(propname, [value,]))
+ def normalizeAttachments(self):
+ """
+ Remove any ATTACH properties that relate to a dropbox.
+ """
+
+ # Do to all sub-components
+ for component in self.subcomponents():
+ dropboxPrefix = component.propertyValue("X-APPLE-DROPBOX")
+ if dropboxPrefix is None:
+ continue
+ for attachment in tuple(component.properties("ATTACH")):
+ valueType = attachment.paramValue("VALUE")
+ if valueType in (None, "URI"):
+ dataValue = attachment.value()
+ if dataValue.find(dropboxPrefix) != -1:
+ component.removeProperty(attachment)
+
##
# Dates and date-times
##
Modified: CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py 2009-02-18 21:49:36 UTC (rev 3682)
+++ CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py 2009-02-19 03:58:10 UTC (rev 3683)
@@ -241,6 +241,7 @@
calendar.normalizePropertyValueLists("EXDATE")
calendar.removePropertyParameters("ORGANIZER", ("SCHEDULE-STATUS",))
calendar.normalizeAll()
+ calendar.normalizeAttachments()
iTipGenerator.prepareSchedulingMessage(calendar, reply=True)
return calendar
Modified: CalendarServer/trunk/twistedcaldav/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/itip.py 2009-02-18 21:49:36 UTC (rev 3682)
+++ CalendarServer/trunk/twistedcaldav/scheduling/itip.py 2009-02-19 03:58:10 UTC (rev 3683)
@@ -622,7 +622,12 @@
itip.removeXProperties(do_subcomponents=False)
# Component properties - remove all X- except for those specified
- keep_properties = ("X-CALENDARSERVER-PRIVATE-COMMENT",) if reply else ()
+ if not reply:
+ # Organizer properties that need to go to the Attendees
+ keep_properties = ("X-APPLE-DROPBOX",)
+ else:
+ # Attendee properties that need to go to the Organizer
+ keep_properties = ("X-CALENDARSERVER-PRIVATE-COMMENT",)
itip.removeXProperties(keep_properties=keep_properties)
# Property Parameters
Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2009-02-18 21:49:36 UTC (rev 3682)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2009-02-19 03:58:10 UTC (rev 3683)
@@ -1,5 +1,5 @@
##
-# Copyright (c) 2005-2007 Apple Inc. All rights reserved.
+# Copyright (c) 2005-2009 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -2025,3 +2025,110 @@
ical2 = str(ical2)
diff = "\n".join(unified_diff(ical1.split("\n"), ical2.split("\n")))
self.assertEqual(str(ical1), str(ical2), "Failed comparison: %s\n%s" % (title, diff,))
+
+ def test_normalize_attachments(self):
+
+ data = (
+ (
+ "1.1 - no attach",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+END:VEVENT
+END:VCALENDAR
+""",
+ ),
+ (
+ "1.2 - attach with no dropbox",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+ATTACH:http://example.com/file.txt
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+ATTACH:http://example.com/file.txt
+END:VEVENT
+END:VCALENDAR
+""",
+ ),
+ (
+ "1.3 - attach with dropbox",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+ATTACH:http://example.com/calendars/user.dropbox/file.txt
+X-APPLE-DROPBOX:/calendars/user.dropbox
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+X-APPLE-DROPBOX:/calendars/user.dropbox
+END:VEVENT
+END:VCALENDAR
+""",
+ ),
+ (
+ "1.4 - attach with different dropbox",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+ATTACH:http://example.com/calendars/user.dropbox/file.txt
+X-APPLE-DROPBOX:/calendars/user1.dropbox
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;VALUE=DATE-TIME:20071114
+ATTACH:http://example.com/calendars/user.dropbox/file.txt
+X-APPLE-DROPBOX:/calendars/user1.dropbox
+END:VEVENT
+END:VCALENDAR
+""",
+ ),
+ )
+
+ for title, original, result in data:
+ ical1 = Component.fromString(original)
+ ical1.normalizeAttachments()
+ ical1 = str(ical1)
+ ical2 = Component.fromString(result)
+ ical2 = str(ical2)
+ diff = "\n".join(unified_diff(ical1.split("\n"), ical2.split("\n")))
+ self.assertEqual(str(ical1), str(ical2), "Failed comparison: %s\n%s" % (title, diff,))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090218/568e1cd5/attachment.html>
More information about the calendarserver-changes
mailing list