<!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>[14169] CalendarServer/branches/release/CalendarServer-5.3-dev</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/14169">14169</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-11-13 17:18:13 -0800 (Thu, 13 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Client transp fix.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devsupportbuildsh">CalendarServer/branches/release/CalendarServer-5.3-dev/support/build.sh</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwextpythonlaunchdpy">CalendarServer/branches/release/CalendarServer-5.3-dev/twext/python/launchd.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavstdconfigpy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavstorebridgepy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavutilpy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/util.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingicaldiffpy">CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/icaldiff.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingimplicitpy">CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/implicit.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingtesttest_icaldiffpy">CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/test/test_icaldiff.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavtesttest_utilpy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_util.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesreleaseCalendarServer53devsupportbuildsh"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/support/build.sh (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/support/build.sh        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/support/build.sh        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -809,7 +809,7 @@
</span><span class="cx"> 
</span><span class="cx">   # XXX actually PyCalendar should be imported in-place.
</span><span class="cx">   py_dependency -fe -i &quot;src&quot; -r HEAD \
</span><del>-    &quot;PyCalendar&quot; &quot;pycalendar&quot; &quot;pycalendar&quot; \
</del><ins>+    &quot;PyCalendar&quot; &quot;pycalendar&quot; &quot;pycalendar-2&quot; \
</ins><span class="cx">     &quot;${svn_uri_base}/PyCalendar/branches/CalendarServer-5.2&quot;;
</span><span class="cx"> 
</span><span class="cx">   #
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwextpythonlaunchdpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twext/python/launchd.py (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twext/python/launchd.py        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twext/python/launchd.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -40,9 +40,9 @@
</span><span class="cx"> 
</span><span class="cx"> ffi.cdef(&quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-static const char* LAUNCH_KEY_CHECKIN;
-static const char* LAUNCH_JOBKEY_LABEL;
-static const char* LAUNCH_JOBKEY_SOCKETS;
</del><ins>+static char const* const LAUNCH_KEY_CHECKIN;
+static char const* const LAUNCH_JOBKEY_LABEL;
+static char const* const LAUNCH_JOBKEY_SOCKETS;
</ins><span class="cx"> 
</span><span class="cx"> typedef enum {
</span><span class="cx">     LAUNCH_DATA_DICTIONARY = 1,
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -867,6 +867,16 @@
</span><span class="cx">     &quot;MaxPrincipalSearchReportResults&quot;: 500,
</span><span class="cx"> 
</span><span class="cx">     #
</span><ins>+    # Client fixes per user-agent match
+    #
+    &quot;ClientFixes&quot; : {
+        &quot;ForceAttendeeTRANSP&quot; : [
+            &quot;iOS/8\\.0(\\..*)?&quot;,
+            &quot;iOS/8\\.1(\\..*)?&quot;,
+        ],
+    },
+
+    #
</ins><span class="cx">     # Localization
</span><span class="cx">     #
</span><span class="cx">     &quot;Localization&quot; : {
</span><span class="lines">@@ -1427,6 +1437,19 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+def _updateClientFixes(configDict, reloading=False):
+    #
+    # Compile ClientFixes expressions for speed
+    #
+    try:
+        configDict.ClientFixesCompiled = {}
+        for key, expressions in configDict.ClientFixes.items():
+            configDict.ClientFixesCompiled[key] = [re.compile(&quot;^{}$&quot;.format(x)) for x in expressions]
+    except re.error, e:
+        raise ConfigurationError(&quot;Invalid regular expression in ClientFixes: %s&quot; % (e,))
+
+
+
</ins><span class="cx"> def _updateLogLevels(configDict, reloading=False):
</span><span class="cx">     log.publisher.levels.clearLogLevels()
</span><span class="cx"> 
</span><span class="lines">@@ -1625,6 +1648,7 @@
</span><span class="cx">     _postUpdateProxyDBService,
</span><span class="cx">     _updateACLs,
</span><span class="cx">     _updateRejectClients,
</span><ins>+    _updateClientFixes,
</ins><span class="cx">     _updateLogLevels,
</span><span class="cx">     _updateNotifications,
</span><span class="cx">     _updateScheduling,
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/storebridge.py (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/storebridge.py        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/storebridge.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> from twistedcaldav.resource import CalDAVResource, GlobalAddressBookResource, \
</span><span class="cx">     DefaultAlarmPropertyMixin
</span><span class="cx"> from twistedcaldav.scheduling_store.caldav.resource import ScheduleInboxResource
</span><ins>+from twistedcaldav.util import matchClientFixes
</ins><span class="cx"> from twistedcaldav.vcard import Component as VCard, InvalidVCardDataError
</span><span class="cx"> 
</span><span class="cx"> from txdav.base.propertystore.base import PropertyName
</span><span class="lines">@@ -2809,6 +2810,10 @@
</span><span class="cx">                     &quot;Can't parse calendar data&quot;
</span><span class="cx">                 ))
</span><span class="cx"> 
</span><ins>+            # Look for client fixes
+            ua = request.headers.getHeader(&quot;User-Agent&quot;)
+            self._newStoreParent._txn._client_fixes = matchClientFixes(config, ua)
+
</ins><span class="cx">             # storeComponent needs to know who the auth'd user is for access control
</span><span class="cx">             # TODO: this needs to be done in a better way - ideally when the txn is created for the request,
</span><span class="cx">             # we should set a txn.authzid attribute.
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavtesttest_utilpy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_util.py (0 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_util.py                                (rev 0)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_util.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -0,0 +1,98 @@
</span><ins>+##
+# Copyright (c) 2005-2014 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+import twistedcaldav.test.util
+from twistedcaldav.util import userAgentProductTokens, matchClientFixes
+from twistedcaldav.stdconfig import _updateClientFixes
+from twistedcaldav.config import ConfigDict
+
+class TestUtil(twistedcaldav.test.util.TestCase):
+    &quot;&quot;&quot;
+    Tests for L{twistedcaldav.util}
+    &quot;&quot;&quot;
+    def test_userAgentProductTokens(self):
+        &quot;&quot;&quot;
+        Test that L{userAgentProductTokens} correctly parses a User-Agent header.
+        &quot;&quot;&quot;
+        for hdr, result in (
+            # Valid syntax
+            (&quot;Client/1.0&quot;, [&quot;Client/1.0&quot;, ]),
+            (&quot;Client/1.0 FooBar/2&quot;, [&quot;Client/1.0&quot;, &quot;FooBar/2&quot;, ]),
+            (&quot;Client/1.0 (commentary here)&quot;, [&quot;Client/1.0&quot;, ]),
+            (&quot;Client/1.0 (FooBar/2)&quot;, [&quot;Client/1.0&quot;, ]),
+            (&quot;Client/1.0 (commentary here) FooBar/2&quot;, [&quot;Client/1.0&quot;, &quot;FooBar/2&quot;, ]),
+            (&quot;Client/1.0 (commentary here) FooBar/2 (more commentary here) &quot;, [&quot;Client/1.0&quot;, &quot;FooBar/2&quot;, ]),
+
+            # Invalid syntax
+            (&quot;Client/1.0 (commentary here FooBar/2&quot;, [&quot;Client/1.0&quot;, ]),
+            (&quot;Client/1.0 commentary here) FooBar/2&quot;, [&quot;Client/1.0&quot;, &quot;commentary&quot;, &quot;here)&quot;, &quot;FooBar/2&quot;, ]),
+        ):
+            self.assertEqual(userAgentProductTokens(hdr), result, msg=&quot;Mismatch: {}&quot;.format(hdr))
+
+
+    def test_matchClientFixes(self):
+        &quot;&quot;&quot;
+        Test that L{matchClientFixes} correctly identifies clients with matching fix tokens.
+        &quot;&quot;&quot;
+        c = ConfigDict()
+        c.ClientFixes = {
+            &quot;fix1&quot;: [
+                &quot;Client/1\\.0.*&quot;,
+                &quot;Client/1\\.1(\\..*)?&quot;,
+                &quot;Client/2&quot;,
+            ],
+            &quot;fix2&quot;: [
+                &quot;Other/1\\.0.*&quot;,
+            ],
+        }
+        _updateClientFixes(c)
+        _updateClientFixes(c)
+
+        # Valid matches
+        for ua in (
+            &quot;Client/1.0 FooBar/2&quot;,
+            &quot;Client/1.0.1 FooBar/2&quot;,
+            &quot;Client/1.0.1.1 FooBar/2&quot;,
+            &quot;Client/1.1 FooBar/2&quot;,
+            &quot;Client/1.1.1 FooBar/2&quot;,
+            &quot;Client/2 FooBar/2&quot;,
+        ):
+            self.assertEqual(
+                matchClientFixes(c, ua),
+                set((&quot;fix1&quot;,)),
+                msg=&quot;Did not match {}&quot;.format(ua),
+            )
+
+        # Valid non-matches
+        for ua in (
+            &quot;Client/1 FooBar/2&quot;,
+            &quot;Client/1.10 FooBar/2&quot;,
+            &quot;Client/2.0 FooBar/2&quot;,
+            &quot;Client/2.0.1 FooBar/2&quot;,
+            &quot;Client FooBar/2&quot;,
+            &quot;Client/3 FooBar/2&quot;,
+            &quot;Client/3.0 FooBar/2&quot;,
+            &quot;Client/10 FooBar/2&quot;,
+            &quot;Client/10.0 FooBar/2&quot;,
+            &quot;Client/10.0.1 FooBar/2&quot;,
+            &quot;Client/10.0.1 (Client/1.0) FooBar/2&quot;,
+            &quot;Client/10.0.1 (foo Client/1.0 bar) FooBar/2&quot;,
+        ):
+            self.assertEqual(
+                matchClientFixes(c, ua),
+                set(),
+                msg=&quot;Incorrectly matched {}&quot;.format(ua),
+            )
</ins></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/util.py (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/util.py        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/util.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -18,6 +18,7 @@
</span><span class="cx"> import re
</span><span class="cx"> import sys
</span><span class="cx"> import base64
</span><ins>+import itertools
</ins><span class="cx"> 
</span><span class="cx"> from subprocess import Popen, PIPE, STDOUT
</span><span class="cx"> from hashlib import md5, sha1
</span><span class="lines">@@ -517,3 +518,57 @@
</span><span class="cx">         cuas = principal.record.calendarUserAddresses
</span><span class="cx"> 
</span><span class="cx">         return (fullName, rec.guid, cuas)
</span><ins>+
+
+
+def userAgentProductTokens(user_agent):
+    &quot;&quot;&quot;
+    Parse an HTTP User-Agent header to extract the product tokens and ignore
+    any parenthesized comment strings in the header.
+
+    @param user_agent: text of User-Agent header value
+    @type user_agent: L{str}
+
+    @return: list of product tokens extracted from the header
+    @rtype: L{list}
+    &quot;&quot;&quot;
+
+    ua_hdr = user_agent.split()
+    ua_tokens = []
+    comment = False
+    for token in ua_hdr:
+        if comment:
+            if token.endswith(&quot;)&quot;):
+                comment = False
+        elif token.startswith(&quot;(&quot;):
+            if not token.endswith(&quot;)&quot;):
+                comment = True
+        else:
+            ua_tokens.append(token)
+
+    return ua_tokens
+
+
+
+def matchClientFixes(config, user_agent):
+    &quot;&quot;&quot;
+    Given a user-agent string, see if it matches any of the configured client fixes.
+
+    @param config: the L{config} to match against.
+    @type config: L{ConfigDict}
+    @param user_agent: the HTTP User-Agent header value to test.
+    @type user_agent: L{str}
+    &quot;&quot;&quot;
+
+    if len(config.ClientFixesCompiled) == 0 or not user_agent:
+        return set()
+
+    ua_tokens = userAgentProductTokens(user_agent)
+
+    client_fixes = set()
+    for fix, patterns in config.ClientFixesCompiled.items():
+        for pattern, token in itertools.product(patterns, ua_tokens):
+            if pattern.match(token) is not None:
+                client_fixes.add(fix)
+                break
+    return client_fixes
</ins></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingicaldiffpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/icaldiff.py (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/icaldiff.py        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/icaldiff.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -27,10 +27,6 @@
</span><span class="cx"> from txdav.caldav.datastore.scheduling.cuaddress import normalizeCUAddr
</span><span class="cx"> from txdav.caldav.datastore.scheduling.itip import iTipGenerator
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot;
-Class that handles diff'ing two calendar objects.
-&quot;&quot;&quot;
-
</del><span class="cx"> __all__ = [
</span><span class="cx">     &quot;iCalDiff&quot;,
</span><span class="cx"> ]
</span><span class="lines">@@ -38,19 +34,33 @@
</span><span class="cx"> log = Logger()
</span><span class="cx"> 
</span><span class="cx"> class iCalDiff(object):
</span><ins>+    &quot;&quot;&quot;
+    This object is used for doing comparisons between two calendar objects to
+    work out what the changes are, in order to determine whether a scheduling
+    operation might be needed. The behavior will varying based on whether the
+    change is being triggered by an Organizer or an Attendee.
+    &quot;&quot;&quot;
</ins><span class="cx"> 
</span><del>-    def __init__(self, oldcalendar, newcalendar, smart_merge):
</del><ins>+
+    def __init__(self, oldcalendar, newcalendar, smart_merge, forceTRANSP=False):
</ins><span class="cx">         &quot;&quot;&quot;
</span><ins>+        Note that this object will always duplicate the calendar objects when doing
+        comparisons so as not to change the calendar objects passed in.
</ins><span class="cx"> 
</span><del>-        @param oldcalendar:
-        @type oldcalendar:
-        @param newcalendar:
-        @type newcalendar:
</del><ins>+        @param oldcalendar: the existing calendar object to compare to
+        @type oldcalendar: L{Component}
+        @param newcalendar: the new calendar object
+        @type newcalendar: L{Component}
+        @param smart_merge: whether or not a &quot;smart&quot; CalDAV merge is done (If-Schedule-Tag-Match)
+        @type smart_merge: L{bool}
+        @param forceTRANSP: whether or not to apply a fix for clients failing to set TRANSP properly
+        @type forceTRANSP: L{bool}
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">         self.oldcalendar = oldcalendar
</span><span class="cx">         self.newcalendar = newcalendar
</span><span class="cx">         self.smart_merge = smart_merge
</span><ins>+        self.forceTRANSP = forceTRANSP
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def organizerDiff(self):
</span><span class="lines">@@ -501,6 +511,13 @@
</span><span class="cx"> 
</span><span class="cx">             replyNeeded = True
</span><span class="cx"> 
</span><ins>+            # Apply client fix only if the PARTSTAT was changed
+            if self.forceTRANSP:
+                if clientAttendee.parameterValue(&quot;PARTSTAT&quot;, &quot;NEEDS-ACTION&quot;) in (&quot;ACCEPTED&quot;, &quot;TENTATIVE&quot;,):
+                    clientComponent.replaceProperty(Property(&quot;TRANSP&quot;, &quot;OPAQUE&quot;))
+                else:
+                    clientComponent.replaceProperty(Property(&quot;TRANSP&quot;, &quot;TRANSPARENT&quot;))
+
</ins><span class="cx">         if serverAttendee.parameterValue(&quot;RSVP&quot;, &quot;FALSE&quot;) != clientAttendee.parameterValue(&quot;RSVP&quot;, &quot;FALSE&quot;):
</span><span class="cx">             if clientAttendee.parameterValue(&quot;RSVP&quot;, &quot;FALSE&quot;) == &quot;FALSE&quot;:
</span><span class="cx">                 try:
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingimplicitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/implicit.py (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/implicit.py        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/implicit.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -1355,7 +1355,14 @@
</span><span class="cx">                     (caldav_namespace, &quot;valid-attendee-change&quot;),
</span><span class="cx">                     &quot;Cannot use an event when not listed as an attendee in the organizer's copy&quot;,
</span><span class="cx">                 ))
</span><del>-        differ = iCalDiff(oldcalendar, self.calendar, self.do_smart_merge)
</del><ins>+
+        # Check for a required client fix
+        if hasattr(self.txn, &quot;_client_fixes&quot;):
+            forceTRANSP = &quot;ForceAttendeeTRANSP&quot; in self.txn._client_fixes
+        else:
+            forceTRANSP = False
+
+        differ = iCalDiff(oldcalendar, self.calendar, self.do_smart_merge, forceTRANSP=forceTRANSP)
</ins><span class="cx">         return differ.attendeeMerge(self.attendee)
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingtesttest_icaldiffpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/test/test_icaldiff.py (14168 => 14169)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/test/test_icaldiff.py        2014-11-14 01:14:48 UTC (rev 14168)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/test/test_icaldiff.py        2014-11-14 01:18:13 UTC (rev 14169)
</span><span class="lines">@@ -4654,6 +4654,391 @@
</span><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><ins>+    def test_attendee_merge_forceTRANSP(self):
+
+        data = (
+            (
+                &quot;#1.1 Simple component, no change&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, False, (), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+            (
+                &quot;#1.2 Simple component, change to ACCEPTED&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, True, (&quot;&quot;,), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED;X-CALENDARSERVER-DTSTAMP=XXXXXXXXTXXXXXXZ:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+            (
+                &quot;#1.3 Simple component, change to DECLINED&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, True, (&quot;&quot;,), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=DECLINED;X-CALENDARSERVER-DTSTAMP=XXXXXXXXTXXXXXXZ:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+            (
+                &quot;#1.4 Simple component, change to TENTATIVE&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=TENTATIVE:mailto:user2@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, True, (&quot;&quot;,), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=TENTATIVE;X-CALENDARSERVER-DTSTAMP=XXXXXXXXTXXXXXXZ:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+            (
+                &quot;#1.5 Simple component, change to ACCEPTED with TRANSP&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=TENTATIVE:mailto:user2@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, True, (&quot;&quot;,), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=TENTATIVE;X-CALENDARSERVER-DTSTAMP=XXXXXXXXTXXXXXXZ:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+            (
+                &quot;#1.6 Simple component, remain as ACCEPTED with TRANSP&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, False, (), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+            (
+                &quot;#1.7 Simple component, remain as ACCEPTED change TRANSP&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, False, (), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+            (
+                &quot;#1.8 Simple component, ACCEPTED-&gt;DECLINED with TRANSP&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2@example.com
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user1@example.com
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user2@example.com
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;mailto:user2@example.com&quot;,
+                (True, True, (&quot;&quot;,), &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1@example.com
+ATTENDEE;PARTSTAT=DECLINED;X-CALENDARSERVER-DTSTAMP=XXXXXXXXTXXXXXXZ:mailto:user2@example.com
+ORGANIZER;CN=User 01:mailto:user1@example.com
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;)
+            ),
+        )
+
+        for description, calendar1, calendar2, attendee, result in data:
+            differ = iCalDiff(
+                Component.fromString(calendar1),
+                Component.fromString(calendar2),
+                False,
+                forceTRANSP=True,
+            )
+            diffResult = differ.attendeeMerge(attendee)
+            diffResult = (
+                diffResult[0],
+                diffResult[1],
+                tuple(sorted(diffResult[2])),
+                re.sub(
+                    &quot;X-CALENDARSERVER-DTSTAMP=[^Z]+&quot;,
+                    &quot;X-CALENDARSERVER-DTSTAMP=XXXXXXXXTXXXXXX&quot;,
+                    str(diffResult[3]).replace(&quot;\r&quot;, &quot;&quot;).replace(&quot;\n &quot;, &quot;&quot;)
+                ) if diffResult[3] else None,
+            )
+            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]),))
+
+
</ins><span class="cx">     def test_organizer_smart_merge(self):
</span><span class="cx"> 
</span><span class="cx">         data1 = (
</span></span></pre>
</div>
</div>

</body>
</html>