diff options
author | Lance Stout <lancestout@gmail.com> | 2010-12-16 22:03:56 -0500 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2010-12-16 22:03:56 -0500 |
commit | adade2e5eccf5a0c48b0b6541fc3d990d732710c (patch) | |
tree | 9d5bd167058070bfe2b90a7a093e53978a4e29ed /sleekxmpp/plugins/xep_0030/static.py | |
parent | c16913c99929a6a5a57611ec8a1757e3e82d4a45 (diff) | |
parent | cbc42c29fb02a6fd22a0c303e8d02364545c86cf (diff) | |
download | slixmpp-adade2e5eccf5a0c48b0b6541fc3d990d732710c.tar.gz slixmpp-adade2e5eccf5a0c48b0b6541fc3d990d732710c.tar.bz2 slixmpp-adade2e5eccf5a0c48b0b6541fc3d990d732710c.tar.xz slixmpp-adade2e5eccf5a0c48b0b6541fc3d990d732710c.zip |
Merge branch 'develop' into roster
Diffstat (limited to 'sleekxmpp/plugins/xep_0030/static.py')
-rw-r--r-- | sleekxmpp/plugins/xep_0030/static.py | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/sleekxmpp/plugins/xep_0030/static.py b/sleekxmpp/plugins/xep_0030/static.py index f3693228..b0e931b4 100644 --- a/sleekxmpp/plugins/xep_0030/static.py +++ b/sleekxmpp/plugins/xep_0030/static.py @@ -35,6 +35,11 @@ class StaticDisco(object): def __init__(self, xmpp): """ + Create a static disco interface. Sets of disco#info and + disco#items are maintained for every given JID and node + combination. These stanzas are used to store disco + information in memory without any additional processing. + Arguments: xmpp -- The main SleekXMPP object. """ @@ -52,7 +57,7 @@ class StaticDisco(object): self.nodes[(jid, node)]['info']['node'] = node self.nodes[(jid, node)]['items']['node'] = node - def get_info(self, jid, node, data=None): + def get_info(self, jid, node, data): if (jid, node) not in self.nodes: if not node: return DiscoInfo() @@ -61,11 +66,11 @@ class StaticDisco(object): else: return self.nodes[(jid, node)]['info'] - def del_info(self, jid, node, data=None): + def del_info(self, jid, node, data): if (jid, node) in self.nodes: self.nodes[(jid, node)]['info'] = DiscoInfo() - def get_items(self, jid, node, data=None): + def get_items(self, jid, node, data): if (jid, node) not in self.nodes: if not node: return DiscoInfo() @@ -74,14 +79,16 @@ class StaticDisco(object): else: return self.nodes[(jid, node)]['items'] - def set_items(self, jid, node, data=None): - pass + def set_items(self, jid, node, data): + items = data.get('items', set()) + self.add_node(jid, node) + self.nodes[(jid, node)]['items']['items'] = items - def del_items(self, jid, node, data=None): + def del_items(self, jid, node, data): if (jid, node) in self.nodes: self.nodes[(jid, node)]['items'] = DiscoItems() - def add_identity(self, jid, node, data={}): + def add_identity(self, jid, node, data): self.add_node(jid, node) self.nodes[(jid, node)]['info'].add_identity( data.get('category', ''), @@ -89,10 +96,12 @@ class StaticDisco(object): data.get('name', None), data.get('lang', None)) - def set_identities(self, jid, node, data=None): - pass + def set_identities(self, jid, node, data): + identities = data.get('identities', set()) + self.add_node(jid, node) + self.nodes[(jid, node)]['info']['identities'] = identities - def del_identity(self, jid, node, data=None): + def del_identity(self, jid, node, data): if (jid, node) not in self.nodes: return self.nodes[(jid, node)]['info'].del_identity( @@ -101,27 +110,29 @@ class StaticDisco(object): data.get('name', None), data.get('lang', None)) - - def add_feature(self, jid, node, data=None): + def add_feature(self, jid, node, data): self.add_node(jid, node) self.nodes[(jid, node)]['info'].add_feature(data.get('feature', '')) - def set_features(self, jid, node, data=None): - pass + def set_features(self, jid, node, data): + features = data.get('features', set()) + self.add_node(jid, node) + self.nodes[(jid, node)]['info']['features'] = features - def del_feature(self, jid, node, data=None): + def del_feature(self, jid, node, data): if (jid, node) not in self.nodes: return self.nodes[(jid, node)]['info'].del_feature(data.get('feature', '')) - def add_item(self, jid, node, data=None): + def add_item(self, jid, node, data): 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)) - def del_item(self, jid, node, data=None): + def del_item(self, jid, node, data): if (jid, node) in self.nodes: - self.nodes[(jid, node)]['items'].del_item(**data) - + self.nodes[(jid, node)]['items'].del_item( + data.get('ijid', ''), + node=data.get('inode', None)) |