Remove more threaded= and block= options from the plugins

(also, correct a typo)
This commit is contained in:
mathieui 2015-02-12 12:21:20 +01:00
parent 44f02fb3ab
commit 4d063e287e
No known key found for this signature in database
GPG Key ID: C59F84CEEFD616E3
22 changed files with 66 additions and 128 deletions

View File

@ -116,7 +116,7 @@ class XEP_0047(BasePlugin):
self._preauthed_sids[(jid, sid, ifrom)] = True self._preauthed_sids[(jid, sid, ifrom)] = True
def open_stream(self, jid, block_size=None, sid=None, window=1, use_messages=False, def open_stream(self, jid, block_size=None, sid=None, window=1, use_messages=False,
ifrom=None, block=True, timeout=None, callback=None): ifrom=None, timeout=None, callback=None):
if sid is None: if sid is None:
sid = str(uuid.uuid4()) sid = str(uuid.uuid4())
if block_size is None: if block_size is None:
@ -139,20 +139,15 @@ class XEP_0047(BasePlugin):
self._pending_streams[iq['id']] = stream self._pending_streams[iq['id']] = stream
if block: cb = None
resp = iq.send(timeout=timeout) if callback is not None:
self._handle_opened_stream(resp) def chained(resp):
return stream self._handle_opened_stream(resp)
callback(resp)
cb = chained
else: else:
cb = None cb = self._handle_opened_stream
if callback is not None: return iq.send(timeout=timeout, callback=cb)
def chained(resp):
self._handle_opened_stream(resp)
callback(resp)
cb = chained
else:
cb = self._handle_opened_stream
return iq.send(block=block, timeout=timeout, callback=cb)
def _handle_opened_stream(self, iq): def _handle_opened_stream(self, iq):
if iq['type'] == 'result': if iq['type'] == 'result':

View File

@ -70,7 +70,7 @@ class IBBytestream(object):
iq['ibb_data']['data'] = data iq['ibb_data']['data'] = data
self.window_empty.clear() self.window_empty.clear()
self.window_ids.add(iq['id']) self.window_ids.add(iq['id'])
iq.send(block=False, callback=self._recv_ack) iq.send(callback=self._recv_ack)
return len(data) return len(data)
def sendall(self, data): def sendall(self, data):

View File

@ -37,10 +37,6 @@ class XEP_0050(BasePlugin):
Also see <http://xmpp.org/extensions/xep-0050.html> Also see <http://xmpp.org/extensions/xep-0050.html>
Configuration Values:
threaded -- Indicates if command events should be threaded.
Defaults to True.
Events: Events:
command_execute -- Received a command with action="execute" command_execute -- Received a command with action="execute"
command_next -- Received a command with action="next" command_next -- Received a command with action="next"
@ -48,8 +44,6 @@ class XEP_0050(BasePlugin):
command_cancel -- Received a command with action="cancel" command_cancel -- Received a command with action="cancel"
Attributes: Attributes:
threaded -- Indicates if command events should be threaded.
Defaults to True.
commands -- A dictionary mapping JID/node pairs to command commands -- A dictionary mapping JID/node pairs to command
names and handlers. names and handlers.
sessions -- A dictionary or equivalent backend mapping sessions -- A dictionary or equivalent backend mapping
@ -83,7 +77,6 @@ class XEP_0050(BasePlugin):
dependencies = set(['xep_0030', 'xep_0004']) dependencies = set(['xep_0030', 'xep_0004'])
stanza = stanza stanza = stanza
default_config = { default_config = {
'threaded': True,
'session_db': None 'session_db': None
} }

View File

