<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12349] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12349">12349</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-01-15 08:23:30 -0800 (Wed, 15 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>STATUS:CANCELLED now sends METHOD:CANCEL.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavicalpy">CalendarServer/trunk/twistedcaldav/ical.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingicaldiffpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingimplicitpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingtesttest_icaldiffpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwistedcaldavicalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/ical.py (12348 => 12349)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/ical.py        2014-01-15 16:21:14 UTC (rev 12348)
+++ CalendarServer/trunk/twistedcaldav/ical.py        2014-01-15 16:23:30 UTC (rev 12349)
</span><span class="lines">@@ -2700,7 +2700,7 @@
</span><span class="cx">     def filterComponents(self, rids):
</span><span class="cx"> 
</span><span class="cx">         # If master is in rids do nothing
</span><del>-        if not rids or &quot;&quot; in rids:
</del><ins>+        if not rids or None in rids:
</ins><span class="cx">             return True
</span><span class="cx"> 
</span><span class="cx">         assert self.name() == &quot;VCALENDAR&quot;, &quot;Not a calendar: %r&quot; % (self,)
</span><span class="lines">@@ -2713,7 +2713,7 @@
</span><span class="cx">                 remaining -= 1
</span><span class="cx">                 continue
</span><span class="cx">             rid = component.getRecurrenceIDUTC()
</span><del>-            if (rid.getText() if rid else &quot;&quot;) not in rids:
</del><ins>+            if rid not in rids:
</ins><span class="cx">                 self.removeComponent(component)
</span><span class="cx">                 remaining -= 1
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingicaldiffpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py (12348 => 12349)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py        2014-01-15 16:21:14 UTC (rev 12348)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py        2014-01-15 16:23:30 UTC (rev 12349)
</span><span class="lines">@@ -334,7 +334,7 @@
</span><span class="cx">                     overridden = returnCalendar.overriddenComponent(rid)
</span><span class="cx">                     if self._attendeeDecline(overridden):
</span><span class="cx">                         changeCausesReply = True
</span><del>-                        changedRids.append(rid.getText() if rid else &quot;&quot;)
</del><ins>+                        changedRids.append(rid)
</ins><span class="cx"> 
</span><span class="cx">                     # When a master component is present we keep the missing override in place but mark it as hidden.
</span><span class="cx">                     # When no master is present we now do the same so we can track updates to the override correctly.
</span><span class="lines">@@ -417,7 +417,7 @@
</span><span class="cx">                 #return False, False, (), None
</span><span class="cx">             changeCausesReply |= reply
</span><span class="cx">             if reply:
</span><del>-                changedRids.append(rid.getText() if rid else &quot;&quot;)
</del><ins>+                changedRids.append(rid)
</ins><span class="cx"> 
</span><span class="cx">         # We need to derive instances for any declined using an EXDATE
</span><span class="cx">         for decline in sorted(declines):
</span><span class="lines">@@ -427,7 +427,7 @@
</span><span class="cx">                 if overridden is not None:
</span><span class="cx">                     if self._attendeeDecline(overridden):
</span><span class="cx">                         changeCausesReply = True
</span><del>-                        changedRids.append(decline.getText() if decline else &quot;&quot;)
</del><ins>+                        changedRids.append(decline)
</ins><span class="cx"> 
</span><span class="cx">                     # When a master component is present we keep the missing override in place but mark it as hidden.
</span><span class="cx">                     # When no master is present we remove the override,
</span><span class="lines">@@ -828,7 +828,7 @@
</span><span class="cx"> 
</span><span class="cx">         if addedChanges:
</span><span class="cx">             rid = comp1.getRecurrenceIDUTC()
</span><del>-            rids[rid.getText() if rid is not None else &quot;&quot;] = propsChanged
</del><ins>+            rids[rid] = propsChanged
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def _logDiffError(self, title):
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingimplicitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py (12348 => 12349)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py        2014-01-15 16:21:14 UTC (rev 12348)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py        2014-01-15 16:23:30 UTC (rev 12349)
</span><span class="lines">@@ -553,7 +553,7 @@
</span><span class="cx">                 self.calendar.sequenceInSync(self.oldcalendar)
</span><span class="cx"> 
</span><span class="cx">             # Significant change
</span><del>-            no_change, self.changed_rids, self.needs_action_rids, reinvites, recurrence_reschedule = self.isOrganizerChangeInsignificant()
</del><ins>+            no_change, self.changed_rids, self.needs_action_rids, reinvites, recurrence_reschedule, status_cancelled, only_status = self.isOrganizerChangeInsignificant()
</ins><span class="cx">             if no_change:
</span><span class="cx">                 if reinvites:
</span><span class="cx">                     log.debug(&quot;Implicit - organizer '{organizer}' is re-inviting UID: '{uid}', attendees: {attendees}&quot;, organizer=self.organizer, uid=self.uid, attendees=&quot;, &quot;.join(reinvites))
</span><span class="lines">@@ -594,6 +594,8 @@
</span><span class="cx">                 else:
</span><span class="cx">                     self.findRemovedAttendeesOnRecurrenceChange()
</span><span class="cx"> 
</span><ins>+                self.checkStatusCancelled(status_cancelled, only_status)
+
</ins><span class="cx">                 # For now we always bump the sequence number on modifications because we cannot track DTSTAMP on
</span><span class="cx">                 # the Attendee side. But we check the old and the new and only bump if the client did not already do it.
</span><span class="cx">                 self.needs_sequence_change = self.calendar.needsiTIPSequenceChange(self.oldcalendar)
</span><span class="lines">@@ -630,6 +632,8 @@
</span><span class="cx">         date_changed_rids = None
</span><span class="cx">         reinvites = None
</span><span class="cx">         recurrence_reschedule = False
</span><ins>+        status_cancelled = set()
+        only_status = None
</ins><span class="cx">         differ = iCalDiff(self.oldcalendar, self.calendar, self.do_smart_merge)
</span><span class="cx">         no_change = differ.organizerDiff()
</span><span class="cx">         if not no_change:
</span><span class="lines">@@ -653,7 +657,7 @@
</span><span class="cx">                     date_changed_rids.add(rid)
</span><span class="cx"> 
</span><span class="cx">                 # Check to see whether a change to R-ID's happened
</span><del>-                if rid == &quot;&quot;:
</del><ins>+                if rid is None:
</ins><span class="cx"> 
</span><span class="cx">                     if &quot;DTSTART&quot; in props and self.calendar.masterComponent().hasProperty(&quot;RRULE&quot;):
</span><span class="cx">                         # DTSTART change with RRULE present is always a reschedule
</span><span class="lines">@@ -693,6 +697,16 @@
</span><span class="cx">                             if newrrule == oldrrule:
</span><span class="cx">                                 recurrence_reschedule = False
</span><span class="cx"> 
</span><ins>+                # Check for addition of STATUS:CANCELLED
+                if &quot;STATUS&quot; in props:
+                    if only_status is None and len(props) == 1:
+                        only_status = True
+                    instance = self.calendar.overriddenComponent(rid)
+                    if instance and instance.propertyValue(&quot;STATUS&quot;) == &quot;CANCELLED&quot;:
+                        status_cancelled.add(rid)
+                else:
+                    only_status = False
+
</ins><span class="cx">             if checkOrganizerValue:
</span><span class="cx">                 oldOrganizer = self.oldcalendar.getOrganizer()
</span><span class="cx">                 newOrganizer = self.calendar.getOrganizer()
</span><span class="lines">@@ -713,7 +727,7 @@
</span><span class="cx">                 except KeyError:
</span><span class="cx">                     pass
</span><span class="cx"> 
</span><del>-        return no_change, rids, date_changed_rids, reinvites, recurrence_reschedule
</del><ins>+        return no_change, rids, date_changed_rids, reinvites, recurrence_reschedule, status_cancelled, only_status
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def findRemovedAttendees(self):
</span><span class="lines">@@ -816,6 +830,22 @@
</span><span class="cx">                 self.cancelledAttendees.add((attendee, rid,))
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def checkStatusCancelled(self, cancelled, only_status):
+        &quot;&quot;&quot;
+        Check to see whether STATUS:CANCELLED has been added to any/all instances, and if so
+        always trigger a METHOD:CANCEL on those. In the case where only STATUS has changed, we
+        need to only send METHOD:CANCEL and suppress any METHOD:REQUEST.
+        &quot;&quot;&quot;
+        if cancelled:
+            for attendee, rid in self.calendar.getAttendeesByInstance(onlyScheduleAgentServer=True):
+                if rid in cancelled:
+                    self.cancelledAttendees.add((attendee, rid,))
+
+            # If only a cancel is done, then suppress any METHOD:REQUEST that a normal &quot;modify: would do
+            if only_status:
+                self.action = &quot;modify-cancelled&quot;
+
+
</ins><span class="cx">     def coerceAttendeesPartstatOnCreate(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Make sure any attendees handled by the server start off with PARTSTAT=NEEDS-ACTION as
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py (12348 => 12349)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2014-01-15 16:21:14 UTC (rev 12348)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2014-01-15 16:23:30 UTC (rev 12349)
</span><span class="lines">@@ -604,10 +604,10 @@
</span><span class="cx">                 update_details = []
</span><span class="cx">                 for rid, props_changed in sorted(rids.iteritems(), key=lambda x: x[0]):
</span><span class="cx">                     recurrence = []
</span><del>-                    if rid == &quot;&quot;:
</del><ins>+                    if rid is None:
</ins><span class="cx">                         recurrence.append(customxml.Master())
</span><span class="cx">                     else:
</span><del>-                        recurrence.append(customxml.RecurrenceID.fromString(rid))
</del><ins>+                        recurrence.append(customxml.RecurrenceID.fromString(rid.getText()))
</ins><span class="cx">                     changes = []
</span><span class="cx">                     for propName, paramNames in sorted(props_changed.iteritems(), key=lambda x: x[0]):
</span><span class="cx">                         params = tuple([customxml.ChangedParameter(name=param) for param in paramNames])
</span><span class="lines">@@ -679,7 +679,7 @@
</span><span class="cx">                     # Build the schedule-changes XML element
</span><span class="cx">                     if rids:
</span><span class="cx">                         action = customxml.Cancel(
</span><del>-                            *[customxml.Recurrence(customxml.RecurrenceID.fromString(rid)) for rid in sorted(rids)]
</del><ins>+                            *[customxml.Recurrence(customxml.RecurrenceID.fromString(rid.getText())) for rid in sorted(rids)]
</ins><span class="cx">                         )
</span><span class="cx">                     else:
</span><span class="cx">                         action = customxml.Cancel()
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingtesttest_icaldiffpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py (12348 => 12349)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py        2014-01-15 16:21:14 UTC (rev 12348)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py        2014-01-15 16:23:30 UTC (rev 12349)
</span><span class="lines">@@ -23,6 +23,8 @@
</span><span class="cx"> 
</span><span class="cx"> from txdav.caldav.datastore.scheduling.icaldiff import iCalDiff
</span><span class="cx"> 
</span><ins>+from pycalendar.datetime import DateTime
+
</ins><span class="cx"> import itertools
</span><span class="cx"> import re
</span><span class="cx"> 
</span><span class="lines">@@ -1192,6 +1194,9 @@
</span><span class="cx">                     str(diffResult[3]).replace(&quot;\r&quot;, &quot;&quot;).replace(&quot;\n &quot;, &quot;&quot;)
</span><span class="cx">                 ) if diffResult[3] else None,
</span><span class="cx">             )
</span><ins>+            result = list(result)
+            result[2] = tuple([(DateTime.parseText(dt) if dt else None) for dt in result[2]])
+            result = tuple(result)
</ins><span class="cx">             self.assertEqual(diffResult, result, msg=&quot;%s: actual result: (%s)&quot; % (description, &quot;, &quot;.join([str(i).replace(&quot;\r&quot;, &quot;&quot;) for i in diffResult]),))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1694,6 +1699,9 @@
</span><span class="cx">                     str(diffResult[3]).replace(&quot;\r&quot;, &quot;&quot;).replace(&quot;\n &quot;, &quot;&quot;)
</span><span class="cx">                 ) if diffResult[3] else None,
</span><span class="cx">             )
</span><ins>+            result = list(result)
+            result[2] = tuple([(DateTime.parseText(dt) if dt else None) for dt in result[2]])
+            result = tuple(result)
</ins><span class="cx">             self.assertEqual(diffResult, result, msg=&quot;%s: actual result: (%s)&quot; % (description, &quot;, &quot;.join([str(i).replace(&quot;\r&quot;, &quot;&quot;) for i in diffResult]),))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -2050,6 +2058,9 @@
</span><span class="cx">                 tuple(sorted(diffResult[2])),
</span><span class="cx">                 str(diffResult[3]).replace(&quot;\r&quot;, &quot;&quot;) if diffResult[3] else None,
</span><span class="cx">             )
</span><ins>+            result = list(result)
+            result[2] = tuple([(DateTime.parseText(dt) if dt else None) for dt in result[2]])
+            result = tuple(result)
</ins><span class="cx">             self.assertEqual(diffResult, result, msg=&quot;%s: actual result: (%s)&quot; % (description, &quot;, &quot;.join([str(i).replace(&quot;\r&quot;, &quot;&quot;) for i in diffResult]),))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -2415,6 +2426,9 @@
</span><span class="cx">                 tuple(sorted(diffResult[2])),
</span><span class="cx">                 str(diffResult[3]).replace(&quot;\r&quot;, &quot;&quot;) if diffResult[3] else None,
</span><span class="cx">             )
</span><ins>+            result = list(result)
+            result[2] = tuple([(DateTime.parseText(dt) if dt else None) for dt in result[2]])
+            result = tuple(result)
</ins><span class="cx">             self.assertEqual(diffResult, result, msg=&quot;%s: actual result: (%s)&quot; % (description, &quot;, &quot;.join([str(i).replace(&quot;\r&quot;, &quot;&quot;) for i in diffResult]),))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -2696,6 +2710,9 @@
</span><span class="cx">                 tuple(sorted(diffResult[2])),
</span><span class="cx">                 str(diffResult[3]).replace(&quot;\r&quot;, &quot;&quot;) if diffResult[3] else None,
</span><span class="cx">             )
</span><ins>+            result = list(result)
+            result[2] = tuple([(DateTime.parseText(dt) if dt else None) for dt in result[2]])
+            result = tuple(result)
</ins><span class="cx">             self.assertEqual(diffResult, result, msg=&quot;%s: actual result: (%s)&quot; % (description, &quot;, &quot;.join([str(i).replace(&quot;\r&quot;, &quot;&quot;) for i in diffResult]),))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -3250,6 +3267,9 @@
</span><span class="cx">                     str(diffResult[3]).replace(&quot;\r&quot;, &quot;&quot;).replace(&quot;\n &quot;, &quot;&quot;)
</span><span class="cx">                 ) if diffResult[3] else None,
</span><span class="cx">             )
</span><ins>+            result = list(result)
+            result[2] = tuple([(DateTime.parseText(dt) if dt else None) for dt in result[2]])
+            result = tuple(result)
</ins><span class="cx">             self.assertEqual(diffResult, result, msg=&quot;%s: actual result: (%s)&quot; % (description, &quot;, &quot;.join([str(i).replace(&quot;\r&quot;, &quot;&quot;) for i in diffResult]),))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -4268,6 +4288,7 @@
</span><span class="cx">         for description, calendar1, calendar2, rids in itertools.chain(data1, data2, data3,):
</span><span class="cx">             differ = iCalDiff(Component.fromString(calendar1), Component.fromString(calendar2), False)
</span><span class="cx">             got_rids = differ.whatIsDifferent()
</span><ins>+            rids = dict([(DateTime.parseText(k) if k else None, v) for k, v in rids.items()])
</ins><span class="cx">             self.assertEqual(got_rids, rids, msg=&quot;%s expected R-IDs: '%s', got: '%s'&quot; % (description, rids, got_rids,))
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>