diff options
author | mathieui <mathieui@mathieui.net> | 2012-04-15 23:55:50 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-04-15 23:55:50 +0200 |
commit | 265702b1501d2c279a887ed3c90c0ba0ad7d95c2 (patch) | |
tree | 49c2a87dac8c03a20eb791bfc6d13923e09265ee | |
parent | 941acdb612061190fec341a78d5741c4ee0374e2 (diff) | |
download | poezio-265702b1501d2c279a887ed3c90c0ba0ad7d95c2.tar.gz poezio-265702b1501d2c279a887ed3c90c0ba0ad7d95c2.tar.bz2 poezio-265702b1501d2c279a887ed3c90c0ba0ad7d95c2.tar.xz poezio-265702b1501d2c279a887ed3c90c0ba0ad7d95c2.zip |
Add a way to bookmark all the rooms at once
(/bookmark * or /bookmark_local *)
-rw-r--r-- | src/bookmark.py | 2 | ||||
-rw-r--r-- | src/core.py | 38 |
2 files changed, 37 insertions, 3 deletions
diff --git a/src/bookmark.py b/src/bookmark.py index 38979697..95f42dd8 100644 --- a/src/bookmark.py +++ b/src/bookmark.py @@ -124,7 +124,7 @@ def save_privatexml(xmpp): """"Save the remote bookmarks with privatexml.""" xmpp.plugin['xep_0048'].set_bookmarks_old(stanza_storage('privatexml')) -def save_remote(xmpp, method="privatexml"): +def save_remote(xmpp, method=preferred): """Save the remote bookmarks.""" method = "privatexml" if method != 'pep' else 'pep' diff --git a/src/core.py b/src/core.py index eb7d9e89..f8450ef2 100644 --- a/src/core.py +++ b/src/core.py @@ -1719,6 +1719,7 @@ class Core(object): jids_list = ['%s/%s' % (jid.bare, nick) for nick in nicks] return the_input.auto_completion(jids_list, '') muc_list = [tab.get_name() for tab in self.tabs if isinstance(tab, tabs.MucTab)] + muc_list.append('*') return the_input.auto_completion(muc_list, '') def completion_bookmark(self, the_input): @@ -1753,6 +1754,7 @@ class Core(object): jids_list = ['%s/%s' % (jid.bare, nick) for nick in nicks] return the_input.auto_completion(jids_list, '') muc_list = [tab.get_name() for tab in self.tabs if isinstance(tab, tabs.MucTab)] + muc_list.append('*') return the_input.auto_completion(muc_list, '') def completion_version(self, the_input): @@ -1869,15 +1871,28 @@ class Core(object): roomname = tab.get_name() if tab.joined: nick = tab.own_nick + elif args[0] == '*': + for tab in self.tabs: + if isinstance(tab, tabs.MucTab): + b = bookmark.get_by_jid(tab.get_name()) + if not b: + b = bookmark.Bookmark(tab.get_name(), autojoin=True, method="local") + bookmark.bookmarks.append(b) + else: + b.method = "local" + bookmark.save_local() + self.information('Bookmarks added and saved.', 'Info') + return else: info = JID(args[0]) if info.resource != '': nick = info.resource roomname = info.bare - if roomname == '': + if not roomname: if not isinstance(self.current_tab(), tabs.MucTab): return roomname = self.current_tab().get_name() + bm = bookmark.get_by_jid(roomname) if not bm: bm = bookmark.Bookmark(jid=roomname) @@ -1897,6 +1912,7 @@ class Core(object): """ /bookmark [room][/nick] [autojoin] [password] """ + if config.get('use_remote_bookmarks', 'true').lower() == 'false': self.command_bookmark_local(arg) return @@ -1911,6 +1927,24 @@ class Core(object): nick = tab.own_nick autojoin = True password = None + elif args[0] == '*': + if len(args) > 1: + autojoin = False if args[1].lower() == 'false' else True + else: + autojoin = True + for tab in self.tabs: + if isinstance(tab, tabs.MucTab): + b = bookmark.get_by_jid(tab.get_name()) + if not b: + b = bookmark.Bookmark(tab.get_name(), autojoin=autojoin) + bookmark.bookmarks.append(b) + else: + b.method = "local" + if bookmark.save_remote(self.xmpp, self): + self.information("Bookmarks added.", "Info") + else: + self.information("Could not add the bookmarks.", "Info") + return else: info = JID(args[0]) if info.resource != '': @@ -1939,7 +1973,7 @@ class Core(object): bm.password = password if autojoin: bm.autojoin = autojoin - if bookmark.save_remote(self.xmpp, self): + if bookmark.save_remote(self.xmpp): self.information('Bookmark added.', 'Info') self.information(_('Your remote bookmarks are now: %s') % [b for b in bookmark.bookmarks if b.method in ('pep', 'privatexml')], 'Info') |