core, bridge, jp: management of service discovery extensions (XEP-0128)
This commit is contained in:
parent
c50e5adb72
commit
35108bc5ba
3 changed files with 69 additions and 22 deletions
|
|
@ -235,7 +235,7 @@ class DbusObject(dbus.service.Object):
|
|||
return self._callback("delContact", unicode(entity_jid), unicode(profile_key), callback=callback, errback=errback)
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='ss', out_signature='(asa(sss))',
|
||||
in_signature='ss', out_signature='(asa(sss)a{sa(a{ss}as)})',
|
||||
async_callbacks=('callback', 'errback'))
|
||||
def discoInfos(self, entity_jid, profile_key, callback=None, errback=None):
|
||||
return self._callback("discoInfos", unicode(entity_jid), unicode(profile_key), callback=callback, errback=errback)
|
||||
|
|
|
|||
|
|
@ -614,11 +614,20 @@ async=
|
|||
type=method
|
||||
category=core
|
||||
sig_in=ss
|
||||
sig_out=(asa(sss))
|
||||
sig_out=(asa(sss)a{sa(a{ss}as)})
|
||||
doc=Discover infos on an entity
|
||||
doc_param_0=entity_jid: JID to discover
|
||||
doc_param_1=%(doc_profile_key)s
|
||||
doc_return=discovery data
|
||||
doc_return=discovery data:
|
||||
- list of features
|
||||
- list of identities (category, type, name)
|
||||
- dictionary of extensions (FORM_TYPE as key), with value of:
|
||||
- list of field which are:
|
||||
- dictionary key/value where key can be:
|
||||
* var
|
||||
* label
|
||||
* type
|
||||
- list of values
|
||||
|
||||
[discoItems]
|
||||
async=
|
||||
|
|
|
|||
|
|
@ -254,7 +254,24 @@ class Discovery(object):
|
|||
@return: list of tu"""
|
||||
entity = jid.JID(entity_jid_s)
|
||||
disco_infos = yield self.getInfos(entity, profile_key)
|
||||
defer.returnValue((disco_infos.features, [(cat, type_, name or '') for (cat, type_), name in disco_infos.identities.items()]))
|
||||
extensions = {}
|
||||
for form_type, form in disco_infos.extensions.items():
|
||||
fields = []
|
||||
for field in form.fieldList:
|
||||
data = {'type': field.fieldType}
|
||||
for attr in ('var', 'label', 'desc'):
|
||||
value = getattr(field, attr)
|
||||
if value is not None:
|
||||
data[attr] = value
|
||||
|
||||
values = [field.value] if field.value is not None else field.values
|
||||
fields.append((data, values))
|
||||
|
||||
extensions[form_type or ""] = fields
|
||||
|
||||
defer.returnValue((disco_infos.features,
|
||||
[(cat, type_, name or '') for (cat, type_), name in disco_infos.identities.items()],
|
||||
extensions))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _discoItems(self, entity_jid_s, profile_key=C.PROF_KEY_NONE):
|
||||
|
|
|
|||
Loading…
Reference in a new issue