summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/connection.py1
-rw-r--r--poezio/core/core.py1
-rw-r--r--poezio/core/handlers.py32
-rw-r--r--poezio/tabs/confirmtab.py2
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