Beispiel #1
0
    def _onAccContextMenu(self, label):
        acc = self._getSelectedAccount()
        if not acc:
            return

        if label == 'Unregister':
            acc.setRegistration(False)
        elif label == 'Reregister':
            acc.setRegistration(True)
        elif label == 'Online':
            ps = pj.PresenceStatus()
            ps.status = pj.PJSUA_BUDDY_STATUS_ONLINE
            acc.setOnlineStatus(ps)
        elif label == 'Invisible':
            ps = pj.PresenceStatus()
            ps.status = pj.PJSUA_BUDDY_STATUS_OFFLINE
            acc.setOnlineStatus(ps)
        elif label == 'Away':
            ps = pj.PresenceStatus()
            ps.status = pj.PJSUA_BUDDY_STATUS_ONLINE
            ps.activity = pj.PJRPID_ACTIVITY_AWAY
            ps.note = "Away"
            acc.setOnlineStatus(ps)
        elif label == 'Busy':
            ps = pj.PresenceStatus()
            ps.status = pj.PJSUA_BUDDY_STATUS_ONLINE
            ps.activity = pj.PJRPID_ACTIVITY_BUSY
            ps.note = "Busy"
            acc.setOnlineStatus(ps)
        elif label == 'Settings...':
            self.cfgChanged = False
            dlg = accountsetting.Dialog(self.master, acc.cfg)
            if dlg.doModal():
                self.updateAccount(acc)
                acc.modify(acc.cfg)
        elif label == 'Delete...':
            msg = "Do you really want to delete account '%s'?" % acc.cfg.idUri
            if msgbox.askquestion('Delete account?', msg,
                                  default=msgbox.NO) != u'yes':
                return
            iid = str(acc.randId)
            self.accList.remove(acc)
            acc.setRegistration(False)
            acc.deleting = True
            del acc
            self.tv.delete((iid, ))
        elif label == 'Add buddy...':
            cfg = pj.BuddyConfig()
            dlg = buddy.SettingDialog(self.master, cfg)
            if dlg.doModal():
                self._createBuddy(acc, cfg)
        else:
            assert not ("Unknown menu " + label)
Beispiel #2
0
    def _onBuddyContextMenu(self, label):
        bud = self._getSelectedBuddy()
        if not bud:
            return
        acc = bud.account

        if label == 'Audio call':
            chat = acc.findChat(bud.cfg.uri)
            if not chat: chat = acc.newChat(bud.cfg.uri)
            chat.showWindow()
            chat.startCall()
        elif label == 'Send instant message':
            chat = acc.findChat(bud.cfg.uri)
            if not chat: chat = acc.newChat(bud.cfg.uri)
            chat.showWindow(True)
        elif label == 'Subscribe':
            bud.subscribePresence(True)
        elif label == 'Unsubscribe':
            bud.subscribePresence(False)
        elif label == 'Settings...':
            subs = bud.cfg.subscribe
            uri = bud.cfg.uri
            dlg = buddy.SettingDialog(self.master, bud.cfg)
            if dlg.doModal():
                self.updateBuddy(bud)
                # URI updated?
                if uri != bud.cfg.uri:
                    cfg = bud.cfg
                    # del old
                    iid = 'buddy' + str(bud.randId)
                    acc.buddyList.remove(bud)
                    del bud
                    self.tv.delete((iid, ))
                    # add new
                    self._createBuddy(acc, cfg)
                # presence subscribe setting updated
                elif subs != bud.cfg.subscribe:
                    bud.subscribePresence(bud.cfg.subscribe)
        elif label == 'Delete...':
            msg = "Do you really want to delete buddy '%s'?" % bud.cfg.uri
            if msgbox.askquestion('Delete buddy?', msg,
                                  default=msgbox.NO) != u'yes':
                return
            iid = 'buddy' + str(bud.randId)
            acc.buddyList.remove(bud)
            del bud
            self.tv.delete((iid, ))
        else:
            assert not ("Unknown menu " + label)