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 onGetNewMailEvent (self, event): # 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 view = self.itsView # @@@DLD bug 1998 - why do we have to commit here? Are we pushing our changes # over to mail? view.commit() for account in Mail.IMAPAccount.getActiveAccounts(self.itsView): Globals.mailService.getIMAPInstance(account).getMail() for account in Mail.POPAccount.getActiveAccounts(self.itsView): Globals.mailService.getPOPInstance(account).getMail() view.refresh()
def onGetNewMailEvent(self, event): # 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 view = self.itsView # @@@DLD bug 1998 - why do we have to commit here? Are we pushing our changes # over to mail? view.commit() for account in Mail.IMAPAccount.getActiveAccounts(self.itsView): Globals.mailService.getIMAPInstance(account).getMail() for account in Mail.POPAccount.getActiveAccounts(self.itsView): Globals.mailService.getPOPInstance(account).getMail() view.refresh()
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