<!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>[12187] CalendarServer/branches/users/cdaboo/cross-pod-sharing</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/12187">12187</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2013-12-21 14:50:14 -0800 (Sat, 21 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Checkpoint: cross-pod direct sharing.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingconfcaldavdtestpodBplist">CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavdirectoryprincipalpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavsharingpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavstorebridgepy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingconduitpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresqlpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingconfcaldavdtestpodBplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist (12186 => 12187)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist        2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist        2013-12-21 22:50:14 UTC (rev 12187)
</span><span class="lines">@@ -101,6 +101,19 @@
</span><span class="cx"> </dict>
</span><span class="cx"> </dict>
</span><span class="cx">
</span><ins>+ <!-- Sqlite ProxyDB Service - must use the same one as Pod A-->
+ <key>ProxyDBService</key>
+ <dict>
+ <key>type</key>
+ <string>twistedcaldav.directory.calendaruserproxy.ProxySqliteDB</string>
+
+ <key>params</key>
+ <dict>
+ <key>dbpath</key>
+ <string>./data/podA/Data/proxies.sqlite</string>
+ </dict>
+ </dict>
+
</ins><span class="cx"> <key>ProxyLoadFromFile</key>
</span><span class="cx"> <string>./conf/auth/proxies-test-pod.xml</string>
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavdirectoryprincipalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py (12186 => 12187)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py        2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py        2013-12-21 22:50:14 UTC (rev 12187)
</span><span class="lines">@@ -922,6 +922,23 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><ins>+ def proxyMode(self, principal):
+ """
+ Determine whether what proxy mode this principal has in relation to the one specified.
+ """
+
+ read_uids = (yield self.proxyFor(False))
+ if principal in read_uids:
+ returnValue("read")
+
+ write_uids = (yield self.proxyFor(True))
+ if principal in write_uids:
+ returnValue("write")
+
+ returnValue("none")
+
+
+ @inlineCallbacks
</ins><span class="cx"> def proxyFor(self, read_write, resolve_memberships=True):
</span><span class="cx">
</span><span class="cx"> proxyFors = set()
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavsharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py (12186 => 12187)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py        2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py        2013-12-21 22:50:14 UTC (rev 12187)
</span><span class="lines">@@ -267,10 +267,10 @@
</span><span class="cx"> """
</span><span class="cx"> if self._newStoreObject.direct():
</span><span class="cx"> owner = self.principalForUID(self._newStoreObject.ownerHome().uid())
</span><ins>+ sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
</ins><span class="cx"> if owner.record.recordType == WikiDirectoryService.recordType_wikis:
</span><span class="cx"> # Access level comes from what the wiki has granted to the
</span><span class="cx"> # sharee
</span><del>- sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
</del><span class="cx"> userID = sharee.record.guid
</span><span class="cx"> wikiID = owner.record.shortNames[0]
</span><span class="cx"> access = (yield getWikiAccess(userID, wikiID))
</span><span class="lines">@@ -281,7 +281,12 @@
</span><span class="cx"> else:
</span><span class="cx"> returnValue(None)
</span><span class="cx"> else:
</span><del>- returnValue("original")
</del><ins>+ # Check proxy access
+ proxy_mode = yield sharee.proxyMode(owner)
+ if proxy_mode == "none":
+ returnValue("original")
+ else:
+ returnValue("read-write" if proxy_mode == "write" else "read-only")
</ins><span class="cx"> else:
</span><span class="cx"> # Invited shares use access mode from the invite
</span><span class="cx"> # Get the access for self
</span><span class="lines">@@ -318,7 +323,7 @@
</span><span class="cx"> sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
</span><span class="cx"> access = yield self._checkAccessControl()
</span><span class="cx">
</span><del>- if access == "original":
</del><ins>+ if access == "original" and not self._newStoreObject.ownerHome().external():
</ins><span class="cx"> original = (yield request.locateResource(self._share_url))
</span><span class="cx"> result = (yield original.accessControlList(request, *args, **kwargs))
</span><span class="cx"> returnValue(result)
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py (12186 => 12187)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py        2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py        2013-12-21 22:50:14 UTC (rev 12187)
</span><span class="lines">@@ -495,11 +495,6 @@
</span><span class="cx">
</span><span class="cx"> # Now do normal delete
</span><span class="cx">
</span><del>- # Handle sharing
- wasShared = self.isShared()
- if wasShared:
- yield self.downgradeFromShare(request)
-
</del><span class="cx"> # Actually delete it.
</span><span class="cx"> yield self._newStoreObject.remove()
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingconduitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py (12186 => 12187)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py        2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py        2013-12-21 22:50:14 UTC (rev 12187)
</span><span class="lines">@@ -378,66 +378,6 @@
</span><span class="cx"> })
</span><span class="cx">
</span><span class="cx">
</span><del>- @inlineCallbacks
- def send_shareremove(self, txn, homeType, ownerUID, shareeUID, shareUID):
- """
- Send a sharing remove cross-pod message.
-
- @param homeType: Type of home being shared.
- @type homeType: C{int}
- @param ownerUID: GUID of the sharer.
- @type ownerUID: C{str}
- @param shareeUID: GUID of the recipient
- @type shareeUID: C{str}
- @param shareUID: Resource/invite ID for recipient
- @type shareUID: C{str}
- """
-
- _ignore_sender, recipient = self.validRequst(shareeUID, ownerUID)
-
- action = {
- "action": "shareremove",
- "type": homeType,
- "owner": ownerUID,
- "sharee": shareeUID,
- "share_id": shareUID,
- }
-
- result = yield self.sendRequest(txn, recipient, action)
- returnValue(result)
-
-
- @inlineCallbacks
- def recv_shareremove(self, txn, message):
- """
- Process a sharing remove cross-pod message. Message arguments as per L{send_shareremove}.
-
- @param message: message arguments
- @type message: C{dict}
- """
-
- if message["action"] != "shareremove":
- raise FailedCrossPodRequestError("Wrong action '{}' for recv_shareremove".format(message["action"]))
-
- # Create a share
- ownerHome = yield txn.homeWithUID(message["type"], message["owner"])
- if ownerHome is None or ownerHome.external():
- FailedCrossPodRequestError("Invalid owner UID specified")
-
- try:
- yield ownerHome.processExternalRemove(
- message["owner"],
- message["sharee"],
- message["share_id"],
- )
- except ExternalShareFailed as e:
- FailedCrossPodRequestError(str(e))
-
- returnValue({
- "result": "ok",
- })
-
-
</del><span class="cx"> #
</span><span class="cx"> # Sharer data access related apis
</span><span class="cx"> #
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py (12186 => 12187)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py        2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py        2013-12-21 22:50:14 UTC (rev 12187)
</span><span class="lines">@@ -1568,32 +1568,13 @@
</span><span class="cx"> if bindStatus == _BIND_STATUS_ACCEPTED:
</span><span class="cx"> yield shareeHome.acceptShare(shareUID, summary)
</span><span class="cx"> elif bindStatus == _BIND_STATUS_DECLINED:
</span><del>- yield shareeHome.declineShare(shareUID)
</del><ins>+ if shareeView.direct():
+ yield shareeView.deleteShare()
+ else:
+ yield shareeHome.declineShare(shareUID)
</ins><span class="cx">
</span><span class="cx">
</span><del>- @inlineCallbacks
- def processExternalRemove(self, ownerUID, shareeUID, shareUID):
- """
- External invite received.
- """
</del><span class="cx">
</span><del>- # Make sure the shareeUID and shareUID match
-
- # Get the owner home - create external one if not present
- shareeHome = yield self._txn.homeWithUID(self._homeType, shareeUID)
- if shareeHome is None or not shareeHome.external():
- raise ExternalShareFailed("Invalid sharee UID: {}".format(shareeUID))
-
- # Try to find owner calendar via its external id
- shareeView = yield shareeHome.anyObjectWithShareUID(shareUID)
- if shareeView is None:
- raise ExternalShareFailed("Invalid share UID: {}".format(shareUID))
-
- # Now carry out the share operation
- yield shareeView.deleteShare()
-
-
-
</del><span class="cx"> class CommonHome(SharingHomeMixIn):
</span><span class="cx"> log = Logger()
</span><span class="cx">
</span><span class="lines">@@ -3219,18 +3200,32 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def deleteShare(self):
</span><span class="cx"> """
</span><del>- This share is being deleted - either decline or remove (for direct shares).
</del><ins>+ This share is being deleted (by the sharee) - either decline or remove (for direct shares).
</ins><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> ownerView = yield self.ownerView()
</span><span class="cx"> if self.direct():
</span><span class="cx"> yield ownerView.removeShare(self)
</span><span class="cx"> if ownerView.external():
</span><del>- yield self._removeExternalInvite()
</del><ins>+ yield self._replyExternalInvite(_BIND_STATUS_DECLINED)
</ins><span class="cx"> else:
</span><span class="cx"> yield self.declineShare()
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def ownerDeleteShare(self):
+ """
+ This share is being deleted (by the owner) - either decline or remove (for direct shares).
+ """
+
+ # Change status on store object
+ yield self.setShared(False)
+
+ # Remove all sharees (direct and invited)
+ for invitation in (yield self.sharingInvites()):
+ yield self.uninviteUserFromShare(invitation.shareeUID)
+
+
</ins><span class="cx"> def newShare(self, displayname=None):
</span><span class="cx"> """
</span><span class="cx"> Override in derived classes to do any specific operations needed when a share
</span><span class="lines">@@ -3371,24 +3366,12 @@
</span><span class="cx"> self.viewerHome()._homeType,
</span><span class="cx"> self.ownerHome().uid(),
</span><span class="cx"> self.viewerHome().uid(),
</span><del>- self.shareName(),
</del><ins>+ self.shareUID(),
</ins><span class="cx"> status,
</span><span class="cx"> summary,
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><del>- @inlineCallbacks
- def _removeExternalInvite(self):
-
- yield self._txn.store().conduit.send_shareremove(
- self._txn,
- self.viewerHome()._homeType,
- self.ownerHome().uid(),
- self.viewerHome().uid(),
- self.shareName(),
- )
-
-
</del><span class="cx"> #
</span><span class="cx"> # Lower level API
</span><span class="cx"> #
</span><span class="lines">@@ -4422,6 +4405,9 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def remove(self):
</span><span class="cx">
</span><ins>+ # Stop sharing first
+ yield self.ownerDeleteShare()
+
</ins><span class="cx"> # Do before setting _resourceID making changes
</span><span class="cx"> yield self.notifyPropertyChanged()
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>