jabber
index
/home/kalfa/debian/mypackages/jabber.py/jabber.py-0.5.0/jabber/jabber.py

__intro__
 
jabber.py is a Python module for the jabber instant messaging protocol.
jabber.py deals with the xml parsing and socket code, leaving the programmer
to concentrate on developing quality jabber based applications with Python.
 
The eventual aim is to produce a fully featured easy to use library for
creating both jabber clients and servers.
 
jabber.py requires at least python 2.0 and the XML expat parser module
( included in the standard Python distrubution ).
 
It is developed on Linux but should run happily on over Unix's and win32.
 
__Usage__
 
jabber.py basically subclasses the xmlstream classs and provides the
processing of jabber protocol elements into object instances as well
'helper' functions for parts of the protocol such as authentication
and roster management.
 
An example of usage for a simple client would be ( only psuedo code !)
 
<> Read documentation on jabber.org for the jabber protocol.
 
<> Birth a jabber.Client object with your jabber servers host
 
<> Define callback functions for the protocol elements you want to use
   and optionally a disconnection.
 
<> Authenticate with the server via auth method, or register via the
   reg methods to get an account.
 
<> Call requestRoster() and sendPresence()
 
<> loop over process(). Send Iqs,messages and presences by birthing
   them via there respective clients , manipulating them and using
   the Client's send() method.
 
<> Respond to incoming elements passed to your callback functions.
 
<> Find bugs :)

 
Modules
       
debug
sha
time
xmlstream

 
Classes
       
xmlstream.Client(xmlstream.Stream)
Connection
Client
Component
exceptions.Exception
NodeProcessed
JID
xmlstream.Node
Protocol
Iq
Log
Message
Presence
XDB
Roster
Server

 
class Client(Connection)
    Class for managing a client connection to a jabber server.
 
 
Method resolution order:
Client
Connection
xmlstream.Client
xmlstream.Stream
xmlstream.NodeBuilder

Methods defined here:
__init__(self, host, port=5222, debug=[], log=0, connection=1, hostIP=None, proxy=None)
addRosterItem(self, jid)
Send off a request to subscribe to the given jid.
auth(self, username, passwd, resource)
Authenticates and logs in to the specified jabber server
Automatically selects the 'best' authentication method
provided by the server.
Supports plain text, digest and zero-k authentication.
 
Returns True if the login was successful, False otherwise.
deregister(self, agent=None)
Send off a request to deregister with the server or with the given
agent.  Returns True if successful, else False.
 
Note that you must be authorised before attempting to deregister.
disconnect(self)
Safely disconnects from the connected server
discoverInfo(self, jid, node=None)
According to JEP-0030:
For identity: category, name is mandatory, type is optional.
For feature: var is mandatory
discoverItems(self, jid, node=None)
According to JEP-0030: jid is mandatory, name, node, action is optional.
getRegInfo(self)
Returns a dictionary of fields requested by the server for a
registration attempt.  Each dictionary entry maps from the name of
the field to the field's current value (either as returned by the
server or set programmatically by calling setRegInfo().
getRoster(self)
Returns the current Roster() class instance. Does
not contact the server.
removeRosterItem(self, jid)
Removes an item with Jabber ID jid from both the
server's roster and the local internal Roster()
instance
requestAgents(self)
Requests a list of available agents.  Returns a dictionary
containing information about each agent; each entry in the
dictionary maps the agent's JID to a dictionary of attributes
describing what that agent can do (as returned by the
NS_AGENTS query).
requestRegInfo(self, agent='')
Requests registration info from the server.
Returns the Iq object received from the server.
requestRoster(self)
Requests the roster from the server and returns a
Roster() class instance.
sendInitPresence = sendPresence(self, type=None, priority=None, show=None, status=None)
sendPresence(self, type=None, priority=None, show=None, status=None)
Sends a presence protocol element to the server.
Used to inform the server that you are online
sendRegInfo(self, agent=None)
Sends the populated registration dictionary back to the server
setRegInfo(self, key, val)
Sets a name/value attribute. Note: requestRegInfo must be
called before setting.
updateRosterItem(self, jid, name=None, groups=None)
Update the information stored in the roster about a roster item.
 
'jid' is the Jabber ID of the roster entry; 'name' is the value to
set the entry's name to, and 'groups' is a list of groups to which
this roster entry can belong.  If either 'name' or 'groups' is not
specified, that value is not updated in the roster.

Methods inherited from Connection:
SendAndWaitForResponse(self, obj, ID=None, timeout=300)
Sends a protocol element object and blocks until a response with
the same ID is received.  The received protocol object is returned
as the function result.
dispatch(self, stanza)
Called internally when a 'protocol element' is received.
Builds the relevant jabber.py object and dispatches it
to a relevant function or callback.
getAnID(self)
Returns a unique ID
header(self)
registerHandler(self, name, handler, type='', ns='', chained=0, makefirst=0, system=0)
Sets the callback func for processing incoming stanzas.
Multiple callback functions can be set which are called in
succession. Callback can optionally raise an NodeProcessed error to
stop stanza from further processing. A type and namespace attributes can
also be optionally passed so the callback is only called when a stanza of
this type is received. Namespace attribute MUST be omitted if you
registering an Iq processing handler.
 
If 'chainOutput' is set to False (the default), the given function
should be defined as follows:
 
     def myCallback(c, p)
 
Where the first parameter is the Client object, and the second
parameter is the [ancestor of] Protocol object representing the stanza
which was received.
 
