summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0065/stanza.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-01-23 02:18:27 -0800
committerLance Stout <lancestout@gmail.com>2013-01-23 02:18:27 -0800
commit9165cbf7f6839ee8ba2a4514b297f27fb019098a (patch)
treef231999e6ad8bc4ac92ae3b450192ad138515188 /sleekxmpp/plugins/xep_0065/stanza.py
parentbad405bea96405eb952888dc6996b8b40be85ac4 (diff)
downloadslixmpp-9165cbf7f6839ee8ba2a4514b297f27fb019098a.tar.gz
slixmpp-9165cbf7f6839ee8ba2a4514b297f27fb019098a.tar.bz2
slixmpp-9165cbf7f6839ee8ba2a4514b297f27fb019098a.tar.xz
slixmpp-9165cbf7f6839ee8ba2a4514b297f27fb019098a.zip
Cleanup and expand XEP-0065 plugin.
Diffstat (limited to 'sleekxmpp/plugins/xep_0065/stanza.py')
-rw-r--r--sleekxmpp/plugins/xep_0065/stanza.py54
1 files changed, 30 insertions, 24 deletions
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)