diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-11-29 18:36:54 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-11-29 18:36:54 +0000 |
commit | cbcec6a798557d4905554c446a5291ac2c1f46ec (patch) | |
tree | f66ebc7cf2e930f7c712157ba1ea2734f69a0a6d /src | |
parent | 69e335c0ad073069291ef45a1fcfc2f1d6462309 (diff) | |
download | poezio-cbcec6a798557d4905554c446a5291ac2c1f46ec.tar.gz poezio-cbcec6a798557d4905554c446a5291ac2c1f46ec.tar.bz2 poezio-cbcec6a798557d4905554c446a5291ac2c1f46ec.tar.xz poezio-cbcec6a798557d4905554c446a5291ac2c1f46ec.zip |
completion of the jid's node when doing /join ro@some.server.fr/[TAB](it completes the 'ro' part \o/. Also a begining of /list command, but that does nothing
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.py | 7 | ||||
-rw-r--r-- | src/core.py | 55 |
2 files changed, 51 insertions, 11 deletions
diff --git a/src/connection.py b/src/connection.py index e313af37..073e216e 100644 --- a/src/connection.py +++ b/src/connection.py @@ -18,6 +18,9 @@ Defines the Connection class """ +import logging +log = logging.getLogger(__name__) + from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) @@ -45,10 +48,12 @@ class Connection(sleekxmpp.ClientXMPP): jid = '%s/%s' % (config.get('server', 'anon.louiz.org'), resource) password = None sleekxmpp.ClientXMPP.__init__(self, jid, password, ssl=True) + self.registerPlugin('xep_0030') self.registerPlugin('xep_0045') - + def start(self): # TODO, try multiple servers + # With anon auth. # (domain, config.get('port', 5222)) custom_host = config.get('custom_host', '') custom_port = config.get('custom_port', -1) diff --git a/src/core.py b/src/core.py index cd9cb32a..f7ad4386 100644 --- a/src/core.py +++ b/src/core.py @@ -122,6 +122,7 @@ class Core(object): 'link': (self.command_link, _("Usage: /link [option] [number]\nLink: Interact with a link in the conversation. Available options are 'open', 'copy'. Open just opens the link in the browser if it's http://, Copy just copy the link in the clipboard. An optional number can be provided, it indicates which link to interact with."), None), 'whois': (self.command_whois, _('Usage: /whois <nickname>\nWhois: Request many informations about the user.'), None), 'theme': (self.command_theme, _('Usage: /theme\nTheme: Reload the theme defined in the config file.'), None), + 'list': (self.command_list, _('Usage: /list\n/List: get the list of public chatrooms on the specified server'), self.completion_list), } self.key_func = { @@ -925,17 +926,51 @@ class Core(object): # we are not on the 1st argument of the command line return False jid = JID(txt.split()[1]) - if not jid.user or not jid.server or jid.resource != '': - # we are not writing the server part of the jid - return True - serv = jid.server - serv_list = [] - for tab in self.tabs: - if isinstance(tab, MucTab): - serv_list.append('%s@%s'% (jid.user, JID(tab.get_name()).host)) - the_input.auto_completion(serv_list, '') + if jid.server: + if jid.resource or jid.full.endswith('/'): + # we are writing the resource: complete the node + if not the_input.last_completion: + items = self.xmpp.plugin['xep_0030'].getItems(jid.server)['disco_items'].getItems() + items = ['%s/%s' % (tup[0], jid.resource) for tup in items] + for i in range(len(jid.server) + 2 + len(jid.resource)): + log.debug('allo') + the_input.key_backspace() + else: + items = [] + the_input.auto_completion(items, '') + else: + # we are writing the server: complete the server + serv = jid.server + serv_list = [] + for tab in self.tabs: + if isinstance(tab, MucTab): + serv_list.append('%s@%s'% (jid.user, JID(tab.get_name()).host)) + the_input.auto_completion(serv_list, '') return True + def command_list(self, arg): + """ + Opens a MucListTab for the specified server + """ + args = arg.split() + if len(args) != 1: + self.command_win('list') + return + server = args[1] + # TODO + + def completion_list(self, the_input): + """ + """ + txt = the_input.get_text() + muc_serv_list = [] + for tab in self.tabs: # TODO, also from an history + if isinstance(tab, MucTab) and\ + tab.get_name() not in muc_serv_list: + muc_serv_list.append(tab.get_name()) + if muc_serv_list: + the_input.auto_completion(muc_serv_list, ' ') + def command_join(self, arg): """ /join [room][/nick] [password] @@ -950,7 +985,7 @@ class Core(object): nick = t.get_room().own_nick else: info = args[0].split('/') - if len(info) == 1: + if len(info) == 1 or info[1] == '': default = os.environ.get('USER') if os.environ.get('USER') else 'poezio' nick = config.get('default_nick', '') if nick == '': |