Пример #1
0
    def _add_bookmark(self, jid, autojoin, password, method):
        nick = None
        if not jid:
            tab = self.core.tabs.current_tab
            roomname = tab.name
            if tab.joined and tab.own_nick != self.core.own_nick:
                nick = tab.own_nick
            if password is None and tab.password is not None:
                password = tab.password
        elif jid == '*':
            return self._add_wildcard_bookmarks(method)
        else:
            info = safeJID(jid)
            roomname, nick = info.bare, info.resource
            if roomname == '':
                tab = self.core.tabs.current_tab
                if not isinstance(tab, tabs.MucTab):
                    return
                roomname = tab.name
        bookmark = self.core.bookmarks[roomname]
        if bookmark is None:
            bookmark = Bookmark(roomname)
            self.core.bookmarks.append(bookmark)
        bookmark.method = method
        bookmark.autojoin = autojoin
        if nick:
            bookmark.nick = nick
        if password:
            bookmark.password = password

        self.core.bookmarks.save_local()
        self.core.bookmarks.save_remote(self.core.xmpp,
                                        self.core.handler.on_bookmark_result)
Пример #2
0
    def _add_bookmark(self, jid, autojoin, password, method):
        nick = None
        if not jid:
            tab = self.core.tabs.current_tab
            roomname = tab.jid.bare
            if tab.joined and tab.own_nick != self.core.own_nick:
                nick = tab.own_nick
            if password is None and tab.password is not None:
                password = tab.password
        elif jid == '*':
            return self._add_wildcard_bookmarks(method)
        else:
            info = safeJID(jid)
            roomname, nick = info.bare, info.resource
            if roomname == '':
                tab = self.core.tabs.current_tab
                if not isinstance(tab, tabs.MucTab):
                    return
                roomname = tab.jid.bare
        bookmark = self.core.bookmarks[roomname]
        if bookmark is None:
            bookmark = Bookmark(roomname)
            self.core.bookmarks.append(bookmark)
        bookmark.method = method
        bookmark.autojoin = autojoin
        if nick:
            bookmark.nick = nick
        if password:
            bookmark.password = password

        self.core.bookmarks.save_local()
        self.core.bookmarks.save_remote(self.core.xmpp,
                                        self.core.handler.on_bookmark_result)
Пример #3
0
 def _add_wildcard_bookmarks(self, method):
     new_bookmarks = []
     for tab in self.core.get_tabs(tabs.MucTab):
         bookmark = self.core.bookmarks[tab.name]
         if not bookmark:
             bookmark = Bookmark(tab.name, autojoin=True, method=method)
             new_bookmarks.append(bookmark)
         else:
             bookmark.method = method
             new_bookmarks.append(bookmark)
             self.core.bookmarks.remove(bookmark)
     new_bookmarks.extend(self.core.bookmarks.bookmarks)
     self.core.bookmarks.set(new_bookmarks)
     self.core.bookmarks.save_local()
     self.core.bookmarks.save_remote(self.core.xmpp,
                                     self.core.handler.on_bookmark_result)
Пример #4
0
 def _add_wildcard_bookmarks(self, method):
     new_bookmarks = []
     for tab in self.core.get_tabs(tabs.MucTab):
         bookmark = self.core.bookmarks[tab.jid.bare]
         if not bookmark:
             bookmark = Bookmark(tab.jid.bare, autojoin=True, method=method)
             new_bookmarks.append(bookmark)
         else:
             bookmark.method = method
             new_bookmarks.append(bookmark)
             self.core.bookmarks.remove(bookmark)
     new_bookmarks.extend(self.core.bookmarks.bookmarks)
     self.core.bookmarks.set(new_bookmarks)
     self.core.bookmarks.save_local()
     self.core.bookmarks.save_remote(self.core.xmpp,
                                     self.core.handler.on_bookmark_result)
Пример #5
0
 def _add_wildcard_bookmarks(self, method):
     new_bookmarks = []
     for tab in self.core.get_tabs(tabs.MucTab):
         bookmark = self.core.bookmarks[tab.name]
         if not bookmark:
             bookmark = Bookmark(tab.name, autojoin=True,
                                 method=method)
             new_bookmarks.append(bookmark)
         else:
             bookmark.method = method
             new_bookmarks.append(bookmark)
             self.core.bookmarks.remove(bookmark)
     new_bookmarks.extend(self.core.bookmarks.bookmarks)
     self.core.bookmarks.set(new_bookmarks)
     def _cb(iq):
         if iq["type"] != "error":
             self.core.information("Bookmarks saved.", "Info")
         else:
             self.core.information("Could not save the remote bookmarks.", "Info")
     self.core.bookmarks.save_local()
     self.core.bookmarks.save_remote(self.core.xmpp, _cb)
Пример #6
0
 def _add_wildcard_bookmarks(self, method):
     new_bookmarks = []
     for tab in self.core.get_tabs(tabs.MucTab):
         bookmark = self.core.bookmarks[tab.name]
         if not bookmark:
             bookmark = Bookmark(tab.name, autojoin=True,
                                 method=method)
             new_bookmarks.append(bookmark)
         else:
             bookmark.method = method
             new_bookmarks.append(bookmark)
             self.core.bookmarks.remove(bookmark)
     new_bookmarks.extend(self.core.bookmarks.bookmarks)
     self.core.bookmarks.set(new_bookmarks)
     def _cb(iq):
         if iq["type"] != "error":
             self.core.information("Bookmarks saved.", "Info")
         else:
             self.core.information("Could not save the remote bookmarks.", "Info")
     self.core.bookmarks.save_local()
     self.core.bookmarks.save_remote(self.core.xmpp, _cb)
Пример #7
0
    def _add_bookmark(self, jid, autojoin, password, method):
        nick = None
        if not jid:
            tab = self.core.current_tab()
            roomname = tab.name
            if tab.joined and tab.own_nick != self.core.own_nick:
                nick = tab.own_nick
            if password is None and tab.password is not None:
                password = tab.password
        elif jid == '*':
            return self._add_wildcard_bookmarks(method)
        else:
            info = safeJID(jid)
            roomname, nick = info.bare, info.resource
            if roomname == '':
                tab = self.core.current_tab()
                if not isinstance(tab, tabs.MucTab):
                    return
                roomname = tab.name
        bookmark = self.core.bookmarks[roomname]
        if bookmark is None:
            bookmark = Bookmark(roomname)
            self.core.bookmarks.append(bookmark)
        bookmark.method = method
        bookmark.autojoin = autojoin
        if nick:
            bookmark.nick = nick
        if password:
            bookmark.password = password

        def callback(iq):
            if iq["type"] != "error":
                self.core.information('Bookmark added.', 'Info')
            else:
                self.core.information("Could not add the bookmarks.", "Info")

        self.core.bookmarks.save_local()
        self.core.bookmarks.save_remote(self.core.xmpp, callback)
Пример #8
0
    def _add_bookmark(self, jid, autojoin, password, method):
        nick = None
        if not jid:
            tab = self.core.tabs.current_tab
            roomname = tab.name
            if tab.joined and tab.own_nick != self.core.own_nick:
                nick = tab.own_nick
            if password is None and tab.password is not None:
                password = tab.password
        elif jid == '*':
            return self._add_wildcard_bookmarks(method)
        else:
            info = safeJID(jid)
            roomname, nick = info.bare, info.resource
            if roomname == '':
                tab = self.core.tabs.current_tab
                if not isinstance(tab, tabs.MucTab):
                    return
                roomname = tab.name
        bookmark = self.core.bookmarks[roomname]
        if bookmark is None:
            bookmark = Bookmark(roomname)
            self.core.bookmarks.append(bookmark)
        bookmark.method = method
        bookmark.autojoin = autojoin
        if nick:
            bookmark.nick = nick
        if password:
            bookmark.password = password

        def callback(iq):
            if iq["type"] != "error":
                self.core.information('Bookmark added.', 'Info')
            else:
                self.core.information("Could not add the bookmarks.", "Info")

        self.core.bookmarks.save_local()
        self.core.bookmarks.save_remote(self.core.xmpp, callback)