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/bookmark.py | 2 +- 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') -- 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(-) 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(-) 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(-) 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(-) 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(-) 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 d049ea753497a255e0554e37c4c81e15541ed08f Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:10:57 +0200 Subject: Do not split args in command_info as it is not needed --- src/tabs.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 9a8f3794..9f67ab29 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -693,18 +693,20 @@ class MucTab(ChatTab): self.input.refresh() def command_info(self, arg): - args = common.shell_split(arg) - if len(args) != 1: - return self.core.information("Info command takes only 1 argument") - user = self.get_user_by_name(args[0]) + """ + /info + """ + if not arg: + return self.command_help('info') + user = self.get_user_by_name(arg) if not user: - return self.core.information("Unknown user: %s" % args[0]) - info = '%s%s: show: %s, affiliation: %s, role: %s%s' % (args[0], - ' (%s)' % user.jid if user.jid else '', - user.show or 'Available', - user.role or 'None', - user.affiliation or 'None', - '\n%s' % user.status if user.status else '') + return self.core.information("Unknown user: %s" % arg) + info = '%s%s: show: %s, affiliation: %s, role: %s%s' % (arg, + ' (%s)' % user.jid if user.jid else '', + user.show or 'Available', + user.role or 'None', + user.affiliation or 'None', + '\n%s' % user.status if user.status else '') self.core.information(info, 'Info') def command_configure(self, arg): -- cgit v1.2.3 From 13a9811cf6768a0819d6157468f07619ee4ca22b Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:11:58 +0200 Subject: Do not split on command_recolor as it is unneeded --- src/tabs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 9f67ab29..d0ade8f5 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -740,9 +740,10 @@ class MucTab(ChatTab): def command_recolor(self, arg): """ + /recolor [random] Re-assign color to the participants of the room """ - args = common.shell_split(arg) + arg = arg.strip() compare_users = lambda x: x.last_talked users = list(self.users) sorted_users = sorted(users, key=compare_users, reverse=True) @@ -752,9 +753,8 @@ class MucTab(ChatTab): sorted_users.remove(user) user.color = get_theme().COLOR_OWN_NICK colors = list(get_theme().LIST_COLOR_NICKNAMES) - if len(args) >= 1: - if args[0] == 'random': - random.shuffle(colors) + if arg and arg == 'random': + random.shuffle(colors) for i, user in enumerate(sorted_users): user.color = colors[i % len(colors)] self.text_win.rebuild_everything(self._text_buffer) -- cgit v1.2.3 From dd751ea14d00708edcb0dd7ad1e72a9a7b8595eb Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:13:09 +0200 Subject: Do not split on command_version as it is unnecessary --- src/tabs.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index d0ade8f5..258b1bc8 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -770,18 +770,18 @@ class MucTab(ChatTab): if not res: return self.core.information('Could not get the software version from %s' % (jid,), 'Warning') version = '%s is running %s version %s on %s' % (jid, - res.get('name') or _('an unknown software'), - res.get('version') or _('unknown'), - res.get('os') or _('on an unknown platform')) + res.get('name') or _('an unknown software'), + res.get('version') or _('unknown'), + res.get('os') or _('on an unknown platform')) self.core.information(version, 'Info') - args = common.shell_split(arg) - if len(args) < 1: - return - if args[0] in [user.nick for user in self.users]: - jid = self.name + '/' + args[0] + if not arg: + return self.command_help('version') + if arg in [user.nick for user in self.users]: + jid = JID(self.name) + jid.resource = arg else: - jid = args[0] + jid = JID(arg) self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback) def command_nick(self, arg): -- cgit v1.2.3 From d0e0be2dd6d3161fde60b21e822042a21ebe7265 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:13:44 +0200 Subject: Do not split on command_nick as it is unnecessary --- src/tabs.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 258b1bc8..b1363ddd 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -788,12 +788,11 @@ class MucTab(ChatTab): """ /nick """ - args = common.shell_split(arg) - if len(args) != 1: - return - nick = args[0] + if not arg: + return self.command_help('nick') + nick = arg if not self.joined: - return + return self.core.information('/nick only works in joined rooms', 'Info') current_status = self.core.get_status() muc.change_nick(self.core.xmpp, self.name, nick, current_status.message, current_status.show) -- cgit v1.2.3 From 1c18c6e2b505f0a9ffe8867aa63edae90a355c2c Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:14:08 +0200 Subject: Do not split on command_part as it is unnecessary --- src/tabs.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index b1363ddd..908a0ce5 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -800,11 +800,7 @@ class MucTab(ChatTab): """ /part [msg] """ - args = arg.split() - if len(args): - arg = ' '.join(args) - else: - arg = None + arg = arg.strip() if self.joined: self.disconnect() muc.leave_groupchat(self.core.xmpp, self.name, self.own_nick, arg) @@ -824,7 +820,6 @@ class MucTab(ChatTab): self.command_part(arg) self.core.close_tab() - def command_query(self, arg): """ /query [message] -- cgit v1.2.3 From 4ab6a591cfb00afe9ebdbee624220562f1f81081 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:14:56 +0200 Subject: Remove a if not len(list) in command_kick --- src/tabs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabs.py b/src/tabs.py index 908a0ce5..c3da59db 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -907,7 +907,7 @@ class MucTab(ChatTab): /kick [reason] """ args = common.shell_split(arg) - if not len(args): + if not args: self.core.command_help('kick') else: if len(args) > 1: -- cgit v1.2.3 From e934d8b513bb6537aad4b0f164666c916ab6dcad Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:16:00 +0200 Subject: Do not split on command_ignore as it is unnecessary --- src/tabs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index c3da59db..0bb8174e 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -984,11 +984,10 @@ class MucTab(ChatTab): """ /ignore """ - args = common.shell_split(arg) - if len(args) != 1: + if not arg: self.core.command_help('ignore') return - nick = args[0] + nick = arg user = self.get_user_by_name(nick) if not user: self.core.information(_('%s is not in the room') % nick) -- cgit v1.2.3 From 31382401500292c27797d21d8e86bc7c2fe48161 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:16:44 +0200 Subject: Do not split on command_unignore as it is unnecessary --- src/tabs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 0bb8174e..4f95194b 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1001,11 +1001,10 @@ class MucTab(ChatTab): """ /unignore """ - args = common.shell_split(arg) - if len(args) != 1: + if not arg: self.core.command_help('unignore') return - nick = args[0] + nick = arg user = self.get_user_by_name(nick) if not user: self.core.information(_('%s is not in the room') % nick) -- cgit v1.2.3 From 3a1a1dcc6d20f1921d3ea2bb2347ab52c70bea3d Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:17:16 +0200 Subject: Do not split on command_deny as it is unneeded --- src/tabs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 4f95194b..13c642ee 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1763,12 +1763,12 @@ class RosterInfoTab(Tab): self.core.information_win.rebuild_everything(self.core.information_buffer) self.refresh() - def command_deny(self, args): + def command_deny(self, arg): """ + /deny [jid] Denies a JID from our roster """ - args = args.split() - if not args: + if not arg: item = self.roster_win.selected_row if isinstance(item, Contact) and item.ask == 'asked': jid = item.bare_jid @@ -1776,7 +1776,7 @@ class RosterInfoTab(Tab): self.core.information('No subscription to deny') return else: - jid = JID(args[0]).bare + jid = JID(arg).bare if not jid in [contact.bare_jid for contact in roster.get_contacts()]: self.core.information('No subscription to deny') return -- cgit v1.2.3 From abd8d30990b64b35b86d56326a489ac9f1ad1b85 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:17:46 +0200 Subject: Split correctly on command_name --- src/tabs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 13c642ee..5e1f3038 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1800,13 +1800,13 @@ class RosterInfoTab(Tab): return self.core.xmpp.sendPresence(pto=jid, ptype='subscribe') - def command_name(self, args): + def command_name(self, arg): """ Set a name for the specified JID in your roster """ - args = args.split(None, 1) - if len(args) < 1: - return + args = common.shell_split(arg) + if not args: + return self.command_help('name') jid = JID(args[0]).bare name = args[1] if len(args) == 2 else '' -- cgit v1.2.3 From 1fdb91a98393aa0ad2f9b844cec7d714b4a3f2f7 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:18:18 +0200 Subject: Split correctly on command_groupremove --- src/tabs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabs.py b/src/tabs.py index 5e1f3038..0814d2fc 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1855,7 +1855,7 @@ class RosterInfoTab(Tab): """ Remove the specified JID to the specified group """ - args = args.split(None, 1) + args = common.shell_split(args) if len(args) != 2: return jid = JID(args[0]).bare -- cgit v1.2.3 From 5c06af299e51f7861649bcd74127ac8c40de09c1 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:21:53 +0200 Subject: Fix some completions accordingly (name/groupadd/groupremove) --- src/tabs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 0814d2fc..c2e2fc57 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1961,7 +1961,7 @@ class RosterInfoTab(Tab): def completion_name(self, the_input): text = the_input.get_text() - n = len(text.split()) + n = len(common.shell_split(text)) if text.endswith(' '): n += 1 @@ -1972,7 +1972,7 @@ class RosterInfoTab(Tab): def completion_groupadd(self, the_input): text = the_input.get_text() - n = len(text.split()) + n = len(common.shell_split(text)) if text.endswith(' '): n += 1 @@ -1986,7 +1986,7 @@ class RosterInfoTab(Tab): def completion_groupremove(self, the_input): text = the_input.get_text() - args = text.split() + args = common.shell_split(text) n = len(args) if text.endswith(' '): n += 1 -- cgit v1.2.3 From c2e122d87377acbc6b512b7fe83d1461ac876288 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:22:30 +0200 Subject: Do not split on command_accept as it is unneeded --- src/tabs.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index c2e2fc57..9c63f232 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2015,12 +2015,11 @@ class RosterInfoTab(Tab): if contact.ask == 'asked'] return the_input.auto_completion(jids, '') - def command_accept(self, args): + def command_accept(self, arg): """ Accept a JID from in roster. Authorize it AND subscribe to it """ - args = args.split() - if not args: + if not arg: item = self.roster_win.selected_row if isinstance(item, Contact) and item.ask == 'asked': jid = item.bare_jid @@ -2028,7 +2027,7 @@ class RosterInfoTab(Tab): self.core.information('No subscription to accept') return else: - jid = args[0] + jid = JID(arg).bare self.core.xmpp.sendPresence(pto=jid, ptype='subscribed') self.core.xmpp.sendPresence(pto=jid, ptype='') contact = roster.get_contact_by_jid(jid) -- cgit v1.2.3 From 609f55a4d7f224e0994098558e2d9e7834edf8ec Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:23:28 +0200 Subject: Quote everything that is completed by default, except commands --- src/tabs.py | 2 +- src/windows.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 9c63f232..a87aed23 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -211,7 +211,7 @@ class Tab(object): # complete the command's name words = ['/%s'% (name) for name in self.core.commands] +\ ['/%s' % (name) for name in self.commands] - the_input.auto_completion(words, '') + the_input.auto_completion(words, '', quotify=False) # Do not try to cycle command completion if there was only # one possibily. The next tab will complete the argument. # Otherwise we would need to add a useless space before being diff --git a/src/windows.py b/src/windows.py index 50cad4c6..77523e8f 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1077,8 +1077,7 @@ class Input(Win): completion_type = config.get('completion', 'normal') if quotify: for i, word in enumerate(word_list[:]): - if ' ' in word: - word_list[i] = '"' + word + '"' + word_list[i] = '"' + word + '"' if completion_type == 'shell' and self.text != '': self.shell_completion(word_list, add_after) else: -- 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 +++++----- src/tabs.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) 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): """ diff --git a/src/tabs.py b/src/tabs.py index a87aed23..fce2bade 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -415,7 +415,7 @@ class ChatTab(Tab): for word in txt.split(): if len(word) >= 4 and word not in words: words.append(word) - self.input.auto_completion(words, ' ') + self.input.auto_completion(words, ' ', quotify=False) def on_enter(self): txt = self.input.key_enter() @@ -629,23 +629,23 @@ class MucTab(ChatTab): if user.nick != self.own_nick] contact_list = [contact.bare_jid for contact in roster.get_contacts()] userlist.extend(contact_list) - return the_input.auto_completion(userlist, '') + return the_input.auto_completion(userlist, '', quotify=False) def completion_nick(self, the_input): """Completion for /nick""" nicks = [os.environ.get('USER'), config.get('default_nick', ''), self.core.get_bookmark_nickname(self.get_name())] while nicks.count(''): nicks.remove('') - return the_input.auto_completion(nicks, '') + return the_input.auto_completion(nicks, '', quotify=False) def completion_recolor(self, the_input): - return the_input.auto_completion(['random'], '') + return the_input.auto_completion(['random'], '', quotify=False) def completion_ignore(self, the_input): """Completion for /ignore""" userlist = [user.nick for user in self.users] userlist.remove(self.own_nick) - return the_input.auto_completion(userlist, '') + return the_input.auto_completion(userlist, '', quotify=False) def completion_role(self, the_input): """Completion for /role""" @@ -1015,7 +1015,7 @@ class MucTab(ChatTab): self.core.information(_('%s is now unignored') % nick) def completion_unignore(self, the_input): - return the_input.auto_completion([user.nick for user in self.ignores], ' ') + return the_input.auto_completion([user.nick for user in self.ignores], ' ', quotify=False) def resize(self): """ @@ -2013,7 +2013,7 @@ class RosterInfoTab(Tab): """ jids = [contact.bare_jid for contact in roster.get_contacts()\ if contact.ask == 'asked'] - return the_input.auto_completion(jids, '') + return the_input.auto_completion(jids, '', quotify=False) def command_accept(self, arg): """ -- cgit v1.2.3 From 26a9876ae88fd111a064ba5946f2f0524adae06e Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 00:42:31 +0200 Subject: Document the command/quote behaviour --- doc/en/usage.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/en/usage.txt b/doc/en/usage.txt index 46e88a7e..8f8d3ad4 100644 --- a/doc/en/usage.txt +++ b/doc/en/usage.txt @@ -151,6 +151,14 @@ The commands described in this page are shown like this: You can get the same help as below with the _/help_ command. +NOTE: Use command parameters like this: + +* Do not use quotes if they are unnecessary (words without special chars) +* If the command takes several agrguments, you need to put quotes around + arguments containing special chars such as backslashes or quotes +* If the command always takes only one argument, then do not use quotes even + for words containing special chars + Global commands ~~~~~~~~~~~~~~~ -- cgit v1.2.3 From 6b01e714623b6d7c1c60c98019c52633b2788250 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 15:54:16 +0200 Subject: Adda config.getl to return a lowercase value --- src/config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/config.py b/src/config.py index b4b07491..e99572d7 100644 --- a/src/config.py +++ b/src/config.py @@ -50,6 +50,12 @@ class Config(RawConfigParser): return default return res + def getl(self, option, default, section=DEFSECTION): + """ + get a value and return it lowercase + """ + return self.get(option, default, section).lower() + def get_by_tabname(self, option, default, tabname, fallback=True): """ Try to get the value for the option. First we look in -- cgit v1.2.3 From 384f6939cb09268ebbb3072490b3b0c87bff82ba Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 15:54:52 +0200 Subject: Add a get_nick method to the tabs --- src/tabs.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/tabs.py b/src/tabs.py index fce2bade..66af43b5 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -269,6 +269,12 @@ class Tab(object): """ return self.__class__.__name__ + def get_nick(self): + """ + Get the nick of the tab (defaults to its name) + """ + return self.get_name() + def get_text_window(self): """ Returns the principal TextWin window, if there's one @@ -1086,6 +1092,11 @@ class MucTab(ChatTab): def get_name(self): return self.name + def get_nick(self): + if config.getl('show_muc_jid', 'true') == 'false': + return JID(self.name).user + return self.name + def get_text_window(self): return self.text_win @@ -1585,6 +1596,9 @@ class PrivateTab(ChatTab): def get_name(self): return self.name + def get_nick(self): + return JID(self.name).resource + def on_input(self, key, raw): if not raw and key in self.key_func: self.key_func[key]() @@ -2350,6 +2364,10 @@ class ConversationTab(ChatTab): def get_name(self): return self.name + def get_nick(self): + jid = JID(self.name) + return roster.get_contact_by_jid(jid.bare).name or jid.user + def on_input(self, key, raw): if not raw and key in self.key_func: self.key_func[key]() -- cgit v1.2.3 From b3c4dd93eb8cb573c4c8980bc01d578aae2bd7e4 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 15:55:24 +0200 Subject: Add new options use_tab_nicks, show_tab_numbers, and show_tab_names (thanks gio) --- src/windows.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/windows.py b/src/windows.py index 77523e8f..56b72884 100644 --- a/src/windows.py +++ b/src/windows.py @@ -319,15 +319,24 @@ class GlobalInfoBar(Win): self._win.erase() self.addstr(0, 0, "[", to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) sorted_tabs = sorted(self.core.tabs, key=comp) + show_names = config.getl('show_tab_names', 'false') == 'true' + show_nums = config.getl('show_tab_numbers', 'true') != 'false' + use_nicks = config.getl('use_tab_nicks', 'true') != 'false' for tab in sorted_tabs: color = tab.color if config.get('show_inactive_tabs', 'true') == 'false' and\ color is get_theme().COLOR_TAB_NORMAL: continue try: - self.addstr("%s" % str(tab.nb), to_curses_attr(color)) - if config.get('show_tab_names', 'false') == 'true': - self.addstr(" %s" % str(tab.get_name()), to_curses_attr(color)) + if show_nums or not show_names: + self.addstr("%s" % str(tab.nb), to_curses_attr(color)) + if show_names: + self.addstr(' ', to_curses_attr(color)) + if show_names: + if use_nicks: + self.addstr("%s" % str(tab.get_nick()), to_curses_attr(color)) + else: + self.addstr("%s" % str(tab.get_name()), to_curses_attr(color)) self.addstr("|", to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) except: # end of line break @@ -356,6 +365,7 @@ class VerticalGlobalInfoBar(Win): sorted_tabs = [tab for tab in sorted_tabs if\ tab.vertical_color is not get_theme().COLOR_VERTICAL_TAB_NORMAL] nb_tabs = len(sorted_tabs) + use_nicks = config.getl('use_tab_nicks', 'true') != 'false' if nb_tabs >= height: for y, tab in enumerate(sorted_tabs): if tab.vertical_color == get_theme().COLOR_VERTICAL_TAB_CURRENT: @@ -372,7 +382,10 @@ class VerticalGlobalInfoBar(Win): color = tab.vertical_color self.addstr(y if config.get('vertical_tab_list_sort', 'desc') != 'asc' else height - y - 1, 0, "%2d" % tab.nb, to_curses_attr(get_theme().COLOR_VERTICAL_TAB_NUMBER)) self.addstr('.') - self.addnstr("%s" % tab.get_name(), width - 4, to_curses_attr(color)) + if use_nicks: + self.addnstr("%s" % tab.get_nick(), width - 4, to_curses_attr(color)) + else: + self.addnstr("%s" % tab.get_name(), width - 4, to_curses_attr(color)) self._win.attron(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) self._win.vline(0, width-1, curses.ACS_VLINE, height) self._win.attroff(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) -- cgit v1.2.3 From 25a9a36201cf1e00fc5ece9a39ec2a9a57ced6b3 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 15:57:43 +0200 Subject: Document the new options --- data/default_config.cfg | 16 ++++++++++++++++ doc/en/configure.txt | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/data/default_config.cfg b/data/default_config.cfg index dc5cc4d6..59655f99 100644 --- a/data/default_config.cfg +++ b/data/default_config.cfg @@ -199,6 +199,22 @@ plugins_autoload = # with no activity, set to true. Else, set to false show_inactive_tabs = true +# If you want to show the tab names in the bottom tab bar, set this to true +show_tab_names = false + +# If you want to disable the numbers in the bottom tab bar, set this to false +# If show_tab_names and show_tab_numbers are both false, the numbers will be +# shown +show_tab_numbers = true + +# Use the contact name, the nick in the MUC instead of the full JID to +# display the tab if set to true. +use_tab_nicks = true + +# If set to false, poezio will only display the user part of the JID (before +# the @) when displaying the MUC tab name. +show_muc_jid = true + # The terminal can beep on various event. Put the event you want in a list # (separated by spaces). # The events can be diff --git a/doc/en/configure.txt b/doc/en/configure.txt index b6fe41bf..e4cb11a8 100644 --- a/doc/en/configure.txt +++ b/doc/en/configure.txt @@ -247,6 +247,28 @@ section of this documentation. If you want to show all the tabs in the Tab bar, even those with no activity, set to true. Else, set to false +*show_tab_names*:: false + + If you want to show the tab name in the bottom Tab bar, set this to true. + +*show_tab_numbers*:: true + + If you want to disable the numbers in the bottom Tab bar, set this to false. + Note that if both show_tab_names and show_tab_numbers are set to false, the + numbers will still be displayed. + +*use_tab_nicks*:: true + + The tabs have a name, and a nick, which is, for a contact, its name in the + roster, or for a private conversation, the nickname in the MUC. Set this to + true if you want to have them shown instead of the jid of the contact. + +*show_muc_jid*:: true + + Set this to false if you want to display only the *user* part of the MUC + jid. E.g. if you have poezio@muc.poezio.eu, it will be displayed as + `poezio`. This will be used only if use_tab_nicks is set to true. + *beep_on*:: highlight private -- cgit v1.2.3 From 37e3c1ea299c6e27302ab8009f977b90a80d7671 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 19:42:04 +0200 Subject: Fix a small mistake --- src/tabs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index 66af43b5..32186898 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -703,7 +703,7 @@ class MucTab(ChatTab): /info """ if not arg: - return self.command_help('info') + return self.core.command_help('info') user = self.get_user_by_name(arg) if not user: return self.core.information("Unknown user: %s" % arg) @@ -782,7 +782,7 @@ class MucTab(ChatTab): self.core.information(version, 'Info') if not arg: - return self.command_help('version') + return self.core.command_help('version') if arg in [user.nick for user in self.users]: jid = JID(self.name) jid.resource = arg @@ -795,7 +795,7 @@ class MucTab(ChatTab): /nick """ if not arg: - return self.command_help('nick') + return self.core.command_help('nick') nick = arg if not self.joined: return self.core.information('/nick only works in joined rooms', 'Info') @@ -1820,7 +1820,7 @@ class RosterInfoTab(Tab): """ args = common.shell_split(arg) if not args: - return self.command_help('name') + return self.core.command_help('name') jid = JID(args[0]).bare name = args[1] if len(args) == 2 else '' -- cgit v1.2.3 From cc00f44e775e84fcddb63ddb5101e015751e141c Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 19:42:37 +0200 Subject: Add a /groupmove command. Fixes #2352 (based on a patch from gio) --- src/tabs.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/tabs.py b/src/tabs.py index 32186898..88e94e64 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1717,6 +1717,7 @@ class RosterInfoTab(Tab): self.commands['add'] = (self.command_add, _("Usage: /add \nAdd: Add the specified JID to your roster, ask him to allow you to see his presence, and allow him to see your presence."), None) self.commands['name'] = (self.command_name, _("Usage: /name \nSet the given JID's name."), self.completion_name) self.commands['groupadd'] = (self.command_groupadd, _("Usage: /groupadd \nAdd the given JID to the given group."), self.completion_groupadd) + self.commands['groupmove'] = (self.command_groupmove, _("Usage: /groupchange \nMoves the given JID from the old group to the new group."), self.completion_groupmove) self.commands['groupremove'] = (self.command_groupremove, _("Usage: /groupremove \nRemove the given JID from the given group."), self.completion_groupremove) self.commands['remove'] = (self.command_remove, _("Usage: /remove [jid]\nRemove: Remove the specified JID from your roster. This wil unsubscribe you from its presence, cancel its subscription to yours, and remove the item from your roster."), self.completion_remove) self.commands['export'] = (self.command_export, _("Usage: /export [/path/to/file]\nExport: Export your contacts into /path/to/file if specified, or $HOME/poezio_contacts if not."), self.completion_file) @@ -1865,9 +1866,55 @@ class RosterInfoTab(Tab): if self.core.xmpp.update_roster(jid, name=name, groups=new_groups, subscription=subscription): roster.edit_groups_of_contact(contact, new_groups) + def command_groupmove(self, arg): + """ + Remove the specified JID from the first specified group and add it to the second one + """ + args = common.shell_split(arg) + if len(args) != 3: + return self.core.command_help('groupmove') + jid = JID(args[0]).bare + group_from = args[1] + group_to = args[2] + + contact = roster.get_contact_by_jid(jid) + if not contact: + self.core.information(_('No such JID in roster'), 'Error') + return + + new_groups = set(contact.groups) + if 'none' in new_groups: + new_groups.remove('none') + + if group_to == 'none' or group_from == 'none': + self.core.information(_('"none" is not a group.'), 'Error') + return + + if group_from not in new_groups: + self.core.information(_('JID not in first group'), 'Error') + return + + if group_to in new_groups: + self.core.information(_('JID already in second group'), 'Error') + return + + if group_to == group_from: + self.core.information(_('The groups are the same.'), 'Error') + return + + new_groups.add(group_to) + if 'none' in new_groups: + new_groups.remove('none') + + new_groups.remove(group_from) + name = contact.name + subscription = contact.subscription + if self.core.xmpp.update_roster(jid, name=name, groups=new_groups, subscription=subscription): + roster.edit_groups_of_contact(contact, new_groups) + def command_groupremove(self, args): """ - Remove the specified JID to the specified group + Remove the specified JID from the specified group """ args = common.shell_split(args) if len(args) != 2: @@ -1998,6 +2045,29 @@ class RosterInfoTab(Tab): return the_input.auto_completion(groups, '') return False + def completion_groupmove(self, the_input): + text = the_input.get_text() + args = common.shell_split(text) + n = len(args) + if text.endswith(' '): + n += 1 + + if n == 2: + jids = [contact.bare_jid for contact in roster.get_contacts()] + return the_input.auto_completion(jids, '') + elif n == 3: + contact = roster.get_contact_by_jid(args[1]) + if not contact: + return False + groups = list(contact.groups) + if 'none' in groups: + groups.remove('none') + return the_input.auto_completion(groups, '') + elif n == 4: + groups = [group.name for group in roster.get_groups() if group.name != 'none'] + return the_input.auto_completion(groups, '') + return False + def completion_groupremove(self, the_input): text = the_input.get_text() args = common.shell_split(text) -- cgit v1.2.3 From 2ad7416a6d2effb548e0b374ee47cc2fd14ffd53 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 19:44:37 +0200 Subject: Document the /groupmove command --- doc/en/usage.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/en/usage.txt b/doc/en/usage.txt index 8f8d3ad4..d843a173 100644 --- a/doc/en/usage.txt +++ b/doc/en/usage.txt @@ -372,6 +372,10 @@ Roster tab commands */groupadd *:: Add the given JID to the given group (if the group does not exist, it will be created). +*/groupmove *:: Move the given JID from one group + to another (the JID has to be in the first group, and the new group may not + exist). + */groupremove *:: Remove the given JID from the given group (if the group is empty after that, it will get deleted). -- cgit v1.2.3 From bdcddf56e12567d20baa38717335f41c49e978bc Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 23:07:28 +0200 Subject: Load xep_0092 even if send_poezio_info is false --- src/connection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/connection.py b/src/connection.py index e4e2cfb2..2c51a78c 100644 --- a/src/connection.py +++ b/src/connection.py @@ -62,7 +62,9 @@ class Connection(sleekxmpp.ClientXMPP): 'version':'0.7.5-dev'} if config.get('send_os_info', 'true') == 'true': info['os'] = common.get_os_info() - self.register_plugin('xep_0092', pconfig=info) + else: + info = {'name': '', 'version': ''} + self.register_plugin('xep_0092', pconfig=info) if config.get('send_time', 'true') == 'true': self.register_plugin('xep_0202') self.register_plugin('xep_0224') -- cgit v1.2.3 From 71596ec10b56e40a87b91c1e9dab5de3a0398761 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 23:45:16 +0200 Subject: Add a 'v' keybind on the roster to get the version of the selected resource-s --- src/contact.py | 5 +++++ src/tabs.py | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/contact.py b/src/contact.py index 1874ff59..66f8c453 100644 --- a/src/contact.py +++ b/src/contact.py @@ -78,6 +78,11 @@ class Contact(object): """Groups the contact is in""" return self._groups + @property + def resources(self): + """Resources of the contact""" + return self._resources + @property def bare_jid(self): """The bare_jid or the contact""" diff --git a/src/tabs.py b/src/tabs.py index 88e94e64..403e05f8 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -44,7 +44,7 @@ from sleekxmpp.xmlstream import matcher from sleekxmpp.xmlstream.handler import Callback from config import config from roster import RosterGroup, roster -from contact import Contact +from contact import Contact, Resource from text_buffer import TextBuffer from user import User from os import getenv, path @@ -1710,6 +1710,7 @@ class RosterInfoTab(Tab): self.key_func["M-[1;5B"] = self.move_cursor_to_next_group self.key_func["M-[1;5A"] = self.move_cursor_to_prev_group self.key_func["o"] = self.toggle_offline_show + self.key_func["v"] = self.get_contact_version self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow self.commands['deny'] = (self.command_deny, _("Usage: /deny [jid]\nDeny: Deny your presence to the provided JID (or the selected contact in your roster), who is asking you to be in his/here roster."), self.completion_deny) @@ -2247,6 +2248,16 @@ class RosterInfoTab(Tab): selected_row.toggle_folded() return True + def get_contact_version(self): + selected_row = self.roster_win.get_selected_row() + if isinstance(selected_row, Contact): + for resource in selected_row.resources: + self.core.command_version(str(resource.jid)) + elif isinstance(selected_row, Resource): + self.core.command_version(str(selected_row.jid)) + else: + self.core.information('Nothing to get versions from', 'Info') + def start_search(self): """ Start the search. The input should appear with a short instruction -- cgit v1.2.3 From 80b1e835b74b5f5d497f8a13bc55b07a92227558 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 19 Apr 2012 00:12:22 +0200 Subject: Show the contact info in the roster when 'i' is pressed --- src/tabs.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/tabs.py b/src/tabs.py index 403e05f8..2c714bac 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1711,6 +1711,7 @@ class RosterInfoTab(Tab): self.key_func["M-[1;5A"] = self.move_cursor_to_prev_group self.key_func["o"] = self.toggle_offline_show self.key_func["v"] = self.get_contact_version + self.key_func["i"] = self.show_contact_info self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow self.commands['deny'] = (self.command_deny, _("Usage: /deny [jid]\nDeny: Deny your presence to the provided JID (or the selected contact in your roster), who is asking you to be in his/here roster."), self.completion_deny) @@ -2258,6 +2259,33 @@ class RosterInfoTab(Tab): else: self.core.information('Nothing to get versions from', 'Info') + def show_contact_info(self): + selected_row = self.roster_win.get_selected_row() + if isinstance(selected_row, Contact): + cont = selected_row + res = selected_row.get_highest_priority_resource() + msg = 'Contact: %s (%s)\n%s connected resources\nCurrent status: %s' % ( + cont.bare_jid, + res.presence if res else 'unavailable', + cont.get_nb_resources(), + res.status if res else '',) + elif isinstance(selected_row, Resource): + res = selected_row + msg = 'Resource: %s (%s)\nCurrent status: %s' % ( + res.jid, + res.presence, + res.status,) + elif isinstance(selected_row, RosterGroup): + rg = selected_row + msg = 'Group: %s [%s/%s] contacts online' % ( + rg.name, + rg.get_nb_connected_contacts(), + len(rg),) + else: + msg = None + if msg: + self.core.information(msg, 'Info') + def start_search(self): """ Start the search. The input should appear with a short instruction -- cgit v1.2.3 From 9ddd2481c7e5f32a4984e2796bff4654eb396f0d Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 19 Apr 2012 00:12:41 +0200 Subject: Show the current status in the ContactInfoWin --- src/windows.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/windows.py b/src/windows.py index 56b72884..fe4d16ce 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1688,6 +1688,8 @@ class ContactInfoWin(Win): else: self.addstr('Ask: %s' % (contact.ask,)) self.finish_line() + if resource: + self.addstr(2, 0, 'Status: %s' % (resource.status)) def draw_group_info(self, group): -- cgit v1.2.3 From abe8c0ab7143abbf41b756fb4593e8ea1f86b413 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 19 Apr 2012 00:20:03 +0200 Subject: Add a show_roster_jids option --- data/default_config.cfg | 6 ++++++ doc/en/configure.txt | 5 +++++ src/windows.py | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/data/default_config.cfg b/data/default_config.cfg index 59655f99..2c5f0d81 100644 --- a/data/default_config.cfg +++ b/data/default_config.cfg @@ -215,6 +215,12 @@ use_tab_nicks = true # the @) when displaying the MUC tab name. show_muc_jid = true +# If this option is set to false, the roster will not show the contact JIDs +# when that is possible. +# e.g. instead of: toto (toto@example.org) (2) +# poezio will only show: toto (2) +show_roster_jids = true + # The terminal can beep on various event. Put the event you want in a list # (separated by spaces). # The events can be diff --git a/doc/en/configure.txt b/doc/en/configure.txt index e4cb11a8..36a49206 100644 --- a/doc/en/configure.txt +++ b/doc/en/configure.txt @@ -269,6 +269,11 @@ section of this documentation. jid. E.g. if you have poezio@muc.poezio.eu, it will be displayed as `poezio`. This will be used only if use_tab_nicks is set to true. +*show_roster_jids*:: true + + Set this to false if you want to hide the JIDs in the roster (and keep only + the contact names). If there is no contact name, the JID will still be + displayed. *beep_on*:: highlight private diff --git a/src/windows.py b/src/windows.py index fe4d16ce..802a6230 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1628,7 +1628,9 @@ class RosterWin(Win): presence = resource.presence nb = ' (%s)' % (contact.get_nb_resources(),) color = RosterWin.color_show[presence]() - if contact.name: + if config.getl('show_roster_jids', 'true') == 'false' and contact.name: + display_name = '%s %s' % (contact.name, nb[1:]) + elif contact.name: display_name = '%s (%s)%s' % (contact.name, contact.bare_jid, nb,) else: -- cgit v1.2.3 From 46c197ef7f958ec3d55aaf3455b3715f5a00dea6 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 19 Apr 2012 01:33:16 +0200 Subject: Fixes #2355 --- src/tabs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tabs.py b/src/tabs.py index 2c714bac..1ef93511 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2264,10 +2264,11 @@ class RosterInfoTab(Tab): if isinstance(selected_row, Contact): cont = selected_row res = selected_row.get_highest_priority_resource() - msg = 'Contact: %s (%s)\n%s connected resources\nCurrent status: %s' % ( + msg = 'Contact: %s (%s)\n%s connected resource%s\nCurrent status: %s' % ( cont.bare_jid, res.presence if res else 'unavailable', cont.get_nb_resources(), + '' if cont.get_nb_resources() == 1 else 's', res.status if res else '',) elif isinstance(selected_row, Resource): res = selected_row -- cgit v1.2.3 From 5a1a7a567d22fdad490df76bf43669d56cf46325 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 19 Apr 2012 13:08:35 +0200 Subject: Do not quote the plugins on completion --- src/plugin_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugin_manager.py b/src/plugin_manager.py index 98879841..40367052 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -213,10 +213,10 @@ class PluginManager(object): self.core.information(_('Completion failed: %s' % e), 'Error') return plugins_files = [name[:-3] for name in names if name.endswith('.py')] - return the_input.auto_completion(plugins_files, '') + return the_input.auto_completion(plugins_files, '', quotify=False) def completion_unload(self, the_input): """ completion function that completes the name of the plugins that are loaded """ - return the_input.auto_completion(list(self.plugins.keys()), '') + return the_input.auto_completion(list(self.plugins.keys()), '', quotify=False) -- cgit v1.2.3 From 2f78a5f2dd3cf73a15700f236cf69384c930f7eb Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 19 Apr 2012 17:37:53 +0200 Subject: Add an autofill for /name in the roster when 'n' is pressed --- src/tabs.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tabs.py b/src/tabs.py index 1ef93511..82427715 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1712,6 +1712,7 @@ class RosterInfoTab(Tab): self.key_func["o"] = self.toggle_offline_show self.key_func["v"] = self.get_contact_version self.key_func["i"] = self.show_contact_info + self.key_func["n"] = self.change_contact_name self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow self.commands['deny'] = (self.command_deny, _("Usage: /deny [jid]\nDeny: Deny your presence to the provided JID (or the selected contact in your roster), who is asking you to be in his/here roster."), self.completion_deny) @@ -2250,6 +2251,9 @@ class RosterInfoTab(Tab): return True def get_contact_version(self): + """ + Show the versions of the resource(s) currently selected + """ selected_row = self.roster_win.get_selected_row() if isinstance(selected_row, Contact): for resource in selected_row.resources: @@ -2260,6 +2264,10 @@ class RosterInfoTab(Tab): self.core.information('Nothing to get versions from', 'Info') def show_contact_info(self): + """ + Show the contact info (resource number, status, presence, etc) + when 'i' is pressed. + """ selected_row = self.roster_win.get_selected_row() if isinstance(selected_row, Contact): cont = selected_row @@ -2287,6 +2295,22 @@ class RosterInfoTab(Tab): if msg: self.core.information(msg, 'Info') + def change_contact_name(self): + """ + Auto-fill a /name command when 'n' is pressed + """ + selected_row = self.roster_win.get_selected_row() + if isinstance(selected_row, Contact): + jid = selected_row.bare_jid + elif isinstance(selected_row, Resource): + jid = JID(selected_row.jid).bare + else: + return + self.on_slash() + self.input.text = '/name "%s" ' % jid + self.input.key_end() + self.input.refresh() + def start_search(self): """ Start the search. The input should appear with a short instruction -- cgit v1.2.3 From 4ee3566a749e504c5168ca3b4eb2fdc57ab92b07 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 26 Apr 2012 01:57:46 +0200 Subject: Avoid a traceback when getting the nick of a converstation with someone not in our roster. fixes #2356 --- src/tabs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tabs.py b/src/tabs.py index 82427715..f8923304 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2500,7 +2500,11 @@ class ConversationTab(ChatTab): def get_nick(self): jid = JID(self.name) - return roster.get_contact_by_jid(jid.bare).name or jid.user + contact = roster.get_contact_by_jid(jid.bare) + if contact: + return contact.name + else: + return jid.user def on_input(self, key, raw): if not raw and key in self.key_func: -- cgit v1.2.3 From 2a3434b1f81bed7e6c781a9504a87905f2d07948 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Fri, 27 Apr 2012 19:40:39 +0200 Subject: Fix the get_nick issue correctly this time. --- src/tabs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabs.py b/src/tabs.py index f8923304..4b39ccc8 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2502,7 +2502,7 @@ class ConversationTab(ChatTab): jid = JID(self.name) contact = roster.get_contact_by_jid(jid.bare) if contact: - return contact.name + return contact.name or jid.user else: return jid.user -- cgit v1.2.3