<!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>[14924] 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/14924">14924</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2015-06-26 13:56:38 -0700 (Fri, 26 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Keep location/attendee/x-apple-structured-location properties in sync</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavicalpy">CalendarServer/trunk/twistedcaldav/ical.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_icalendarpy">CalendarServer/trunk/twistedcaldav/test/test_icalendar.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.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 (14923 => 14924)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/ical.py        2015-06-26 20:18:44 UTC (rev 14923)
+++ CalendarServer/trunk/twistedcaldav/ical.py        2015-06-26 20:56:38 UTC (rev 14924)
</span><span class="lines">@@ -3541,13 +3541,6 @@
</span><span class="cx">                 if name:
</span><span class="cx">                     if name != oldCN:
</span><span class="cx">                         prop.setParameter(&quot;CN&quot;, name)
</span><del>-
-                        # Also adjust any previously matching location property
-                        if cutype == &quot;ROOM&quot;:
-                            location = component.getProperty(&quot;LOCATION&quot;)
-                            if location is not None:
-                                if location.value() == oldCN:
-                                    location.setValue(name)
</del><span class="cx">                 else:
</span><span class="cx">                     prop.removeParameter(&quot;CN&quot;)
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_icalendarpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py (14923 => 14924)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py        2015-06-26 20:18:44 UTC (rev 14923)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py        2015-06-26 20:56:38 UTC (rev 14924)
</span><span class="lines">@@ -8241,9 +8241,6 @@
</span><span class="cx"> 
</span><span class="cx">         yield component.normalizeCalendarUserAddresses(lookupFunction, None, toCanonical=True)
</span><span class="cx"> 
</span><del>-        # Location value changed
-        prop = component.mainComponent().getProperty(&quot;LOCATION&quot;)
-        self.assertEquals(prop.value(), &quot;{Restricted} Buzz&quot;)
</del><span class="cx">         prop = component.getAttendeeProperty((&quot;urn:x-uid:buzz&quot;,))
</span><span class="cx">         self.assertEquals(&quot;urn:x-uid:buzz&quot;, prop.value())
</span><span class="cx">         self.assertEquals(prop.parameterValue(&quot;CN&quot;), &quot;{Restricted} Buzz&quot;)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (14923 => 14924)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2015-06-26 20:18:44 UTC (rev 14923)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2015-06-26 20:56:38 UTC (rev 14924)
</span><span class="lines">@@ -3296,14 +3296,39 @@
</span><span class="cx">         Scan the component for ROOM attendees; if any are associated with an
</span><span class="cx">         address record which has street address and geo coordinates, add an
</span><span class="cx">         X-APPLE-STRUCTURED-LOCATION property and update the LOCATION property
</span><del>-        to contain the name and street address.
</del><ins>+        to contain the name and street address.  X-APPLE-STRUCTURED-LOCATION
+        with X-CUADDR but no corresponding ATTENDEE are removed.
</ins><span class="cx">         &quot;&quot;&quot;
</span><ins>+        dir = self.directoryService()
</ins><span class="cx"> 
</span><ins>+        changed = False
</ins><span class="cx">         cache = {}
</span><del>-        dir = self.directoryService()
</del><ins>+
</ins><span class="cx">         for sub in component.subcomponents():
</span><del>-            locations = []
-            removed = False
</del><ins>+            existingLocationProps = list(sub.properties(&quot;LOCATION&quot;))
+            if len(existingLocationProps) == 0:
+                existingLocationValue = &quot;&quot;
+            else:
+                existingLocationValue = existingLocationProps[0].value()
+            existingLocations = []
+            for value in existingLocationValue.split(&quot;;&quot;):
+                if value:
+                    existingLocations.append(value.strip())
+
+            # index the structured locations on X-CUADDR and X-TITLE
+            allStructured = {
+                &quot;cua&quot;: {},
+                &quot;title&quot;: {}
+            }
+            for structured in sub.properties(&quot;X-APPLE-STRUCTURED-LOCATION&quot;):
+                cuAddr = structured.parameterValue(&quot;X-CUADDR&quot;)
+                if cuAddr:
+                    allStructured[&quot;cua&quot;][cuAddr] = structured
+                else:
+                    title = structured.parameterValue(&quot;X-TITLE&quot;)
+                    if title:
+                        allStructured[&quot;title&quot;][title] = structured
+
</ins><span class="cx">             for attendee in sub.getAllAttendeeProperties():
</span><span class="cx">                 if attendee.parameterValue(&quot;CUTYPE&quot;) == &quot;ROOM&quot;:
</span><span class="cx">                     value = attendee.value()
</span><span class="lines">@@ -3326,34 +3351,91 @@
</span><span class="cx">                     # Use the cached data if present
</span><span class="cx">                     entry = cache[value]
</span><span class="cx">                     if entry is not None:
</span><ins>+
</ins><span class="cx">                         street, geo, title = entry
</span><ins>+                        newLocationValue = &quot;{0}\n{1}&quot;.format(title, street.encode(&quot;utf-8&quot;))
+
+                        # Is there already a structured location property for
+                        # this attendee?  If so, we'll update it.
+                        # Unfortunately, we can only depend on X-CUADDR
+                        # going forward, but there is going to be old existing
+                        # X-APPLE-STRUCTURED-LOCATIONs that haven't yet had
+                        # those added.  So let's first look up by X-CUADDR and
+                        # then by X-TITLE.
+                        if value in allStructured[&quot;cua&quot;]:
+                            structured = allStructured[&quot;cua&quot;][value]
+                        elif title in allStructured[&quot;title&quot;]:
+                            structured = allStructured[&quot;title&quot;][title]
+                        else:
+                            structured = None
+
</ins><span class="cx">                         params = {
</span><span class="cx">                             &quot;X-ADDRESS&quot;: street,
</span><span class="cx">                             &quot;X-APPLE-RADIUS&quot;: &quot;71&quot;,
</span><span class="cx">                             &quot;X-TITLE&quot;: title,
</span><ins>+                            &quot;X-CUADDR&quot;: value,
</ins><span class="cx">                         }
</span><del>-                        structured = Property(
-                            &quot;X-APPLE-STRUCTURED-LOCATION&quot;,
-                            geo.encode(&quot;utf-8&quot;), params=params,
-                            valuetype=Value.VALUETYPE_URI
-                        )
</del><span class="cx"> 
</span><del>-                        # The first time we have any X- prop, remove all existing ones
-                        if not removed:
-                            sub.removeProperty(&quot;X-APPLE-STRUCTURED-LOCATION&quot;)
-                            removed = True
-                        sub.addProperty(structured)
-                        locations.append(&quot;{0}\n{1}&quot;.format(title, street.encode(&quot;utf-8&quot;)))
</del><ins>+                        if structured is None:
+                            # Create a new one
+                            prevTitle = attendee.parameterValue(&quot;CN&quot;)
+                            structured = Property(
+                                &quot;X-APPLE-STRUCTURED-LOCATION&quot;,
+                                geo.encode(&quot;utf-8&quot;), params=params,
+                                valuetype=Value.VALUETYPE_URI
+                            )
+                            changed = True
+                            sub.addProperty(structured)
+                        else:
+                            # Update existing one
+                            prevTitle = structured.parameterValue(&quot;X-TITLE&quot;)
+                            for paramName, paramValue in params.iteritems():
+                                prevValue = structured.parameterValue(paramName)
+                                if paramValue != prevValue:
+                                    structured.setParameter(paramName, paramValue)
+                                    changed = True
</ins><span class="cx"> 
</span><del>-            # Update the LOCATION if X-'s were added
-            if locations:
</del><ins>+                        if changed:
+                            # Replace old location values with the new ones
+                            for i in xrange(len(existingLocations)):
+                                existingLocation = existingLocations[i]
+                                if (
+                                    prevTitle is not None and
+                                    (
+                                        # it's either an exact match or matches
+                                        # up to the newline which precedes the
+                                        # street address
+                                        existingLocation == prevTitle or
+                                        existingLocation.startswith(&quot;{}\n&quot;.format(prevTitle))
+                                    )
+                                ):
+                                    existingLocations[i] = newLocationValue
+                                    break
+                            else:
+                                existingLocations.append(newLocationValue)
+
+            # Remove any server-generated structured locations without an ATTENDEE
+            for structured in sub.properties(&quot;X-APPLE-STRUCTURED-LOCATION&quot;):
+                cuAddr = structured.parameterValue(&quot;X-CUADDR&quot;)
+                if cuAddr is not None: # therefore it's one that requires an ATTENDEE...
+                    attendeeProp = sub.getAttendeeProperty((cuAddr,))
+                    if attendeeProp is None: # ...remove it if no matching ATTENDEE
+                        sub.removeProperty(structured)
+
+            # Update the LOCATION
+            newLocationValue = &quot;;&quot;.join(existingLocations)
+            if newLocationValue != existingLocationValue:
</ins><span class="cx">                 newLocProperty = Property(
</span><span class="cx">                     &quot;LOCATION&quot;,
</span><del>-                    &quot;; &quot;.join(locations)
</del><ins>+                    newLocationValue
</ins><span class="cx">                 )
</span><span class="cx">                 sub.replaceProperty(newLocProperty)
</span><ins>+                changed = True
</ins><span class="cx"> 
</span><ins>+        if changed:
+            self._componentChanged = True
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def decorateHostedStatus(self, component):
</span><span class="cx">         &quot;&quot;&quot;
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py (14923 => 14924)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2015-06-26 20:18:44 UTC (rev 14923)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2015-06-26 20:56:38 UTC (rev 14924)
</span><span class="lines">@@ -21,6 +21,7 @@
</span><span class="cx"> 
</span><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx"> from pycalendar.timezone import Timezone
</span><ins>+from pycalendar.value import Value
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> from txweb2 import responsecode
</span><span class="lines">@@ -38,7 +39,7 @@
</span><span class="cx"> from twistedcaldav.caldavxml import CalendarDescription
</span><span class="cx"> from twistedcaldav.stdconfig import config
</span><span class="cx"> from twistedcaldav.dateops import datetimeMktime
</span><del>-from twistedcaldav.ical import Component, normalize_iCalStr, diff_iCalStrs
</del><ins>+from twistedcaldav.ical import Component, normalize_iCalStr, diff_iCalStrs, Property
</ins><span class="cx"> from twistedcaldav.instance import InvalidOverriddenInstanceError
</span><span class="cx"> from twistedcaldav.timezones import TimezoneCache, readVTZ, TimezoneException
</span><span class="cx"> 
</span><span class="lines">@@ -2682,7 +2683,7 @@
</span><span class="cx">             calendar_name=&quot;calendar&quot;,
</span><span class="cx">             home=&quot;user01&quot;
</span><span class="cx">         )
</span><del>-        comp = yield cobj.component()
</del><ins>+        comp = yield cobj.componentForUser()
</ins><span class="cx">         components = list(comp.subcomponents())
</span><span class="cx"> 
</span><span class="cx">         # Check first component
</span><span class="lines">@@ -2773,14 +2774,14 @@
</span><span class="cx">             calendar_name=&quot;calendar&quot;,
</span><span class="cx">             home=&quot;user01&quot;
</span><span class="cx">         )
</span><del>-        comp = yield cobj.component()
</del><ins>+        comp = yield cobj.componentForUser()
</ins><span class="cx">         components = list(comp.subcomponents())
</span><span class="cx"> 
</span><span class="cx">         # Check first component
</span><span class="cx">         locProp = components[0].getProperty(&quot;LOCATION&quot;)
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             locProp.value(),
</span><del>-            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014; Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;
</del><ins>+            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014;Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;
</ins><span class="cx">         )
</span><span class="cx">         structProps = tuple(components[0].properties(&quot;X-APPLE-STRUCTURED-LOCATION&quot;))
</span><span class="cx">         self.assertEqual(len(structProps), 2)
</span><span class="lines">@@ -2817,7 +2818,7 @@
</span><span class="cx">         locProp = components[0].getProperty(&quot;LOCATION&quot;)
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             locProp.value(),
</span><del>-            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014; Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;
</del><ins>+            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014;Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;
</ins><span class="cx">         )
</span><span class="cx">         structProps = tuple(components[0].properties(&quot;X-APPLE-STRUCTURED-LOCATION&quot;))
</span><span class="cx">         self.assertEqual(len(structProps), 2)
</span><span class="lines">@@ -2830,6 +2831,147 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><ins>+    def test_setComponent_structuredLocation_Mixed(self):
+        &quot;&quot;&quot;
+        Verify adding a location that's not in the directory to an event which
+        already has a location that's in the directory keeps them both.
+        X-APPLE-STRUCTURED-LOCATION properties which have X-CUADDR but no
+        corresponding ATTENDEE are removed.
+        &quot;&quot;&quot;
+
+        data = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
+BEGIN:VEVENT
+UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
+DTSTART:20131211T164500Z
+DURATION:PT1H
+ATTENDEE;CN=Old Room with Address 1;CUTYPE=ROOM;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPAN
+ T;SCHEDULE-STATUS=2.0:urn:x-uid:room-addr-1
+ATTENDEE;CN=Room with Address 2;CUTYPE=ROOM;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPAN
+ T;SCHEDULE-STATUS=2.0:urn:x-uid:room-addr-2
+ATTENDEE;CN=Mercury Seven;CUTYPE=ROOM;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPAN
+ T;SCHEDULE-STATUS=2.0:urn:x-uid:mercury
+ATTENDEE;CN=User 01;CUTYPE=INDIVIDUAL;EMAIL=user01@example.com;PARTSTAT=AC
+ CEPTED:urn:x-uid:user01
+X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=&quot;1 Infinite Loop, Cupertin
+ o, CA 95014&quot;;X-APPLE-RADIUS=71;X-CUADDR=&quot;urn:x-uid:room-addr-1&quot;;X-TITLE=O
+ ld Room with Address 1:geo:37.331741,-122.030333
+X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=&quot;2 Infinite Loop, Cupertin
+ o, CA 95014&quot;;X-APPLE-RADIUS=71;X-TITLE=Room with Address 2:geo:37.332633,
+ -122.030502
+X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=123 Main St;X-APPLE-RADIUS
+ =14164;X-TITLE=Mercury Seven:geo:37.351164,-122.032686
+CREATED:20131211T221854Z
+DTSTAMP:20131211T230632Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
+SEQUENCE:1
+SUMMARY:locations
+LOCATION:Old Room with Address 1;Unstructured Location; Mercury Seven; Room with Address 2
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
+        yield calendar.createCalendarObjectWithName(
+            &quot;structured.ics&quot;,
+            Component.fromString(data)
+        )
+
+        yield self.commit()
+
+        cobj = yield self.calendarObjectUnderTest(
+            name=&quot;structured.ics&quot;,
+            calendar_name=&quot;calendar&quot;,
+            home=&quot;user01&quot;
+        )
+        comp = yield cobj.componentForUser()
+        components = list(comp.subcomponents())
+
+        # Check first component -- LOCATION now has the street addresses, and
+        # location values that don't have an ATTENDEE or X-APPLE-STRUCTURED-LOCATIONs
+        # are retained
+        locProp = components[0].getProperty(&quot;LOCATION&quot;)
+        self.assertEquals(
+            locProp.value(),
+            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014;Unstructured Location;Mercury Seven;Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;
+        )
+        structProps = tuple(components[0].properties(&quot;X-APPLE-STRUCTURED-LOCATION&quot;))
+        self.assertEqual(len(structProps), 3)
+        self.assertEquals(
+            structProps[0].value(),
+            &quot;geo:37.331741,-122.030333&quot;,
+        )
+        # Make sure server has also added X-CUADDR
+        self.assertEquals(
+            structProps[0].parameterValue(&quot;X-CUADDR&quot;),
+            &quot;urn:x-uid:room-addr-1&quot;
+        )
+
+        # Client now adds a location not in the directory:
+        comp = comp.duplicate()
+        main = comp.mainComponent()
+        main.replaceProperty(Property(&quot;LOCATION&quot;, &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014; Unstructured Location; Falafel Stop\n1325 Sunnyvale Saratoga, Sunnyvale, CA 94087;Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;))
+
+        params = {
+            &quot;X-ADDRESS&quot;: &quot;1325 Sunnyvale Saratoga Rd&quot;,
+            &quot;X-APPLE-RADIUS&quot;: &quot;14164&quot;,
+            &quot;X-TITLE&quot;: &quot;Falafel Stop&quot;,
+        }
+        structured = Property(
+            &quot;X-APPLE-STRUCTURED-LOCATION&quot;,
+            &quot;geo:37.351164,-122.032686&quot;, params=params,
+            valuetype=Value.VALUETYPE_URI
+        )
+        main.addProperty(structured)
+
+        # ...plus let's prove we clean up structured locations which have X-CUADDR
+        # but no matching ATTENDEE
+        params = {
+            &quot;X-ADDRESS&quot;: &quot;1122 Boogie Woogie Ave&quot;,
+            &quot;X-APPLE-RADIUS&quot;: &quot;14164&quot;,
+            &quot;X-TITLE&quot;: &quot;Home of the Boogie, House of the Funk&quot;,
+            &quot;X-CUADDR&quot;: &quot;urn:x-uid:boogie-home&quot;,
+        }
+        structured = Property(
+            &quot;X-APPLE-STRUCTURED-LOCATION&quot;,
+            &quot;geo:37.351164,-122.032686&quot;, params=params,
+            valuetype=Value.VALUETYPE_URI
+        )
+        main.addProperty(structured)
+
+        # Store the new component and let the server do its thing
+        yield cobj.setComponent(comp)
+        yield self.commit()
+
+        cobj = yield self.calendarObjectUnderTest(
+            name=&quot;structured.ics&quot;,
+            calendar_name=&quot;calendar&quot;,
+            home=&quot;user01&quot;
+        )
+        comp = yield cobj.componentForUser()
+        components = list(comp.subcomponents())
+
+        # Check first component
+        structProps = tuple(components[0].properties(&quot;X-APPLE-STRUCTURED-LOCATION&quot;))
+        self.assertEqual(len(structProps), 4)
+        self.assertEquals(
+            set([structProp.parameterValue(&quot;X-TITLE&quot;) for structProp in structProps]),
+            set((&quot;Room with Address 1&quot;, &quot;Room with Address 2&quot;, &quot;Falafel Stop&quot;, &quot;Mercury Seven&quot;))
+        )
+
+        locProp = components[0].getProperty(&quot;LOCATION&quot;)
+        self.assertEquals(
+            locProp.value(),
+            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014;Unstructured Location;Falafel Stop\n1325 Sunnyvale Saratoga, Sunnyvale, CA 94087;Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;
+        )
+
+        yield self.commit()
+
+
+    @inlineCallbacks
</ins><span class="cx">     def test_setComponent_externalPrincipal(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Verify attendees who are not locally hosted have X-APPLE-HOSTED-STATUS=EXTERNAL
</span></span></pre>
</div>
</div>

</body>
</html>