2011-12-06 04:37:47 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
2011-12-06 04:37:47 +00:00
|
|
|
sleekxmpp.clientxmpp
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2011-12-06 04:37:47 +00:00
|
|
|
This module provides XMPP functionality that
|
|
|
|
is specific to client connections.
|
|
|
|
|
|
|
|
Part of SleekXMPP: The Sleek XMPP Library
|
|
|
|
|
|
|
|
:copyright: (c) 2011 Nathanael C. Fritz
|
|
|
|
:license: MIT, see LICENSE for more details
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
|
|
|
|
import logging
|
2012-02-17 22:41:31 +00:00
|
|
|
|
|
|
|
from sleekxmpp.stanza import StreamFeatures
|
2010-10-06 18:20:32 +00:00
|
|
|
from sleekxmpp.basexmpp import BaseXMPP
|
2012-03-07 19:44:07 +00:00
|
|
|
from sleekxmpp.exceptions import XMPPError
|
2012-02-17 22:41:31 +00:00
|
|
|
from sleekxmpp.xmlstream import XMLStream
|
2012-04-07 21:19:39 +00:00
|
|
|
from sleekxmpp.xmlstream.matcher import StanzaPath, MatchXPath
|
2012-02-17 22:41:31 +00:00
|
|
|
from sleekxmpp.xmlstream.handler import Callback
|
2010-10-06 18:20:32 +00:00
|
|
|
|
|
|
|
# Flag indicating if DNS SRV records are available for use.
|
|
|
|
try:
|
|
|
|
import dns.resolver
|
2011-08-18 07:35:18 +00:00
|
|
|
except ImportError:
|
|
|
|
DNSPYTHON = False
|
|
|
|
else:
|
|
|
|
DNSPYTHON = True
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2010-10-06 18:31:33 +00:00
|
|
|
|
2010-11-06 05:28:59 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2010-10-06 18:20:32 +00:00
|
|
|
class ClientXMPP(BaseXMPP):
|
|
|
|
|
|
|
|
"""
|
2011-12-06 04:37:47 +00:00
|
|
|
SleekXMPP's client class. (Use only for good, not for evil.)
|
|
|
|
|
|
|
|
Typical use pattern:
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
xmpp = ClientXMPP('user@server.tld/resource', 'password')
|
|
|
|
# ... Register plugins and event handlers ...
|
|
|
|
xmpp.connect()
|
|
|
|
xmpp.process(block=False) # block=True will block the current
|
|
|
|
# thread. By default, block=False
|
|
|
|
|
|
|
|
:param jid: The JID of the XMPP user account.
|
|
|
|
:param password: The password for the XMPP user account.
|
|
|
|
:param ssl: **Deprecated.**
|
|
|
|
:param plugin_config: A dictionary of plugin configurations.
|
2012-06-19 08:29:48 +00:00
|
|
|
:param plugin_whitelist: A list of approved plugins that
|
|
|
|
will be loaded when calling
|
2011-12-06 04:37:47 +00:00
|
|
|
:meth:`~sleekxmpp.basexmpp.BaseXMPP.register_plugins()`.
|
|
|
|
:param escape_quotes: **Deprecated.**
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
|
|
|
|
2012-06-19 08:29:48 +00:00
|
|
|
def __init__(self, jid, password, plugin_config={}, plugin_whitelist=[],
|
2012-06-05 23:54:26 +00:00
|
|
|
escape_quotes=True, sasl_mech=None, lang='en'):
|
2010-10-27 03:47:17 +00:00
|
|
|
BaseXMPP.__init__(self, jid, 'jabber:client')
|
2010-10-06 18:20:32 +00:00
|
|
|
|
|
|
|
self.set_jid(jid)
|
|
|
|
self.escape_quotes = escape_quotes
|
|
|
|
self.plugin_config = plugin_config
|
|
|
|
self.plugin_whitelist = plugin_whitelist
|
2011-08-18 07:35:18 +00:00
|
|
|
self.default_port = 5222
|
2012-06-05 23:54:26 +00:00
|
|
|
self.default_lang = lang
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2012-01-20 09:08:25 +00:00
|
|
|
self.credentials = {}
|
|
|
|
|
|
|
|
self.password = password
|
|
|
|
|
2012-06-05 23:54:26 +00:00
|
|
|
self.stream_header = "<stream:stream to='%s' %s %s %s %s>" % (
|
2010-10-16 19:09:40 +00:00
|
|
|
self.boundjid.host,
|
2010-10-06 18:20:32 +00:00
|
|
|
"xmlns:stream='%s'" % self.stream_ns,
|
2012-06-05 23:54:26 +00:00
|
|
|
"xmlns='%s'" % self.default_ns,
|
|
|
|
"xml:lang='%s'" % self.default_lang,
|
|
|
|
"version='1.0'")
|
2010-10-06 18:20:32 +00:00
|
|
|
self.stream_footer = "</stream:stream>"
|
|
|
|
|
2011-07-03 05:30:34 +00:00
|
|
|
self.features = set()
|
2011-01-28 05:49:37 +00:00
|
|
|
self._stream_feature_handlers = {}
|
|
|
|
self._stream_feature_order = []
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2012-03-29 22:11:24 +00:00
|
|
|
self.dns_service = 'xmpp-client'
|
|
|
|
|
2010-10-06 18:20:32 +00:00
|
|
|
#TODO: Use stream state here
|
|
|
|
self.authenticated = False
|
|
|
|
self.sessionstarted = False
|
|
|
|
self.bound = False
|
|
|
|
self.bindfail = False
|
2011-01-28 05:49:37 +00:00
|
|
|
|
|
|
|
self.add_event_handler('connected', self._handle_connected)
|
2012-01-07 04:30:14 +00:00
|
|
|
self.add_event_handler('session_bind', self._handle_session_bind)
|
2011-01-28 05:49:37 +00:00
|
|
|
|
|
|
|
self.register_stanza(StreamFeatures)
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2012-01-18 19:51:00 +00:00
|
|
|
self.register_handler(
|
|
|
|
Callback('Stream Features',
|
|
|
|
MatchXPath('{%s}features' % self.stream_ns),
|
|
|
|
self._handle_stream_features))
|
2010-10-06 22:45:11 +00:00
|
|
|
self.register_handler(
|
2010-10-06 18:20:32 +00:00
|
|
|
Callback('Roster Update',
|
2012-04-07 21:19:39 +00:00
|
|
|
StanzaPath('iq@type=set/roster'),
|
2010-10-06 18:20:32 +00:00
|
|
|
self._handle_roster))
|
|
|
|
|
2011-06-30 22:40:22 +00:00
|
|
|
# Setup default stream features
|
|
|
|
self.register_plugin('feature_starttls')
|
|
|
|
self.register_plugin('feature_bind')
|
|
|
|
self.register_plugin('feature_session')
|
2011-09-29 02:48:30 +00:00
|
|
|
self.register_plugin('feature_mechanisms',
|
|
|
|
pconfig={'use_mech': sasl_mech} if sasl_mech else None)
|
2012-03-07 19:44:07 +00:00
|
|
|
self.register_plugin('feature_rosterver')
|
2010-10-14 01:15:21 +00:00
|
|
|
|
2012-01-20 09:08:25 +00:00
|
|
|
@property
|
|
|
|
def password(self):
|
|
|
|
return self.credentials.get('password', '')
|
|
|
|
|
|
|
|
@password.setter
|
|
|
|
def password(self, value):
|
|
|
|
self.credentials['password'] = value
|
|
|
|
|
2011-11-11 09:52:18 +00:00
|
|
|
def connect(self, address=tuple(), reattempt=True,
|
|
|
|
use_tls=True, use_ssl=False):
|
2011-12-06 04:37:47 +00:00
|
|
|
"""Connect to the XMPP server.
|
2010-10-06 18:20:32 +00:00
|
|
|
|
|
|
|
When no address is given, a SRV lookup for the server will
|
|
|
|
be attempted. If that fails, the server user in the JID
|
|
|
|
will be used.
|
|
|
|
|
2011-12-06 04:37:47 +00:00
|
|
|
:param address -- A tuple containing the server's host and port.
|
|
|
|
:param reattempt: If ``True``, repeat attempting to connect if an
|
|
|
|
error occurs. Defaults to ``True``.
|
|
|
|
:param use_tls: Indicates if TLS should be used for the
|
|
|
|
connection. Defaults to ``True``.
|
|
|
|
:param use_ssl: Indicates if the older SSL connection method
|
|
|
|
should be used. Defaults to ``False``.
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
2010-10-21 02:18:27 +00:00
|
|
|
self.session_started_event.clear()
|
2012-03-29 22:11:24 +00:00
|
|
|
|
|
|
|
# If an address was provided, disable using DNS SRV lookup;
|
|
|
|
# otherwise, use the domain from the client JID with the standard
|
|
|
|
# XMPP client port and allow SRV lookup.
|
|
|
|
if address:
|
|
|
|
self.dns_service = None
|
|
|
|
else:
|
2011-08-18 07:59:27 +00:00
|
|
|
address = (self.boundjid.host, 5222)
|
2012-03-29 22:11:24 +00:00
|
|
|
self.dns_service = 'xmpp-client'
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2012-05-22 10:56:06 +00:00
|
|
|
self._expected_server_name = self.boundjid.host
|
|
|
|
|
2011-01-07 21:41:31 +00:00
|
|
|
return XMLStream.connect(self, address[0], address[1],
|
2011-11-11 09:52:18 +00:00
|
|
|
use_tls=use_tls, use_ssl=use_ssl,
|
|
|
|
reattempt=reattempt)
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2011-01-28 05:49:37 +00:00
|
|
|
def register_feature(self, name, handler, restart=False, order=5000):
|
2011-12-06 04:37:47 +00:00
|
|
|
"""Register a stream feature handler.
|
|
|
|
|
|
|
|
:param name: The name of the stream feature.
|
|
|
|
:param handler: The function to execute if the feature is received.
|
|
|
|
:param restart: Indicates if feature processing should halt with
|
|
|
|
this feature. Defaults to ``False``.
|
|
|
|
:param order: The relative ordering in which the feature should
|
|
|
|
be negotiated. Lower values will be attempted
|
|
|
|
earlier when available.
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
2011-01-28 05:49:37 +00:00
|
|
|
self._stream_feature_handlers[name] = (handler, restart)
|
|
|
|
self._stream_feature_order.append((order, name))
|
|
|
|
self._stream_feature_order.sort()
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2012-07-10 08:35:25 +00:00
|
|
|
def unregister_feature(self, name, order):
|
|
|
|
if name in self._stream_feature_handlers:
|
|
|
|
del self._stream_feature_handlers[name]
|
|
|
|
self._stream_feature_order.remove((order, name))
|
|
|
|
self._stream_feature_order.sort()
|
|
|
|
|
Resolve timeout errors for get_roster.
See issue #89
Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.
To ensure that the get_roster call was successful, here
is a pattern to follow:
def __init__(self, ...):
...
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('roster_timeout', self.roster_timeout)
self.add_event_handler('roster_received', self.roster_received)
def session_start(self, e):
self.send_presence()
self.get_roster()
def roster_timeout(self, e):
# Optionally increase the timeout period
self.get_roster(timeout=self.response_timeout * 2)
def roster_received(self, iq):
# Do stuff, roster has been initialized.
...
2011-05-20 16:56:00 +00:00
|
|
|
def update_roster(self, jid, name=None, subscription=None, groups=[],
|
|
|
|
block=True, timeout=None, callback=None):
|
2011-12-06 04:37:47 +00:00
|
|
|
"""Add or change a roster item.
|
|
|
|
|
|
|
|
:param jid: The JID of the entry to modify.
|
|
|
|
:param name: The user's nickname for this JID.
|
|
|
|
:param subscription: The subscription status. May be one of
|
|
|
|
``'to'``, ``'from'``, ``'both'``, or
|
|
|
|
``'none'``. If set to ``'remove'``,
|
|
|
|
the entry will be deleted.
|
|
|
|
:param groups: The roster groups that contain this item.
|
|
|
|
:param block: Specify if the roster request will block
|
|
|
|
until a response is received, or a timeout
|
|
|
|
occurs. Defaults to ``True``.
|
|
|
|
:param timeout: The length of time (in seconds) to wait
|
|
|
|
for a response before continuing if blocking
|
2012-06-19 08:29:48 +00:00
|
|
|
is used. Defaults to
|
2011-12-06 04:37:47 +00:00
|
|
|
:attr:`~sleekxmpp.xmlstream.xmlstream.XMLStream.response_timeout`.
|
|
|
|
:param callback: Optional reference to a stream handler function.
|
|
|
|
Will be executed when the roster is received.
|
|
|
|
Implies ``block=False``.
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
2011-11-14 19:20:53 +00:00
|
|
|
return self.client_roster.update(jid, name, subscription, groups,
|
2011-06-16 23:09:15 +00:00
|
|
|
block, timeout, callback)
|
2010-10-06 18:20:32 +00:00
|
|
|
|
|
|
|
def del_roster_item(self, jid):
|
2011-12-06 04:37:47 +00:00
|
|
|
"""Remove an item from the roster.
|
2012-06-19 08:29:48 +00:00
|
|
|
|
2011-12-06 04:37:47 +00:00
|
|
|
This is done by setting its subscription status to ``'remove'``.
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2011-12-06 04:37:47 +00:00
|
|
|
:param jid: The JID of the item to remove.
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
2011-06-16 23:09:15 +00:00
|
|
|
return self.client_roster.remove(jid)
|
2010-10-06 18:20:32 +00:00
|
|
|
|
Resolve timeout errors for get_roster.
See issue #89
Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.
To ensure that the get_roster call was successful, here
is a pattern to follow:
def __init__(self, ...):
...
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('roster_timeout', self.roster_timeout)
self.add_event_handler('roster_received', self.roster_received)
def session_start(self, e):
self.send_presence()
self.get_roster()
def roster_timeout(self, e):
# Optionally increase the timeout period
self.get_roster(timeout=self.response_timeout * 2)
def roster_received(self, iq):
# Do stuff, roster has been initialized.
...
2011-05-20 16:56:00 +00:00
|
|
|
def get_roster(self, block=True, timeout=None, callback=None):
|
2011-12-06 04:37:47 +00:00
|
|
|
"""Request the roster from the server.
|
Resolve timeout errors for get_roster.
See issue #89
Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.
To ensure that the get_roster call was successful, here
is a pattern to follow:
def __init__(self, ...):
...
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('roster_timeout', self.roster_timeout)
self.add_event_handler('roster_received', self.roster_received)
def session_start(self, e):
self.send_presence()
self.get_roster()
def roster_timeout(self, e):
# Optionally increase the timeout period
self.get_roster(timeout=self.response_timeout * 2)
def roster_received(self, iq):
# Do stuff, roster has been initialized.
...
2011-05-20 16:56:00 +00:00
|
|
|
|
2011-12-06 04:37:47 +00:00
|
|
|
:param block: Specify if the roster request will block until a
|
|
|
|
response is received, or a timeout occurs.
|
|
|
|
Defaults to ``True``.
|
|
|
|
:param timeout: The length of time (in seconds) to wait for a response
|
Resolve timeout errors for get_roster.
See issue #89
Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.
To ensure that the get_roster call was successful, here
is a pattern to follow:
def __init__(self, ...):
...
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('roster_timeout', self.roster_timeout)
self.add_event_handler('roster_received', self.roster_received)
def session_start(self, e):
self.send_presence()
self.get_roster()
def roster_timeout(self, e):
# Optionally increase the timeout period
self.get_roster(timeout=self.response_timeout * 2)
def roster_received(self, iq):
# Do stuff, roster has been initialized.
...
2011-05-20 16:56:00 +00:00
|
|
|
before continuing if blocking is used.
|
2012-06-19 08:29:48 +00:00
|
|
|
Defaults to
|
2011-12-06 04:37:47 +00:00
|
|
|
:attr:`~sleekxmpp.xmlstream.xmlstream.XMLStream.response_timeout`.
|
|
|
|
:param callback: Optional reference to a stream handler function. Will
|
|
|
|
be executed when the roster is received.
|
|
|
|
Implies ``block=False``.
|
Resolve timeout errors for get_roster.
See issue #89
Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.
To ensure that the get_roster call was successful, here
is a pattern to follow:
def __init__(self, ...):
...
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('roster_timeout', self.roster_timeout)
self.add_event_handler('roster_received', self.roster_received)
def session_start(self, e):
self.send_presence()
self.get_roster()
def roster_timeout(self, e):
# Optionally increase the timeout period
self.get_roster(timeout=self.response_timeout * 2)
def roster_received(self, iq):
# Do stuff, roster has been initialized.
...
2011-05-20 16:56:00 +00:00
|
|
|
"""
|
|
|
|
iq = self.Iq()
|
|
|
|
iq['type'] = 'get'
|
|
|
|
iq.enable('roster')
|
2012-03-07 19:44:07 +00:00
|
|
|
if 'rosterver' in self.features:
|
|
|
|
iq['roster']['ver'] = self.client_roster.version
|
2012-01-11 03:57:38 +00:00
|
|
|
|
|
|
|
if not block and callback is None:
|
2012-04-07 21:30:25 +00:00
|
|
|
callback = lambda resp: self._handle_roster(resp)
|
2012-01-11 03:57:38 +00:00
|
|
|
|
Resolve timeout errors for get_roster.
See issue #89
Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.
To ensure that the get_roster call was successful, here
is a pattern to follow:
def __init__(self, ...):
...
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('roster_timeout', self.roster_timeout)
self.add_event_handler('roster_received', self.roster_received)
def session_start(self, e):
self.send_presence()
self.get_roster()
def roster_timeout(self, e):
# Optionally increase the timeout period
self.get_roster(timeout=self.response_timeout * 2)
def roster_received(self, iq):
# Do stuff, roster has been initialized.
...
2011-05-20 16:56:00 +00:00
|
|
|
response = iq.send(block, timeout, callback)
|
2012-04-07 21:30:25 +00:00
|
|
|
self.event('roster_received', response)
|
Resolve timeout errors for get_roster.
See issue #89
Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.
To ensure that the get_roster call was successful, here
is a pattern to follow:
def __init__(self, ...):
...
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('roster_timeout', self.roster_timeout)
self.add_event_handler('roster_received', self.roster_received)
def session_start(self, e):
self.send_presence()
self.get_roster()
def roster_timeout(self, e):
# Optionally increase the timeout period
self.get_roster(timeout=self.response_timeout * 2)
def roster_received(self, iq):
# Do stuff, roster has been initialized.
...
2011-05-20 16:56:00 +00:00
|
|
|
|
2012-06-19 08:29:48 +00:00
|
|
|
if block:
|
2012-04-07 21:19:39 +00:00
|
|
|
self._handle_roster(response)
|
2012-01-13 01:21:43 +00:00
|
|
|
return response
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2011-01-28 05:49:37 +00:00
|
|
|
def _handle_connected(self, event=None):
|
|
|
|
#TODO: Use stream state here
|
|
|
|
self.authenticated = False
|
|
|
|
self.sessionstarted = False
|
|
|
|
self.bound = False
|
|
|
|
self.bindfail = False
|
2011-07-03 05:30:34 +00:00
|
|
|
self.features = set()
|
2010-10-06 18:20:32 +00:00
|
|
|
|
|
|
|
def _handle_stream_features(self, features):
|
2011-12-06 04:37:47 +00:00
|
|
|
"""Process the received stream features.
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2011-12-06 04:37:47 +00:00
|
|
|
:param features: The features stanza.
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
2011-01-28 05:49:37 +00:00
|
|
|
for order, name in self._stream_feature_order:
|
|
|
|
if name in features['features']:
|
|
|
|
handler, restart = self._stream_feature_handlers[name]
|
|
|
|
if handler(features) and restart:
|
|
|
|
# Don't continue if the feature requires
|
|
|
|
# restarting the XML stream.
|
|
|
|
return True
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2012-04-07 21:19:39 +00:00
|
|
|
def _handle_roster(self, iq):
|
2011-12-06 04:37:47 +00:00
|
|
|
"""Update the roster after receiving a roster stanza.
|
2010-10-06 18:20:32 +00:00
|
|
|
|
2011-12-06 04:37:47 +00:00
|
|
|
:param iq: The roster stanza.
|
2010-10-06 18:20:32 +00:00
|
|
|
"""
|
2012-04-07 21:19:39 +00:00
|
|
|
if iq['type'] == 'set':
|
|
|
|
if iq['from'].bare and iq['from'].bare != self.boundjid.bare:
|
|
|
|
raise XMPPError(condition='service-unavailable')
|
|
|
|
|
|
|
|
roster = self.client_roster
|
|
|
|
if iq['roster']['ver']:
|
|
|
|
roster.version = iq['roster']['ver']
|
2012-07-06 20:50:15 +00:00
|
|
|
items = iq['roster']['items']
|
|
|
|
for jid in items:
|
|
|
|
item = items[jid]
|
2012-04-07 21:19:39 +00:00
|
|
|
roster[jid]['name'] = item['name']
|
|
|
|
roster[jid]['groups'] = item['groups']
|
|
|
|
roster[jid]['from'] = item['subscription'] in ['from', 'both']
|
|
|
|
roster[jid]['to'] = item['subscription'] in ['to', 'both']
|
|
|
|
roster[jid]['pending_out'] = (item['ask'] == 'subscribe')
|
|
|
|
|
|
|
|
roster[jid].save(remove=(item['subscription'] == 'remove'))
|
2012-06-19 08:29:48 +00:00
|
|
|
|
2010-10-06 18:20:32 +00:00
|
|
|
self.event("roster_update", iq)
|
|
|
|
if iq['type'] == 'set':
|
2012-04-25 18:03:33 +00:00
|
|
|
resp = self.Iq(stype='result',
|
|
|
|
sto=iq['from'],
|
|
|
|
sid=iq['id'])
|
|
|
|
resp.enable('roster')
|
|
|
|
resp.send()
|
2011-02-14 18:49:43 +00:00
|
|
|
|
2012-01-07 04:30:14 +00:00
|
|
|
def _handle_session_bind(self, jid):
|
|
|
|
"""Set the client roster to the JID set by the server.
|
|
|
|
|
|
|
|
:param :class:`sleekxmpp.xmlstream.jid.JID` jid: The bound JID as
|
|
|
|
dictated by the server. The same as :attr:`boundjid`.
|
|
|
|
"""
|
|
|
|
self.client_roster = self.roster[jid]
|
|
|
|
|
2011-02-14 18:49:43 +00:00
|
|
|
|
|
|
|
# To comply with PEP8, method names now use underscores.
|
|
|
|
# Deprecated method names are re-mapped for backwards compatibility.
|
|
|
|
ClientXMPP.updateRoster = ClientXMPP.update_roster
|
|
|
|
ClientXMPP.delRosterItem = ClientXMPP.del_roster_item
|
|
|
|
ClientXMPP.getRoster = ClientXMPP.get_roster
|
|
|
|
ClientXMPP.registerFeature = ClientXMPP.register_feature
|