If 'chainOutput' is set to True, the output from the various
handler functions will be chained together.  In this case,
the given callback function should be defined like this:
 
     def myCallback(c, p, output)
 
Where 'output' is the value returned by the previous
callback function.  For the first callback routine, 'output' will be
set to an empty string.
 
'makefirst' argument gives you control over handler prioriy in its type
and namespace scope. Note that handlers for particular type or namespace always
have lower priority that common handlers.
registerProtocol(self, tag_name, Proto)
Registers a protocol in protocol processing chain. You MUST register
a protocol before you register any handler function for it.
First parameter, that passed to this function is the tag name that
belongs to all protocol elements. F.e.: message, presence, iq, xdb, ...
Second parameter is the [ancestor of] Protocol class, which instance will
built from the received node with call
 
     if received_packet.getName()==tag_name:
         stanza = Proto(node = received_packet)
send(self, what)
Sends a jabber protocol element (Node) to the server
setDisconnectHandler(self, func)
Set the callback for a disconnect.
The given function will be called with a single parameter (the
connection object) when the connection is broken unexpectedly (eg,
in response to sending badly formed XML).  self.lastErr and
self.lastErrCode will be set to the error which caused the
disconnection, if any.
setIqHandler(self, func, type='', ns='')
Back compartibility method
setMessageHandler(self, func, type='', chainOutput=0)
Back compartibility method
setPresenceHandler(self, func, type='', chainOutput=0)
Back compartibility method
waitForResponse(self, ID, timeout=300)
Blocks untils a protocol element with the given id is received.
If an error is received, waitForResponse returns None and
self.lastErr and self.lastErrCode is set to the received error.  If
the operation times out (which only happens if a timeout value is
given), waitForResponse will return None and self.lastErr will be
set to "Timeout".
Changed default from timeout=0 to timeout=300 to avoid hangs in
scripts and such.
If you _really_ want no timeout, just set it to 0

Methods inherited from xmlstream.Client:
connect(self)
Attempt to connect to specified host
getSocket(self)

Methods inherited from xmlstream.Stream:
disconnectHandler(self, conn)
Called when a Network Error or disconnection occurs.
Designed to be overidden
disconnected(self, conn)
Called when a Network Error or disconnection occurs.
getIncomingID(self)
Returns the streams ID
getOutgoingID(self)
Returns the streams ID
log(self, data, inout='')
Logs data to the specified filehandle. Data is time stamped
and prefixed with inout
process(self, timeout=0)
Receives incoming data (if any) and processes it.
Waits for data no more than timeout seconds.
read(self)
Reads incoming data. Blocks until done. Calls disconnected(self) if appropriate.
timestampLog(self, timestamp)
Enable or disable the showing of a timestamp in the log.
By default, timestamping is enabled.
write(self, raw_data)
Writes raw outgoing data. Blocks until done.
If supplied data is not unicode string, ENCODING
is used for convertion. Avoid this!
Always send your data as a unicode string.

Methods inherited from xmlstream.NodeBuilder:
DEBUG(self, dup1, dup2=None)
getDom(self)
handle_data(self, data)
XML Parser callback
unknown_endtag(self, tag)
XML Parser callback
unknown_starttag(self, tag, attrs)
XML Parser callback

 
class Component(Connection)
    docs to come soon...
 
 
Method resolution order:
Component
Connection
xmlstream.Client
xmlstream.Stream
xmlstream.NodeBuilder

Methods defined here:
__init__(self, host, port, connection=1, debug=[], log=0, ns='jabber:component:accept', hostIP=None, proxy=None)
auth(self, secret)
will disconnect on failure
dispatch(self, root_node)
Catch the <handshake/> here

Methods inherited from Connection:
SendAndWaitForResponse(self, obj, ID=None, timeout=300)
Sends a protocol element object and blocks until a response with
the same ID is received.  The received protocol object is returned
as the function result.
getAnID(self)
Returns a unique ID
header(self)
registerHandler(self, name, handler, type='', ns='', chained=0, makefirst=0, system=0)
Sets the callback func for processing incoming stanzas.
Multiple callback functions can be set which are called in
succession. Callback can optionally raise an NodeProcessed error to
stop stanza from further processing. A type and namespace attributes can
also be optionally passed so the callback is only called when a stanza of
this type is received. Namespace attribute MUST be omitted if you
registering an Iq processing handler.
 
If 'chainOutput' is set to False (the default), the given function
should be defined as follows:
 
     def myCallback(c, p)
 
Where the first parameter is the Client object, and the second
parameter is the [ancestor of] Protocol object representing the stanza
which was received.
 
If 'chainOutput' is set to True, the output from the various
handler functions will be chained together.  In this case,
the given callback function should be defined like this:
 
     def myCallback(c, p, output)
 
Where 'output' is the value returned by the previous
callback function.  For the first callback routine, 'output' will be
set to an empty string.
 
'makefirst' argument gives you control over handler prioriy in its type
and namespace scope. Note that handlers for particular type or namespace always
have lower priority that common handlers.
registerProtocol(self, tag_name, Proto)
Registers a protocol in protocol processing chain. You MUST register
a protocol before you register any handler function for it.
First parameter, that passed to this function is the tag name that
belongs to all protocol elements. F.e.: message, presence, iq, xdb, ...
Second parameter is the [ancestor of] Protocol class, which instance will
built from the received node with call
 
     if received_packet.getName()==tag_name:
         stanza = Proto(node = received_packet)
