From a2891d760867c00f222ff4323b107378cd7a3a3d Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 15 Jan 2011 10:08:35 -0500 Subject: Fix how disco plugin looks up info and items for clients. --- sleekxmpp/plugins/xep_0030/disco.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'sleekxmpp/plugins/xep_0030') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index 6fd4e85f..72dda1db 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -177,7 +177,10 @@ class xep_0030(base_plugin): elif node is None: self._handlers[htype]['jid'][jid] = handler elif jid is None: - jid = self.xmpp.boundjid.full + if self.xmpp.is_component: + jid = self.xmpp.boundjid.full + else: + jid = self.xmpp.boundjid.bare self._handlers[htype]['node'][(jid, node)] = handler else: self._handlers[htype]['node'][(jid, node)] = handler @@ -500,7 +503,10 @@ class xep_0030(base_plugin): data -- Optional, custom data to pass to the handler. """ if jid is None: - jid = self.xmpp.boundjid.full + if self.xmpp.is_component: + jid = self.xmpp.boundjid.full + else: + jid = self.xmpp.boundjid.bare if node is None: node = '' @@ -526,8 +532,12 @@ class xep_0030(base_plugin): if iq['type'] == 'get': log.debug("Received disco info query from " + \ "<%s> to <%s>." % (iq['from'], iq['to'])) + if self.xmpp.is_component: + jid = iq['to'].full + else: + jid = iq['to'].bare info = self._run_node_handler('get_info', - iq['to'].full, + jid, iq['disco_info']['node'], iq) iq.reply() @@ -552,8 +562,12 @@ class xep_0030(base_plugin): if iq['type'] == 'get': log.debug("Received disco items query from " + \ "<%s> to <%s>." % (iq['from'], iq['to'])) + if self.xmpp.is_component: + jid = iq['to'].full + else: + jid = iq['to'].bare items = self._run_node_handler('get_items', - iq['to'].full, + jid, iq['disco_items']['node']) iq.reply() if items: -- cgit v1.2.3 From f1db2fc156aabba78e4aa726b441c434d48e9136 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 19 Jan 2011 12:08:28 -0500 Subject: Fix error in disco add_item. None values were not being treated properly. --- sleekxmpp/plugins/xep_0030/disco.py | 7 +++++-- sleekxmpp/plugins/xep_0030/static.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'sleekxmpp/plugins/xep_0030') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index 72dda1db..67468735 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -345,7 +345,7 @@ class xep_0030(base_plugin): """ self._run_node_handler('del_items', jid, node, kwargs) - def add_item(self, jid=None, name='', node=None, subnode='', ijid=None): + def add_item(self, jid='', name='', node=None, subnode='', ijid=None): """ Add a new item element to the given JID/node combination. @@ -359,10 +359,12 @@ class xep_0030(base_plugin): subnode -- Optional node for the item. ijid -- The JID to modify. """ + if jid is None: + jid = '' kwargs = {'ijid': jid, 'name': name, 'inode': subnode} - self._run_node_handler('add_item', jid, node, kwargs) + self._run_node_handler('add_item', ijid, node, kwargs) def del_item(self, jid=None, node=None, **kwargs): """ @@ -604,3 +606,4 @@ class xep_0030(base_plugin): "Using default disco#info feature.") info.add_feature(info.namespace) return info + diff --git a/sleekxmpp/plugins/xep_0030/static.py b/sleekxmpp/plugins/xep_0030/static.py index eff67f02..f957c84c 100644 --- a/sleekxmpp/plugins/xep_0030/static.py +++ b/sleekxmpp/plugins/xep_0030/static.py @@ -247,8 +247,8 @@ class StaticDisco(object): self.add_node(jid, node) self.nodes[(jid, node)]['items'].add_item( data.get('ijid', ''), - node=data.get('inode', None), - name=data.get('name', None)) + node=data.get('inode', ''), + name=data.get('name', '')) def del_item(self, jid, node, data): """ @@ -262,3 +262,4 @@ class StaticDisco(object): self.nodes[(jid, node)]['items'].del_item( data.get('ijid', ''), node=data.get('inode', None)) + -- cgit v1.2.3 From acc2d071ac5da8e822bd3c63dda640a81e93deec Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 19 Jan 2011 17:27:53 -0500 Subject: Fix disco add_item. If no JID is specified for the item, use xmpp.boundjid.full. --- sleekxmpp/plugins/xep_0030/disco.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/plugins/xep_0030') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index 67468735..a976b988 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -359,8 +359,8 @@ class xep_0030(base_plugin): subnode -- Optional node for the item. ijid -- The JID to modify. """ - if jid is None: - jid = '' + if not jid: + jid = self.xmpp.boundjid.full kwargs = {'ijid': jid, 'name': name, 'inode': subnode} -- cgit v1.2.3