summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0128/static.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-03-22 20:48:09 -0400
committerLance Stout <lancestout@gmail.com>2011-03-22 20:48:09 -0400
commit756c4c032f820285455c7c57e4925887f9c8e213 (patch)
treebc964a6c96cdbf9ccf1c8c82a6e9291b4d5f738a /sleekxmpp/plugins/xep_0128/static.py
parente1360ae04946a4b6f9fe7ed19f9349ce24405dd1 (diff)
parent4b1fadde4bd87a8763131165701c08a3035005eb (diff)
downloadslixmpp-756c4c032f820285455c7c57e4925887f9c8e213.tar.gz
slixmpp-756c4c032f820285455c7c57e4925887f9c8e213.tar.bz2
slixmpp-756c4c032f820285455c7c57e4925887f9c8e213.tar.xz
slixmpp-756c4c032f820285455c7c57e4925887f9c8e213.zip
Merge branch 'develop' into roster
Diffstat (limited to 'sleekxmpp/plugins/xep_0128/static.py')
-rw-r--r--sleekxmpp/plugins/xep_0128/static.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0128/static.py b/sleekxmpp/plugins/xep_0128/static.py
new file mode 100644
index 00000000..493d9370
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0128/static.py
@@ -0,0 +1,72 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz, Lance J.T. Stout
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+import logging
+
+import sleekxmpp
+from sleekxmpp.plugins.xep_0030 import StaticDisco
+
+
+log = logging.getLogger(__name__)
+
+
+class StaticExtendedDisco(object):
+
+ """
+ Extend the default StaticDisco implementation to provide
+ support for extended identity information.
+ """
+
+ def __init__(self, static):
+ """
+ Augment the default XEP-0030 static handler object.
+
+ Arguments:
+ static -- The default static XEP-0030 handler object.
+ """
+ self.static = static
+
+ def set_extended_info(self, jid, node, data):
+ """
+ Replace the extended identity data for a JID/node combination.
+
+ The data parameter may provide:
+ data -- Either a single data form, or a list of data forms.
+ """
+ self.del_extended_info(jid, node, data)
+ self.add_extended_info(jid, node, data)
+
+ def add_extended_info(self, jid, node, data):
+ """
+ Add additional extended identity data for a JID/node combination.
+
+ The data parameter may provide:
+ data -- Either a single data form, or a list of data forms.
+ """
+ self.static.add_node(jid, node)
+
+ forms = data.get('data', [])
+ if not isinstance(forms, list):
+ forms = [forms]
+
+ for form in forms:
+ self.static.nodes[(jid, node)]['info'].append(form)
+
+ def del_extended_info(self, jid, node, data):
+ """
+ Replace the extended identity data for a JID/node combination.
+
+ The data parameter is not used.
+ """
+ if (jid, node) not in self.static.nodes:
+ return
+
+ info = self.static.nodes[(jid, node)]['info']
+
+ for form in info['substanza']:
+ info.xml.remove(form.xml)