summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-12 05:59:46 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-12 05:59:46 +0100
commit01e945a907e125b729599855636f8fc980312409 (patch)
treea30e4a8e029602ea89a1f677b098d057ab5fa989
parent9e8706a2e8bfb5dc1242ca42f87a6e3df90d9138 (diff)
downloadpoezio-01e945a907e125b729599855636f8fc980312409.tar.gz
poezio-01e945a907e125b729599855636f8fc980312409.tar.bz2
poezio-01e945a907e125b729599855636f8fc980312409.tar.xz
poezio-01e945a907e125b729599855636f8fc980312409.zip
Add a gpg command, doesn’t work yet.
-rw-r--r--plugins/gpg/__init__.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/gpg/__init__.py b/plugins/gpg/__init__.py
index 873aa285..f1b97575 100644
--- a/plugins/gpg/__init__.py
+++ b/plugins/gpg/__init__.py
@@ -35,12 +35,14 @@ Version: GnuPG
class Plugin(BasePlugin):
def init(self):
self.contacts = {}
- # a dict of {full-JID: 'signed'/'valid'/'invalid'}
+ # a dict of {full-JID: 'signed'/'valid'/'invalid'/'disabled'}
# Whenever we receive a signed presence from a JID, we add it to this
# dict, this way we know if we can encrypt the messages we will send to
# this JID.
# If that resource sends a non-signed presence, then we remove it
# from that dict and stop encrypting our messages.
+ # 'disabled' means that the user do NOT want to encrypt its messages
+ # even if the key is valid.
self.gpg = gnupg.GPG()
self.keyid = self.config.get('keyid', '') or None
self.passphrase = self.config.get('passphrase', '') or None
@@ -52,11 +54,13 @@ 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_tab_command(ConversationTab, 'gpg', self.command_gpg, "Usage: /gpg <force|disable>\nGpg: Force or disable gpg encryption with this fulljid.", lambda the_input: the_input.auto_completion(['force', 'disable']))
ConversationTab.add_information_element('gpg', self.display_encryption_status)
def cleanup(self):
self.send_unsigned_presence()
ConversationTab.remove_information_element('gpg')
+ self.del_tab_command(ConversationTab, 'gpg')
def sign_presence(self, presence):
"""
@@ -151,6 +155,10 @@ class Plugin(BasePlugin):
return ''
return ' GPG Key: %s' % self.contacts[jid.full]
+ def command_gpg(self, args):
+ # TODO
+ return
+
def remove_gpg_headers(self, text):
lines = text.splitlines()
while lines[0].strip() != '':