send(self, what)
Sends a jabber protocol element (Node) to the server
setDisconnectHandler(self, func)
Set the callback for a disconnect.
The given function will be called with a single parameter (the
connection object) when the connection is broken unexpectedly (eg,
in response to sending badly formed XML).  self.lastErr and
self.lastErrCode will be set to the error which caused the
disconnection, if any.
setIqHandler(self, func, type='', ns='')
Back compartibility method
setMessageHandler(self, func, type='', chainOutput=0)
Back compartibility method
setPresenceHandler(self, func, type='', chainOutput=0)
Back compartibility method
waitForResponse(self, ID, timeout=300)
Blocks untils a protocol element with the given id is received.
If an error is received, waitForResponse returns None and
self.lastErr and self.lastErrCode is set to the received error.  If
the operation times out (which only happens if a timeout value is
given), waitForResponse will return None and self.lastErr will be
set to "Timeout".
Changed default from timeout=0 to timeout=300 to avoid hangs in
scripts and such.
If you _really_ want no timeout, just set it to 0

Methods inherited from xmlstream.Client:
connect(self)
Attempt to connect to specified host
getSocket(self)

Methods inherited from xmlstream.Stream:
disconnect(self)
Close the stream and socket
disconnectHandler(self, conn)
Called when a Network Error or disconnection occurs.
Designed to be overidden
disconnected(self, conn)
Called when a Network Error or disconnection occurs.
getIncomingID(self)
Returns the streams ID
getOutgoingID(self)
Returns the streams ID
log(self, data, inout='')
Logs data to the specified filehandle. Data is time stamped
and prefixed with inout
process(self, timeout=0)
Receives incoming data (if any) and processes it.
Waits for data no more than timeout seconds.
read(self)
Reads incoming data. Blocks until done. Calls disconnected(self) if appropriate.
timestampLog(self, timestamp)
Enable or disable the showing of a timestamp in the log.
By default, timestamping is enabled.
write(self, raw_data)
Writes raw outgoing data. Blocks until done.
If supplied data is not unicode string, ENCODING
is used for convertion. Avoid this!
Always send your data as a unicode string.

Methods inherited from xmlstream.NodeBuilder:
DEBUG(self, dup1, dup2=None)
getDom(self)
handle_data(self, data)
XML Parser callback
unknown_endtag(self, tag)
XML Parser callback
unknown_starttag(self, tag, attrs)
XML Parser callback

 
class Connection(xmlstream.Client)
    Forms the base for both Client and Component Classes
 
 
Method resolution order:
Connection
xmlstream.Client
xmlstream.Stream
xmlstream.NodeBuilder

Methods defined here:
SendAndWaitForResponse(self, obj, ID=None, timeout=300)
Sends a protocol element object and blocks until a response with
the same ID is received.  The received protocol object is returned
as the function result.
__init__(self, host, port, namespace, debug=[], log=0, connection=1, hostIP=None, proxy=None)
dispatch(self, stanza)
Called internally when a 'protocol element' is received.
Builds the relevant jabber.py object and dispatches it
to a relevant function or callback.
getAnID(self)
Returns a unique ID
header(self)
registerHandler(self, name, handler, type='', ns='', chained=0, makefirst=0, system=0)
Sets the callback func for processing incoming stanzas.
Multiple callback functions can be set which are called in
succession. Callback can optionally raise an NodeProcessed error to
stop stanza from further processing. A type and namespace attributes can
also be optionally passed so the callback is only called when a stanza of
this type is received. Namespace attribute MUST be omitted if you
registering an Iq processing handler.
 
If 'chainOutput' is set to False (the default), the given function
should be defined as follows:
 
     def myCallback(c, p)
 
Where the first parameter is the Client object, and the second
parameter is the [ancestor of] Protocol object representing the stanza
which was received.
 
If 'chainOutput' is set to True, the output from the various
handler functions will be chained together.  In this case,
the given callback function should be defined like this:
 
     def myCallback(c, p, output)
 
Where 'output' is the value returned by the previous
callback function.  For the first callback routine, 'output' will be
set to an empty string.
 
'makefirst' argument gives you control over handler prioriy in its type
and namespace scope. Note that handlers for particular type or namespace always
have lower priority that common handlers.
registerProtocol(self, tag_name, Proto)
Registers a protocol in protocol processing chain. You MUST register
a protocol before you register any handler function for it.
First parameter, that passed to this function is the tag name that
belongs to all protocol elements. F.e.: message, presence, iq, xdb, ...
Second parameter is the [ancestor of] Protocol class, which instance will
built from the received node with call
 
     if received_packet.getName()==tag_name:
         stanza = Proto(node = received_packet)
send(self, what)
Sends a jabber protocol element (Node) to the server
setDisconnectHandler(self, func)
Set the callback for a disconnect.
The given function will be called with a single parameter (the
connection object) when the connection is broken unexpectedly (eg,
in response to sending badly formed XML).  self.lastErr and
self.lastErrCode will be set to the error which caused the
disconnection, if any.
setIqHandler(self, func, type='', ns='')
Back compartibility method
setMessageHandler(self, func, type='', chainOutput=0)
Back compartibility method
setPresenceHandler(self, func, type='', chainOutput=0)
Back compartibility method
waitForResponse(self, ID, timeout=300)
Blocks untils a protocol element with the given id is received.
If an error is received, waitForResponse returns None and
self.lastErr and self.lastErrCode is set to the received error.  If
the operation times out (which only happens if a timeout value is
given), waitForResponse will return None and self.lastErr will be
set to "Timeout".
Changed default from timeout=0 to timeout=300 to avoid hangs in
scripts and such.
If you _really_ want no timeout, just set it to 0

