Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime Buquet
poezio
Commits
9cd87884
Commit
9cd87884
authored
Aug 20, 2016
by
mathieui
Browse files
Implement XEP-0070 using the confirmtab
parent
9230126a
Changes
4
Hide whitespace changes
Inline
Side-by-side
poezio/connection.py
View file @
9cd87884
...
...
@@ -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
...
...
poezio/core/core.py
View file @
9cd87884
...
...
@@ -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
),
...
...
poezio/core/handlers.py
View file @
9cd87884
...
...
@@ -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
):
...
...
poezio/tabs/confirmtab.py
View file @
9cd87884
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment