comparison src/plugins/plugin_xep_0055.py @ 761:2f8d72226bc0

core (xml_tools): dataForm*2XML renamed to dataForm*2XMLUI and now return XMLUI instead of raw XML + submit_id is managed, and session_id is returned if present
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 15:43:22 +0100
parents 7c806491c76a
children bfabeedbf32e
comparison
equal deleted inserted replaced
760:73a0077f80cc 761:2f8d72226bc0
20 from logging import debug, info, warning, error 20 from logging import debug, info, warning, error
21 from twisted.words.protocols.jabber.xmlstream import IQ 21 from twisted.words.protocols.jabber.xmlstream import IQ
22 from twisted.words.protocols.jabber import jid 22 from twisted.words.protocols.jabber import jid
23 from wokkel import data_form 23 from wokkel import data_form
24 from sat.core.exceptions import DataError 24 from sat.core.exceptions import DataError
25 from sat.tools.xml_tools import dataForm2XML, dataFormResult2XML 25 from sat.tools.xml_tools import dataForm2XMLUI, dataFormResult2XMLUI
26 26
27 NS_SEARCH = 'jabber:iq:search' 27 NS_SEARCH = 'jabber:iq:search'
28 28
29 PLUGIN_INFO = { 29 PLUGIN_INFO = {
30 "name": "Jabber Search", 30 "name": "Jabber Search",
77 form_elt = query_elts.elements(data_form.NS_X_DATA, 'x').next() 77 form_elt = query_elts.elements(data_form.NS_X_DATA, 'x').next()
78 except StopIteration: 78 except StopIteration:
79 info(_("No data form found")) 79 info(_("No data form found"))
80 raise NotImplementedError("Only search through data form is implemented so far") 80 raise NotImplementedError("Only search through data form is implemented so far")
81 parsed_form = data_form.Form.fromElement(form_elt) 81 parsed_form = data_form.Form.fromElement(form_elt)
82 return dataForm2XML(parsed_form) 82 return dataForm2XMLUI(parsed_form, "").toXml()
83 83
84 def _fieldsErr(self, failure, profile): 84 def _fieldsErr(self, failure, profile):
85 """ Called when something is wrong with fields request """ 85 """ Called when something is wrong with fields request """
86 info(_("Fields request failure: %s") % str(failure.value)) 86 info(_("Fields request failure: %s") % str(failure.value))
87 return failure 87 return failure
117 try: 117 try:
118 form_elt = query_elts.elements(data_form.NS_X_DATA, 'x').next() 118 form_elt = query_elts.elements(data_form.NS_X_DATA, 'x').next()
119 except StopIteration: 119 except StopIteration:
120 info(_("No data form found")) 120 info(_("No data form found"))
121 raise NotImplementedError("Only search through data form is implemented so far") 121 raise NotImplementedError("Only search through data form is implemented so far")
122 xmlui = dataFormResult2XML(form_elt) 122 xmlui = dataFormResult2XMLUI(form_elt).toXml()
123 print "=== XMLUI ===\n%s\n\n" % xmlui 123 print "=== XMLUI ===\n%s\n\n" % xmlui
124 return xmlui 124 return xmlui
125 125
126 126
127 def _searchErr(self, failure, profile): 127 def _searchErr(self, failure, profile):