From a0c5f958819444035894b665a1ef10ddab91dd0b Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 12 Oct 2014 22:08:28 +0200 Subject: 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. --- plugins/otr.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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') -- cgit v1.2.3