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') 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') 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') 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 From c3be6ea0b2141fe86b9aa0c2701e43b72f86ae30 Mon Sep 17 00:00:00 2001 From: Stefan de Konink Date: Sun, 23 Jan 2011 01:47:22 +0800 Subject: My hunch is that these should also be updated. --- sleekxmpp/plugins/xep_0078.py | 2 +- sleekxmpp/plugins/xep_0199.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/xep_0078.py b/sleekxmpp/plugins/xep_0078.py index d2c81b16..bb6a4632 100644 --- a/sleekxmpp/plugins/xep_0078.py +++ b/sleekxmpp/plugins/xep_0078.py @@ -36,7 +36,7 @@ class xep_0078(base.base_plugin): log.debug("Starting jabber:iq:auth Authentication") auth_request = self.xmpp.makeIqGet() auth_request_query = ET.Element('{jabber:iq:auth}query') - auth_request.attrib['to'] = self.xmpp.server + auth_request.attrib['to'] = self.xmpp.boundjid.host username = ET.Element('username') username.text = self.xmpp.username auth_request_query.append(username) diff --git a/sleekxmpp/plugins/xep_0199.py b/sleekxmpp/plugins/xep_0199.py index 2e99ae76..16e79e26 100644 --- a/sleekxmpp/plugins/xep_0199.py +++ b/sleekxmpp/plugins/xep_0199.py @@ -33,7 +33,7 @@ class xep_0199(base.base_plugin): def scheduled_ping(self): log.debug("pinging...") - if self.sendPing(self.xmpp.server, self.config.get('timeout', 30)) is False: + if self.sendPing(self.xmpp.boundjid.host, self.config.get('timeout', 30)) is False: log.debug("Did not recieve ping back in time. Requesting Reconnect.") self.xmpp.reconnect() -- cgit v1.2.3 From 0c8a8314b2e70d4a82b1c199b7e5bc16b494e275 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 26 Jan 2011 11:27:41 -0500 Subject: Cleanup for stanzabase. Use stanza.values instead of _get/set_stanza_values where used. ElementBase stanzas can now use .tag May use class method tag_name() for stanza classes. ElementBase now has .clear() method. --- sleekxmpp/plugins/xep_0092/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/xep_0092/version.py b/sleekxmpp/plugins/xep_0092/version.py index f59f8819..fb3671e4 100644 --- a/sleekxmpp/plugins/xep_0092/version.py +++ b/sleekxmpp/plugins/xep_0092/version.py @@ -84,5 +84,5 @@ class xep_0092(base_plugin): result = iq.send() if result and result['type'] != 'error': - return result['software_version']._get_stanza_values() + return result['software_version'].values return False -- cgit v1.2.3 From b4004cd4d677d6e6c0504d38f7ef0c18db23c71d Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 22 Jan 2011 03:18:04 +0800 Subject: xep_0045: fix the 'to' value when configuring room --- sleekxmpp/plugins/xep_0045.py | 1 + 1 file changed, 1 insertion(+) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py index feec70db..364fbbd9 100644 --- a/sleekxmpp/plugins/xep_0045.py +++ b/sleekxmpp/plugins/xep_0045.py @@ -316,6 +316,7 @@ class xep_0045(base.base_plugin): x = ET.Element('{jabber:x:data}x', type='cancel') query.append(x) iq = self.xmpp.makeIqSet(query) + iq['to'] = room iq.send() def setRoomConfig(self, room, config, ifrom=''): -- cgit v1.2.3 From 5313338c3ac3350e0c4a524c974021972f10ab94 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 31 Jan 2011 15:40:00 -0500 Subject: Fixes for XEP-0202 --- sleekxmpp/plugins/xep_0202.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/xep_0202.py b/sleekxmpp/plugins/xep_0202.py index fe1191ea..3b31c97a 100644 --- a/sleekxmpp/plugins/xep_0202.py +++ b/sleekxmpp/plugins/xep_0202.py @@ -27,10 +27,12 @@ class EntityTime(ElementBase): interfaces = set(('tzo', 'utc')) sub_interfaces = set(('tzo', 'utc')) - #def get_utc(self): # TODO: return a datetime.tzinfo object? + #def get_tzo(self): + # TODO: Right now it returns a string but maybe it should + # return a datetime.tzinfo object or maybe a datetime.timedelta? #pass - def set_tzo(self, tzo): # TODO: support datetime.tzinfo objects? + def set_tzo(self, tzo): if isinstance(tzo, tzinfo): td = datetime.now(tzo).utcoffset() # What if we are faking the time? datetime.now() shouldn't be used here' seconds = td.seconds + td.days * 24 * 3600 @@ -45,7 +47,7 @@ class EntityTime(ElementBase): # Returns a datetime object instead the string. Is this a good idea? value = self._get_sub_text('utc') if '.' in value: - return datetime.strptime(value, '%Y-%m-%d.%fT%H:%M:%SZ') + return datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ') else: return datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') -- cgit v1.2.3