Methods inherited from xmlstream.Client:
connect(self)
Attempt to connect to specified host
getSocket(self)

Methods inherited from xmlstream.Stream:
disconnect(self)
Close the stream and socket
disconnectHandler(self, conn)
Called when a Network Error or disconnection occurs.
Designed to be overidden
disconnected(self, conn)
Called when a Network Error or disconnection occurs.
getIncomingID(self)
Returns the streams ID
getOutgoingID(self)
Returns the streams ID
log(self, data, inout='')
Logs data to the specified filehandle. Data is time stamped
and prefixed with inout
process(self, timeout=0)
Receives incoming data (if any) and processes it.
Waits for data no more than timeout seconds.
read(self)
Reads incoming data. Blocks until done. Calls disconnected(self) if appropriate.
timestampLog(self, timestamp)
Enable or disable the showing of a timestamp in the log.
By default, timestamping is enabled.
write(self, raw_data)
Writes raw outgoing data. Blocks until done.
If supplied data is not unicode string, ENCODING
is used for convertion. Avoid this!
Always send your data as a unicode string.

Methods inherited from xmlstream.NodeBuilder:
DEBUG(self, dup1, dup2=None)
getDom(self)
handle_data(self, data)
XML Parser callback
unknown_endtag(self, tag)
XML Parser callback
unknown_starttag(self, tag, attrs)
XML Parser callback

 
class Iq(Protocol)
    Class for creating and managing jabber <iq> protocol
elements
 
 
Method resolution order:
Iq
Protocol
xmlstream.Node

Methods defined here:
__init__(self, to=None, type=None, query=None, attrs=None, frm=None, payload=[], node=None)
getList(self)
returns the list namespace
getQuery(self)
returns the query namespace
getQueryNode(self)
Returns any textual data contained by the query tag
getQueryPayload(self)
Returns the query's payload as a Node list
setList(self, namespace)
setQuery(self, namespace)
Sets a query's namespace, and inserts a query tag if
one doesn't already exist.  The resulting query tag
is returned as the function result.
setQueryNode(self, val)
Sets textual data contained by the query tag
setQueryPayload(self, payload, add=0)
Sets a Iq's query payload.  'payload' can be either a Node
structure or a valid xml document. The query tag is automatically
inserted if it doesn't already exist.

Methods inherited from Protocol:
__repr__(self)
asNode(self)
Back compartibility method
fromTo(self)
Swaps the element's from and to attributes.
Note that this is only useful for writing components; if you are
writing a Jabber client you shouldn't use this, because the Jabber
server will set the 'from' field automatically.
getError(self)
Returns the error string, if any
getErrorCode(self)
Returns the error code, if any
getFrom(self)
Returns the 'from' attribute as a JID object.
getID(self)
Returns the 'id' attribute of the protocol element.
getTo(self)
Returns the 'to' attribute as a JID object.
getType(self)
Returns the 'type' attribute of the protocol element.
getX(self, index=0)
Returns the x namespace, optionally passed an index if there are
multiple tags.
getXNode(self, val=None)
Returns the x Node instance. If there are multiple tags
the first Node is returned. For multiple X nodes use getXNodes
or pass an index integer value or namespace string to getXNode
and if a match is found it will be returned.
getXNodes(self)
Returns a list of X nodes.
getXPayload(self, val=None)
Returns the x tags' payload as a list of Node instances.
setError(self, val, code)
Sets an error string and code
setFrom(self, val)
Sets the 'from' element to the given JID.
setID(self, val)
Sets the ID of the protocol element
setTo(self, val)
Sets the 'to' element to the given JID.
setType(self, val)
Sets the 'type' attribute of the protocol element
setX(self, namespace, index=0)
Sets the name space of the x tag. It also creates the node
if it doesn't already exist.
setXNode(self, val='')
Sets the x tag's data to the given textual value.
setXPayload(self, payload, namespace='')
Sets the Child of an 'x' tag. Can be a Node instance or an
XML document

Methods inherited from xmlstream.Node:
__str__(self)
getAttr(self, key)
Get a value for the nodes named attribute.
getChildren(self)
Returns a nodes children
getData(self)
Return the nodes textual data
getDataAsParts(self)
Return the node data as an array
getName(self)
Set the nodes tag name.
getNamespace(self)
Returns the nodes namespace.
getParent(self)
return the nodes parent node.
getTag(self, name, index=None)
Returns a child node with tag name. Returns None
if not found.
getTags(self, name)
Like getTag but returns a list with matching child nodes
insertData(self, data)
Set the nodes textual data
insertNode(self, node)
Add a child node to the node
insertTag(self, name=None, attrs={}, payload=[], node=None)
Add a child tag of name 'name' to the node.
 
Returns the newly created node.
insertXML(self, xml_str)
Add raw xml as a child of the node
putAttr(self, key, val)
Add a name/value attribute to the node.
putData(self, data)
Set the nodes textual data
removeTag(self, tag)
Pops out specified child and returns it.
setName(self, val)
Set the nodes tag name.
setNamespace(self, namespace)
Set the nodes namespace.
setParent(self, node)
Set the nodes parent node.

 
class JID
    A Simple class for managing jabber users id's
 
  Methods defined here:
__eq__(self, other)
Returns whether this JID is identical to another one.
The "other" can be a JID object or a string.
__init__(self, jid='', node='', domain='', resource='')
__repr__ = __str__(self)
__str__(self)
getDomain(self)
Returns JID domain as string or None if absent
getNode(self)
Returns JID Node as string
getResource(self)
Returns JID resource as string or None if absent
getStripped(self)
Returns a JID string with no resource
setDomain(self, val)
Sets JID domain from string
setNode(self, val)
Sets JID Node from string
setResource(self, val)
Sets JID resource from string

 
class Log(Protocol)
    
Method resolution order:
Log
Protocol
xmlstream.Node

Methods defined here:
__init__(self, attrs=None, type=None, frm=None, to=None, payload=[], node=None)
## eg: <log type='warn' from='component'>Hello Log File</log>
getBody(self)
Returns the log message text.
setBody(self, val)
Sets the log message text.

Methods inherited from Protocol:
__repr__(self)
asNode(self)
Back compartibility method
fromTo(self)
Swaps the element's from and to attributes.
Note that this is only useful for writing components; if you are
writing a Jabber client you shouldn't use this, because the Jabber
server will set the 'from' field automatically.
getError(self)
Returns the error string, if any
getErrorCode(self)
Returns the error code, if any
getFrom(self)
Returns the 'from' attribute as a JID object.
getID(self)
Returns the 'id' attribute of the protocol element.
getTo(self)
Returns the 'to' attribute as a JID object.
getType(self)
Returns the 'type' attribute of the protocol element.
getX(self, index=0)
Returns the x namespace, optionally passed an index if there are
multiple tags.
getXNode(self, val=None)
Returns the x Node instance. If there are multiple tags
the first Node is returned. For multiple X nodes use getXNodes
or pass an index integer value or namespace string to getXNode
and if a match is found it will be returned.
getXNodes(self)
Returns a list of X nodes.
getXPayload(self, val=None)
Returns the x tags' payload as a list of Node instances.
setError(self, val, code)
Sets an error string and code
setFrom(self, val)
Sets the 'from' element to the given JID.
setID(self, val)
Sets the ID of the protocol element
setTo(self, val)
Sets the 'to' element to the given JID.
setType(self, val)
Sets the 'type' attribute of the protocol element
setX(self, namespace, index=0)
Sets the name space of the x tag. It also creates the node
if it doesn't already exist.
setXNode(self, val='')
Sets the x tag's data to the given textual value.
setXPayload(self, payload, namespace='')
Sets the Child of an 'x' tag. Can be a Node instance or an
XML document

Methods inherited from xmlstream.Node:
__str__(self)
getAttr(self, key)
Get a value for the nodes named attribute.
getChildren(self)
Returns a nodes children
getData(self)
Return the nodes textual data
getDataAsParts(self)
Return the node data as an array
getName(self)
Set the nodes tag name.
getNamespace(self)
Returns the nodes namespace.
getParent(self)
return the nodes parent node.
getTag(self, name, index=None)
Returns a child node with tag name. Returns None
if not found.
getTags(self, name)
Like getTag but returns a list with matching child nodes
insertData(self, data)
Set the nodes textual data
insertNode(self, node)
Add a child node to the node
insertTag(self, name=None, attrs={}, payload=[], node=None)
Add a child tag of name 'name' to the node.
 
Returns the newly created node.
insertXML(self, xml_str)
Add raw xml as a child of the node
putAttr(self, key, val)
Add a name/value attribute to the node.
putData(self, data)
Set the nodes textual data
removeTag(self, tag)
Pops out specified child and returns it.
setName(self, val)
Set the nodes tag name.
setNamespace(self, namespace)
Set the nodes namespace.
setParent(self, node)
Set the nodes parent node.

 
class Message(Protocol)
    Builds on the Protocol class to provide an interface for sending
message protocol elements
 
 
Method resolution order:
Message
Protocol
xmlstream.Node

Methods defined here:
__init__(self, to=None, body=None, type=None, subject=None, attrs=None, frm=None, payload=[], node=None)
buildReply(self, reply_txt='')
Returns a new Message object as a reply to itself.
The reply message has the 'to', 'type' and 'thread' attributes
automatically set.
build_reply(self, reply_txt='')
getBody(self)
Returns the message body.
getSubject(self)
Returns the message's subject.
getThread(self)
Returns the message's thread ID.
getTimestamp(self)
setBody(self, val)
Sets the message body text.
setSubject(self, val)
Sets the message subject text.
setThread(self, val)
Sets the message thread ID.
setTimestamp(self, val=None)

Methods inherited from Protocol:
__repr__(self)
asNode(self)
Back compartibility method
fromTo(self)
Swaps the element's from and to attributes.
Note that this is only useful for writing components; if you are
writing a Jabber client you shouldn't use this, because the Jabber
server will set the 'from' field automatically.
getError(self)
Returns the error string, if any
getErrorCode(self)
Returns the error code, if any
getFrom(self)
Returns the 'from' attribute as a JID object.
getID(self)
Returns the 'id' attribute of the protocol element.
getTo(self)
Returns the 'to' attribute as a JID object.
getType(self)
Returns the 'type' attribute of the protocol element.
getX(self, index=0)
Returns the x namespace, optionally passed an index if there are
multiple tags.
getXNode(self, val=None)
Returns the x Node instance. If there are multiple tags
the first Node is returned. For multiple X nodes use getXNodes
or pass an index integer value or namespace string to getXNode
and if a match is found it will be returned.
getXNodes(self)
Returns a list of X nodes.
getXPayload(self, val=None)
Returns the x tags' payload as a list of Node instances.
setError(self, val, code)
Sets an error string and code
setFrom(self, val)
Sets the 'from' element to the given JID.
setID(self, val)
Sets the ID of the protocol element
setTo(self, val)
Sets the 'to' element to the given JID.
setType(self, val)
Sets the 'type' attribute of the protocol element
setX(self, namespace, index=0)
Sets the name space of the x tag. It also creates the node
if it doesn't already exist.
setXNode(self, val='')
Sets the x tag's data to the given textual value.
setXPayload(self, payload, namespace='')
Sets the Child of an 'x' tag. Can be a Node instance or an
XML document

