Commit 9cd87884 authored by mathieui's avatar mathieui

Implement XEP-0070 using the confirmtab

parent 9230126a
......@@ -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
......
......@@ -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),
......
......@@ -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):
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment