From 8749f5e09bcc13c6b40e98025329b23194277803 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 28 Dec 2010 15:37:02 -0500 Subject: Make the new XEP-30 plugin retain older API signatures. --- sleekxmpp/plugins/xep_0030/disco.py | 40 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'sleekxmpp/plugins/xep_0030/disco.py') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index 92ee5ec6..2e993e28 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -90,6 +90,10 @@ class xep_0030(base_plugin): self.description = 'Service Discovery' self.stanza = sleekxmpp.plugins.xep_0030.stanza + # Retain some backwards compatibility + self.getInfo = self.get_info + self.getItems = self.get_items + self.xmpp.register_handler( Callback('Disco Info', StanzaPath('iq/disco_info'), @@ -248,7 +252,8 @@ class xep_0030(base_plugin): return self._fix_default_info(info) iq = self.xmpp.Iq() - iq['from'] = kwargs.get('ifrom', '') + # Check dfrom parameter for backwards compatibility + iq['from'] = kwargs.get('ifrom', kwargs.get('dfrom', '')) iq['to'] = jid iq['type'] = 'get' iq['disco_info']['node'] = node if node else '' @@ -285,7 +290,8 @@ class xep_0030(base_plugin): return self._run_node_handler('get_items', jid, node, kwargs) iq = self.xmpp.Iq() - iq['from'] = kwargs.get('ifrom', '') + # Check dfrom parameter for backwards compatibility + iq['from'] = kwargs.get('ifrom', kwargs.get('dfrom', '')) iq['to'] = jid iq['type'] = 'get' iq['disco_items']['node'] = node if node else '' @@ -317,7 +323,7 @@ class xep_0030(base_plugin): """ self._run_node_handler('del_items', jid, node, kwargs) - def add_item(self, jid=None, node=None, **kwargs): + def add_item(self, jid=None, name='', node=None, subnode='', ijid=None): """ Add a new item element to the given JID/node combination. @@ -325,12 +331,15 @@ class xep_0030(base_plugin): a node value to reference non-addressable entities. Arguments: - jid -- The JID to modify. - node -- The node to modify. - ijid -- The JID for the item. - inode -- Optional node for the item. + jid -- The JID for the item. name -- Optional name for the item. + node -- The node to modify. + subnode -- Optional node for the item. + ijid -- The JID to modify. """ + kwargs = {'ijid': jid, + 'name': name, + 'inode': subnode} self._run_node_handler('add_item', jid, node, kwargs) def del_item(self, jid=None, node=None, **kwargs): @@ -345,7 +354,7 @@ class xep_0030(base_plugin): """ self._run_node_handler('del_item', jid, node, kwargs) - def add_identity(self, jid=None, node=None, **kwargs): + def add_identity(self, category='', itype='', name='', node=None, jid=None, lang=None): """ Add a new identity to the given JID/node combination. @@ -358,24 +367,29 @@ class xep_0030(base_plugin): names are different. A category and type is always required. Arguments: - jid -- The JID to modify. - node -- The node to modify. category -- The identity's category. itype -- The identity's type. name -- Optional name for the identity. lang -- Optional two-letter language code. + node -- The node to modify. + jid -- The JID to modify. """ + kwargs = {'category': category, + 'itype': itype, + 'name': name, + 'lang': lang} self._run_node_handler('add_identity', jid, node, kwargs) - def add_feature(self, jid=None, node=None, **kwargs): + def add_feature(self, feature, node=None, jid=None): """ Add a feature to a JID/node combination. Arguments: - jid -- The JID to modify. - node -- The node to modify. feature -- The namespace of the supported feature. + node -- The node to modify. + jid -- The JID to modify. """ + kwargs = {'feature': feature} self._run_node_handler('add_feature', jid, node, kwargs) def del_identity(self, jid=None, node=None, **kwargs): -- cgit v1.2.3 From 4b145958fae50c5e2a13a59238364a479c54bd9e Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 4 Jan 2011 18:38:21 -0500 Subject: Clarify docs for disco.get_info. --- sleekxmpp/plugins/xep_0030/disco.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/plugins/xep_0030/disco.py') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index 2e993e28..b47cd4bb 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -240,7 +240,8 @@ class xep_0030(base_plugin): ifrom -- Specifiy the sender's JID. block -- If true, block and wait for the stanzas' reply. timeout -- The time in seconds to block while waiting for - a reply. If None, then wait indefinitely. + a reply. If None, then wait indefinitely. The + timeout value is only used when block=True. callback -- Optional callback to execute when a reply is received instead of blocking and waiting for the reply. -- cgit v1.2.3 From 8b29431cdeff5647208e3eab108bba9e9c8318fc Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 4 Jan 2011 19:39:10 -0500 Subject: More clarification in docs for XEP-0030 plugin. --- sleekxmpp/plugins/xep_0030/disco.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sleekxmpp/plugins/xep_0030/disco.py') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index b47cd4bb..4958c931 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -229,6 +229,9 @@ class xep_0030(base_plugin): by executing the local node handlers, or if a disco#info stanza must be generated and sent. + If requesting items from a local JID/node, then only a DiscoInfo + stanza will be returned. Otherwise, an Iq stanza will be returned. + Arguments: jid -- Request info from this JID. node -- The particular node to query. @@ -271,6 +274,9 @@ class xep_0030(base_plugin): executing the local node handlers, or if a disco#items stanza must be generated and sent. + If requesting items from a local JID/node, then only a DiscoItems + stanza will be returned. Otherwise, an Iq stanza will be returned. + Arguments: jid -- Request info from this JID. node -- The particular node to query. -- cgit v1.2.3