def OnUnPubSub(self, evt): share = Sharing.getShare(self.collection) if Sharing.isSharedByMe(share): Sharing.unpublish(self.collection) else: Sharing.unsubscribe(self.collection) self.EndModal(True)
def onShareItemEvent(self, event): """ Share an ItemCollection. """ itemCollection = event.arguments["item"] # Make sure we have all the accounts; returns False if the user cancels # out and we don't. if not Sharing.ensureAccountSetUp(self.itsView): return webdavAccount = Sharing.getWebDAVAccount(self.itsView) # commit changes, since we'll be switching to Twisted thread # @@@DLD bug 1998 - update comment above and use refresh instead? self.RepositoryCommitWithStatus() # show status self.setStatusMessage(_("Sharing collection %s") % itemCollection.displayName) # Get or make a share for this item collection share = Sharing.getShare(itemCollection) isNewShare = share is None if isNewShare: share = Sharing.newOutboundShare(self.itsView, itemCollection, account=webdavAccount) # Copy the invitee list into the share's list. As we go, collect the # addresses we'll notify. if len(itemCollection.invitees) == 0: self.setStatusMessage(_("No invitees!")) return inviteeList = [] inviteeStringsList = [] for invitee in itemCollection.invitees: inviteeList.append(invitee) inviteeStringsList.append(invitee.emailAddress) inviteeContact = Contact.getContactForEmailAddress(self.itsView, invitee.emailAddress) if not inviteeContact in share.sharees: share.sharees.append(inviteeContact) # Sync the collection with WebDAV self.setStatusMessage(_("accessing WebDAV server")) try: if not share.exists(): share.create() share.put() except Sharing.SharingError, err: self.setStatusMessage(_("Sharing failed.")) msg = "Couldn't share collection:\n%s" % err.message application.dialogs.Util.ok(wx.GetApp().mainFrame, "Error", msg) if isNewShare: share.conduit.delete() share.format.delete() share.delete() return
def onCopyCollectionURLEventUpdateUI(self, event): enable = False collection = self.getSidebarSelectedCollection() if collection is not None: share = Sharing.getShare(collection) if share is not None: enable = True event.arguments['Enable'] = enable
def onCopyCollectionURLEventUpdateUI(self, event): enable = False collection = self.getSidebarSelectedCollection() if collection is not None: share = Sharing.getShare(collection) if share is not None: enable = True event.arguments["Enable"] = enable
def onCopyCollectionURLEvent(self, event): collection = self.getSidebarSelectedCollection() if collection is not None: share = Sharing.getShare(collection) if share is not None: url = str(share.getLocation()) gotClipboard = wx.TheClipboard.Open() if gotClipboard: wx.TheClipboard.SetData(wx.TextDataObject(url)) wx.TheClipboard.Close()
def getButtonState (self, buttonName, item): if buttonName == u'Icon': if item in self.checkedItems: return 'Checked' elif buttonName == u'SharingIcon': share = Sharing.getShare(item) if share is not None: if (share.sharer is not None and str(share.sharer.itsPath) == "//userdata/me"): return "Upload" else: return "Download" return ""
def __init__(self, parent, title, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, resources=None, view=None, collection=None, filterKindPath=None): wx.Dialog.__init__(self, parent, -1, title, pos, size, style) self.resources = resources self.view = view self.parent = parent self.collection = collection # The collection to share # List of kinds (paths) to share if filterKindPath is None: self.filterKinds = [] else: self.filterKinds = [filterKindPath] self.mySizer = wx.BoxSizer(wx.VERTICAL) # Is this collection already shared? self.shareXML = Sharing.getShare(self.collection) if self.shareXML is None: # Not yet shared, show "Publish" self.mainPanel = self.resources.LoadPanel(self, "PublishCollection") self.buttonPanel = self.resources.LoadPanel(self, "PublishButtonsPanel") else: # Already shared, show "Manage" self.mainPanel = self.resources.LoadPanel(self, "ManageCollection") self.buttonPanel = self.resources.LoadPanel(self, "ManageButtonsPanel") # Create/Hide the status panel that appears when there is text to # display self.statusPanel = self.resources.LoadPanel(self, "StatusPanel") self.statusPanel.Hide() self.textStatus = wx.xrc.XRCCTRL(self, "TEXT_STATUS") # Fit all the pieces together self.mySizer.Add(self.mainPanel, 0, wx.GROW|wx.ALL, 5) self.mySizer.Add(self.buttonPanel, 0, wx.GROW|wx.ALL, 5) self.SetSizer(self.mySizer) self.mySizer.SetSizeHints(self) self.mySizer.Fit(self) if self.shareXML is None: # Not yet shared, show "Publish" self.ShowPublishPanel() else: # Already shared, show "Manage" self.ShowManagePanel()
def ShowManagePanel(self): # "Manage" mode -- i.e., the collection has already been shared self.Bind(wx.EVT_BUTTON, self.OnManageDone, id=wx.ID_OK) self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL) self.Bind(wx.EVT_BUTTON, self.OnCopy, id=wx.xrc.XRCID("BUTTON_CLIPBOARD")) self.Bind(wx.EVT_BUTTON, self.OnUnPubSub, id=wx.xrc.XRCID("BUTTON_UNPUBLISH")) name = self.collection.displayName wx.xrc.XRCCTRL(self, "TEXT_MANAGE_COLLNAME").SetLabel(name) name = self.shareXML.conduit.account.displayName wx.xrc.XRCCTRL(self, "TEXT_ACCOUNT").SetLabel(name) url = self.shareXML.conduit.getLocation() wx.xrc.XRCCTRL(self, "TEXT_URL").SetLabel(url) self.UnPubSub = wx.xrc.XRCCTRL(self, "BUTTON_UNPUBLISH") share = Sharing.getShare(self.collection) if Sharing.isSharedByMe(share): self.UnPubSub.SetLabel("Unpublish") else: self.UnPubSub.SetLabel("Unsubscribe") # Controls for managing filtered shares: self.RadioItems = wx.xrc.XRCCTRL(self, "RADIO_ITEMS") self.RadioItemsHidden = wx.xrc.XRCCTRL(self, "RADIO_ITEMS_HIDDEN") self.RadioItemsHidden.Hide() wx.EVT_RADIOBUTTON(self.RadioItems, self.RadioItems.GetId(), self.OnAllItemsClicked) self.CheckboxMail = wx.xrc.XRCCTRL(self, "CHECK_MAIL") wx.EVT_CHECKBOX(self.CheckboxMail, self.CheckboxMail.GetId(), self.OnFilterClicked) self.CheckboxTasks = wx.xrc.XRCCTRL(self, "CHECK_TASKS") wx.EVT_CHECKBOX(self.CheckboxTasks, self.CheckboxTasks.GetId(), self.OnFilterClicked) self.CheckboxEvents = wx.xrc.XRCCTRL(self, "CHECK_EVENTS") wx.EVT_CHECKBOX(self.CheckboxEvents, self.CheckboxEvents.GetId(), self.OnFilterClicked) self.CheckboxShareAlarms = wx.xrc.XRCCTRL(self, "CHECKBOX_ALARMS") self.CheckboxShareAlarms.Enable(False) self.CheckboxShareStatus = wx.xrc.XRCCTRL(self, "CHECKBOX_STATUS") self.CheckboxShareStatus.Enable(False) self.filterKinds = self.shareXML.filterKinds self._loadKindFilterState() self._loadAttributeFilterState(self.shareXML) self.SetDefaultItem(wx.xrc.XRCCTRL(self, "wxID_OK"))
def onUnpublishSidebarCollectionEventUpdateUI(self, event): collection = self.getSidebarSelectedCollection () if collection is not None: share = Sharing.getShare(collection) sharedByMe = Sharing.isSharedByMe(share) event.arguments['Enable'] = collection is not None and Sharing.isShared(collection) and sharedByMe
def onShareItemEvent (self, event): """ Share an ItemCollection. """ itemCollection = event.arguments ['item'] # Make sure we have all the accounts; returns False if the user cancels # out and we don't. if not Sharing.ensureAccountSetUp(self.itsView): return webdavAccount = Sharing.getWebDAVAccount(self.itsView) # commit changes, since we'll be switching to Twisted thread # @@@DLD bug 1998 - update comment above and use refresh instead? self.RepositoryCommitWithStatus() # show status self.setStatusMessage (_("Sharing collection %s") % itemCollection.displayName) # Get or make a share for this item collection share = Sharing.getShare(itemCollection) isNewShare = share is None if isNewShare: share = Sharing.newOutboundShare(self.itsView, itemCollection, account=webdavAccount) # Copy the invitee list into the share's list. As we go, collect the # addresses we'll notify. if len (itemCollection.invitees) == 0: self.setStatusMessage (_("No invitees!")) return inviteeList = [] inviteeStringsList = [] for invitee in itemCollection.invitees: inviteeList.append(invitee) inviteeStringsList.append(invitee.emailAddress) inviteeContact = Contact.getContactForEmailAddress(self.itsView, invitee.emailAddress) if not inviteeContact in share.sharees: share.sharees.append(inviteeContact) # Sync the collection with WebDAV self.setStatusMessage (_("accessing WebDAV server")) try: if not share.exists(): share.create() share.put() except Sharing.SharingError, err: self.setStatusMessage (_("Sharing failed.")) msg = "Couldn't share collection:\n%s" % err.message application.dialogs.Util.ok(wx.GetApp().mainFrame, "Error", msg) if isNewShare: share.conduit.delete() share.format.delete() share.delete() return
def onUnpublishSidebarCollectionEventUpdateUI(self, event): collection = self.getSidebarSelectedCollection() if collection is not None: share = Sharing.getShare(collection) sharedByMe = Sharing.isSharedByMe(share) event.arguments["Enable"] = collection is not None and Sharing.isShared(collection) and sharedByMe