Methods inherited from xmlstream.Node:
__str__(self)
getAttr(self, key)
Get a value for the nodes named attribute.
getChildren(self)
Returns a nodes children
getData(self)
Return the nodes textual data
getDataAsParts(self)
Return the node data as an array
getName(self)
Set the nodes tag name.
getNamespace(self)
Returns the nodes namespace.
getParent(self)
return the nodes parent node.
getTag(self, name, index=None)
Returns a child node with tag name. Returns None
if not found.
getTags(self, name)
Like getTag but returns a list with matching child nodes
insertData(self, data)
Set the nodes textual data
insertNode(self, node)
Add a child node to the node
insertTag(self, name=None, attrs={}, payload=[], node=None)
Add a child tag of name 'name' to the node.
 
Returns the newly created node.
insertXML(self, xml_str)
Add raw xml as a child of the node
putAttr(self, key, val)
Add a name/value attribute to the node.
putData(self, data)
Set the nodes textual data
removeTag(self, tag)
Pops out specified child and returns it.
setName(self, val)
Set the nodes tag name.
setNamespace(self, namespace)
Set the nodes namespace.
setParent(self, node)
Set the nodes parent node.

 
class NodeProcessed(exceptions.Exception)
     Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class Presence(Protocol)
    Class for creating and managing jabber <presence> protocol
elements
 
 
Method resolution order:
Presence
Protocol
xmlstream.Node

Methods defined here:
__init__(self, to=None, type=None, priority=None, show=None, status=None, attrs=None, frm=None, payload=[], node=None)
getPriority(self)
Returns the presence priority
getShow(self)
Returns the presence show
getStatus(self)
Returns the presence status
setPriority(self, val)
Sets the presence priority
setShow(self, val)
Sets the presence show
setStatus(self, val)
Sets the presence status

Methods inherited from Protocol:
__repr__(self)
asNode(self)
Back compartibility method
fromTo(self)
Swaps the element's from and to attributes.
Note that this is only useful for writing components; if you are
writing a Jabber client you shouldn't use this, because the Jabber
server will set the 'from' field automatically.
getError(self)
Returns the error string, if any
getErrorCode(self)
Returns the error code, if any
getFrom(self)
Returns the 'from' attribute as a JID object.
getID(self)
Returns the 'id' attribute of the protocol element.
getTo(self)
Returns the 'to' attribute as a JID object.
getType(self)
Returns the 'type' attribute of the protocol element.
getX(self, index=0)
Returns the x namespace, optionally passed an index if there are
multiple tags.
getXNode(self, val=None)
Returns the x Node instance. If there are multiple tags
the first Node is returned. For multiple X nodes use getXNodes
or pass an index integer value or namespace string to getXNode
and if a match is found it will be returned.
getXNodes(self)
Returns a list of X nodes.
getXPayload(self, val=None)
Returns the x tags' payload as a list of Node instances.
setError(self, val, code)
Sets an error string and code
setFrom(self, val)
Sets the 'from' element to the given JID.
setID(self, val)
Sets the ID of the protocol element
setTo(self, val)
Sets the 'to' element to the given JID.
setType(self, val)
Sets the 'type' attribute of the protocol element
setX(self, namespace, index=0)
Sets the name space of the x tag. It also creates the node
if it doesn't already exist.
setXNode(self, val='')
Sets the x tag's data to the given textual value.
setXPayload(self, payload, namespace='')
Sets the Child of an 'x' tag. Can be a Node instance or an
XML document

Methods inherited from xmlstream.Node:
__str__(self)
getAttr(self, key)
Get a value for the nodes named attribute.
getChildren(self)
Returns a nodes children
getData(self)
Return the nodes textual data
getDataAsParts(self)
Return the node data as an array
getName(self)
Set the nodes tag name.
getNamespace(self)
Returns the nodes namespace.
getParent(self)
return the nodes parent node.
getTag(self, name, index=None)
Returns a child node with tag name. Returns None
if not found.
getTags(self, name)
Like getTag but returns a list with matching child nodes
insertData(self, data)
Set the nodes textual data
insertNode(self, node)
Add a child node to the node
insertTag(self, name=None, attrs={}, payload=[], node=None)
Add a child tag of name 'name' to the node.
 
Returns the newly created node.
insertXML(self, xml_str)
Add raw xml as a child of the node
putAttr(self, key, val)
Add a name/value attribute to the node.
putData(self, data)
Set the nodes textual data
removeTag(self, tag)
Pops out specified child and returns it.
setName(self, val)
Set the nodes tag name.
setNamespace(self, namespace)
Set the nodes namespace.
setParent(self, node)
Set the nodes parent node.

 
class Protocol(xmlstream.Node)
    Base class for jabber 'protocol elements' - messages, presences and iqs.
