Exemplo n.º 1
0
    def ShowPublishPanel(self):
        # "Publish" mode -- i.e., the collection has not yet been shared

        self.Bind(wx.EVT_BUTTON, self.OnPublish, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)

        collName = Sharing.getFilteredCollectionDisplayName(self.collection,
                                                            self.filterKinds)
        wx.xrc.XRCCTRL(self,
                       "TEXT_COLLNAME").SetLabel(collName)

        self.currentAccount = Sharing.getWebDAVAccount(self.view)

        # Populate the listbox of sharing accounts
        self.accounts = self._getSharingAccounts()
        self.accountsControl = wx.xrc.XRCCTRL(self, "CHOICE_ACCOUNT")
        self.accountsControl.Clear()

        for account in self.accounts:
            newIndex = self.accountsControl.Append(account.displayName)
            self.accountsControl.SetClientData(newIndex, account)
            if account is self.currentAccount:
                self.accountsControl.SetSelection(newIndex)

        self.Bind(wx.EVT_CHOICE,
                  self.OnChangeAccount,
                  id=wx.xrc.XRCID("CHOICE_ACCOUNT"))

        self.CheckboxShareAlarms = wx.xrc.XRCCTRL(self, "CHECKBOX_ALARMS")
        self.CheckboxShareAlarms.SetValue(False)
        self.CheckboxShareStatus = wx.xrc.XRCCTRL(self, "CHECKBOX_STATUS")
        self.CheckboxShareStatus.SetValue(False)

        self.SetDefaultItem(wx.xrc.XRCCTRL(self, "wxID_OK"))
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    def __init__(self,
                 parent,
                 title,
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 resources=None,
                 view=None,
                 url=None):

        wx.Dialog.__init__(self, parent, -1, title, pos, size, style)

        self.view = view
        self.resources = resources
        self.parent = parent

        self.mySizer = wx.BoxSizer(wx.VERTICAL)
        self.toolPanel = self.resources.LoadPanel(self, "Subscribe")
        self.mySizer.Add(self.toolPanel, 0, wx.GROW | wx.ALL, 5)

        self.statusPanel = self.resources.LoadPanel(self, "StatusPanel")
        self.statusPanel.Hide()
        self.accountPanel = self.resources.LoadPanel(self,
                                                     "UsernamePasswordPanel")
        self.accountPanel.Hide()

        self.SetSizer(self.mySizer)
        self.mySizer.SetSizeHints(self)
        self.mySizer.Fit(self)

        self.textUrl = wx.xrc.XRCCTRL(self, "TEXT_URL")
        if url is not None:
            self.textUrl.SetValue(url)
        else:
            account = Sharing.getWebDAVAccount(self.view)
            if account:
                url = account.getLocation()
                self.textUrl.SetValue(url)

        self.Bind(wx.EVT_TEXT, self.OnTyping, self.textUrl)

        self.textStatus = wx.xrc.XRCCTRL(self, "TEXT_STATUS")
        self.textUsername = wx.xrc.XRCCTRL(self, "TEXT_USERNAME")
        self.textPassword = wx.xrc.XRCCTRL(self, "TEXT_PASSWORD")
        self.checkboxKeepOut = wx.xrc.XRCCTRL(self, "CHECKBOX_KEEPOUT")
        self.checkboxKeepOut.Enable(False)  # Not yet supported

        self.Bind(wx.EVT_BUTTON, self.OnSubscribe, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)

        self.SetDefaultItem(wx.xrc.XRCCTRL(self, "wxID_OK"))

        self.textUrl.SetFocus()
        self.textUrl.SetInsertionPointEnd()
Exemplo n.º 4
0
    def __init__(self, parent, title, size=wx.DefaultSize,
         pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE,
         resources=None, view=None, url=None):

        wx.Dialog.__init__(self, parent, -1, title, pos, size, style)

        self.view = view
        self.resources = resources
        self.parent = parent

        self.mySizer = wx.BoxSizer(wx.VERTICAL)
        self.toolPanel = self.resources.LoadPanel(self, "Subscribe")
        self.mySizer.Add(self.toolPanel, 0, wx.GROW|wx.ALL, 5)

        self.statusPanel = self.resources.LoadPanel(self, "StatusPanel")
        self.statusPanel.Hide()
        self.accountPanel = self.resources.LoadPanel(self, "UsernamePasswordPanel")
        self.accountPanel.Hide()

        self.SetSizer(self.mySizer)
        self.mySizer.SetSizeHints(self)
        self.mySizer.Fit(self)

        self.textUrl = wx.xrc.XRCCTRL(self, "TEXT_URL")
        if url is not None:
            self.textUrl.SetValue(url)
        else:
            account = Sharing.getWebDAVAccount(self.view)
            if account:
                url = account.getLocation()
                self.textUrl.SetValue(url)

        self.Bind(wx.EVT_TEXT, self.OnTyping, self.textUrl)

        self.textStatus = wx.xrc.XRCCTRL(self, "TEXT_STATUS")
        self.textUsername = wx.xrc.XRCCTRL(self, "TEXT_USERNAME")
        self.textPassword = wx.xrc.XRCCTRL(self, "TEXT_PASSWORD")
        self.checkboxKeepOut = wx.xrc.XRCCTRL(self, "CHECKBOX_KEEPOUT")
        self.checkboxKeepOut.Enable(False) # Not yet supported

        self.Bind(wx.EVT_BUTTON, self.OnSubscribe, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)

        self.SetDefaultItem(wx.xrc.XRCCTRL(self, "wxID_OK"))


        self.textUrl.SetFocus()
        self.textUrl.SetInsertionPointEnd()
