From fd00955ce44d587d8174b2e16530bd804c9b3f08 Mon Sep 17 00:00:00 2001 From: souliane Date: Wed, 18 Jun 2014 14:52:52 +0200 Subject: [PATCH] plugin XEP-0050: handle note element in command answer --- src/plugins/plugin_xep_0050.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin_xep_0050.py b/src/plugins/plugin_xep_0050.py index dcf19d26..e267d464 100644 --- a/src/plugins/plugin_xep_0050.py +++ b/src/plugins/plugin_xep_0050.py @@ -262,7 +262,18 @@ class XEP_0050(object): remote_session_id = command_elt.getAttribute('sessionid') if remote_session_id: session_data['remote_id'] = remote_session_id - data_elt = command_elt.elements(data_form.NS_X_DATA, 'x').next() + try: + data_elt = command_elt.elements(data_form.NS_X_DATA, 'x').next() + except StopIteration: + # FIXME: command answer can contains several 'note' elements + try: + data_elt = command_elt.elements(NS_COMMANDS, 'note').next() + xml_ui = xml_tools.XMLUI('popup', title=data_elt.getAttribute('type')) + xml_ui.addText(str(data_elt)) + return xml_ui + except StopIteration: + log.error(_('Unmanaged command answer: %s') % command_elt.toXml()) + return None if session_id is None: return xml_tools.dataFormResult2XMLUI(data_elt) form = data_form.Form.fromElement(data_elt)