Implements methods that are common to all these
 
  Methods defined here:
__init__(self, name=None, to=None, type=None, attrs=None, frm=None, payload=[], node=None)
__repr__(self)
asNode(self)
Back compartibility method
fromTo(self)
Swaps the element's from and to attributes.
Note that this is only useful for writing components; if you are
writing a Jabber client you shouldn't use this, because the Jabber
server will set the 'from' field automatically.
getError(self)
Returns the error string, if any
getErrorCode(self)
Returns the error code, if any
getFrom(self)
Returns the 'from' attribute as a JID object.
getID(self)
Returns the 'id' attribute of the protocol element.
getTo(self)
Returns the 'to' attribute as a JID object.
getType(self)
Returns the 'type' attribute of the protocol element.
getX(self, index=0)
Returns the x namespace, optionally passed an index if there are
multiple tags.
getXNode(self, val=None)
Returns the x Node instance. If there are multiple tags
the first Node is returned. For multiple X nodes use getXNodes
or pass an index integer value or namespace string to getXNode
and if a match is found it will be returned.
getXNodes(self)
Returns a list of X nodes.
getXPayload(self, val=None)
Returns the x tags' payload as a list of Node instances.
setError(self, val, code)
Sets an error string and code
setFrom(self, val)
Sets the 'from' element to the given JID.
setID(self, val)
Sets the ID of the protocol element
setTo(self, val)
Sets the 'to' element to the given JID.
setType(self, val)
Sets the 'type' attribute of the protocol element
setX(self, namespace, index=0)
Sets the name space of the x tag. It also creates the node
if it doesn't already exist.
setXNode(self, val='')
Sets the x tag's data to the given textual value.
setXPayload(self, payload, namespace='')
Sets the Child of an 'x' tag. Can be a Node instance or an
XML document

Methods inherited from xmlstream.Node:
__str__(self)
getAttr(self, key)
Get a value for the nodes named attribute.
getChildren(self)
Returns a nodes children
getData(self)
Return the nodes textual data
getDataAsParts(self)
Return the node data as an array
getName(self)
Set the nodes tag name.
getNamespace(self)
Returns the nodes namespace.
getParent(self)
return the nodes parent node.
getTag(self, name, index=None)
Returns a child node with tag name. Returns None
if not found.
getTags(self, name)
Like getTag but returns a list with matching child nodes
insertData(self, data)
Set the nodes textual data
insertNode(self, node)
Add a child node to the node
insertTag(self, name=None, attrs={}, payload=[], node=None)
Add a child tag of name 'name' to the node.
 
Returns the newly created node.
insertXML(self, xml_str)
Add raw xml as a child of the node
putAttr(self, key, val)
Add a name/value attribute to the node.
putData(self, data)
Set the nodes textual data
removeTag(self, tag)
Pops out specified child and returns it.
setName(self, val)
Set the nodes tag name.
setNamespace(self, namespace)
Set the nodes namespace.
setParent(self, node)
Set the nodes parent node.

 
class Roster
    A Class for simplifying roster management. Also tracks roster
item availability.
 
  Methods defined here:
__init__(self)
getAsk(self, jid)
Returns the 'ask' status for a Roster item with the given jid.
getGroups(self, jid)
Returns the lsit of groups associated with the given roster item.
getJIDs(self)
Returns a list of JIDs stored within the roster.  Each entry in the
list is a JID object.
getName(self, jid)
Returns the 'name' for a Roster item with the given jid.
getOnline(self, jid)
Returns the 'online' status for a Roster item with the given jid.
getRaw(self)
Returns the internal data representation of the roster.
getShow(self, jid)
Returns the 'show' value for a Roster item with the given jid.
getStatus(self, jid)
Returns the 'status' value for a Roster item with the given jid.
getSub(self, jid)
Returns the 'subscription' status for a Roster item with the given
jid.
getSummary(self)
Returns a summary of the roster's contents.  The returned value is a
dictionary mapping the basic (no resource) JIDs to their current
availability status (online, offline, pending).
isOnline(self, jid)
Returns True if the given jid is online, False if not.
setListener(self, listener)
Set a listener function to be called whenever the roster changes.
 
The given function will be called whenever the contents of the
roster changes in response to a received <presence> or <iq> packet.
The listener function should be defined as follows:
 
    def listener(action, jid, info)
 
'action' is a string indicating what type of change has occurred:
 
    "add"     A new item has been added to the roster.
    "update"  An existing roster item has been updated.
    "remove"  A roster entry has been removed.
 
'jid' is the Jabber ID (as a string) of the affected roster entry.
 
'info' is a dictionary containing the information that has been
added or updated for this roster entry.  This dictionary may
contain any combination of the following:
 
    "name"    The associated name of this roster entry.
    "groups"  A list of groups associated with this roster entry.
    "online"  The roster entry's "online" value ("online",
              "offline" or "pending").
    "sub"     The roster entry's subscription value ("none",
              "from", "to" or "both").
    "ask"     The roster entry's ask value, if any (None,
              "subscribe", "unsubscribe").
    "show"    The roster entry's show value, if any (None, "away",
              "chat", "dnd", "normal", "xa").
    "status"  The roster entry's current 'status' value, if
              specified.

 
class Server
    

 
class XDB(Protocol)
    
Method resolution order:
XDB
Protocol
xmlstream.Node

Methods defined here:
__init__(self, attrs=None, type=None, frm=None, to=None, payload=[], node=None)

