changeset 2150:91347fe95384

core(memory.disco), bridge: discoInfos and discoItems now handle node
author Goffi <goffi@goffi.org>
date Sun, 12 Feb 2017 21:17:56 +0100
parents a0e6f7951bd7
children fff88c33442f
files frontends/src/bridge/dbus_bridge.py src/bridge/bridge_constructor/bridge_template.ini src/bridge/dbus_bridge.py src/memory/disco.py
diffstat 4 files changed, 26 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/bridge/dbus_bridge.py	Sun Feb 12 21:17:56 2017 +0100
+++ b/frontends/src/bridge/dbus_bridge.py	Sun Feb 12 21:17:56 2017 +0100
@@ -209,23 +209,23 @@
             error_handler = lambda err:errback(dbus_to_bridge_exception(err))
         return self.db_core_iface.delContact(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
 
-    def discoInfos(self, entity_jid, profile_key, callback=None, errback=None):
+    def discoInfos(self, entity_jid, node=u'', profile_key=u"@DEFAULT@", callback=None, errback=None):
         if callback is None:
             error_handler = None
         else:
             if errback is None:
                 errback = log.error
             error_handler = lambda err:errback(dbus_to_bridge_exception(err))
-        return self.db_core_iface.discoInfos(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
+        return self.db_core_iface.discoInfos(entity_jid, node, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
 
-    def discoItems(self, entity_jid, profile_key, callback=None, errback=None):
+    def discoItems(self, entity_jid, node=u'', profile_key=u"@DEFAULT@", callback=None, errback=None):
         if callback is None:
             error_handler = None
         else:
             if errback is None:
                 errback = log.error
             error_handler = lambda err:errback(dbus_to_bridge_exception(err))
-        return self.db_core_iface.discoItems(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
+        return self.db_core_iface.discoItems(entity_jid, node, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
 
     def disconnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
         if callback is None:
--- a/src/bridge/bridge_constructor/bridge_template.ini	Sun Feb 12 21:17:56 2017 +0100
+++ b/src/bridge/bridge_constructor/bridge_template.ini	Sun Feb 12 21:17:56 2017 +0100
@@ -696,11 +696,14 @@
 async=
 type=method
 category=core
-sig_in=ss
+sig_in=sss
 sig_out=(asa(sss)a{sa(a{ss}as)})
+param_1_default=u''
+param_2_default=u"@DEFAULT@"
 doc=Discover infos on an entity
 doc_param_0=entity_jid: JID to discover
-doc_param_1=%(doc_profile_key)s
+doc_param_1=node: node to use
+doc_param_2=%(doc_profile_key)s
 doc_return=discovery data:
  - list of features
  - list of identities (category, type, name)
@@ -717,11 +720,14 @@
 async=
 type=method
 category=core
-sig_in=ss
+sig_in=sss
 sig_out=a(sss)
+param_1_default=u''
+param_2_default=u"@DEFAULT@"
 doc=Discover items of an entity
 doc_param_0=entity_jid: JID to discover
-doc_param_1=%(doc_profile_key)s
+doc_param_1=node: node to use
+doc_param_2=%(doc_profile_key)s
 doc_return=array of tuple (entity, node identifier, name)
 
 [saveParamsTemplate]
--- a/src/bridge/dbus_bridge.py	Sun Feb 12 21:17:56 2017 +0100
+++ b/src/bridge/dbus_bridge.py	Sun Feb 12 21:17:56 2017 +0100
@@ -234,16 +234,16 @@
         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)a{sa(a{ss}as)})',
+                         in_signature='sss', 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)
+    def discoInfos(self, entity_jid, node=u'', profile_key=u"@DEFAULT@", callback=None, errback=None):
+        return self._callback("discoInfos", unicode(entity_jid), unicode(node), unicode(profile_key), callback=callback, errback=errback)
 
     @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
-                         in_signature='ss', out_signature='a(sss)',
+                         in_signature='sss', out_signature='a(sss)',
                          async_callbacks=('callback', 'errback'))
-    def discoItems(self, entity_jid, profile_key, callback=None, errback=None):
-        return self._callback("discoItems", unicode(entity_jid), unicode(profile_key), callback=callback, errback=errback)
+    def discoItems(self, entity_jid, node=u'', profile_key=u"@DEFAULT@", callback=None, errback=None):
+        return self._callback("discoItems", unicode(entity_jid), unicode(node), unicode(profile_key), callback=callback, errback=errback)
 
     @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='',
--- a/src/memory/disco.py	Sun Feb 12 21:17:56 2017 +0100
+++ b/src/memory/disco.py	Sun Feb 12 21:17:56 2017 +0100
@@ -308,15 +308,16 @@
         return cap_hash
 
     @defer.inlineCallbacks
-    def _discoInfos(self, entity_jid_s, profile_key=C.PROF_KEY_NONE):
+    def _discoInfos(self, entity_jid_s, node=u'', profile_key=C.PROF_KEY_NONE):
         """ Discovery method for the bridge
         @param entity_jid_s: entity we want to discover
+        @param node(unicode): optional node to use
 
         @return: list of tuples
         """
         client = self.host.getClient(profile_key)
         entity = jid.JID(entity_jid_s)
-        disco_infos = yield self.getInfos(client, entity)
+        disco_infos = yield self.getInfos(client, entity, node)
         extensions = {}
         for form_type, form in disco_infos.extensions.items():
             fields = []
@@ -349,13 +350,14 @@
             yield (item.entity.full(), item.nodeIdentifier or '', item.name or '')
 
     @defer.inlineCallbacks
-    def _discoItems(self, entity_jid_s, profile_key=C.PROF_KEY_NONE):
+    def _discoItems(self, entity_jid_s, node=u'', profile_key=C.PROF_KEY_NONE):
         """ Discovery method for the bridge
 
         @param entity_jid_s: entity we want to discover
+        @param node(unicode): optional node to use
         @return: list of tuples"""
         client = self.host.getClient(profile_key)
         entity = jid.JID(entity_jid_s)
-        disco_items = yield self.getItems(client, entity)
+        disco_items = yield self.getItems(client, entity, node)
         ret = list(self.items2tuples(disco_items))
         defer.returnValue(ret)