From e6bec8681e07ced607db1fbcbc5e356c3936f1d1 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 19 Jul 2010 04:22:31 -0400 Subject: Added implementation for XEP-0128 Service Discovery Extensions. Uses the alt_0004 plugin for jabber:x:data stanza objects. --- sleekxmpp/plugins/xep_0128.py | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sleekxmpp/plugins/xep_0128.py (limited to 'sleekxmpp/plugins/xep_0128.py') 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) -- cgit v1.2.3 From d5e42ac0e7282500583bf17f21eb2f944600ce76 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 19 Jul 2010 13:58:53 -0400 Subject: Condensed all of the stanzaPlugin functions into a single registerStanzaPlugin function. Updated plugins and tests to use new function. --- sleekxmpp/plugins/xep_0128.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/plugins/xep_0128.py') diff --git a/sleekxmpp/plugins/xep_0128.py b/sleekxmpp/plugins/xep_0128.py index 3e660b19..7ba00bf5 100644 --- a/sleekxmpp/plugins/xep_0128.py +++ b/sleekxmpp/plugins/xep_0128.py @@ -10,7 +10,7 @@ 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 .. xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID from .. stanza.iq import Iq from . xep_0030 import DiscoInfo, DiscoItems from . alt_0004 import Form @@ -25,8 +25,8 @@ class xep_0128(base.base_plugin): self.xep = '0128' self.description = 'Service Discovery Extensions' - self.xmpp.stanzaPlugin(DiscoInfo, Form) - self.xmpp.stanzaPlugin(DiscoItems, Form) + registerStanzaPlugin(DiscoInfo, Form) + registerStanzaPlugin(DiscoItems, Form) def extend_info(self, node, data=None): if data is None: -- cgit v1.2.3 From 9ca4bba2def8cffe1c079ce98304f1fa89b95b75 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 20 Jul 2010 00:34:24 -0400 Subject: Update XEP-0128 to use new xep_0004 --- sleekxmpp/plugins/xep_0128.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sleekxmpp/plugins/xep_0128.py') diff --git a/sleekxmpp/plugins/xep_0128.py b/sleekxmpp/plugins/xep_0128.py index 7ba00bf5..dfe5829f 100644 --- a/sleekxmpp/plugins/xep_0128.py +++ b/sleekxmpp/plugins/xep_0128.py @@ -13,7 +13,7 @@ from .. xmlstream.matcher.xpath import MatchXPath from .. xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID from .. stanza.iq import Iq from . xep_0030 import DiscoInfo, DiscoItems -from . alt_0004 import Form +from . xep_0004 import Form class xep_0128(base.base_plugin): -- cgit v1.2.3 From 690eaf8d3c3856c6242612da22e6c6d323f193ed Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 20 Jul 2010 11:19:49 -0400 Subject: Updated license notices to use the correct MIT format. Also corrected references to nonexistant license.txt to LICENSE. --- sleekxmpp/plugins/xep_0128.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sleekxmpp/plugins/xep_0128.py') diff --git a/sleekxmpp/plugins/xep_0128.py b/sleekxmpp/plugins/xep_0128.py index dfe5829f..824977b6 100644 --- a/sleekxmpp/plugins/xep_0128.py +++ b/sleekxmpp/plugins/xep_0128.py @@ -3,7 +3,7 @@ Copyright (C) 2010 Nathanael C. Fritz, Lance J.T. Stout This file is part of SleekXMPP. - See the file license.txt for copying permission. + See the file LICENSE for copying permission. """ import logging -- cgit v1.2.3