diff options
author | Lance Stout <lancestout@gmail.com> | 2010-12-16 23:52:17 -0500 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2010-12-16 23:52:17 -0500 |
commit | 53a5026301b6f6e842fa29b52bef1721e068eddf (patch) | |
tree | 3266574dc6cd6b84edcb990eefebfdfbf3303351 | |
parent | 0aee445e6976b03f7e04bcab6ec40ecf14b5d1a4 (diff) | |
download | slixmpp-53a5026301b6f6e842fa29b52bef1721e068eddf.tar.gz slixmpp-53a5026301b6f6e842fa29b52bef1721e068eddf.tar.bz2 slixmpp-53a5026301b6f6e842fa29b52bef1721e068eddf.tar.xz slixmpp-53a5026301b6f6e842fa29b52bef1721e068eddf.zip |
Almost done with xep-30; added more docs.
-rw-r--r-- | sleekxmpp/plugins/xep_0030/disco.py | 8 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0030/static.py | 47 |
2 files changed, 51 insertions, 4 deletions
diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index ad3d0ae2..1b78d522 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -230,7 +230,7 @@ class xep_0030(base_plugin): no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remove JID to retrieve the info. - dfrom -- Specifiy the sender's JID. + 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. @@ -245,7 +245,7 @@ class xep_0030(base_plugin): return self._fix_default_info(info) iq = self.xmpp.Iq() - iq['from'] = kwargs.get('dfrom', '') + iq['from'] = kwargs.get('ifrom', '') iq['to'] = jid iq['type'] = 'get' iq['disco_info']['node'] = node if node else '' @@ -270,7 +270,7 @@ class xep_0030(base_plugin): no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remove JID to retrieve the items. - dfrom -- Specifiy the sender's JID. + 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. @@ -282,7 +282,7 @@ class xep_0030(base_plugin): return self._run_node_handler('get_items', jid, node, kwargs) iq = self.xmpp.Iq() - iq['from'] = kwargs.get('dfrom', '') + iq['from'] = kwargs.get('ifrom', '') iq['to'] = jid iq['type'] = 'get' iq['disco_items']['node'] = node if node else '' diff --git a/sleekxmpp/plugins/xep_0030/static.py b/sleekxmpp/plugins/xep_0030/static.py index b0e931b4..11674e6e 100644 --- a/sleekxmpp/plugins/xep_0030/static.py +++ b/sleekxmpp/plugins/xep_0030/static.py @@ -31,6 +31,11 @@ class StaticDisco(object): StaticDisco provides a set of node handlers that will store static sets of disco info and items in memory. + + Attributes: + nodes -- A dictionary mapping (JID, node) tuples to a dict + containing a disco#info and a disco#items stanza. + xmpp -- The main SleekXMPP object. """ def __init__(self, xmpp): @@ -47,6 +52,14 @@ class StaticDisco(object): self.xmpp = xmpp def add_node(self, jid=None, node=None): + """ + Create a new set of stanzas for the provided + JID and node combination. + + Arguments: + jid -- The JID that will own the new stanzas. + node -- The node that will own the new stanzas. + """ if jid is None: jid = self.xmpp.boundjid.full if node is None: @@ -57,7 +70,21 @@ class StaticDisco(object): self.nodes[(jid, node)]['info']['node'] = node self.nodes[(jid, node)]['items']['node'] = node + # ================================================================= + # Node Handlers + # + # Each handler accepts three arguments: jid, node, and data. + # The jid and node parameters together determine the set of + # info and items stanzas that will be retrieved or added. + # The data parameter is a dictionary with additional paramters + # that will be passed to other calls. + def get_info(self, jid, node, data): + """ + Return the stored info data for the requested JID/node combination. + + The data parameter is not used. + """ if (jid, node) not in self.nodes: if not node: return DiscoInfo() @@ -67,10 +94,20 @@ class StaticDisco(object): return self.nodes[(jid, node)]['info'] def del_info(self, jid, node, data): + """ + Reset the info stanza for a given JID/node combination. + + The data parameter is not used. + """ if (jid, node) in self.nodes: self.nodes[(jid, node)]['info'] = DiscoInfo() def get_items(self, jid, node, data): + """ + Return the stored items data for the requested JID/node combination. + + The data parameter is not used. + """ if (jid, node) not in self.nodes: if not node: return DiscoInfo() @@ -80,11 +117,21 @@ class StaticDisco(object): return self.nodes[(jid, node)]['items'] def set_items(self, jid, node, data): + """ + Replace the stored items data for a JID/node combination. + + The data parameter is not used. + """ items = data.get('items', set()) self.add_node(jid, node) self.nodes[(jid, node)]['items']['items'] = items def del_items(self, jid, node, data): + """ + Reset the items stanza for a given JID/node combination. + + The data parameter is not used. + """ if (jid, node) in self.nodes: self.nodes[(jid, node)]['items'] = DiscoItems() |