@ -60,7 +60,7 @@ class XEP_0054(BasePlugin):
return VCardTemp() return VCardTemp()
def get_vcard(self, jid=None, ifrom=None, local=None, cached=False, def get_vcard(self, jid=None, ifrom=None, local=None, cached=False,
block=True, callback=None, timeout=None): 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)
@ -99,13 +99,9 @@ class XEP_0054(BasePlugin):
iq['type'] = 'get' iq['type'] = 'get'
iq.enable('vcard_temp') iq.enable('vcard_temp')
vcard = iq.send(block=block, callback=callback, timeout=timeout) iq.send(callback=callback, timeout=timeout)
if block: def publish_vcard(self, vcard=None, jid=None, ifrom=None,
self.api['set_vcard'](vcard['from'], args=vcard['vcard_temp'])
return vcard
def publish_vcard(self, vcard=None, jid=None, block=True, ifrom=None,
callback=None, timeout=None): 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:
@ -116,7 +112,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(block=block, callback=callback, timeout=timeout) 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':

View File

@ -92,7 +92,7 @@ class XEP_0065(BasePlugin):
self.xmpp.event('stream:%s:%s' % (sid, to), socket) self.xmpp.event('stream:%s:%s' % (sid, to), socket)
return socket return socket
def request_stream(self, to, sid=None, ifrom=None, block=True, timeout=None, callback=None): def request_stream(self, to, sid=None, ifrom=None, timeout=None, callback=None):
if sid is None: if sid is None:
sid = uuid4().hex sid = uuid4().hex
@ -107,7 +107,7 @@ class XEP_0065(BasePlugin):
iq['socks']['sid'] = sid iq['socks']['sid'] = sid
for proxy, (host, port) in self._proxies.items(): for proxy, (host, port) in self._proxies.items():
iq['socks'].add_streamhost(proxy, host, port) iq['socks'].add_streamhost(proxy, host, port)
return iq.send(block=block, timeout=timeout, callback=callback) return iq.send(timeout=timeout, callback=callback)
def discover_proxies(self, jid=None, ifrom=None, timeout=None): def discover_proxies(self, jid=None, ifrom=None, timeout=None):
"""Auto-discover the JIDs of SOCKS5 proxies on an XMPP server.""" """Auto-discover the JIDs of SOCKS5 proxies on an XMPP server."""
@ -143,11 +143,11 @@ class XEP_0065(BasePlugin):
return self._proxies return self._proxies
def get_network_address(self, proxy, ifrom=None, block=True, timeout=None, callback=None): def get_network_address(self, proxy, ifrom=None, timeout=None, callback=None):
"""Get the network information of a proxy.""" """Get the network information of a proxy."""
iq = self.xmpp.Iq(sto=proxy, stype='get', sfrom=ifrom) iq = self.xmpp.Iq(sto=proxy, stype='get', sfrom=ifrom)
iq.enable('socks') iq.enable('socks')
return iq.send(block=block, timeout=timeout, callback=callback) return iq.send(timeout=timeout, callback=callback)
def _handle_streamhost(self, iq): def _handle_streamhost(self, iq):
"""Handle incoming SOCKS5 session request.""" """Handle incoming SOCKS5 session request."""
@ -187,12 +187,12 @@ class XEP_0065(BasePlugin):
self.xmpp.event('socks5_stream', conn) self.xmpp.event('socks5_stream', conn)
self.xmpp.event('stream:%s:%s' % (sid, conn.peer_jid), conn) self.xmpp.event('stream:%s:%s' % (sid, conn.peer_jid), conn)
def activate(self, proxy, sid, target, ifrom=None, block=True, timeout=None, callback=None): def activate(self, proxy, sid, target, ifrom=None, timeout=None, callback=None):
"""Activate the socks5 session that has been negotiated.""" """Activate the socks5 session that has been negotiated."""
iq = self.xmpp.Iq(sto=proxy, stype='set', sfrom=ifrom) iq = self.xmpp.Iq(sto=proxy, stype='set', sfrom=ifrom)
iq['socks']['sid'] = sid iq['socks']['sid'] = sid
iq['socks']['activate'] = target iq['socks']['activate'] = target
iq.send(block=block, timeout=timeout, callback=callback) iq.send(timeout=timeout, callback=callback)
def deactivate(self, sid): def deactivate(self, sid):
"""Closes the proxy socket associated with this SID.""" """Closes the proxy socket associated with this SID."""

View File

@ -81,26 +81,25 @@ class XEP_0077(BasePlugin):
return True return True
return False return False
def get_registration(self, jid=None, ifrom=None, block=True, def get_registration(self, jid=None, ifrom=None,
timeout=None, callback=None): 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(block=block, timeout=timeout, return iq.send(timeout=timeout, callback=callback)
callback=callback)
def cancel_registration(self, jid=None, ifrom=None, block=True, def cancel_registration(self, jid=None, ifrom=None,
timeout=None, callback=None): 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(block=block, timeout=timeout, callback=callback) return iq.send(timeout=timeout, callback=callback)
def change_password(self, password, jid=None, ifrom=None, block=True, def change_password(self, password, jid=None, ifrom=None,
timeout=None, callback=None): timeout=None, callback=None):
iq = self.xmpp.Iq() iq = self.xmpp.Iq()
iq['type'] = 'set' iq['type'] = 'set'
@ -112,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(block=block, timeout=timeout, callback=callback) return iq.send(timeout=timeout, callback=callback)

View File

@ -76,8 +76,6 @@ class XEP_0080(BasePlugin):
options -- Optional form of publish options. options -- Optional form of publish options.
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -86,7 +84,6 @@ class XEP_0080(BasePlugin):
""" """
options = kwargs.get('options', None) options = kwargs.get('options', None)
ifrom = kwargs.get('ifrom', None) ifrom = kwargs.get('ifrom', None)
block = kwargs.get('block', None)
callback = kwargs.get('callback', None) callback = kwargs.get('callback', None)
timeout = kwargs.get('timeout', None) timeout = kwargs.get('timeout', None)
for param in ('ifrom', 'block', 'callback', 'timeout', 'options'): for param in ('ifrom', 'block', 'callback', 'timeout', 'options'):
@ -99,18 +96,15 @@ class XEP_0080(BasePlugin):
return self.xmpp['xep_0163'].publish(geoloc, return self.xmpp['xep_0163'].publish(geoloc,
options=options, options=options,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def stop(self, ifrom=None, block=True, callback=None, timeout=None): def stop(self, ifrom=None, callback=None, timeout=None):
""" """
Clear existing user location information to stop notifications. Clear existing user location information to stop notifications.
Arguments: Arguments:
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -120,6 +114,5 @@ class XEP_0080(BasePlugin):
geoloc = Geoloc() geoloc = Geoloc()
return self.xmpp['xep_0163'].publish(geoloc, return self.xmpp['xep_0163'].publish(geoloc,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)

View File

@ -44,27 +44,25 @@ class XEP_0084(BasePlugin):
def generate_id(self, data): def generate_id(self, data):
return hashlib.sha1(data).hexdigest() return hashlib.sha1(data).hexdigest()
def retrieve_avatar(self, jid, id, url=None, ifrom=None, block=True, def retrieve_avatar(self, jid, id, url=None, ifrom=None,
callback=None, timeout=None): callback=None, timeout=None):
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id, return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def publish_avatar(self, data, ifrom=None, block=True, callback=None, def publish_avatar(self, data, ifrom=None, callback=None,
timeout=None): 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,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def publish_avatar_metadata(self, items=None, pointers=None, def publish_avatar_metadata(self, items=None, pointers=None,
ifrom=None, block=True, ifrom=None,
callback=None, timeout=None): callback=None, timeout=None):
metadata = MetaData() metadata = MetaData()
if items is None: if items is None:
@ -84,18 +82,15 @@ class XEP_0084(BasePlugin):
return self.xmpp['xep_0163'].publish(metadata, return self.xmpp['xep_0163'].publish(metadata,
id=info['id'], id=info['id'],
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def stop(self, ifrom=None, block=True, callback=None, timeout=None): def stop(self, ifrom=None, callback=None, timeout=None):
""" """
Clear existing avatar metadata information to stop notifications. Clear existing avatar metadata information to stop notifications.
Arguments: Arguments:
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -106,6 +101,5 @@ class XEP_0084(BasePlugin):
return self.xmpp['xep_0163'].publish(metadata, return self.xmpp['xep_0163'].publish(metadata,
node=MetaData.namespace, node=MetaData.namespace,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)

View File

@ -70,7 +70,7 @@ class XEP_0092(BasePlugin):
iq['software_version']['os'] = self.os iq['software_version']['os'] = self.os
iq.send() iq.send()
def get_version(self, jid, ifrom=None, block=True, timeout=None, callback=None): def get_version(self, jid, ifrom=None, timeout=None, callback=None):
""" """
Retrieve the software version of a remote agent. Retrieve the software version of a remote agent.
@ -82,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(block=block, timeout=timeout, callback=callback) return iq.send(timeout=timeout, callback=callback)

View File

@ -182,7 +182,6 @@ class XEP_0095(BasePlugin):
if stream_handler: if stream_handler:
self.xmpp.add_event_handler('stream:%s:%s' % (sid, jid), self.xmpp.add_event_handler('stream:%s:%s' % (sid, jid),
stream_handler, stream_handler,
threaded=True,
disposable=True) disposable=True)
return iq.send() return iq.send()

View File

@ -35,7 +35,7 @@ class XEP_0118(BasePlugin):
def publish_tune(self, artist=None, length=None, rating=None, source=None, def publish_tune(self, artist=None, length=None, rating=None, source=None,
title=None, track=None, uri=None, options=None, title=None, track=None, uri=None, options=None,
ifrom=None, block=True, callback=None, timeout=None): ifrom=None, callback=None, timeout=None):
""" """
Publish the user's current tune. Publish the user's current tune.
@ -49,8 +49,6 @@ class XEP_0118(BasePlugin):
uri -- A URL to more information about the song. uri -- A URL to more information about the song.
options -- Optional form of publish options. options -- Optional form of publish options.
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -69,18 +67,15 @@ class XEP_0118(BasePlugin):
node=UserTune.namespace, node=UserTune.namespace,
options=options, options=options,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def stop(self, ifrom=None, block=True, callback=None, timeout=None): def stop(self, ifrom=None, callback=None, timeout=None):
""" """
Clear existing user tune information to stop notifications. Clear existing user tune information to stop notifications.
Arguments: Arguments:
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -91,6 +86,5 @@ class XEP_0118(BasePlugin):
return self.xmpp['xep_0163'].publish(tune, return self.xmpp['xep_0163'].publish(tune,
node=UserTune.namespace, node=UserTune.namespace,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)

View File

@ -35,15 +35,14 @@ class XEP_0133(BasePlugin):
def create_command(name): def create_command(name):
def admin_command(self, jid=None, session=None, ifrom=None, block=False): def admin_command(self, jid=None, session=None, ifrom=None):
if jid is None: if jid is None:
jid = self.xmpp.boundjid.server jid = self.xmpp.boundjid.server
self.xmpp['xep_0050'].start_command( self.xmpp['xep_0050'].start_command(
jid=jid, jid=jid,
node='http://jabber.org/protocol/admin#%s' % name, node='http://jabber.org/protocol/admin#%s' % name,
session=session, session=session,
ifrom=ifrom, ifrom=ifrom)
block=block)
return admin_command return admin_command

View File

@ -34,7 +34,7 @@ class XEP_0152(BasePlugin):
self.xmpp['xep_0163'].register_pep('reachability', Reachability) self.xmpp['xep_0163'].register_pep('reachability', Reachability)
def publish_reachability(self, addresses, options=None, def publish_reachability(self, addresses, options=None,
ifrom=None, block=True, callback=None, timeout=None): ifrom=None, callback=None, timeout=None):
""" """
Publish alternative addresses where the user can be reached. Publish alternative addresses where the user can be reached.
@ -43,8 +43,6 @@ class XEP_0152(BasePlugin):
optional description for each address. optional description for each address.
options -- Optional form of publish options. options -- Optional form of publish options.
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -66,18 +64,15 @@ class XEP_0152(BasePlugin):
node=Reachability.namespace, node=Reachability.namespace,
options=options, options=options,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def stop(self, ifrom=None, block=True, callback=None, timeout=None): def stop(self, ifrom=None, callback=None, timeout=None):
""" """
Clear existing user activity information to stop notifications. Clear existing user activity information to stop notifications.
Arguments: Arguments:
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -88,6 +83,5 @@ class XEP_0152(BasePlugin):
return self.xmpp['xep_0163'].publish(reach, return self.xmpp['xep_0163'].publish(reach,
node=Reachability.namespace, node=Reachability.namespace,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)

View File

@ -59,7 +59,7 @@ 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)
def set_avatar(self, jid=None, avatar=None, mtype=None, block=True, def set_avatar(self, jid=None, avatar=None, mtype=None,
timeout=None, callback=None): timeout=None, callback=None):
if jid is None: if jid is None:
jid = self.xmpp.boundjid.bare jid = self.xmpp.boundjid.bare

View File

@ -27,18 +27,18 @@ class XEP_0186(BasePlugin):
register_stanza_plugin(Iq, Visible) register_stanza_plugin(Iq, Visible)
register_stanza_plugin(Iq, Invisible) register_stanza_plugin(Iq, Invisible)
def set_invisible(self, ifrom=None, block=True, callback=None, def set_invisible(self, ifrom=None, callback=None,
timeout=None): timeout=None):
iq = self.xmpp.Iq() iq = self.xmpp.Iq()
iq['type'] = 'set' iq['type'] = 'set'
iq['from'] = ifrom iq['from'] = ifrom
iq.enable('invisible') iq.enable('invisible')
iq.send(block=block, callback=callback, timeout=timeout) iq.send(callback=callback, timeout=timeout)
def set_visible(self, ifrom=None, block=True, callback=None, def set_visible(self, ifrom=None, callback=None,
timeout=None): timeout=None):
iq = self.xmpp.Iq() iq = self.xmpp.Iq()
iq['type'] = 'set' iq['type'] = 'set'
iq['from'] = ifrom iq['from'] = ifrom
iq.enable('visible') iq.enable('visible')
iq.send(block=block, callback=callback, timeout=timeout) iq.send(callback=callback, timeout=timeout)

View File

@ -45,14 +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')
def get_blocked(self, ifrom=None, block=True, timeout=None, callback=None): def get_blocked(self, ifrom=None, timeout=None, callback=None):
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(block=block, timeout=timeout, callback=callback) return iq.send(timeout=timeout, callback=callback)
def block(self, jids, ifrom=None, block=True, timeout=None, callback=None): def block(self, jids, ifrom=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
@ -61,9 +61,9 @@ class XEP_0191(BasePlugin):
jids = [jids] jids = [jids]
iq['block']['items'] = jids iq['block']['items'] = jids
return iq.send(block=block, timeout=timeout, callback=callback) return iq.send(timeout=timeout, callback=callback)
def unblock(self, jids=None, ifrom=None, block=True, timeout=None, callback=None): def unblock(self, jids=None, ifrom=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
@ -74,7 +74,7 @@ class XEP_0191(BasePlugin):
jids = [jids] jids = [jids]
iq['unblock']['items'] = jids iq['unblock']['items'] = jids
return iq.send(block=block, timeout=timeout, callback=callback) 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)

View File

@ -71,8 +71,7 @@ class XEP_0199(BasePlugin):
if self.keepalive: if self.keepalive:
self.xmpp.add_event_handler('session_start', self.xmpp.add_event_handler('session_start',
self.enable_keepalive, self.enable_keepalive)
threaded=True)
self.xmpp.add_event_handler('session_end', self.xmpp.add_event_handler('session_end',
self.disable_keepalive) self.disable_keepalive)
@ -129,8 +128,7 @@ class XEP_0199(BasePlugin):
timeout -- Time in seconds to wait for a response. timeout -- Time in seconds to wait for a response.
Defaults to self.timeout. Defaults to self.timeout.
callback -- Optional handler to execute when a pong callback -- Optional handler to execute when a pong
is received. Useful in conjunction with is received.
the option block=False.
""" """
if not timeout: if not timeout:
timeout = self.timeout timeout = self.timeout

View File

@ -40,12 +40,11 @@ class XEP_0222(BasePlugin):
return self.xmpp['xep_0060'].set_node_config(None, node, config, return self.xmpp['xep_0060'].set_node_config(None, node, config,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def store(self, stanza, node=None, id=None, ifrom=None, options=None, def store(self, stanza, node=None, id=None, ifrom=None, options=None,
block=True, callback=None, timeout=None): callback=None, timeout=None):
""" """
Store public data via PEP. Store public data via PEP.
@ -60,8 +59,6 @@ class XEP_0222(BasePlugin):
options -- Publish options to use, which will be modified to options -- Publish options to use, which will be modified to
fit the persistent storage option profile. fit the persistent storage option profile.
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -85,12 +82,11 @@ class XEP_0222(BasePlugin):
return self.xmpp['xep_0163'].publish(stanza, node, return self.xmpp['xep_0163'].publish(stanza, node,
options=options, options=options,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)
def retrieve(self, node, id=None, item_ids=None, ifrom=None, def retrieve(self, node, id=None, item_ids=None, ifrom=None,
block=True, callback=None, timeout=None): callback=None, timeout=None):
""" """
Retrieve public data via PEP. Retrieve public data via PEP.
@ -103,8 +99,6 @@ class XEP_0222(BasePlugin):
item_ids -- Specify a group of IDs. If id is also specified, it item_ids -- Specify a group of IDs. If id is also specified, it
will be included in item_ids. will be included in item_ids.
ifrom -- Specify the sender's JID. ifrom -- Specify the sender's JID.
block -- Specify if the send call will block until a response
is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used. before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@ -119,7 +113,6 @@ class XEP_0222(BasePlugin):
return self.xmpp['xep_0060'].get_items(None, node, return self.xmpp['xep_0060'].get_items(None, node,
item_ids=item_ids, item_ids=item_ids,
ifrom=ifrom, ifrom=ifrom,
block=block,
callback=callback, callback=callback,
timeout=timeout) timeout=timeout)

View File

@ -82,7 +82,7 @@ class XEP_0231(BasePlugin):
return cid return cid
def get_bob(self, jid=None, cid=None, cached=True, ifrom=None, def get_bob(self, jid=None, cid=None, cached=True, ifrom=None,
block=True, timeout=None, callback=None): 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:
@ -97,7 +97,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(block=block, timeout=timeout, callback=callback) 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)

View File

@ -34,11 +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)
def get_catalog(self, jid, ifrom=None, block=True, def get_catalog(self, jid, ifrom=None,
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(block=block, callback=callback, timeout=timeout) return iq.send(callback=callback, timeout=timeout)

View File

@ -41,7 +41,7 @@ class XEP_0313(BasePlugin):
register_stanza_plugin(stanza.MAM, self.xmpp['xep_0059'].stanza.Set) register_stanza_plugin(stanza.MAM, self.xmpp['xep_0059'].stanza.Set)
def retrieve(self, jid=None, start=None, end=None, with_jid=None, ifrom=None, def retrieve(self, jid=None, start=None, end=None, with_jid=None, ifrom=None,
block=True, timeout=None, callback=None, iterator=False): timeout=None, callback=None, iterator=False):
iq = self.xmpp.Iq() iq = self.xmpp.Iq()
query_id = iq['id'] query_id = iq['id']
@ -60,21 +60,12 @@ class XEP_0313(BasePlugin):
if iterator: if iterator:
return self.xmpp['xep_0059'].iterate(iq, 'mam', 'results') return self.xmpp['xep_0059'].iterate(iq, 'mam', 'results')
elif not block and callback is not None: def wrapped_cb(iq):
def wrapped_cb(iq): results = collector.stop()
results = collector.stop() if iq['type'] == 'result':
if iq['type'] == 'result': iq['mam']['results'] = results
iq['mam']['results'] = results callback(iq)
callback(iq) return iq.send(timeout=timeout, callback=wrapped_cb)
return iq.send(block=block, timeout=timeout, callback=wrapped_cb)
else:
try:
resp = iq.send(block=block, timeout=timeout, callback=callback)
resp['mam']['results'] = collector.stop()
return resp
except XMPPError as e:
collector.stop()
raise e
def set_preferences(self, jid=None, default=None, always=None, never=None, def set_preferences(self, jid=None, default=None, always=None, never=None,
ifrom=None, block=True, timeout=None, callback=None): ifrom=None, block=True, timeout=None, callback=None):

View File

@ -145,7 +145,7 @@ class XEP_0325(BasePlugin):
self.test_authenticated_from = "" self.test_authenticated_from = ""
def post_init(self): def post_init(self):
""" Init complete. Register our features in Serivce discovery. """ """ Init complete. Register our features in Service discovery. """
BasePlugin.post_init(self) BasePlugin.post_init(self)
self.xmpp['xep_0030'].add_feature(Control.namespace) self.xmpp['xep_0030'].add_feature(Control.namespace)
self.xmpp['xep_0030'].set_items(node=Control.namespace, items=tuple()) self.xmpp['xep_0030'].set_items(node=Control.namespace, items=tuple())