From f97f6e5985b5781ce87a2095b4bf9cccb12ae978 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 21 Dec 2010 11:33:03 -0500 Subject: More documentation for XEP-0030 plugin. --- sleekxmpp/plugins/xep_0030/disco.py | 5 ++- sleekxmpp/plugins/xep_0030/static.py | 79 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index 1b78d522..92ee5ec6 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -108,7 +108,8 @@ class xep_0030(base_plugin): self._disco_ops = ['get_info', 'set_identities', 'set_features', 'get_items', 'set_items', 'del_items', 'add_identity', 'del_identity', 'add_feature', - 'del_feature', 'add_item', 'del_item'] + 'del_feature', 'add_item', 'del_item', + 'del_identities', 'del_features'] self._handlers = {} for op in self._disco_ops: self._handlers[op] = {'global': getattr(self.static, op), @@ -141,8 +142,10 @@ class xep_0030(base_plugin): set_features set_items del_items + del_identities del_identity del_feature + del_features del_item add_identity add_feature diff --git a/sleekxmpp/plugins/xep_0030/static.py b/sleekxmpp/plugins/xep_0030/static.py index 11674e6e..eff67f02 100644 --- a/sleekxmpp/plugins/xep_0030/static.py +++ b/sleekxmpp/plugins/xep_0030/static.py @@ -136,6 +136,15 @@ class StaticDisco(object): self.nodes[(jid, node)]['items'] = DiscoItems() def add_identity(self, jid, node, data): + """ + Add a new identity to te JID/node combination. + + The data parameter may provide: + category -- The general category to which the agent belongs. + itype -- A more specific designation with the category. + name -- Optional human readable name for this identity. + lang -- Optional standard xml:lang value. + """ self.add_node(jid, node) self.nodes[(jid, node)]['info'].add_identity( data.get('category', ''), @@ -144,11 +153,27 @@ class StaticDisco(object): data.get('lang', None)) def set_identities(self, jid, node, data): + """ + Add or replace all identities for a JID/node combination. + + The data parameter should include: + identities -- A list of identities in tuple form: + (category, type, name, lang) + """ identities = data.get('identities', set()) self.add_node(jid, node) self.nodes[(jid, node)]['info']['identities'] = identities def del_identity(self, jid, node, data): + """ + Remove an identity from a JID/node combination. + + The data parameter may provide: + category -- The general category to which the agent belonged. + itype -- A more specific designation with the category. + name -- Optional human readable name for this identity. + lang -- Optional, standard xml:lang value. + """ if (jid, node) not in self.nodes: return self.nodes[(jid, node)]['info'].del_identity( @@ -157,21 +182,68 @@ class StaticDisco(object): data.get('name', None), data.get('lang', None)) + def del_identities(self, jid, node, data): + """ + Remove all identities from a JID/node combination. + + The data parameter is not used. + """ + if (jid, node) not in self.nodes: + return + del self.nodes[(jid, node)]['info']['identities'] + def add_feature(self, jid, node, data): + """ + Add a feature to a JID/node combination. + + The data parameter should include: + feature -- The namespace of the supported feature. + """ self.add_node(jid, node) self.nodes[(jid, node)]['info'].add_feature(data.get('feature', '')) def set_features(self, jid, node, data): + """ + Add or replace all features for a JID/node combination. + + The data parameter should include: + features -- The new set of supported features. + """ features = data.get('features', set()) self.add_node(jid, node) self.nodes[(jid, node)]['info']['features'] = features def del_feature(self, jid, node, data): + """ + Remove a feature from a JID/node combination. + + The data parameter should include: + feature -- The namespace of the removed feature. + """ if (jid, node) not in self.nodes: return self.nodes[(jid, node)]['info'].del_feature(data.get('feature', '')) + def del_features(self, jid, node, data): + """ + Remove all features from a JID/node combination. + + The data parameter is not used. + """ + if (jid, node) not in self.nodes: + return + del self.nodes[(jid, node)]['info']['features'] + def add_item(self, jid, node, data): + """ + Add an item to a JID/node combination. + + The data parameter may include: + ijid -- The JID for the item. + inode -- Optional additional information to reference + non-addressable items. + name -- Optional human readable name for the item. + """ self.add_node(jid, node) self.nodes[(jid, node)]['items'].add_item( data.get('ijid', ''), @@ -179,6 +251,13 @@ class StaticDisco(object): name=data.get('name', None)) def del_item(self, jid, node, data): + """ + Remove an item from a JID/node combination. + + The data parameter may include: + ijid -- JID of the item to remove. + inode -- Optional extra identifying information. + """ if (jid, node) in self.nodes: self.nodes[(jid, node)]['items'].del_item( data.get('ijid', ''), -- cgit v1.2.3