Exemplo n.º 5
0
    def __init__(
        self,
        parent,
        title,
        size=wx.DefaultSize,
        pos=wx.DefaultPosition,
        style=wx.DEFAULT_DIALOG_STYLE,
        resources=None,
        view=None,
        share=None,
        join=False,
    ):

        wx.Dialog.__init__(self, parent, -1, title, pos, size, style)

        self.view = view
        self.join = join
        self.share = share
        self.resources = resources

        self.mySizer = wx.BoxSizer(wx.VERTICAL)
        self.toolPanel = self.resources.LoadPanel(self, "ShareEditor")
        self.mySizer.Add(self.toolPanel, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.SetSizer(self.mySizer)
        self.mySizer.SetSizeHints(self)
        self.mySizer.Fit(self)

        self.textTitle = wx.xrc.XRCCTRL(self, "TEXT_TITLE")
        wx.EVT_SET_FOCUS(self.textTitle, self.OnFocusGained)
        self.choiceColl = wx.xrc.XRCCTRL(self, "CHOICE_COLL")
        self.choiceAccount = wx.xrc.XRCCTRL(self, "CHOICE_ACCOUNT")
        self.textShareName = wx.xrc.XRCCTRL(self, "TEXT_SHARENAME")
        wx.EVT_SET_FOCUS(self.textShareName, self.OnFocusGained)

        if join:
            self.choiceColl.Disable()

        if share is not None:  # share provided

            self.textTitle.SetValue(share.getItemDisplayName())
            self.textShareName.SetValue(share.conduit.shareName)
            account = share.conduit.account

        else:  # creating the share

            account = Sharing.getWebDAVAccount(self.view)
            self.textTitle.SetValue("Enter a descriptive title")
            self.textShareName.SetValue("Enter directory name to use")

        self.accounts = []
        i = 0
        for item in Sharing.WebDAVAccount.iterItems(self.view):
            self.accounts.append(item)
            self.choiceAccount.Append(item.getItemDisplayName())
            if account is item:
                defaultChoice = i
            i += 1
        self.choiceAccount.SetSelection(defaultChoice)

        if not join:
            from osaf.pim.ItemCollection import ItemCollection

            self.collections = []
            i = 1
            for item in ItemCollection.iterItems(self.view):
                self.collections.append(item)
                self.choiceColl.Append(item.getItemDisplayName())
                if item.getItemDisplayName() == "Calendar Demo":
                    defaultChoice = i
                if share is not None and share.contents is not None:
                    if item is share.contents:
                        self.choiceColl.SetSelection(i)
                i += 1
            if share is None or share.contents is None:
                self.choiceColl.SetSelection(defaultChoice)

        self.Bind(wx.EVT_BUTTON, self.OnOk, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)

        self.SetDefaultItem(wx.xrc.XRCCTRL(self, "wxID_OK"))
        self.textTitle.SetFocus()
Exemplo n.º 6
0
    def __init__(self,
                 parent,
                 title,
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 resources=None,
                 view=None,
                 share=None,
                 join=False):

        wx.Dialog.__init__(self, parent, -1, title, pos, size, style)

        self.view = view
        self.join = join
        self.share = share
        self.resources = resources

        self.mySizer = wx.BoxSizer(wx.VERTICAL)
        self.toolPanel = self.resources.LoadPanel(self, "ShareEditor")
        self.mySizer.Add(self.toolPanel, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.SetSizer(self.mySizer)
        self.mySizer.SetSizeHints(self)
        self.mySizer.Fit(self)

        self.textTitle = wx.xrc.XRCCTRL(self, "TEXT_TITLE")
        wx.EVT_SET_FOCUS(self.textTitle, self.OnFocusGained)
        self.choiceColl = wx.xrc.XRCCTRL(self, "CHOICE_COLL")
        self.choiceAccount = wx.xrc.XRCCTRL(self, "CHOICE_ACCOUNT")
        self.textShareName = wx.xrc.XRCCTRL(self, "TEXT_SHARENAME")
        wx.EVT_SET_FOCUS(self.textShareName, self.OnFocusGained)

        if join:
            self.choiceColl.Disable()

        if share is not None:  # share provided

            self.textTitle.SetValue(share.getItemDisplayName())
            self.textShareName.SetValue(share.conduit.shareName)
            account = share.conduit.account

        else:  # creating the share

            account = Sharing.getWebDAVAccount(self.view)
            self.textTitle.SetValue("Enter a descriptive title")
            self.textShareName.SetValue("Enter directory name to use")

        self.accounts = []
        i = 0
        for item in Sharing.WebDAVAccount.iterItems(self.view):
            self.accounts.append(item)
            self.choiceAccount.Append(item.getItemDisplayName())
            if account is item:
                defaultChoice = i
            i += 1
        self.choiceAccount.SetSelection(defaultChoice)

        if not join:
            from osaf.pim.ItemCollection import ItemCollection
            self.collections = []
            i = 1
            for item in ItemCollection.iterItems(self.view):
                self.collections.append(item)
                self.choiceColl.Append(item.getItemDisplayName())
                if item.getItemDisplayName() == "Calendar Demo":
                    defaultChoice = i
                if share is not None and share.contents is not None:
                    if item is share.contents:
                        self.choiceColl.SetSelection(i)
                i += 1
            if share is None or share.contents is None:
                self.choiceColl.SetSelection(defaultChoice)

        self.Bind(wx.EVT_BUTTON, self.OnOk, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)

        self.SetDefaultItem(wx.xrc.XRCCTRL(self, "wxID_OK"))
        self.textTitle.SetFocus()
Exemplo n.º 7
0
    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