From 92265678dc05edc5ad0a50fc69046db6acb05b9f Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 17 Dec 2014 21:21:57 +0100 Subject: Add completions for /cert_add and /cert_fetch --- src/tabs/rostertab.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tabs/rostertab.py b/src/tabs/rostertab.py index 084df3fd..e04f37fe 100644 --- a/src/tabs/rostertab.py +++ b/src/tabs/rostertab.py @@ -162,7 +162,8 @@ class RosterInfoTab(Tab): ' if a client connected using this certificate can' ' manage the certificates itself.'), shortdesc=_('Add a client certificate.'), - usage=' [management]') + usage=' [management]', + completion=self.completion_cert_add) self.register_command('cert_disable', self.command_cert_disable, desc=_('Remove a certificate from the list ' 'of allowed ones. Clients currently ' @@ -181,7 +182,8 @@ class RosterInfoTab(Tab): desc=_('Retrieve a certificate with its ' 'name. It will be stored in .'), shortdesc=_('Fetch a certificate'), - usage=' ') + usage=' ', + completion=self.completion_cert_fetch) @command_args_parser.ignored def command_certs(self): @@ -245,6 +247,21 @@ class RosterInfoTab(Tab): self.core.xmpp.plugin['xep_0257'].add_cert(name, crt, callback=cb, allow_management=management) + def completion_cert_add(self, the_input): + """ + completion for /cert_add [management] + """ + text = the_input.get_text() + args = common.shell_split(text) + n = the_input.get_argument_position() + log.debug('%s %s %s', the_input.text, n, the_input.pos) + if n == 1: + return + elif n == 2: + return self.completion_file(2, the_input) + elif n == 3: + return the_input.new_completion(['true', 'false'], n) + @command_args_parser.quoted(1) def command_cert_disable(self, args): """ @@ -313,6 +330,19 @@ class RosterInfoTab(Tab): self.core.xmpp.plugin['xep_0257'].get_certs(callback=cb) + def completion_cert_fetch(self, the_input): + """ + completion for /cert_fetch + """ + text = the_input.get_text() + args = common.shell_split(text) + n = the_input.get_argument_position() + log.debug('%s %s %s', the_input.text, n, the_input.pos) + if n == 1: + return + elif n == 2: + return self.completion_file(2, the_input) + def on_blocked_message(self, message): """ When we try to send a message to a blocked contact -- cgit v1.2.3