Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0055.py @ 2364:918e38622a48
core (xmlui): added method to convert data form result to XMLUI:
- former method was misnamed as it was used to convert data form element to XMLUI, so it has been renamed to dataFormEltResult2XMLUI
- dataFormResult2XMLUI is now use to convert wokkel.data_form.Form instances to XMLUI
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 01 Oct 2017 12:21:23 +0200 |
parents | a543eda2c923 |
children | 8b37a62336c3 |
comparison
equal
deleted
inserted
replaced
2363:41c7717b52cd | 2364:918e38622a48 |
---|---|
268 | 268 |
269 @param main_ui (XMLUI): the main XMLUI instance | 269 @param main_ui (XMLUI): the main XMLUI instance |
270 @param elt (domish.Element): form result element | 270 @param elt (domish.Element): form result element |
271 """ | 271 """ |
272 if [child for child in elt.children if child.name == "item"]: | 272 if [child for child in elt.children if child.name == "item"]: |
273 headers, xmlui_data = xml_tools.dataFormResult2XMLUIData(elt) | 273 headers, xmlui_data = xml_tools.dataFormEltResult2XMLUIData(elt) |
274 if "jid" in headers: # use XMLUI JidsListWidget to display the results | 274 if "jid" in headers: # use XMLUI JidsListWidget to display the results |
275 values = {} | 275 values = {} |
276 for i in range(len(xmlui_data)): | 276 for i in range(len(xmlui_data)): |
277 header = headers.keys()[i % len(headers)] | 277 header = headers.keys()[i % len(headers)] |
278 widget_type, widget_args, widget_kwargs = xmlui_data[i] | 278 widget_type, widget_args, widget_kwargs = xmlui_data[i] |
295 @param to_jid_s (unicode): XEP-0055 compliant search entity | 295 @param to_jid_s (unicode): XEP-0055 compliant search entity |
296 @param profile_key (unicode): %(doc_profile_key)s | 296 @param profile_key (unicode): %(doc_profile_key)s |
297 @return: a deferred XMLUI instance | 297 @return: a deferred XMLUI instance |
298 """ | 298 """ |
299 d = self.getFieldsUI(jid.JID(to_jid_s), profile_key) | 299 d = self.getFieldsUI(jid.JID(to_jid_s), profile_key) |
300 d.addCallback(lambda form: xml_tools.dataFormResult2XMLUI(form).toXml()) | 300 d.addCallback(lambda form: xml_tools.dataFormEltResult2XMLUI(form).toXml()) |
301 return d | 301 return d |
302 | 302 |
303 def getFieldsUI(self, to_jid, profile_key): | 303 def getFieldsUI(self, to_jid, profile_key): |
304 """Ask a service to send us the list of the form fields it manages. | 304 """Ask a service to send us the list of the form fields it manages. |
305 | 305 |
354 @param search_data (dict): filled data, corresponding to the form obtained in getFieldsUI | 354 @param search_data (dict): filled data, corresponding to the form obtained in getFieldsUI |
355 @param profile_key (unicode): %(doc_profile_key)s | 355 @param profile_key (unicode): %(doc_profile_key)s |
356 @return: a deferred XMLUI string representation | 356 @return: a deferred XMLUI string representation |
357 """ | 357 """ |
358 d = self.searchRequest(jid.JID(to_jid_s), search_data, profile_key) | 358 d = self.searchRequest(jid.JID(to_jid_s), search_data, profile_key) |
359 d.addCallback(lambda form: xml_tools.dataFormResult2XMLUI(form).toXml()) | 359 d.addCallback(lambda form: xml_tools.dataFormEltResult2XMLUI(form).toXml()) |
360 return d | 360 return d |
361 | 361 |
362 def searchRequest(self, to_jid, search_data, profile_key): | 362 def searchRequest(self, to_jid, search_data, profile_key): |
363 """Actually do a search, according to filled data. | 363 """Actually do a search, according to filled data. |
364 | 364 |