Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0059.py @ 2717:e3f6de6ce320
plugin XEP-0059: added serialise method
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 10 Dec 2018 20:34:45 +0100 |
parents | 035901dc946d |
children | c4190d5340ab |
comparison
equal
deleted
inserted
replaced
2716:06160b529da6 | 2717:e3f6de6ce320 |
---|---|
72 if rsm_args: | 72 if rsm_args: |
73 return rsm.RSMRequest(**rsm_args) | 73 return rsm.RSMRequest(**rsm_args) |
74 else: | 74 else: |
75 return None | 75 return None |
76 | 76 |
77 def serialise(self, rsm_response, data=None): | |
78 """Serialise data for RSM | |
79 | |
80 Key set in data can be: | |
81 - rsm_first: first item id in the page | |
82 - rsm_last: last item id in the page | |
83 - rsm_index: position of the first item in the full set (may be approximate) | |
84 - rsm_count: total number of items in the full set (may be approximage) | |
85 If a value doesn't exists, it's not set. | |
86 All values are set as strings. | |
87 @param rsm_response(rsm.RSMResponse): response to serialise | |
88 @param data(dict, None): dict to update with rsm_* data. | |
89 If None, a new dict is created | |
90 @return (dict): data dict | |
91 """ | |
92 if data is None: | |
93 data = {} | |
94 if rsm_response.first is not None: | |
95 data[u"rsm_first"] = rsm_response.first | |
96 if rsm_response.last is not None: | |
97 data[u"rsm_last"] = rsm_response.last | |
98 if rsm_response.index is not None: | |
99 data[u"rsm_index"] = unicode(rsm_response.index) | |
100 if rsm_response.index is not None: | |
101 data[u"rsm_index"] = unicode(rsm_response.index) | |
102 return data | |
103 | |
77 | 104 |
78 class XEP_0059_handler(xmlstream.XMPPHandler): | 105 class XEP_0059_handler(xmlstream.XMPPHandler): |
79 implements(iwokkel.IDisco) | 106 implements(iwokkel.IDisco) |
80 | 107 |
81 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): | 108 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |