[Commits] (morgen) Trying to subscribe to a collection twice now gets handled. Also, duplicate

commits at osafoundation.org commits at osafoundation.org
Wed Aug 25 14:54:25 PDT 2004


Commit by: morgen
Modified files:
chandler/application/dialogs/Alert.wdr 1.1 1.2
chandler/application/dialogs/Alert_wdr.xrc 1.1 1.2
chandler/parcels/osaf/framework/sharing/Sharing.py 1.7 1.8
chandler/parcels/osaf/views/main/Main.py 1.43 1.44

Log message:
Trying to subscribe to a collection twice now gets handled.  Also, duplicate
invites will get handled.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/dialogs/Alert.wdr.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/application/dialogs/Alert_wdr.xrc.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/sharing/Sharing.py.diff?r1=text&tr1=1.7&r2=text&tr2=1.8
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.43&r2=text&tr2=1.44

Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.43 chandler/parcels/osaf/views/main/Main.py:1.44
--- chandler/parcels/osaf/views/main/Main.py:1.43	Tue Aug 24 16:06:16 2004
+++ chandler/parcels/osaf/views/main/Main.py	Wed Aug 25 14:54:24 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.43 $"
-__date__ = "$Date: 2004/08/24 23:06:16 $"
+__version__ = "$Revision: 1.44 $"
+__date__ = "$Date: 2004/08/25 21:54:24 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -244,14 +244,14 @@
         Update the menu to reflect the selected collection name
         """
         collection = self.getSidebarSelectedCollection ()
-        if collection is not None and collection.hasAttributeValue('sharedURL'):
-            notification.data ['Enable'] = True
-        else:
-            notification.data ['Enable'] = False
-        if collection:
-            menuTitle = 'Sync collection "%s"' \
-                    % collection.displayName
+        if collection is not None:
+            menuTitle = 'Sync collection "%s"' % collection.displayName
+            if osaf.framework.sharing.Sharing.isShared(collection):
+                notification.data['Enable'] = True
+            else:
+                notification.data['Enable'] = False
         else:
+            notification.data['Enable'] = False
             menuTitle = 'Sync a collection'
         notification.data ['Text'] = menuTitle
 

Index: chandler/parcels/osaf/framework/sharing/Sharing.py
diff -u chandler/parcels/osaf/framework/sharing/Sharing.py:1.7 chandler/parcels/osaf/framework/sharing/Sharing.py:1.8
--- chandler/parcels/osaf/framework/sharing/Sharing.py:1.7	Wed Aug 25 12:16:07 2004
+++ chandler/parcels/osaf/framework/sharing/Sharing.py	Wed Aug 25 14:54:23 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.7 $"
-__date__ = "$Date: 2004/08/25 19:16:07 $"
+__version__ = "$Revision: 1.8 $"
+__date__ = "$Date: 2004/08/25 21:54:23 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -9,9 +9,11 @@
 import osaf.mail.message
 from repository.util.UUID import UUID
 import application.dialogs.PublishCollection
+from repository.item.Query import KindQuery
 
 SHARING = "http://osafoundation.org/parcels/osaf/framework/sharing"
 EVENTS = "http://osafoundation.org/parcels/osaf/framework/blocks/Events"
+CONTENT = "http://osafoundation.org/parcels/osaf/contentmodel"
 
 class Parcel(application.Parcel.Parcel):
 
@@ -27,10 +29,17 @@
     def _sharingUpdateCallback(self, notification):
         # When we receive the event, display a dialog
         url = notification.data['share']
-        if application.dialogs.Util.promptYesNo( \
-         Globals.wxApplication.mainFrame, "Sharing Invitation",
-         "Subscribe to %s?" % url):
-            subscribeToWebDavCollection(url)
+        collection = collectionFromSharedUrl(url)
+        if collection is not None:
+            application.dialogs.Util.showAlert( \
+             Globals.wxApplication.mainFrame,
+             "Received an invite for an already subscribed collection:\n"
+             "%s\n%s" % (collection.displayName, url))
+        else:
+            if application.dialogs.Util.promptYesNo( \
+             Globals.wxApplication.mainFrame, "Sharing Invitation",
+             "Subscribe to %s?" % url):
+                subscribeToWebDavCollection(url)
 
     def _errorCallback(self, notification):
         # When we receive this event, display the error
@@ -43,19 +52,20 @@
     """ Given a URL, tell the webdav subsystem to fetch the collection it
         points to, then add the collection to the sidebar. """
 
+    collection = collectionFromSharedUrl(url)
+    if collection is not None:
+        application.dialogs.Util.showAlert( \
+         Globals.wxApplication.mainFrame,
+         "Already subscribed to collection '%s':\n"
+         "%s" % (collection.displayName, url))
+        return
+
     collection = osaf.framework.webdav.Dav.DAV(url).get( )
     event = Globals.parcelManager.lookup(EVENTS,
      "NewItemCollectionItem")
     event.Post({'collection':collection})
     Globals.repository.commit()
 
-
-def sendInvites(addresses, url):
-    """ Tell the email subsystem to send a sharing invite to the given
-        addresses. """
-    # osaf.mail.sharing.<sendinvite>(address, url)
-    pass
-
 def manualSubscribeToCollection():
     """ Display a dialog box prompting the user for a webdav url to 
         subscribe to.  """
@@ -71,13 +81,20 @@
      Globals.wxApplication.mainFrame, collection)
 
 def syncCollection(collection):
-    if collection.hasAttributeValue('sharedURL'):
+    if isShared(collection):
         print "Synchronizing", collection.sharedURL
         osaf.framework.webdav.Dav.DAV(collection.sharedURL).get()
-    else:
-        print "Collection hasn't been shared yet"
 
+def isShared(collection):
+    return collection.hasAttributeValue('sharedURL') and collection.sharedURL
 
+def collectionFromSharedUrl(url):
+    kind = Globals.parcelManager.lookup(CONTENT, "NamedCollection")
+    for item in KindQuery().run([kind]):
+        if isShared(item):
+            if str(item.sharedURL) == (url):
+                return item
+    return None
 
 # Non-blocking methods that the mail thread can call to post events to the
 # main thread:

Index: chandler/application/dialogs/Alert_wdr.xrc
diff -u chandler/application/dialogs/Alert_wdr.xrc:1.1 chandler/application/dialogs/Alert_wdr.xrc:1.2
--- chandler/application/dialogs/Alert_wdr.xrc:1.1	Wed Aug 25 10:00:01 2004
+++ chandler/application/dialogs/Alert_wdr.xrc	Wed Aug 25 14:54:23 2004
@@ -12,7 +12,7 @@
             <flag>wxALIGN_CENTER|wxALL</flag>
             <border>5</border>
             <object class="wxStaticText" name="ID_TEXT">
-                <size>250,60</size>
+                <size>450,120</size>
                 <label></label>
             </object>
         </object>



More information about the Commits mailing list