diff options
author | mathieui <mathieui@mathieui.net> | 2016-08-20 00:12:59 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2016-08-20 00:12:59 +0200 |
commit | 9cd8788400dc7a4802e6233512dcb20a741f87b2 (patch) | |
tree | 0162f1fbd99677ae1de74dd3b5eb2a003570ef42 | |
parent | 9230126a898ea2b06ed3ca522444750c2eb2baf2 (diff) | |
download | poezio-9cd8788400dc7a4802e6233512dcb20a741f87b2.tar.gz poezio-9cd8788400dc7a4802e6233512dcb20a741f87b2.tar.bz2 poezio-9cd8788400dc7a4802e6233512dcb20a741f87b2.tar.xz poezio-9cd8788400dc7a4802e6233512dcb20a741f87b2.zip |
Implement XEP-0070 using the confirmtab
-rw-r--r-- | poezio/connection.py | 1 | ||||
-rw-r--r-- | poezio/core/core.py | 1 | ||||
-rw-r--r-- | poezio/core/handlers.py | 32 | ||||
-rw-r--r-- | poezio/tabs/confirmtab.py | 2 |
4 files changed, 35 insertions, 1 deletions
diff --git a/poezio/connection.py b/poezio/connection.py index fffcaf9f..7b12a6eb 100644 --- a/poezio/connection.py +++ b/poezio/connection.py @@ -109,6 +109,7 @@ class Connection(slixmpp.ClientXMPP): self.register_plugin('xep_0054') self.register_plugin('xep_0060') self.register_plugin('xep_0066') + self.register_plugin('xep_0070') self.register_plugin('xep_0071') self.register_plugin('xep_0077') self.plugin['xep_0077'].create_account = False diff --git a/poezio/core/core.py b/poezio/core/core.py index d4a5c060..bcc64d1a 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -254,6 +254,7 @@ class Core(object): self.xmpp.add_event_handler("ssl_invalid_chain", self.handler.ssl_invalid_chain) self.xmpp.add_event_handler('carbon_received', self.handler.on_carbon_received) self.xmpp.add_event_handler('carbon_sent', self.handler.on_carbon_sent) + self.xmpp.add_event_handler('http_confirm', self.handler.http_confirm) all_stanzas = Callback('custom matcher', connection.MatchAll(None), diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index ea605b2a..bc94129d 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -1249,6 +1249,38 @@ SHA-512 of the new certificate: %s if not config.silent_set('certificate', sha2_found_cert): self.core.information('Unable to write in the config file', 'Error') + def http_confirm(self, stanza): + confirm = stanza['confirm'] + def cb(result): + if result: + reply = stanza.reply() + else: + reply = stanza.reply() + reply.enable('error') + reply['error']['type'] = 'auth' + reply['error']['code'] = '401' + reply['error']['condition'] = 'not-authorized' + reply.append(stanza['confirm']) + reply.send() + + c_id, c_url, c_method = confirm['id'], confirm['url'], confirm['method'] + confirm_tab = tabs.ConfirmTab(self.core, + 'HTTP Verification', + """ +Someone (maybe you) has requested an identity verification regarding +using method "%s" for the url "%s". + +The transaction id is: %s +And the XMPP address of the verification service is %s. + +""" % (c_method, c_url, c_id, stanza['from'].full), + 'An HTTP verification was requested', + cb, + critical=False) + self.core.add_tab(confirm_tab, False) + self.core.refresh_window() + self.core.doupdate() + ### Ad-hoc commands def next_adhoc_step(self, iq, adhoc_session): diff --git a/poezio/tabs/confirmtab.py b/poezio/tabs/confirmtab.py index 575f47f2..49339fce 100644 --- a/poezio/tabs/confirmtab.py +++ b/poezio/tabs/confirmtab.py @@ -24,7 +24,7 @@ class ConfirmTab(Tab): critical: if the message needs to be displayed in a flashy color """ Tab.__init__(self, core) - self.state = 'normal' + self.state = 'highlight' self.name = name self.default_help_message = windows.HelpText("Choose with arrow keys and press enter") self.input = self.default_help_message |