summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-10-12 22:08:28 +0200
committermathieui <mathieui@mathieui.net>2014-10-12 22:08:28 +0200
commita0c5f958819444035894b665a1ef10ddab91dd0b (patch)
tree416f40a5a8ee8b4385391d108664b1f75dc8a060
parent8e29f6d1ff8402f7d2e2381d2d33b05dcc28503a (diff)
downloadpoezio-a0c5f958819444035894b665a1ef10ddab91dd0b.tar.gz
poezio-a0c5f958819444035894b665a1ef10ddab91dd0b.tar.bz2
poezio-a0c5f958819444035894b665a1ef10ddab91dd0b.tar.xz
poezio-a0c5f958819444035894b665a1ef10ddab91dd0b.zip
Add a notification in the OTR plugin if the session isn't established
With a timeout option that lets the user choose the timeout and if they want this notification.
-rw-r--r--plugins/otr.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/otr.py b/plugins/otr.py
index 47f1fc11..88967b75 100644
--- a/plugins/otr.py
+++ b/plugins/otr.py
@@ -143,6 +143,13 @@ Configuration
Allow OTRv1
+ timeout
+ **Default:** ``3``
+
+ The number of seconds poezio will wait until notifying you
+ that the OTR session was not established. A negative or null
+ value will disable this notification.
+
log
**Default:** false
@@ -599,8 +606,27 @@ class Plugin(BasePlugin):
context.disconnect()
elif arg == 'start' or arg == 'refresh':
otr = self.get_context(name)
+ secs = self.config.get('timeout', 3)
+ def notify_otr_timeout():
+ if otr.state != STATE_ENCRYPTED:
+ text = _('%(jid_c)s%(jid)s%(info)s did not enable'
+ ' OTR after %(sec)s seconds.') % {
+ 'jid': tab.name,
+ 'info': color_info,
+ 'jid_c': color_jid,
+ 'sec': secs}
+ tab.add_message(text, typ=0)
+ self.core.refresh_window()
+ if secs > 0:
+ event = self.api.create_delayed_event(secs, notify_otr_timeout)
+ self.api.add_timed_event(event)
self.core.xmpp.send_message(mto=name, mtype='chat',
mbody=self.contexts[name].sendMessage(0, b'?OTRv?').decode())
+ text = _('%(info)sOTR request to %(jid_c)s%(jid)s%(info)s sent') % {
+ 'jid': tab.name,
+ 'info': color_info,
+ 'jid_c': color_jid}
+ tab.add_message(text, typ=0)
elif arg == 'ourfpr':
fpr = self.account.getPrivkey()
self.api.information('Your OTR key fingerprint is %s' % fpr, 'OTR')