diff options
author | Lance Stout <lancestout@gmail.com> | 2010-07-19 04:22:31 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2010-07-19 04:22:31 -0400 |
commit | e6bec8681e07ced607db1fbcbc5e356c3936f1d1 (patch) | |
tree | d7cb9ee12e7e646a6336c373cf1f45de3909074b /sleekxmpp/plugins | |
parent | 797e92a6a3cf1534f6ecb0f30019b0135d0ffacb (diff) | |
download | slixmpp-e6bec8681e07ced607db1fbcbc5e356c3936f1d1.tar.gz slixmpp-e6bec8681e07ced607db1fbcbc5e356c3936f1d1.tar.bz2 slixmpp-e6bec8681e07ced607db1fbcbc5e356c3936f1d1.tar.xz slixmpp-e6bec8681e07ced607db1fbcbc5e356c3936f1d1.zip |
Added implementation for XEP-0128 Service Discovery Extensions.
Uses the alt_0004 plugin for jabber:x:data stanza objects.
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r-- | sleekxmpp/plugins/xep_0128.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0128.py b/sleekxmpp/plugins/xep_0128.py new file mode 100644 index 00000000..3e660b19 --- /dev/null +++ b/sleekxmpp/plugins/xep_0128.py @@ -0,0 +1,51 @@ +""" + 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.txt for copying permission. +""" + +import logging +from . import base +from .. xmlstream.handler.callback import Callback +from .. xmlstream.matcher.xpath import MatchXPath +from .. xmlstream.stanzabase import ElementBase, ET, JID +from .. stanza.iq import Iq +from . xep_0030 import DiscoInfo, DiscoItems +from . alt_0004 import Form + + +class xep_0128(base.base_plugin): + """ + XEP-0128 Service Discovery Extensions + """ + + def plugin_init(self): + self.xep = '0128' + self.description = 'Service Discovery Extensions' + + self.xmpp.stanzaPlugin(DiscoInfo, Form) + self.xmpp.stanzaPlugin(DiscoItems, Form) + + def extend_info(self, node, data=None): + if data is None: + data = {} + node = self.xmpp['xep_0030'].nodes.get(node, None) + if node is None: + self.xmpp['xep_0030'].add_node(node) + + info = node.info + info['form']['type'] = 'result' + info['form'].setFields(data, default=None) + + def extend_items(self, node, data=None): + if data is None: + data = {} + node = self.xmpp['xep_0030'].nodes.get(node, None) + if node is None: + self.xmpp['xep_0030'].add_node(node) + + items = node.items + items['form']['type'] = 'result' + items['form'].setFields(data, default=None) |