summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-13 18:34:52 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-13 18:34:52 +0100
commitc4f7d9b98a229ad52e834313ab93f0f9ebc77884 (patch)
tree696fef8697181b96616d7953195c4324d1834cfa /plugins
parent45931713bf9735be4b0e2d9f2b607d3183c20f4c (diff)
downloadpoezio-c4f7d9b98a229ad52e834313ab93f0f9ebc77884.tar.gz
poezio-c4f7d9b98a229ad52e834313ab93f0f9ebc77884.tar.bz2
poezio-c4f7d9b98a229ad52e834313ab93f0f9ebc77884.tar.xz
poezio-c4f7d9b98a229ad52e834313ab93f0f9ebc77884.zip
Add a setkey command for the /gpg command.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gpg/__init__.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/plugins/gpg/__init__.py b/plugins/gpg/__init__.py
index 7151b8ff..01ca6ab2 100644
--- a/plugins/gpg/__init__.py
+++ b/plugins/gpg/__init__.py
@@ -56,7 +56,7 @@ class Plugin(BasePlugin):
self.add_event_handler('conversation_say_after', self.on_conversation_say)
self.add_event_handler('conversation_msg', self.on_conversation_msg)
- self.add_command('gpg', self.command_gpg, "Usage: /gpg <force|disable>\nGpg: Force or disable gpg encryption with this fulljid.", self.gpg_completion)
+ self.add_command('gpg', self.command_gpg, "Usage: /gpg <force|disable|setkey> [JID] [keyid]\nGpg: Force or disable gpg encryption with the fulljid of the current conversation. The setkey argument lets you associate a keyid with the given bare JID.", self.gpg_completion)
ConversationTab.add_information_element('gpg', self.display_encryption_status)
def cleanup(self):
@@ -159,7 +159,7 @@ class Plugin(BasePlugin):
return ''
status = self.contacts[jid.full]
self.core.information('%s' % (status,))
- if status in ('valid', 'invalid'):
+ if status in ('valid', 'invalid', 'signed'):
return ' GPG Key: %s (%s)' % (status, 'encrypted' if status == 'valid' else 'NOT encrypted',)
else:
return ' GPG: Encryption %s' % (status,)
@@ -177,7 +177,7 @@ class Plugin(BasePlugin):
if isinstance(self.core.current_tab(), ConversationTab):
jid = JID(self.core.current_tab().get_name())
command = args[0]
- if command == 'force':
+ if command == 'force' or command == 'enable':
# we can force encryption only with contact having an associated
# key, otherwise we cannot encrypt at all
if self.config.has_section('keys') and jid.bare in self.config.options('keys'):
@@ -186,10 +186,17 @@ class Plugin(BasePlugin):
self.core.information('Cannot force encryption: no key associated with %s' % (jid.bare), 'Info')
elif command == 'disable':
self.contacts[JID(jid).full] = 'disabled'
+ elif command == 'setkey':
+ if len(args) != 3:
+ return self.core.command_help("gpg")
+ if not self.config.has_section('keys'):
+ self.config.add_section('keys')
+ self.config.set(jid.bare, args[2], 'keys')
+ self.config.write()
self.core.refresh_window()
- def gpg_completion(self, args):
- pass
+ def gpg_completion(self, the_input):
+ return the_input.auto_completion(['force', 'disable', 'setkey'], ' ')
def remove_gpg_headers(self, text):
lines = text.splitlines()