From 8317b845d810353daab07a467199f411c3fceaa4 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 17 Jul 2012 21:56:04 +0200 Subject: [PATCH] Fix /version to find a fulljid when available And improve the completion in the roster (go to the resources) --- src/core.py | 15 ++++++++++++--- src/tabs.py | 5 +++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core.py b/src/core.py index 4fc8a8b1..f4d11a38 100644 --- a/src/core.py +++ b/src/core.py @@ -13,6 +13,7 @@ import time import curses import ssl +from functools import reduce from hashlib import sha1 from datetime import datetime from xml.etree import cElementTree as ET @@ -1706,8 +1707,14 @@ class Core(object): args = common.shell_split(arg) if len(args) < 1: return self.command_help('version') - jid = args[0] - self.xmpp.plugin['xep_0092'].get_version(jid, callback=callback) + jid = JID(args[0]) + if jid.resource or jid not in roster: + self.xmpp.plugin['xep_0092'].get_version(jid, callback=callback) + elif jid in roster: + for resource in roster[jid].resources: + self.xmpp.plugin['xep_0092'].get_version(resource.jid, callback=callback) + else: + self.xmpp.plugin['xep_0092'].get_version(jid, callback=callback) def command_reconnect(self, args=None): """ @@ -1909,7 +1916,9 @@ 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([jid for jid in roster.jids()], '', quotify=False) + comp = reduce(lambda x, y: x+y, (jid.resources for jid in roster if len(jid)), []) + comp = (str(res.jid) for res in comp) + return the_input.auto_completion(sorted(comp), '', quotify=False) def completion_list(self, the_input): """Completion for /list""" diff --git a/src/tabs.py b/src/tabs.py index dfa5f529..33a7126b 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2577,6 +2577,11 @@ class ConversationTab(ChatTab): if arg: return self.core.command_version(arg) jid = self.name + jid = JID(jid) + if not jid.resource: + if jid in roster: + resource = roster[jid].get_highest_priority_resource() + jid = resource.jid if resource else jid self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback) def resize(self):