diff options
author | mathieui <mathieui@mathieui.net> | 2013-08-05 00:08:11 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-08-05 00:08:11 +0200 |
commit | 90161f81acf1df75503246cedde120fe403bec27 (patch) | |
tree | 79fe5de070a4e838cff5e0b059f3bafeef19f56e /plugins | |
parent | 7373074e392c520e7ff848b65353b198fae4430d (diff) | |
download | poezio-90161f81acf1df75503246cedde120fe403bec27.tar.gz poezio-90161f81acf1df75503246cedde120fe403bec27.tar.bz2 poezio-90161f81acf1df75503246cedde120fe403bec27.tar.xz poezio-90161f81acf1df75503246cedde120fe403bec27.zip |
Add a new "drop" option to the OTR plugin (to drop the privkey)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/otr.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/plugins/otr.py b/plugins/otr.py index e7210869..e7762fcd 100644 --- a/plugins/otr.py +++ b/plugins/otr.py @@ -180,6 +180,13 @@ class PoezioAccount(Account): except: log.error('Error in load_privkey', exc_info=True) + def drop_privkey(self): + try: + os.remove(self.key_dir + '.key3') + except: + log.exception('Error in drop_privkey (removing %s)', self.key_dir + '.key3') + self.privkey = None + def save_privkey(self): try: with open(self.key_dir + '.key3', 'xb') as keyfile: @@ -368,8 +375,13 @@ class Plugin(BasePlugin): if tab.get_name() in self.contexts: ctx = self.contexts[tab.get_name()] self.api.information('The key fingerprint for %s is %s' % (name, ctx.getCurrentKey()) , 'OTR') + elif arg == 'drop': + # drop the privkey (and obviously, end the current conversations before that) + for context in self.contexts.values(): + if context.state not in (STATE_FINISHED, STATE_PLAINTEXT): + context.disconnect() + self.account.drop_privkey() def completion_otr(self, the_input): - return the_input.new_completion(['start', 'fpr', 'ourfpr', 'refresh', 'end'], 1, quotify=True) - + return the_input.new_completion(['start', 'fpr', 'ourfpr', 'refresh', 'end', 'drop'], 1, quotify=True) |