From a14979375b164aa44071dae30521ec15363f3b7a Mon Sep 17 00:00:00 2001 From: Sandro Munda Date: Sun, 3 Jun 2012 19:56:56 +0200 Subject: Added a partial support of the XEP 0065 - Socks5 Bytestreams --- sleekxmpp/plugins/xep_0065/stanza.py | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sleekxmpp/plugins/xep_0065/stanza.py (limited to 'sleekxmpp/plugins/xep_0065/stanza.py') diff --git a/sleekxmpp/plugins/xep_0065/stanza.py b/sleekxmpp/plugins/xep_0065/stanza.py new file mode 100644 index 00000000..4d33be98 --- /dev/null +++ b/sleekxmpp/plugins/xep_0065/stanza.py @@ -0,0 +1,38 @@ +from sleekxmpp.xmlstream import ElementBase + +# The protocol namespace defined in the Socks5Bytestream (0065) spec. +namespace = 'http://jabber.org/protocol/bytestreams' + + +class StreamHost(ElementBase): + """ The streamhost xml element. + """ + + namespace = namespace + name = 'streamhost' + plugin_attrib = 'streamhost' + interfaces = set(('host', 'jid', 'port')) + + +class StreamHostUsed(ElementBase): + """ The streamhost-used xml element. + """ + + namespace = 'http://jabber.org/protocol/bytestreams' + name = 'streamhost-used' + plugin_attrib = 'streamhost-used' + interfaces = set(('jid',)) + + +class Query(ElementBase): + """ The query xml element. + """ + + namespace = 'http://jabber.org/protocol/bytestreams' + name = 'query' + plugin_attrib = 'q' + interfaces = set(('sid', 'activate')) + sub_interfaces = set(('activate',)) + + + -- cgit v1.2.3 From 69cffce7dcaea56fa35f9c39299e98eb5576f20d Mon Sep 17 00:00:00 2001 From: Sandro Munda Date: Mon, 4 Jun 2012 07:57:14 +0200 Subject: Used the namespace in all stanzas --- sleekxmpp/plugins/xep_0065/stanza.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/plugins/xep_0065/stanza.py') diff --git a/sleekxmpp/plugins/xep_0065/stanza.py b/sleekxmpp/plugins/xep_0065/stanza.py index 4d33be98..ef70a368 100644 --- a/sleekxmpp/plugins/xep_0065/stanza.py +++ b/sleekxmpp/plugins/xep_0065/stanza.py @@ -18,7 +18,7 @@ class StreamHostUsed(ElementBase): """ The streamhost-used xml element. """ - namespace = 'http://jabber.org/protocol/bytestreams' + namespace = namespace name = 'streamhost-used' plugin_attrib = 'streamhost-used' interfaces = set(('jid',)) @@ -28,7 +28,7 @@ class Query(ElementBase): """ The query xml element. """ - namespace = 'http://jabber.org/protocol/bytestreams' + namespace = namespace name = 'query' plugin_attrib = 'q' interfaces = set(('sid', 'activate')) -- cgit v1.2.3 From cf24b870b124be3f41c496aa2a99b4c6f626e22f Mon Sep 17 00:00:00 2001 From: Sandro Munda Date: Mon, 4 Jun 2012 08:03:08 +0200 Subject: Registered stanza plugin in the stanza module --- sleekxmpp/plugins/xep_0065/stanza.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/plugins/xep_0065/stanza.py') diff --git a/sleekxmpp/plugins/xep_0065/stanza.py b/sleekxmpp/plugins/xep_0065/stanza.py index ef70a368..0990a509 100644 --- a/sleekxmpp/plugins/xep_0065/stanza.py +++ b/sleekxmpp/plugins/xep_0065/stanza.py @@ -1,4 +1,6 @@ -from sleekxmpp.xmlstream import ElementBase +from sleekxmpp import Iq +from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin + # The protocol namespace defined in the Socks5Bytestream (0065) spec. namespace = 'http://jabber.org/protocol/bytestreams' @@ -34,5 +36,6 @@ class Query(ElementBase): interfaces = set(('sid', 'activate')) sub_interfaces = set(('activate',)) - - +register_stanza_plugin(Iq, Query) +register_stanza_plugin(Query, StreamHost) +register_stanza_plugin(Query, StreamHostUsed) -- cgit v1.2.3 From 289b0523387e3c6dc7bde1161736aa791d6bcc99 Mon Sep 17 00:00:00 2001 From: Sandro Munda Date: Thu, 7 Jun 2012 19:14:37 +0200 Subject: Renamed Query to Socks5 in the xep_0065. Renamed the 'q' plugin_attrib of the Socks5 stanza to 'socks'. --- sleekxmpp/plugins/xep_0065/stanza.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sleekxmpp/plugins/xep_0065/stanza.py') diff --git a/sleekxmpp/plugins/xep_0065/stanza.py b/sleekxmpp/plugins/xep_0065/stanza.py index 0990a509..ae57aba8 100644 --- a/sleekxmpp/plugins/xep_0065/stanza.py +++ b/sleekxmpp/plugins/xep_0065/stanza.py @@ -26,16 +26,16 @@ class StreamHostUsed(ElementBase): interfaces = set(('jid',)) -class Query(ElementBase): +class Socks5(ElementBase): """ The query xml element. """ namespace = namespace name = 'query' - plugin_attrib = 'q' + plugin_attrib = 'socks' interfaces = set(('sid', 'activate')) sub_interfaces = set(('activate',)) -register_stanza_plugin(Iq, Query) -register_stanza_plugin(Query, StreamHost) -register_stanza_plugin(Query, StreamHostUsed) +register_stanza_plugin(Iq, Socks5) +register_stanza_plugin(Socks5, StreamHost) +register_stanza_plugin(Socks5, StreamHostUsed) -- cgit v1.2.3 From 9165cbf7f6839ee8ba2a4514b297f27fb019098a Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 23 Jan 2013 02:18:27 -0800 Subject: Cleanup and expand XEP-0065 plugin. --- sleekxmpp/plugins/xep_0065/stanza.py | 54 ++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'sleekxmpp/plugins/xep_0065/stanza.py') diff --git a/sleekxmpp/plugins/xep_0065/stanza.py b/sleekxmpp/plugins/xep_0065/stanza.py index ae57aba8..e48bf1b5 100644 --- a/sleekxmpp/plugins/xep_0065/stanza.py +++ b/sleekxmpp/plugins/xep_0065/stanza.py @@ -1,41 +1,47 @@ -from sleekxmpp import Iq +from sleekxmpp.jid import JID from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin -# The protocol namespace defined in the Socks5Bytestream (0065) spec. -namespace = 'http://jabber.org/protocol/bytestreams' +class Socks5(ElementBase): + name = 'query' + namespace = 'http://jabber.org/protocol/bytestreams' + plugin_attrib = 'socks' + interfaces = set(['sid', 'activate']) + sub_interfaces = set(['activate']) + def add_streamhost(self, jid, host, port): + sh = StreamHost(parent=self) + sh['jid'] = jid + sh['host'] = host + sh['port'] = port -class StreamHost(ElementBase): - """ The streamhost xml element. - """ - namespace = namespace +class StreamHost(ElementBase): name = 'streamhost' + namespace = 'http://jabber.org/protocol/bytestreams' plugin_attrib = 'streamhost' - interfaces = set(('host', 'jid', 'port')) + plugin_multi_attrib = 'streamhosts' + interfaces = set(['host', 'jid', 'port']) + def set_jid(self, value): + return self._set_attr('jid', str(value)) -class StreamHostUsed(ElementBase): - """ The streamhost-used xml element. - """ + def get_jid(self): + return JID(self._get_attr('jid')) - namespace = namespace + +class StreamHostUsed(ElementBase): name = 'streamhost-used' - plugin_attrib = 'streamhost-used' - interfaces = set(('jid',)) + namespace = 'http://jabber.org/protocol/bytestreams' + plugin_attrib = 'streamhost_used' + interfaces = set(['jid']) + def set_jid(self, value): + return self._set_attr('jid', str(value)) -class Socks5(ElementBase): - """ The query xml element. - """ + def get_jid(self): + return JID(self._get_attr('jid')) - namespace = namespace - name = 'query' - plugin_attrib = 'socks' - interfaces = set(('sid', 'activate')) - sub_interfaces = set(('activate',)) -register_stanza_plugin(Iq, Socks5) -register_stanza_plugin(Socks5, StreamHost) +register_stanza_plugin(Socks5, StreamHost, iterable=True) register_stanza_plugin(Socks5, StreamHostUsed) -- cgit v1.2.3