Methods inherited from Protocol:
__repr__(self)
asNode(self)
Back compartibility method
fromTo(self)
Swaps the element's from and to attributes.
Note that this is only useful for writing components; if you are
writing a Jabber client you shouldn't use this, because the Jabber
server will set the 'from' field automatically.
getError(self)
Returns the error string, if any
getErrorCode(self)
Returns the error code, if any
getFrom(self)
Returns the 'from' attribute as a JID object.
getID(self)
Returns the 'id' attribute of the protocol element.
getTo(self)
Returns the 'to' attribute as a JID object.
getType(self)
Returns the 'type' attribute of the protocol element.
getX(self, index=0)
Returns the x namespace, optionally passed an index if there are
multiple tags.
getXNode(self, val=None)
Returns the x Node instance. If there are multiple tags
the first Node is returned. For multiple X nodes use getXNodes
or pass an index integer value or namespace string to getXNode
and if a match is found it will be returned.
getXNodes(self)
Returns a list of X nodes.
getXPayload(self, val=None)
Returns the x tags' payload as a list of Node instances.
setError(self, val, code)
Sets an error string and code
setFrom(self, val)
Sets the 'from' element to the given JID.
setID(self, val)
Sets the ID of the protocol element
setTo(self, val)
Sets the 'to' element to the given JID.
setType(self, val)
Sets the 'type' attribute of the protocol element
setX(self, namespace, index=0)
Sets the name space of the x tag. It also creates the node
if it doesn't already exist.
setXNode(self, val='')
Sets the x tag's data to the given textual value.
setXPayload(self, payload, namespace='')
Sets the Child of an 'x' tag. Can be a Node instance or an
XML document

Methods inherited from xmlstream.Node:
__str__(self)
getAttr(self, key)
Get a value for the nodes named attribute.
getChildren(self)
Returns a nodes children
getData(self)
Return the nodes textual data
getDataAsParts(self)
Return the node data as an array
getName(self)
Set the nodes tag name.
getNamespace(self)
Returns the nodes namespace.
getParent(self)
return the nodes parent node.
getTag(self, name, index=None)
Returns a child node with tag name. Returns None
if not found.
getTags(self, name)
Like getTag but returns a list with matching child nodes
insertData(self, data)
Set the nodes textual data
insertNode(self, node)
Add a child node to the node
insertTag(self, name=None, attrs={}, payload=[], node=None)
Add a child tag of name 'name' to the node.
 
Returns the newly created node.
insertXML(self, xml_str)
Add raw xml as a child of the node
putAttr(self, key, val)
Add a name/value attribute to the node.
putData(self, data)
Set the nodes textual data
removeTag(self, tag)
Pops out specified child and returns it.
setName(self, val)
Set the nodes tag name.
setNamespace(self, namespace)
Set the nodes namespace.
setParent(self, node)
Set the nodes parent node.

 
Functions
       
ustr(what)
If sending object is already a unicode str, just
return it, otherwise convert it using xmlstream.ENCODING

 
Data
        DBG_ALWAYS = 'always'
DBG_DISPATCH = 'jb-dispatch'
DBG_INIT = 'init'
DBG_NODE = 'jb-node'
DBG_NODE_IQ = 'jb-node-iq'
DBG_NODE_MESSAGE = 'jb-node-message'
DBG_NODE_PRESENCE = 'jb-node-pressence'
DBG_NODE_UNKNOWN = 'jb-node-unknown'
False = 0
NS_AGENT = 'jabber:iq:agent'
NS_AGENTS = 'jabber:iq:agents'
NS_AUTH = 'jabber:iq:auth'
NS_BROWSE = 'jabber:iq:browse'
NS_CLIENT = 'jabber:client'
NS_COMP_ACCEPT = 'jabber:component:accept'
NS_COMP_CONNECT = 'jabber:component:connect'
NS_DELAY = 'jabber:x:delay'
NS_LAST = 'jabber:iq:last'
NS_OOB = 'jabber:iq:oob'
NS_PASS = 'jabber:iq:pass'
NS_PRIVACY = 'jabber:iq:privacy'
NS_P_COMMANDS = 'http://jabber.org/protocol/commands'
NS_P_DISC_INFO = 'http://jabber.org/protocol/disco#info'
NS_P_DISC_ITEMS = 'http://jabber.org/protocol/disco#items'
NS_P_MUC = 'http://jabber.org/protocol/muc'
NS_REGISTER = 'jabber:iq:register'
NS_ROSTER = 'jabber:iq:roster'
NS_RPC = 'jabber:iq:rpc'
NS_SERVER = 'jabber:server'
NS_TIME = 'jabber:iq:time'
NS_VCARD = 'vcard-temp'
NS_VERSION = 'jabber:iq:version'
NS_XDATA = 'jabber:x:data'
NS_XENCRYPTED = 'jabber:x:encrypted'
NS_XEVENT = 'jabber:x:event'
NS_XEXPIRE = 'jabber:x:expire'
NS_XROSTER = 'jabber:x:roster'
NS_XSIGNED = 'jabber:x:signed'
RS_ASK_SUBSCRIBE = 1
RS_ASK_UNSUBSCRIBE = 0
RS_EXT_OFFLINE = 1
RS_EXT_ONLINE = 2
RS_EXT_PENDING = 0
RS_SUB_BOTH = 0
RS_SUB_FROM = 1
RS_SUB_TO = 2
True = 1
VERSION = '0.5'
timeout = 300