Revert or edit most previous XEP plugin changes
In a single commit, because it isn’t that interesting to detail each change. List of reverts: Revert "XEP-0030: allow get_info and get_items to return a coroutine" This reverts commit 506ca6991790cffb90c5b6e3b765237ccc136e1a. Revert "XEP-0060: wrap all iq-sending functions with coroutine_wrapper" This reverts commit e85fa4203e0ee7108d8d37f73913c21628e3d6fc. Revert "XEP-0163: wrap publish() with coroutine_wrapper" This reverts commit 69da1c1d7cf7a1c0dbbeeb83f528b4e5f5b5be0c. Revert "XEP-0084: wrap functions with coroutine_wrapper" This reverts commit ea5615f236bd80fb4217398977833ca790cbef71. Partially revert 3d243f7 (XEP-0054) - continue wrapping functions but with future_wrapper Partially revert 115fe95 (xep-0153) - use callbacks rather than coroutine callbacks, and propagate iqtimeouts in set_avatar. Revert "XEP-0049: wrap functions with coroutine_wrapper" This reverts commit e68135f59f9a224688679eb91e8063041d6f000b. Revert "XEP-0077: wrap functions with coroutine_wrapper" This reverts commit 1e4944d47e8296fdaa792a8b3fc87ea99acc217c. Partially revert cd7ff685 (XEP-0199) - remove the iq.send wrapping but keep ping() as a coroutine Revert "XEP-0257: wrap functions with coroutine_wrapper" This reverts commit 4da870fd191697d010e677eee32ef86439967353. Revert "XEP-0092: wrap get_version() with coroutine_wrapper" This reverts commit 6e35948276c36ea2696f0de64dc179a1073ee3a6. Revert "XEP-0191: wrap functions with coroutine_wrapper" This reverts commit 6e8235544cc1bdefea75a8d93e5e3a48a13552ba. Revert "XEP-0280: wrap functions with coroutine_wrapper" This reverts commit f795ac02e322445be13077463638924d1f22d313. Revert "XEP-0012: wrap get_last_activity() with coroutine_wrapper" This reverts commit 2ee05d9616d2959d19a7a87d21c58e6aae1db56e. Revert "XEP-0202: wrap get_entity_time() with coroutine_wrapper" This reverts commit 6fb3ecd414f24374f17811d7ad2fd01e4924e311. Revert "XEP-0231: wrap get_bob() with coroutine_wrapper" This reverts commit 17464b10a42d9b3c4daba763e06e53c429478abd. Revert "XEP-0258: wrap get_catalog() with coroutine_wrapper" This reverts commit 18a4978456a33e6ea38de1e07b1aa43bcc10d45f. Revert "XEP-0050: wrap send_command() and get_commands() with coroutine_wrapper" This reverts commit e034b31d6bc34f43578456e9c6527bc56dff78e3. Revert "XEP-0279: wrap check_ip() with coroutine_wrapper" This reverts commit e112e864756f1222a044ee28e3c13c5925618b0c.
This commit is contained in:
parent
83d00a5913
commit
997928de91
@ -10,13 +10,12 @@ import logging
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from slixmpp.plugins import BasePlugin, register_plugin
|
from slixmpp.plugins import BasePlugin, register_plugin
|
||||||
from slixmpp import Iq
|
from slixmpp import future_wrapper, Iq
|
||||||
from slixmpp.exceptions import XMPPError
|
from slixmpp.exceptions import XMPPError
|
||||||
from slixmpp.xmlstream import JID, register_stanza_plugin
|
from slixmpp.xmlstream import JID, register_stanza_plugin
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.plugins.xep_0012 import stanza, LastActivity
|
from slixmpp.plugins.xep_0012 import stanza, LastActivity
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -77,9 +76,9 @@ class XEP_0012(BasePlugin):
|
|||||||
def del_last_activity(self, jid):
|
def del_last_activity(self, jid):
|
||||||
self.api['del_last_activity'](jid)
|
self.api['del_last_activity'](jid)
|
||||||
|
|
||||||
@coroutine_wrapper
|
@future_wrapper
|
||||||
def get_last_activity(self, jid, local=False, ifrom=None, timeout=None,
|
def get_last_activity(self, jid, local=False, ifrom=None, timeout=None,
|
||||||
callback=None, timeout_callback=None, coroutine=False):
|
callback=None, timeout_callback=None):
|
||||||
if jid is not None and not isinstance(jid, JID):
|
if jid is not None and not isinstance(jid, JID):
|
||||||
jid = JID(jid)
|
jid = JID(jid)
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ class XEP_0012(BasePlugin):
|
|||||||
iq['to'] = jid
|
iq['to'] = jid
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq.enable('last_activity')
|
iq.enable('last_activity')
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine,
|
return iq.send(timeout=timeout, callback=callback,
|
||||||
timeout_callback=timeout_callback)
|
timeout_callback=timeout_callback)
|
||||||
|
|
||||||
def _handle_get_last_activity(self, iq):
|
def _handle_get_last_activity(self, iq):
|
||||||
|
@ -10,7 +10,6 @@ import logging
|
|||||||
|
|
||||||
from slixmpp import Iq
|
from slixmpp import Iq
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.xmlstream import register_stanza_plugin, JID
|
from slixmpp.xmlstream import register_stanza_plugin, JID
|
||||||
@ -289,7 +288,6 @@ class XEP_0030(BasePlugin):
|
|||||||
'cached': cached}
|
'cached': cached}
|
||||||
return self.api['has_identity'](jid, node, ifrom, data)
|
return self.api['has_identity'](jid, node, ifrom, data)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_info(self, jid=None, node=None, local=None,
|
def get_info(self, jid=None, node=None, local=None,
|
||||||
cached=None, **kwargs):
|
cached=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -364,10 +362,9 @@ class XEP_0030(BasePlugin):
|
|||||||
iq['to'] = jid
|
iq['to'] = jid
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['disco_info']['node'] = node if node else ''
|
iq['disco_info']['node'] = node if node else ''
|
||||||
return iq.send(timeout=kwargs.get('timeout', None),
|
iq.send(timeout=kwargs.get('timeout', None),
|
||||||
callback=kwargs.get('callback', None),
|
callback=kwargs.get('callback', None),
|
||||||
coroutine=kwargs.get('coroutine', False),
|
timeout_callback=kwargs.get('timeout_callback', None))
|
||||||
timeout_callback=kwargs.get('timeout_callback', None))
|
|
||||||
|
|
||||||
def set_info(self, jid=None, node=None, info=None):
|
def set_info(self, jid=None, node=None, info=None):
|
||||||
"""
|
"""
|
||||||
@ -378,7 +375,6 @@ class XEP_0030(BasePlugin):
|
|||||||
info = info['disco_info']
|
info = info['disco_info']
|
||||||
self.api['set_info'](jid, node, None, info)
|
self.api['set_info'](jid, node, None, info)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_items(self, jid=None, node=None, local=False, **kwargs):
|
def get_items(self, jid=None, node=None, local=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
Retrieve the disco#items results from a given JID/node combination.
|
Retrieve the disco#items results from a given JID/node combination.
|
||||||
@ -427,10 +423,9 @@ class XEP_0030(BasePlugin):
|
|||||||
raise NotImplementedError("XEP 0059 has not yet been fixed")
|
raise NotImplementedError("XEP 0059 has not yet been fixed")
|
||||||
return self.xmpp['xep_0059'].iterate(iq, 'disco_items')
|
return self.xmpp['xep_0059'].iterate(iq, 'disco_items')
|
||||||
else:
|
else:
|
||||||
return iq.send(timeout=kwargs.get('timeout', None),
|
iq.send(timeout=kwargs.get('timeout', None),
|
||||||
callback=kwargs.get('callback', None),
|
callback=kwargs.get('callback', None),
|
||||||
coroutine=kwargs.get('coroutine', False),
|
timeout_callback=kwargs.get('timeout_callback', None))
|
||||||
timeout_callback=kwargs.get('timeout_callback', None))
|
|
||||||
|
|
||||||
def set_items(self, jid=None, node=None, **kwargs):
|
def set_items(self, jid=None, node=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from slixmpp import Iq
|
from slixmpp import Iq
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
@ -33,9 +32,8 @@ class XEP_0049(BasePlugin):
|
|||||||
def register(self, stanza):
|
def register(self, stanza):
|
||||||
register_stanza_plugin(PrivateXML, stanza, iterable=True)
|
register_stanza_plugin(PrivateXML, stanza, iterable=True)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def store(self, data, ifrom=None, timeout=None, callback=None,
|
def store(self, data, ifrom=None, timeout=None, callback=None,
|
||||||
timeout_callback=None, coroutine=False):
|
timeout_callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -46,15 +44,14 @@ class XEP_0049(BasePlugin):
|
|||||||
for elem in data:
|
for elem in data:
|
||||||
iq['private'].append(elem)
|
iq['private'].append(elem)
|
||||||
|
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine,
|
return iq.send(timeout=timeout, callback=callback,
|
||||||
timeout_callback=timeout_callback)
|
timeout_callback=timeout_callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def retrieve(self, name, ifrom=None, timeout=None, callback=None,
|
def retrieve(self, name, ifrom=None, timeout=None, callback=None,
|
||||||
timeout_callback=None, coroutine=False):
|
timeout_callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['private'].enable(name)
|
iq['private'].enable(name)
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine,
|
return iq.send(timeout=timeout, callback=callback,
|
||||||
timeout_callback=timeout_callback)
|
timeout_callback=timeout_callback)
|
||||||
|
@ -18,7 +18,6 @@ from slixmpp.plugins import BasePlugin
|
|||||||
from slixmpp.plugins.xep_0050 import stanza
|
from slixmpp.plugins.xep_0050 import stanza
|
||||||
from slixmpp.plugins.xep_0050 import Command
|
from slixmpp.plugins.xep_0050 import Command
|
||||||
from slixmpp.plugins.xep_0004 import Form
|
from slixmpp.plugins.xep_0004 import Form
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -428,7 +427,6 @@ class XEP_0050(BasePlugin):
|
|||||||
# =================================================================
|
# =================================================================
|
||||||
# Client side (command user) API
|
# Client side (command user) API
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_commands(self, jid, **kwargs):
|
def get_commands(self, jid, **kwargs):
|
||||||
"""
|
"""
|
||||||
Return a list of commands provided by a given JID.
|
Return a list of commands provided by a given JID.
|
||||||
@ -454,7 +452,6 @@ class XEP_0050(BasePlugin):
|
|||||||
node=Command.namespace,
|
node=Command.namespace,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def send_command(self, jid, node, ifrom=None, action='execute',
|
def send_command(self, jid, node, ifrom=None, action='execute',
|
||||||
payload=None, sessionid=None, flow=False, **kwargs):
|
payload=None, sessionid=None, flow=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -15,7 +15,7 @@ from slixmpp.xmlstream.handler import Callback
|
|||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.plugins.xep_0054 import VCardTemp, stanza
|
from slixmpp.plugins.xep_0054 import VCardTemp, stanza
|
||||||
from slixmpp import coroutine_wrapper
|
from slixmpp import future_wrapper
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -60,9 +60,9 @@ class XEP_0054(BasePlugin):
|
|||||||
def make_vcard(self):
|
def make_vcard(self):
|
||||||
return VCardTemp()
|
return VCardTemp()
|
||||||
|
|
||||||
@coroutine_wrapper
|
@future_wrapper
|
||||||
def get_vcard(self, jid=None, ifrom=None, local=None, cached=False,
|
def get_vcard(self, jid=None, ifrom=None, local=None, cached=False,
|
||||||
callback=None, timeout=None, coroutine=False):
|
callback=None, timeout=None):
|
||||||
if local is None:
|
if local is None:
|
||||||
if jid is not None and not isinstance(jid, JID):
|
if jid is not None and not isinstance(jid, JID):
|
||||||
jid = JID(jid)
|
jid = JID(jid)
|
||||||
@ -101,11 +101,11 @@ class XEP_0054(BasePlugin):
|
|||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq.enable('vcard_temp')
|
iq.enable('vcard_temp')
|
||||||
|
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine)
|
return iq.send(callback=callback, timeout=timeout)
|
||||||
|
|
||||||
@coroutine_wrapper
|
@future_wrapper
|
||||||
def publish_vcard(self, vcard=None, jid=None, ifrom=None,
|
def publish_vcard(self, vcard=None, jid=None, ifrom=None,
|
||||||
callback=None, timeout=None, coroutine=False):
|
callback=None, timeout=None):
|
||||||
self.api['set_vcard'](jid, None, ifrom, vcard)
|
self.api['set_vcard'](jid, None, ifrom, vcard)
|
||||||
if self.xmpp.is_component:
|
if self.xmpp.is_component:
|
||||||
return
|
return
|
||||||
@ -115,7 +115,7 @@ class XEP_0054(BasePlugin):
|
|||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq.append(vcard)
|
iq.append(vcard)
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine)
|
return iq.send(callback=callback, timeout=timeout)
|
||||||
|
|
||||||
def _handle_get_vcard(self, iq):
|
def _handle_get_vcard(self, iq):
|
||||||
if iq['type'] == 'result':
|
if iq['type'] == 'result':
|
||||||
|
@ -13,7 +13,6 @@ from slixmpp.xmlstream.handler import Callback
|
|||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.plugins.base import BasePlugin
|
from slixmpp.plugins.base import BasePlugin
|
||||||
from slixmpp.plugins.xep_0060 import stanza
|
from slixmpp.plugins.xep_0060 import stanza
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -152,9 +151,8 @@ class XEP_0060(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
self.node_event_map[node] = event_name
|
self.node_event_map[node] = event_name
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def create_node(self, jid, node, config=None, ntype=None, ifrom=None,
|
def create_node(self, jid, node, config=None, ntype=None, ifrom=None,
|
||||||
timeout_callback=None, callback=None, timeout=None, coroutine=False):
|
timeout_callback=None, callback=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Create and configure a new pubsub node.
|
Create and configure a new pubsub node.
|
||||||
|
|
||||||
@ -200,13 +198,11 @@ class XEP_0060(BasePlugin):
|
|||||||
config.add_field(var='pubsub#node_type', value=ntype)
|
config.add_field(var='pubsub#node_type', value=ntype)
|
||||||
iq['pubsub']['configure'].append(config)
|
iq['pubsub']['configure'].append(config)
|
||||||
|
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def subscribe(self, jid, node, bare=True, subscribee=None, options=None,
|
def subscribe(self, jid, node, bare=True, subscribee=None, options=None,
|
||||||
ifrom=None, timeout_callback=None, callback=None,
|
ifrom=None, timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
"""
|
"""
|
||||||
Subscribe to updates from a pubsub node.
|
Subscribe to updates from a pubsub node.
|
||||||
|
|
||||||
@ -248,13 +244,11 @@ class XEP_0060(BasePlugin):
|
|||||||
iq['pubsub']['subscribe']['jid'] = subscribee
|
iq['pubsub']['subscribe']['jid'] = subscribee
|
||||||
if options is not None:
|
if options is not None:
|
||||||
iq['pubsub']['options'].append(options)
|
iq['pubsub']['options'].append(options)
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def unsubscribe(self, jid, node, subid=None, bare=True, subscribee=None,
|
def unsubscribe(self, jid, node, subid=None, bare=True, subscribee=None,
|
||||||
ifrom=None, timeout_callback=None, callback=None,
|
ifrom=None, timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
"""
|
"""
|
||||||
Unubscribe from updates from a pubsub node.
|
Unubscribe from updates from a pubsub node.
|
||||||
|
|
||||||
@ -297,52 +291,42 @@ class XEP_0060(BasePlugin):
|
|||||||
|
|
||||||
iq['pubsub']['unsubscribe']['jid'] = subscribee
|
iq['pubsub']['unsubscribe']['jid'] = subscribee
|
||||||
iq['pubsub']['unsubscribe']['subid'] = subid
|
iq['pubsub']['unsubscribe']['subid'] = subid
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_subscriptions(self, jid, node=None, ifrom=None,
|
def get_subscriptions(self, jid, node=None, ifrom=None,
|
||||||
timeout_callback=None, callback=None,
|
timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
iq['pubsub']['subscriptions']['node'] = node
|
iq['pubsub']['subscriptions']['node'] = node
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
def get_affiliations(self, jid, node=None, ifrom=None,
|
||||||
def get_affiliations(self, jid, node=None, ifrom=None, timeout=None,
|
timeout_callback=None, callback=None, timeout=None):
|
||||||
timeout_callback=None, callback=None, coroutine=False):
|
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
iq['pubsub']['affiliations']['node'] = node
|
iq['pubsub']['affiliations']['node'] = node
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_subscription_options(self, jid, node=None, user_jid=None,
|
def get_subscription_options(self, jid, node=None, user_jid=None,
|
||||||
ifrom=None, timeout_callback=None,
|
ifrom=None, timeout_callback=None,
|
||||||
callback=None, timeout=None, coroutine=False):
|
callback=None, timeout=None):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
if user_jid is None:
|
if user_jid is None:
|
||||||
iq['pubsub']['default']['node'] = node
|
iq['pubsub']['default']['node'] = node
|
||||||
else:
|
else:
|
||||||
iq['pubsub']['options']['node'] = node
|
iq['pubsub']['options']['node'] = node
|
||||||
iq['pubsub']['options']['jid'] = user_jid
|
iq['pubsub']['options']['jid'] = user_jid
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def set_subscription_options(self, jid, node, user_jid, options,
|
def set_subscription_options(self, jid, node, user_jid, options,
|
||||||
ifrom=None, timeout_callback=None,
|
ifrom=None, timeout_callback=None,
|
||||||
callback=None, timeout=None, coroutine=False):
|
callback=None, timeout=None):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
iq['pubsub']['options']['node'] = node
|
iq['pubsub']['options']['node'] = node
|
||||||
iq['pubsub']['options']['jid'] = user_jid
|
iq['pubsub']['options']['jid'] = user_jid
|
||||||
iq['pubsub']['options'].append(options)
|
iq['pubsub']['options'].append(options)
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
def get_node_config(self, jid, node=None, ifrom=None,
|
||||||
def get_node_config(self, jid, node=None, ifrom=None, coroutine=False,
|
|
||||||
timeout_callback=None, callback=None, timeout=None):
|
timeout_callback=None, callback=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Retrieve the configuration for a node, or the pubsub service's
|
Retrieve the configuration for a node, or the pubsub service's
|
||||||
@ -365,13 +349,11 @@ class XEP_0060(BasePlugin):
|
|||||||
iq['pubsub_owner']['default']
|
iq['pubsub_owner']['default']
|
||||||
else:
|
else:
|
||||||
iq['pubsub_owner']['configure']['node'] = node
|
iq['pubsub_owner']['configure']['node'] = node
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_node_subscriptions(self, jid, node, ifrom=None,
|
def get_node_subscriptions(self, jid, node, ifrom=None,
|
||||||
timeout_callback=None, callback=None,
|
timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
"""
|
"""
|
||||||
Retrieve the subscriptions associated with a given node.
|
Retrieve the subscriptions associated with a given node.
|
||||||
|
|
||||||
@ -387,12 +369,10 @@ class XEP_0060(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
iq['pubsub_owner']['subscriptions']['node'] = node
|
iq['pubsub_owner']['subscriptions']['node'] = node
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_node_affiliations(self, jid, node, ifrom=None, timeout_callback=None,
|
def get_node_affiliations(self, jid, node, ifrom=None, timeout_callback=None,
|
||||||
callback=None, timeout=None, coroutine=False):
|
callback=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Retrieve the affiliations associated with a given node.
|
Retrieve the affiliations associated with a given node.
|
||||||
|
|
||||||
@ -408,12 +388,10 @@ class XEP_0060(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
iq['pubsub_owner']['affiliations']['node'] = node
|
iq['pubsub_owner']['affiliations']['node'] = node
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def delete_node(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
|
def delete_node(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
"""
|
"""
|
||||||
Delete a a pubsub node.
|
Delete a a pubsub node.
|
||||||
|
|
||||||
@ -429,21 +407,18 @@ class XEP_0060(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||||
iq['pubsub_owner']['delete']['node'] = node
|
iq['pubsub_owner']['delete']['node'] = node
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
def set_node_config(self, jid, node, config, ifrom=None, coroutine=False,
|
def set_node_config(self, jid, node, config, ifrom=None,
|
||||||
timeout_callback=None, callback=None, timeout=None):
|
timeout_callback=None, callback=None, timeout=None):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||||
iq['pubsub_owner']['configure']['node'] = node
|
iq['pubsub_owner']['configure']['node'] = node
|
||||||
iq['pubsub_owner']['configure'].append(config)
|
iq['pubsub_owner']['configure'].append(config)
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def publish(self, jid, node, id=None, payload=None, options=None,
|
def publish(self, jid, node, id=None, payload=None, options=None,
|
||||||
ifrom=None, timeout_callback=None, callback=None,
|
ifrom=None, timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
"""
|
"""
|
||||||
Add a new item to a node, or edit an existing item.
|
Add a new item to a node, or edit an existing item.
|
||||||
|
|
||||||
@ -478,11 +453,9 @@ class XEP_0060(BasePlugin):
|
|||||||
if payload is not None:
|
if payload is not None:
|
||||||
iq['pubsub']['publish']['item']['payload'] = payload
|
iq['pubsub']['publish']['item']['payload'] = payload
|
||||||
iq['pubsub']['publish_options'] = options
|
iq['pubsub']['publish_options'] = options
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
def retract(self, jid, node, id, notify=None, ifrom=None,
|
||||||
def retract(self, jid, node, id, notify=None, ifrom=None, coroutine=False,
|
|
||||||
timeout_callback=None, callback=None, timeout=None):
|
timeout_callback=None, callback=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Delete a single item from a node.
|
Delete a single item from a node.
|
||||||
@ -492,30 +465,25 @@ class XEP_0060(BasePlugin):
|
|||||||
iq['pubsub']['retract']['node'] = node
|
iq['pubsub']['retract']['node'] = node
|
||||||
iq['pubsub']['retract']['notify'] = notify
|
iq['pubsub']['retract']['notify'] = notify
|
||||||
iq['pubsub']['retract']['item']['id'] = id
|
iq['pubsub']['retract']['item']['id'] = id
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def purge(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
|
def purge(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
"""
|
"""
|
||||||
Remove all items from a node.
|
Remove all items from a node.
|
||||||
"""
|
"""
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||||
iq['pubsub_owner']['purge']['node'] = node
|
iq['pubsub_owner']['purge']['node'] = node
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_nodes(self, *args, **kwargs):
|
def get_nodes(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Discover the nodes provided by a Pubsub service, using disco.
|
Discover the nodes provided by a Pubsub service, using disco.
|
||||||
"""
|
"""
|
||||||
return self.xmpp['xep_0030'].get_items(*args, **kwargs)
|
return self.xmpp['xep_0030'].get_items(*args, **kwargs)
|
||||||
|
|
||||||
@coroutine_wrapper
|
def get_item(self, jid, node, item_id, ifrom=None,
|
||||||
def get_item(self, jid, node, item_id, ifrom=None, timeout=None,
|
timeout_callback=None, callback=None, timeout=None):
|
||||||
timeout_callback=None, callback=None, coroutine=False):
|
|
||||||
"""
|
"""
|
||||||
Retrieve the content of an individual item.
|
Retrieve the content of an individual item.
|
||||||
"""
|
"""
|
||||||
@ -524,13 +492,11 @@ class XEP_0060(BasePlugin):
|
|||||||
item['id'] = item_id
|
item['id'] = item_id
|
||||||
iq['pubsub']['items']['node'] = node
|
iq['pubsub']['items']['node'] = node
|
||||||
iq['pubsub']['items'].append(item)
|
iq['pubsub']['items'].append(item)
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_items(self, jid, node, item_ids=None, max_items=None,
|
def get_items(self, jid, node, item_ids=None, max_items=None,
|
||||||
iterator=False, ifrom=None, timeout_callback=None,
|
iterator=False, ifrom=None, timeout_callback=None,
|
||||||
callback=None, timeout=None, coroutine=False):
|
callback=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Request the contents of a node's items.
|
Request the contents of a node's items.
|
||||||
|
|
||||||
@ -553,26 +519,21 @@ class XEP_0060(BasePlugin):
|
|||||||
if iterator:
|
if iterator:
|
||||||
return self.xmpp['xep_0059'].iterate(iq, 'pubsub')
|
return self.xmpp['xep_0059'].iterate(iq, 'pubsub')
|
||||||
else:
|
else:
|
||||||
return iq.send(callback=callback, timeout=timeout,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
coroutine=coroutine,
|
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_item_ids(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
|
def get_item_ids(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
|
||||||
timeout=None, iterator=False, coroutine=False):
|
timeout=None, iterator=False):
|
||||||
"""
|
"""
|
||||||
Retrieve the ItemIDs hosted by a given node, using disco.
|
Retrieve the ItemIDs hosted by a given node, using disco.
|
||||||
"""
|
"""
|
||||||
self.xmpp['xep_0030'].get_items(jid, node, ifrom=ifrom,
|
self.xmpp['xep_0030'].get_items(jid, node, ifrom=ifrom,
|
||||||
callback=callback, timeout=timeout,
|
callback=callback, timeout=timeout,
|
||||||
iterator=iterator,
|
iterator=iterator,
|
||||||
timeout_callback=timeout_callback,
|
timeout_callback=timeout_callback)
|
||||||
coroutine=coroutine)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def modify_affiliations(self, jid, node, affiliations=None, ifrom=None,
|
def modify_affiliations(self, jid, node, affiliations=None, ifrom=None,
|
||||||
timeout_callback=None, callback=None,
|
timeout_callback=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||||
iq['pubsub_owner']['affiliations']['node'] = node
|
iq['pubsub_owner']['affiliations']['node'] = node
|
||||||
|
|
||||||
@ -585,13 +546,11 @@ class XEP_0060(BasePlugin):
|
|||||||
aff['affiliation'] = affiliation
|
aff['affiliation'] = affiliation
|
||||||
iq['pubsub_owner']['affiliations'].append(aff)
|
iq['pubsub_owner']['affiliations'].append(aff)
|
||||||
|
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
def modify_subscriptions(self, jid, node, subscriptions=None,
|
||||||
def modify_subscriptions(self, jid, node, subscriptions=None, ifrom=None,
|
ifrom=None, timeout_callback=None,
|
||||||
timeout_callback=None, callback=None,
|
callback=None, timeout=None):
|
||||||
timeout=None, coroutine=False):
|
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||||
iq['pubsub_owner']['subscriptions']['node'] = node
|
iq['pubsub_owner']['subscriptions']['node'] = node
|
||||||
|
|
||||||
@ -604,5 +563,4 @@ class XEP_0060(BasePlugin):
|
|||||||
sub['subscription'] = subscription
|
sub['subscription'] = subscription
|
||||||
iq['pubsub_owner']['subscriptions'].append(sub)
|
iq['pubsub_owner']['subscriptions'].append(sub)
|
||||||
|
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine,
|
return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
|
||||||
timeout_callback=timeout_callback)
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.stanza import StreamFeatures, Iq
|
from slixmpp.stanza import StreamFeatures, Iq
|
||||||
from slixmpp.xmlstream import register_stanza_plugin, JID
|
from slixmpp.xmlstream import register_stanza_plugin, JID
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
@ -82,29 +81,26 @@ class XEP_0077(BasePlugin):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_registration(self, jid=None, ifrom=None,
|
def get_registration(self, jid=None, ifrom=None,
|
||||||
timeout=None, callback=None, coroutine=False):
|
timeout=None, callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['to'] = jid
|
iq['to'] = jid
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('register')
|
iq.enable('register')
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def cancel_registration(self, jid=None, ifrom=None,
|
def cancel_registration(self, jid=None, ifrom=None,
|
||||||
timeout=None, callback=None, coroutine=False):
|
timeout=None, callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['to'] = jid
|
iq['to'] = jid
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['register']['remove'] = True
|
iq['register']['remove'] = True
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def change_password(self, password, jid=None, ifrom=None,
|
def change_password(self, password, jid=None, ifrom=None,
|
||||||
timeout=None, callback=None, coroutine=False):
|
timeout=None, callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['to'] = jid
|
iq['to'] = jid
|
||||||
@ -115,4 +111,4 @@ class XEP_0077(BasePlugin):
|
|||||||
else:
|
else:
|
||||||
iq['register']['username'] = self.xmpp.boundjid.user
|
iq['register']['username'] = self.xmpp.boundjid.user
|
||||||
iq['register']['password'] = password
|
iq['register']['password'] = password
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
@ -15,7 +15,6 @@ from slixmpp.xmlstream.handler import Callback
|
|||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.xmlstream import register_stanza_plugin, JID
|
from slixmpp.xmlstream import register_stanza_plugin, JID
|
||||||
from slixmpp.plugins.xep_0084 import stanza, Data, MetaData
|
from slixmpp.plugins.xep_0084 import stanza, Data, MetaData
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -45,30 +44,26 @@ class XEP_0084(BasePlugin):
|
|||||||
def generate_id(self, data):
|
def generate_id(self, data):
|
||||||
return hashlib.sha1(data).hexdigest()
|
return hashlib.sha1(data).hexdigest()
|
||||||
|
|
||||||
@coroutine_wrapper
|
def retrieve_avatar(self, jid, id, url=None, ifrom=None,
|
||||||
def retrieve_avatar(self, jid, id, url=None, ifrom=None, callback=None,
|
callback=None, timeout=None):
|
||||||
timeout=None, coroutine=False):
|
|
||||||
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
|
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
|
||||||
ifrom=ifrom, callback=callback,
|
ifrom=ifrom,
|
||||||
timeout=timeout,
|
callback=callback,
|
||||||
coroutine=coroutine)
|
timeout=timeout)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def publish_avatar(self, data, ifrom=None, callback=None,
|
def publish_avatar(self, data, ifrom=None, callback=None,
|
||||||
timeout=None, coroutine=False):
|
timeout=None):
|
||||||
payload = Data()
|
payload = Data()
|
||||||
payload['value'] = data
|
payload['value'] = data
|
||||||
return self.xmpp['xep_0163'].publish(payload,
|
return self.xmpp['xep_0163'].publish(payload,
|
||||||
id=self.generate_id(data),
|
id=self.generate_id(data),
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout,
|
timeout=timeout)
|
||||||
coroutine=coroutine)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def publish_avatar_metadata(self, items=None, pointers=None,
|
def publish_avatar_metadata(self, items=None, pointers=None,
|
||||||
ifrom=None, callback=None, timeout=None,
|
ifrom=None,
|
||||||
coroutine=False):
|
callback=None, timeout=None):
|
||||||
metadata = MetaData()
|
metadata = MetaData()
|
||||||
if items is None:
|
if items is None:
|
||||||
items = []
|
items = []
|
||||||
@ -88,11 +83,9 @@ class XEP_0084(BasePlugin):
|
|||||||
id=info['id'],
|
id=info['id'],
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout,
|
timeout=timeout)
|
||||||
coroutine=coroutine)
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
def stop(self, ifrom=None, callback=None, timeout=None):
|
||||||
def stop(self, ifrom=None, callback=None, timeout=None, coroutine=False):
|
|
||||||
"""
|
"""
|
||||||
Clear existing avatar metadata information to stop notifications.
|
Clear existing avatar metadata information to stop notifications.
|
||||||
|
|
||||||
@ -109,5 +102,4 @@ class XEP_0084(BasePlugin):
|
|||||||
node=MetaData.namespace,
|
node=MetaData.namespace,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout,
|
timeout=timeout)
|
||||||
coroutine=coroutine)
|
|
||||||
|
@ -15,7 +15,6 @@ from slixmpp.xmlstream.handler import Callback
|
|||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.plugins.xep_0092 import Version, stanza
|
from slixmpp.plugins.xep_0092 import Version, stanza
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -71,9 +70,7 @@ class XEP_0092(BasePlugin):
|
|||||||
iq['software_version']['os'] = self.os
|
iq['software_version']['os'] = self.os
|
||||||
iq.send()
|
iq.send()
|
||||||
|
|
||||||
@coroutine_wrapper
|
def get_version(self, jid, ifrom=None, timeout=None, callback=None):
|
||||||
def get_version(self, jid, ifrom=None, timeout=None, callback=None,
|
|
||||||
coroutine=False):
|
|
||||||
"""
|
"""
|
||||||
Retrieve the software version of a remote agent.
|
Retrieve the software version of a remote agent.
|
||||||
|
|
||||||
@ -85,4 +82,4 @@ class XEP_0092(BasePlugin):
|
|||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['query'] = Version.namespace
|
iq['query'] = Version.namespace
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import threading
|
|
||||||
|
|
||||||
from slixmpp.stanza import Presence
|
from slixmpp.stanza import Presence
|
||||||
from slixmpp.exceptions import XMPPError
|
from slixmpp.exceptions import XMPPError, IqTimeout
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.plugins.base import BasePlugin
|
from slixmpp.plugins.base import BasePlugin
|
||||||
from slixmpp.plugins.xep_0153 import stanza, VCardTempUpdate
|
from slixmpp.plugins.xep_0153 import stanza, VCardTempUpdate
|
||||||
from slixmpp import asyncio, coroutine_wrapper
|
from slixmpp import asyncio, future_wrapper
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -31,8 +30,6 @@ class XEP_0153(BasePlugin):
|
|||||||
def plugin_init(self):
|
def plugin_init(self):
|
||||||
self._hashes = {}
|
self._hashes = {}
|
||||||
|
|
||||||
self._allow_advertising = threading.Event()
|
|
||||||
|
|
||||||
register_stanza_plugin(Presence, VCardTempUpdate)
|
register_stanza_plugin(Presence, VCardTempUpdate)
|
||||||
|
|
||||||
self.xmpp.add_filter('out', self._update_presence)
|
self.xmpp.add_filter('out', self._update_presence)
|
||||||
@ -60,59 +57,60 @@ class XEP_0153(BasePlugin):
|
|||||||
self.xmpp.del_event_handler('presence_chat', self._recv_presence)
|
self.xmpp.del_event_handler('presence_chat', self._recv_presence)
|
||||||
self.xmpp.del_event_handler('presence_away', self._recv_presence)
|
self.xmpp.del_event_handler('presence_away', self._recv_presence)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@future_wrapper
|
||||||
def _set_avatar_coroutine(self, jid, mtype, avatar):
|
|
||||||
vcard = yield from self.xmpp['xep_0054'].get_vcard(jid, cached=True, coroutine=True)
|
|
||||||
vcard = vcard['vcard_temp']
|
|
||||||
vcard['PHOTO']['TYPE'] = mtype
|
|
||||||
vcard['PHOTO']['BINVAL'] = avatar
|
|
||||||
|
|
||||||
result = yield from self.xmpp['xep_0054'].publish_vcard(jid=jid, vcard=vcard)
|
|
||||||
|
|
||||||
self.api['reset_hash'](jid)
|
|
||||||
self.xmpp.roster[jid].send_last_presence()
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def set_avatar(self, jid=None, avatar=None, mtype=None, timeout=None,
|
def set_avatar(self, jid=None, avatar=None, mtype=None, timeout=None,
|
||||||
callback=None, coroutine=False):
|
callback=None):
|
||||||
if jid is None:
|
if jid is None:
|
||||||
jid = self.xmpp.boundjid.bare
|
jid = self.xmpp.boundjid.bare
|
||||||
|
|
||||||
if coroutine:
|
future = asyncio.Future()
|
||||||
return self._set_avatar_coroutine(jid, mtype, avatar)
|
|
||||||
else:
|
|
||||||
def custom_callback(result):
|
|
||||||
vcard = result['vcard_temp']
|
|
||||||
vcard['PHOTO']['TYPE'] = mtype
|
|
||||||
vcard['PHOTO']['BINVAL'] = avatar
|
|
||||||
|
|
||||||
self.xmpp['xep_0054'].publish_vcard(jid=jid, vcard=vcard, callback=callback)
|
def propagate_timeout_exception(fut):
|
||||||
|
try:
|
||||||
|
fut.done()
|
||||||
|
except IqTimeout as e:
|
||||||
|
future.set_exception(e)
|
||||||
|
|
||||||
|
def custom_callback(result):
|
||||||
|
vcard = result['vcard_temp']
|
||||||
|
vcard['PHOTO']['TYPE'] = mtype
|
||||||
|
vcard['PHOTO']['BINVAL'] = avatar
|
||||||
|
|
||||||
|
new_future = self.xmpp['xep_0054'].publish_vcard(jid=jid,
|
||||||
|
vcard=vcard,
|
||||||
|
timeout=timeout,
|
||||||
|
callback=next_callback)
|
||||||
|
new_future.add_done_callback(propagate_timeout_exception)
|
||||||
|
|
||||||
|
def next_callback(result):
|
||||||
|
if result['type'] == 'error':
|
||||||
|
future.set_exception(result)
|
||||||
|
else:
|
||||||
self.api['reset_hash'](jid)
|
self.api['reset_hash'](jid)
|
||||||
self.xmpp.roster[jid].send_last_presence()
|
self.xmpp.roster[jid].send_last_presence()
|
||||||
callback(result)
|
|
||||||
|
|
||||||
self.xmpp['xep_0054'].get_vcard(jid, cached=True, callback=custom_callback)
|
future.set_result(result)
|
||||||
|
|
||||||
|
first_future = self.xmpp['xep_0054'].get_vcard(jid, cached=False, timeout=timeout,
|
||||||
|
callback=custom_callback)
|
||||||
|
first_future.add_done_callback(propagate_timeout_exception)
|
||||||
|
return future
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _start(self, event):
|
def _start(self, event):
|
||||||
try:
|
try:
|
||||||
vcard = yield from self.xmpp['xep_0054'].get_vcard(self.xmpp.boundjid.bare,
|
vcard = yield from self.xmpp['xep_0054'].get_vcard(self.xmpp.boundjid.bare)
|
||||||
coroutine=True)
|
|
||||||
data = vcard['vcard_temp']['PHOTO']['BINVAL']
|
data = vcard['vcard_temp']['PHOTO']['BINVAL']
|
||||||
if not data:
|
if not data:
|
||||||
new_hash = ''
|
new_hash = ''
|
||||||
else:
|
else:
|
||||||
new_hash = hashlib.sha1(data).hexdigest()
|
new_hash = hashlib.sha1(data).hexdigest()
|
||||||
self.api['set_hash'](self.xmpp.boundjid, args=new_hash)
|
self.api['set_hash'](self.xmpp.boundjid, args=new_hash)
|
||||||
self._allow_advertising.set()
|
|
||||||
except XMPPError:
|
except XMPPError:
|
||||||
log.debug('Could not retrieve vCard for %s' % self.xmpp.boundjid.bare)
|
log.debug('Could not retrieve vCard for %s', self.xmpp.boundjid.bare)
|
||||||
|
|
||||||
def _end(self, event):
|
def _end(self, event):
|
||||||
self._allow_advertising.clear()
|
pass
|
||||||
|
|
||||||
def _update_presence(self, stanza):
|
def _update_presence(self, stanza):
|
||||||
if not isinstance(stanza, Presence):
|
if not isinstance(stanza, Presence):
|
||||||
@ -136,7 +134,7 @@ class XEP_0153(BasePlugin):
|
|||||||
|
|
||||||
def callback(iq):
|
def callback(iq):
|
||||||
if iq['type'] == 'error':
|
if iq['type'] == 'error':
|
||||||
log.debug('Could not retrieve vCard for %s' % jid)
|
log.debug('Could not retrieve vCard for %s', jid)
|
||||||
return
|
return
|
||||||
data = iq['vcard_temp']['PHOTO']['BINVAL']
|
data = iq['vcard_temp']['PHOTO']['BINVAL']
|
||||||
if not data:
|
if not data:
|
||||||
|
@ -10,7 +10,6 @@ import logging
|
|||||||
|
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.plugins.base import BasePlugin, register_plugin
|
from slixmpp.plugins.base import BasePlugin, register_plugin
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -83,9 +82,8 @@ class XEP_0163(BasePlugin):
|
|||||||
feature='%s+notify' % namespace)
|
feature='%s+notify' % namespace)
|
||||||
self.xmpp['xep_0115'].update_caps(jid)
|
self.xmpp['xep_0115'].update_caps(jid)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def publish(self, stanza, node=None, id=None, options=None, ifrom=None,
|
def publish(self, stanza, node=None, id=None, options=None, ifrom=None,
|
||||||
timeout_callback=None, callback=None, timeout=None, coroutine=False):
|
timeout_callback=None, callback=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Publish a PEP update.
|
Publish a PEP update.
|
||||||
|
|
||||||
@ -115,8 +113,7 @@ class XEP_0163(BasePlugin):
|
|||||||
options=options, ifrom=ifrom,
|
options=options, ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
timeout_callback=timeout_callback,
|
timeout_callback=timeout_callback)
|
||||||
coroutine=coroutine)
|
|
||||||
|
|
||||||
|
|
||||||
register_plugin(XEP_0163)
|
register_plugin(XEP_0163)
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from slixmpp import Iq
|
from slixmpp import Iq
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
@ -46,18 +45,14 @@ class XEP_0191(BasePlugin):
|
|||||||
self.xmpp.remove_handler('Blocked Contact')
|
self.xmpp.remove_handler('Blocked Contact')
|
||||||
self.xmpp.remove_handler('Unblocked Contact')
|
self.xmpp.remove_handler('Unblocked Contact')
|
||||||
|
|
||||||
@coroutine_wrapper
|
def get_blocked(self, ifrom=None, timeout=None, callback=None):
|
||||||
def get_blocked(self, ifrom=None, timeout=None, callback=None,
|
|
||||||
coroutine=False):
|
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('blocklist')
|
iq.enable('blocklist')
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
def block(self, jids, ifrom=None, timeout=None, callback=None):
|
||||||
def block(self, jids, ifrom=None, timeout=None, callback=None,
|
|
||||||
coroutine=False):
|
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -66,11 +61,9 @@ class XEP_0191(BasePlugin):
|
|||||||
jids = [jids]
|
jids = [jids]
|
||||||
|
|
||||||
iq['block']['items'] = jids
|
iq['block']['items'] = jids
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
def unblock(self, jids=None, ifrom=None, timeout=None, callback=None):
|
||||||
def unblock(self, jids=None, ifrom=None, timeout=None, callback=None,
|
|
||||||
coroutine=False):
|
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -81,7 +74,7 @@ class XEP_0191(BasePlugin):
|
|||||||
jids = [jids]
|
jids = [jids]
|
||||||
|
|
||||||
iq['unblock']['items'] = jids
|
iq['unblock']['items'] = jids
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
def _handle_blocked(self, iq):
|
def _handle_blocked(self, iq):
|
||||||
self.xmpp.event('blocked', iq)
|
self.xmpp.event('blocked', iq)
|
||||||
|
@ -11,7 +11,7 @@ import logging
|
|||||||
|
|
||||||
from slixmpp.jid import JID
|
from slixmpp.jid import JID
|
||||||
from slixmpp.stanza import Iq
|
from slixmpp.stanza import Iq
|
||||||
from slixmpp import asyncio, coroutine_wrapper
|
from slixmpp import asyncio
|
||||||
from slixmpp.exceptions import IqError, IqTimeout
|
from slixmpp.exceptions import IqError, IqTimeout
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
@ -119,9 +119,8 @@ class XEP_0199(BasePlugin):
|
|||||||
log.debug("Pinged by %s", iq['from'])
|
log.debug("Pinged by %s", iq['from'])
|
||||||
iq.reply().send()
|
iq.reply().send()
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def send_ping(self, jid, ifrom=None, timeout=None, callback=None,
|
def send_ping(self, jid, ifrom=None, timeout=None, callback=None,
|
||||||
timeout_callback=None, coroutine=False):
|
timeout_callback=None):
|
||||||
"""Send a ping request.
|
"""Send a ping request.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
@ -141,7 +140,7 @@ class XEP_0199(BasePlugin):
|
|||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('ping')
|
iq.enable('ping')
|
||||||
|
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine,
|
return iq.send(timeout=timeout, callback=callback,
|
||||||
timeout_callback=timeout_callback)
|
timeout_callback=timeout_callback)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from slixmpp.stanza.iq import Iq
|
from slixmpp.stanza.iq import Iq
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
@ -77,7 +76,6 @@ class XEP_0202(BasePlugin):
|
|||||||
iq['entity_time']['time'] = self.local_time(iq['to'])
|
iq['entity_time']['time'] = self.local_time(iq['to'])
|
||||||
iq.send()
|
iq.send()
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def get_entity_time(self, to, ifrom=None, **iqargs):
|
def get_entity_time(self, to, ifrom=None, **iqargs):
|
||||||
"""
|
"""
|
||||||
Request the time from another entity.
|
Request the time from another entity.
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from slixmpp import coroutine_wrapper
|
from slixmpp import future_wrapper
|
||||||
from slixmpp.stanza import Iq, Message, Presence
|
from slixmpp.stanza import Iq, Message, Presence
|
||||||
from slixmpp.exceptions import XMPPError
|
from slixmpp.exceptions import XMPPError
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
@ -82,9 +82,9 @@ class XEP_0231(BasePlugin):
|
|||||||
|
|
||||||
return cid
|
return cid
|
||||||
|
|
||||||
@coroutine_wrapper
|
@future_wrapper
|
||||||
def get_bob(self, jid=None, cid=None, cached=True, ifrom=None,
|
def get_bob(self, jid=None, cid=None, cached=True, ifrom=None,
|
||||||
timeout=None, callback=None, coroutine=False):
|
timeout=None, callback=None):
|
||||||
if cached:
|
if cached:
|
||||||
data = self.api['get_bob'](None, None, ifrom, args=cid)
|
data = self.api['get_bob'](None, None, ifrom, args=cid)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
@ -99,7 +99,7 @@ class XEP_0231(BasePlugin):
|
|||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['bob']['cid'] = cid
|
iq['bob']['cid'] = cid
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
def del_bob(self, cid):
|
def del_bob(self, cid):
|
||||||
self.api['del_bob'](args=cid)
|
self.api['del_bob'](args=cid)
|
||||||
|
@ -10,7 +10,6 @@ import logging
|
|||||||
|
|
||||||
from slixmpp import Iq
|
from slixmpp import Iq
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.plugins.xep_0257 import stanza, Certs
|
from slixmpp.plugins.xep_0257 import stanza, Certs
|
||||||
from slixmpp.plugins.xep_0257 import AppendCert, DisableCert, RevokeCert
|
from slixmpp.plugins.xep_0257 import AppendCert, DisableCert, RevokeCert
|
||||||
@ -32,39 +31,35 @@ class XEP_0257(BasePlugin):
|
|||||||
register_stanza_plugin(Iq, DisableCert)
|
register_stanza_plugin(Iq, DisableCert)
|
||||||
register_stanza_plugin(Iq, RevokeCert)
|
register_stanza_plugin(Iq, RevokeCert)
|
||||||
|
|
||||||
@coroutine_wrapper
|
def get_certs(self, ifrom=None, timeout=None, callback=None):
|
||||||
def get_certs(self, ifrom=None, timeout=None, callback=None, coroutine=False):
|
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('sasl_certs')
|
iq.enable('sasl_certs')
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def add_cert(self, name, cert, allow_management=True, ifrom=None,
|
def add_cert(self, name, cert, allow_management=True, ifrom=None,
|
||||||
timeout=None, callback=None, coroutine=False):
|
timeout=None, callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['sasl_cert_append']['name'] = name
|
iq['sasl_cert_append']['name'] = name
|
||||||
iq['sasl_cert_append']['x509cert'] = cert
|
iq['sasl_cert_append']['x509cert'] = cert
|
||||||
iq['sasl_cert_append']['cert_management'] = allow_management
|
iq['sasl_cert_append']['cert_management'] = allow_management
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
def disable_cert(self, name, ifrom=None,
|
||||||
def disable_cert(self, name, ifrom=None, coroutine=False,
|
|
||||||
timeout=None, callback=None):
|
timeout=None, callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['sasl_cert_disable']['name'] = name
|
iq['sasl_cert_disable']['name'] = name
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
def revoke_cert(self, name, ifrom=None,
|
||||||
def revoke_cert(self, name, ifrom=None, coroutine=False,
|
|
||||||
timeout=None, callback=None):
|
timeout=None, callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['sasl_cert_revoke']['name'] = name
|
iq['sasl_cert_revoke']['name'] = name
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(timeout=timeout, callback=callback)
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from slixmpp import Iq, Message
|
from slixmpp import Iq, Message
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.plugins.xep_0258 import stanza, SecurityLabel, Catalog
|
from slixmpp.plugins.xep_0258 import stanza, SecurityLabel, Catalog
|
||||||
@ -35,12 +34,11 @@ class XEP_0258(BasePlugin):
|
|||||||
def session_bind(self, jid):
|
def session_bind(self, jid):
|
||||||
self.xmpp['xep_0030'].add_feature(SecurityLabel.namespace)
|
self.xmpp['xep_0030'].add_feature(SecurityLabel.namespace)
|
||||||
|
|
||||||
@coroutine_wrapper
|
def get_catalog(self, jid, ifrom=None,
|
||||||
def get_catalog(self, jid, ifrom=None, coroutine=False,
|
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['to'] = jid
|
iq['to'] = jid
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq.enable('security_label_catalog')
|
iq.enable('security_label_catalog')
|
||||||
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine)
|
return iq.send(callback=callback, timeout=timeout)
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from slixmpp import Iq
|
from slixmpp import Iq
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.plugins.xep_0279 import stanza, IPCheck
|
from slixmpp.plugins.xep_0279 import stanza, IPCheck
|
||||||
@ -32,10 +31,9 @@ class XEP_0279(BasePlugin):
|
|||||||
def plugin_end(self):
|
def plugin_end(self):
|
||||||
self.xmpp['xep_0030'].del_feature(feature='urn:xmpp:sic:0')
|
self.xmpp['xep_0030'].del_feature(feature='urn:xmpp:sic:0')
|
||||||
|
|
||||||
@coroutine_wrapper
|
def check_ip(self, ifrom=None, block=True, timeout=None, callback=None):
|
||||||
def check_ip(self, ifrom=None, timeout=None, callback=None, coroutine=False):
|
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('ip_check')
|
iq.enable('ip_check')
|
||||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
return iq.send(block=block, timeout=timeout, callback=callback)
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import slixmpp
|
import slixmpp
|
||||||
from slixmpp import coroutine_wrapper
|
|
||||||
from slixmpp.stanza import Message, Iq
|
from slixmpp.stanza import Message, Iq
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
@ -67,22 +66,20 @@ class XEP_0280(BasePlugin):
|
|||||||
def _handle_carbon_sent(self, msg):
|
def _handle_carbon_sent(self, msg):
|
||||||
self.xmpp.event('carbon_sent', msg)
|
self.xmpp.event('carbon_sent', msg)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def enable(self, ifrom=None, timeout=None, callback=None,
|
def enable(self, ifrom=None, timeout=None, callback=None,
|
||||||
timeout_callback=None, coroutine=False):
|
timeout_callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('carbon_enable')
|
iq.enable('carbon_enable')
|
||||||
return iq.send(timeout_callback=timeout_callback, timeout=timeout,
|
return iq.send(timeout_callback=timeout_callback, timeout=timeout,
|
||||||
callback=callback, coroutine=coroutine)
|
callback=callback)
|
||||||
|
|
||||||
@coroutine_wrapper
|
|
||||||
def disable(self, ifrom=None, timeout=None, callback=None,
|
def disable(self, ifrom=None, timeout=None, callback=None,
|
||||||
timeout_callback=None, coroutine=False):
|
timeout_callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('carbon_disable')
|
iq.enable('carbon_disable')
|
||||||
return iq.send(timeout_callback=timeout_callback, timeout=timeout,
|
return iq.send(timeout_callback=timeout_callback, timeout=timeout,
|
||||||
callback=callback, coroutine=coroutine)
|
callback=callback)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user