From 265702b1501d2c279a887ed3c90c0ba0ad7d95c2 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 15 Apr 2012 23:55:50 +0200 Subject: Add a way to bookmark all the rooms at once (/bookmark * or /bookmark_local *) --- src/core.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/core.py') 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') -- cgit v1.2.3 From 406e24dcff56a4e4c59a110333d2bc1c7b9d3288 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:07:22 +0200 Subject: Remove if len(list) in command_help --- src/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index f8450ef2..2d7e5129 100644 --- a/src/core.py +++ b/src/core.py @@ -1375,14 +1375,14 @@ class Core(object): /help """ args = arg.split() - if len(args) == 0: + if not args: msg = _('Available commands are: ') for command in self.commands: msg += "%s " % command for command in self.current_tab().commands: msg += "%s " % command msg += _("\nType /help to know what each command does") - if len(args) >= 1: + if args: if args[0] in self.commands: msg = self.commands[args[0]][1] elif args[0] in self.current_tab().commands: -- cgit v1.2.3 From 43b28a1ab0311e16e30711966874d35e2fae254e Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:07:51 +0200 Subject: Replace arg.split with shell_split in command_message --- src/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index 2d7e5129..22dae4cd 100644 --- a/src/core.py +++ b/src/core.py @@ -1537,14 +1537,14 @@ class Core(object): """ /message [message] """ - args = arg.split() + args = common.shell_split(arg) if len(args) < 1: self.command_help('message') return jid = args[0] tab = self.open_conversation_window(jid, focus=True) if len(args) > 1: - tab.command_say(arg.strip()[len(jid)+1:]) + tab.command_say(args[1]) def command_version(self, arg): """ -- cgit v1.2.3 From aef2a905d1a1c54a747d7ed0e07f3e123acac75c Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:09:12 +0200 Subject: Refactor command_list a bit --- src/core.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index 22dae4cd..d700d9dc 100644 --- a/src/core.py +++ b/src/core.py @@ -1576,16 +1576,15 @@ class Core(object): /list Opens a MucListTab containing the list of the room in the specified server """ - args = arg.split() - if len(args) > 1: - self.command_help('list') - return - elif len(args) == 0: + arg = arg.split() + if len(arg) > 1: + return self.command_help('list') + elif arg: + server = JID(arg[0]).server + else: if not isinstance(self.current_tab(), tabs.MucTab): return self.information('Please provide a server', 'Error') server = JID(self.current_tab().get_name()).server - else: - server = arg.strip() list_tab = tabs.MucListTab(server) self.add_tab(list_tab, True) self.xmpp.plugin['xep_0030'].get_items(jid=server, block=False, callback=list_tab.on_muc_list_item_received) -- cgit v1.2.3 From 54a43ab13209721129b961cc7dfb441a70cf7cb5 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:09:39 +0200 Subject: Remove if len(list) in command_theme --- src/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index d700d9dc..c36531c0 100644 --- a/src/core.py +++ b/src/core.py @@ -1592,7 +1592,7 @@ class Core(object): def command_theme(self, arg): """/theme """ args = arg.split() - if len(args) == 1: + if args: self.command_set('theme %s' % (args[0],)) warning = theming.reload_theme() if warning: -- cgit v1.2.3 From 22cd80feb52d539e8aef5a252c75f75cf1f04c5b Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:10:10 +0200 Subject: Refactor command_win a bit --- src/core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index c36531c0..13eea3e1 100644 --- a/src/core.py +++ b/src/core.py @@ -1621,14 +1621,14 @@ class Core(object): """ /win """ - args = arg.split() - if len(args) != 1: + arg = arg.strip() + if not arg: self.command_help('win') return try: - nb = int(args[0]) + nb = int(arg.split()[0]) except ValueError: - nb = arg.strip() + nb = arg if self.current_tab().nb == nb: return self.previous_tab_nb = self.current_tab().nb -- cgit v1.2.3 From d52f5ba40f4f894dfa43162c4e1785ec7345d780 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:35:24 +0200 Subject: Do not quotify completions where it is not allowed --- src/core.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index 13eea3e1..627f7f5c 100644 --- a/src/core.py +++ b/src/core.py @@ -1393,7 +1393,7 @@ class Core(object): def completion_help(self, the_input): commands = list(self.commands.keys()) + list(self.current_tab().commands.keys()) - return the_input.auto_completion(commands, ' ') + return the_input.auto_completion(commands, ' ', quotify=False) def command_status(self, arg): """ @@ -1615,7 +1615,7 @@ class Core(object): theme_files = [name[:-3] for name in names if name.endswith('.py')] if not 'default' in theme_files: theme_files.append('default') - return the_input.auto_completion(theme_files, '') + return the_input.auto_completion(theme_files, '', quotify=False) def command_win(self, arg): """ @@ -1651,7 +1651,7 @@ class Core(object): def completion_win(self, the_input): l = [JID(tab.get_name()).user for tab in self.tabs] l.remove('') - return the_input.auto_completion(l, ' ') + return the_input.auto_completion(l, ' ', quotify=False) def completion_join(self, the_input): """ @@ -1761,7 +1761,7 @@ class Core(object): n = len(the_input.get_text().split()) if n > 2 or (n == 2 and the_input.get_text().endswith(' ')): return - return the_input.auto_completion([contact.bare_jid for contact in roster.get_contacts()], '') + return the_input.auto_completion([contact.bare_jid for contact in roster.get_contacts()], '', quotify=False) def completion_list(self, the_input): muc_serv_list = [] @@ -1770,7 +1770,7 @@ class Core(object): tab.get_name() not in muc_serv_list: muc_serv_list.append(JID(tab.get_name()).server) if muc_serv_list: - return the_input.auto_completion(muc_serv_list, ' ') + return the_input.auto_completion(muc_serv_list, ' ', quotify=False) def command_join(self, arg, histo_length=None): """ -- cgit v1.2.3