Package pyxmpp :: Package jabber :: Module client :: Class JabberClient
[show private | hide private]
[frames | no frames]

Class JabberClient

Client --+
         |
        JabberClient


Base class for a Jabber client.
Method Summary
  __init__(self, jid, password, server, port, auth_methods, tls_settings, keepalive, disco_name, disco_category, disco_type)
Initialize a JabberClient object.
  authorized(self)
Handle "authorized" event.
  connect(self, register)
Connect to the server and set up the stream.
DiscoInfo disco_get_info(self, node, iq)
Return Disco#info data for a node.
DiscoInfo disco_get_items(self, node, iq)
Return Disco#items data for a node.
  process_registration_form(self, stanza, form)
Fill-in the registration form provided by the server.
  register_feature(self, feature_name)
Register a feature to be announced by Service Discovery.
  submit_registration_form(self, form)
Submit a registration form
  unregister_feature(self, feature_name)
Unregister a feature to be announced by Service Discovery.
    Inherited from Client
  authenticated(self)
Handle "authenticated" event.
  connected(self)
Handle "connected" event.
  disconnect(self)
Disconnect from the server.
  disconnected(self)
Handle "disconnected" event.
socket.socket get_socket(self)
Get the socket object of the active connection.
pyxmpp.ClientStream get_stream(self)
Get the connected stream object.
  idle(self)
Do some "housekeeping" work like cache expiration or timeout handling.
  loop(self, timeout)
Simple "main loop" for the client.
  request_roster(self)
Request the user's roster.
  request_session(self)
Request an IM session.
  roster_updated(self, item)
Handle roster update event.
  session_started(self)
Handle session started event.
  stream_closed(self, stream)
Handle stream closure event.
  stream_created(self, stream)
Handle stream creation event.
  stream_error(self, err)
Handle stream error received.
  stream_state_changed(self, state, arg)
Handle any stream state change.

Instance Variable Summary
  disco_identity: default identity of the default disco_info.
DiscoInfo disco_info: default Disco#info reply for a query to an empty node -- provides information about the client and its supported fetures.
DiscoItems disco_items: default Disco#items reply for a query to an empty node.
bool register: when True than registration will be started instead of authentication.
    Inherited from Client
list of str auth_methods: methods allowed for stream authentication.
pyxmpp.JID jid: configured JID of the client (current actual JID is avialable as self.stream.jid).
int keepalive: keepalive interval for the stream or 0 when keepalive is disabled.
threading.RLock lock: lock for synchronizing Client attributes access.
unicode password: authentication password.
int port: port number on the server to use if non-standard and not discoverable by SRV lookups.
pyxmpp.Roster roster: user's roster or None if the roster is not yet retrieved.
unicode server: server to use if non-standard and not discoverable by SRV lookups.
bool session_established: True when an IM session is established.
threading.Condition state_changed: condition notified the the object state changes (stream becomes connected, session established etc.).
pyxmpp.ClientStream stream: current stream when the client is connected, None otherwise.

Method Details

__init__(self, jid=None, password=None, server=None, port=5222, auth_methods=('sasl:DIGEST-MD5', 'digest'), tls_settings=None, keepalive=0, disco_name=u'pyxmpp based Jabber client', disco_category=u'client', disco_type=u'pc')
(Constructor)

Initialize a JabberClient object.
Parameters:
jid - user full JID for the connection.
           (type=pyxmpp.JID)
password - user password.
           (type=unicode)
server - server to use. If not given then address will be derived form the JID.
           (type=unicode)
port - port number to use. If not given then address will be derived form the JID.
           (type=int)
auth_methods - sallowed authentication methods. SASL authentication mechanisms in the list should be prefixed with "sasl:" string.
           (type=sequence of str)
tls_settings - settings for StartTLS -- TLSSettings instance.
           (type=pyxmpp.TLSSettings)
keepalive - keepalive output interval. 0 to disable.
           (type=int)
disco_name - name of the client identity in the disco#info replies.
           (type=unicode)
disco_category - category of the client identity in the disco#info replies. The default of u'client' should be the right choice in most cases.
           (type=unicode)
disco_type - type of the client identity in the disco#info replies. Use the types registered by Jabber Registrar
           (type=unicode)
Overrides:
pyxmpp.client.Client.__init__

authorized(self)

Handle "authorized" event. May be overriden in derived classes. By default: request an IM session and setup Disco handlers.
Overrides:
pyxmpp.client.Client.authorized

connect(self, register=False)

Connect to the server and set up the stream.

Set self.stream and notify self.state_changed when connection succeeds. Additionally, initialize Disco items and info of the client.

Overrides:
pyxmpp.client.Client.connect

disco_get_info(self, node, iq)

Return Disco#info data for a node.
Parameters:
node - the node queried.
           (type=unicode)
iq - the request stanza received.
           (type=pyxmpp.iq.Iq)
Returns:
self.disco_info if node is empty or None otherwise.
           (type=DiscoInfo)

disco_get_items(self, node, iq)

Return Disco#items data for a node.
Parameters:
node - the node queried.
           (type=unicode)
iq - the request stanza received.
           (type=pyxmpp.iq.Iq)
Returns:
self.disco_info if node is empty or None otherwise.
           (type=DiscoInfo)

process_registration_form(self, stanza, form)

Fill-in the registration form provided by the server.

This default implementation fills-in "username" and "passwords" fields only and instantly submits the form.

Parameters:
stanza - the stanza received.
           (type=pyxmpp.iq.Iq)
form - the registration form.
           (type=pyxmpp.jabber.dataforms.Form)

register_feature(self, feature_name)

Register a feature to be announced by Service Discovery.
Parameters:
feature_name - feature namespace or name.
           (type=unicode)

submit_registration_form(self, form)

Submit a registration form
Parameters:
form - the form to submit
           (type=pyxmpp.jabber.dataforms.Form)

unregister_feature(self, feature_name)

Unregister a feature to be announced by Service Discovery.
Parameters:
feature_name - feature namespace or name.
           (type=unicode)

Instance Variable Details

disco_identity

default identity of the default disco_info.

disco_info

default Disco#info reply for a query to an empty node -- provides information about the client and its supported fetures.
Type:
DiscoInfo

disco_items

default Disco#items reply for a query to an empty node.
Type:
DiscoItems

register

when True than registration will be started instead of authentication.
Type:
bool