slixmpp/sleekxmpp/plugins/xep_0065/stanza.py

48 lines
1.3 KiB
Python
Raw Normal View History

2013-01-23 10:18:27 +00:00
from sleekxmpp.jid import JID
from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin
2013-01-23 10:18:27 +00:00
class Socks5(ElementBase):
name = 'query'
namespace = 'http://jabber.org/protocol/bytestreams'
plugin_attrib = 'socks'
interfaces = set(['sid', 'activate'])
sub_interfaces = set(['activate'])
2013-01-23 10:18:27 +00:00
def add_streamhost(self, jid, host, port):
sh = StreamHost(parent=self)
sh['jid'] = jid
sh['host'] = host
sh['port'] = port
2013-01-23 10:18:27 +00:00
class StreamHost(ElementBase):
name = 'streamhost'
2013-01-23 10:18:27 +00:00
namespace = 'http://jabber.org/protocol/bytestreams'
plugin_attrib = 'streamhost'
2013-01-23 10:18:27 +00:00
plugin_multi_attrib = 'streamhosts'
interfaces = set(['host', 'jid', 'port'])
2013-01-23 10:18:27 +00:00
def set_jid(self, value):
return self._set_attr('jid', str(value))
2013-01-23 10:18:27 +00:00
def get_jid(self):
return JID(self._get_attr('jid'))
2013-01-23 10:18:27 +00:00
class StreamHostUsed(ElementBase):
name = 'streamhost-used'
2013-01-23 10:18:27 +00:00
namespace = 'http://jabber.org/protocol/bytestreams'
plugin_attrib = 'streamhost_used'
interfaces = set(['jid'])
2013-01-23 10:18:27 +00:00
def set_jid(self, value):
return self._set_attr('jid', str(value))
2013-01-23 10:18:27 +00:00
def get_jid(self):
return JID(self._get_attr('jid'))
2013-01-23 10:18:27 +00:00
register_stanza_plugin(Socks5, StreamHost, iterable=True)
register_stanza_plugin(Socks5, StreamHostUsed)