QXmppClient Class Reference
[Core]

The QXmppClient class is the main class for using QXmpp. More...

#include <QXmppClient.h>

List of all members.

Public Types

enum  Error { SocketError, KeepAliveError, XmppStreamError }

Public Slots

bool sendPacket (const QXmppPacket &)
void sendMessage (const QString &bareJid, const QString &message)

Signals

void connected ()
void disconnected ()
void error (QXmppClient::Error)
void elementReceived (const QDomElement &element, bool &handled)
void messageReceived (const QXmppMessage &)
void presenceReceived (const QXmppPresence &)
void iqReceived (const QXmppIq &)
void discoveryIqReceived (const QXmppDiscoveryIq &)
 Notifies that an XMPP service discovery iq stanza is received.
void logMessage (QXmppLogger::MessageType type, const QString &msg)
 This signal is emitted to send logging messages.

Public Member Functions

 QXmppClient (QObject *parent=0)
 ~QXmppClient ()
void connectToServer (const QString &host, const QString &user, const QString &passwd, const QString &domain, int port=5222, const QXmppPresence &initialPresence=QXmppPresence())
void connectToServer (const QString &host, const QString &bareJid, const QString &passwd, int port=5222, const QXmppPresence &initialPresence=QXmppPresence())
void connectToServer (const QXmppConfiguration &, const QXmppPresence &initialPresence=QXmppPresence())
void disconnectFromServer ()
bool isConnected () const
QXmppPresence clientPresence () const
void setClientPresence (const QXmppPresence &presence)
QXmppConfigurationconfiguration ()
QXmppLoggerlogger ()
 Returns the QXmppLogger associated with the current QXmppClient.
void setLogger (QXmppLogger *logger)
 Sets the QXmppLogger associated with the current QXmppClient.
QAbstractSocket::SocketError socketError ()
QXmppStanza::Error::Condition xmppStreamError ()
QXmppArchiveManagerarchiveManager ()
QXmppCallManagercallManager ()
QXmppMucManagermucManager ()
QXmppRosterManagerrosterManager ()
QXmppTransferManagertransferManager ()
QXmppVCardManagervCardManager ()
QXmppReconnectionManager * reconnectionManager ()
bool setReconnectionManager (QXmppReconnectionManager *)

Detailed Description

The QXmppClient class is the main class for using QXmpp.

It provides the user all the required functionality to connect to the server and perform operations afterwards.

This class will provide the handle/reference to QXmppRosterManager (roster management), QXmppVCardManager (vCard manager), QXmppReconnectionManager (reconnection mechanism) and QXmppTransferManager (file transfers).

By default, a reconnection mechanism exists, which makes sure of reconnecting to the server on disconnections due to an error. User can have a custom reconnection mechanism as well.

For removing QXmpp dependency in QtGui, use DEFINES += QXMPP_NO_GUI in the source.pro file and build as usual.


Member Enumeration Documentation

An enumeration for type of error. Error could come due a TCP socket or XML stream or due to various stanzas.

Enumerator:
SocketError 

Error due to TCP socket.

KeepAliveError 

Error due to no response to a keep alive.

XmppStreamError 

Error due to XML stream.


Constructor & Destructor Documentation

QXmppClient::QXmppClient ( QObject *  parent = 0  ) 

Creates a QXmppClient object.

Parameters:
parent is passed to the QObject's constructor. The default value is 0.
QXmppClient::~QXmppClient (  ) 

Destructor, destroys the QXmppClient object.


Member Function Documentation

QXmppArchiveManager & QXmppClient::archiveManager (  ) 

Returns the reference to QXmppArchiveManager, implementation of XEP-0136. http://xmpp.org/extensions/xep-0136.html

QXmppCallManager & QXmppClient::callManager (  ) 

Returns the reference to QXmppCallManager, implementation of XEP-0166. http://xmpp.org/extensions/xep-0166.html

QXmppPresence QXmppClient::clientPresence (  )  const

Returns the client's current presence.

QXmppConfiguration & QXmppClient::configuration (  ) 

Returns a modifiable reference to the current configuration of QXmppClient.

Returns:
Reference to the QXmppClient's configuration for the connection.
void QXmppClient::connected (  )  [signal]

This signal is emitted when the client connects successfully to the XMPP server i.e. when a successful XMPP connection is established. XMPP Connection involves following sequential steps:

  • TCP socket connection
  • Client sends start stream
  • Server sends start stream
  • TLS negotiation (encryption)
  • Authentication
  • Resource binding
  • Session establishment

After all these steps a successful XMPP connection is established and connected() signal is emitted.

After the connected() signal is emitted QXmpp will send the roster request to the server. On receiving the roster, QXmpp will emit QXmppRosterManager::rosterReceived(). After this signal, QXmppRosterManager object gets populated and you can use rosterManager() to get the handle of QXmppRosterManager object.

void QXmppClient::connectToServer ( const QXmppConfiguration config,
const QXmppPresence initialPresence = QXmppPresence() 
)

Attempts to connect to the XMPP server. Server details and other configurations are specified using the config parameter. Use signals connected(), error(QXmppClient::Error) and disconnected() to know the status of the connection.

Parameters:
config Specifies the configuration object for connecting the XMPP server. This contains the host name, user, passwd etc. See QXmppConfiguration for details.
initialPresence The initial presence which will be set for this user after establishing the session. The default value is QXmppPresence::Available
void QXmppClient::connectToServer ( const QString &  host,
const QString &  bareJid,
const QString &  passwd,
int  port = 5222,
const QXmppPresence initialPresence = QXmppPresence() 
)

Overloaded function.

Parameters:
host host name of the XMPP server where connection has to be made (e.g. "jabber.org" and "talk.google.com"). It can also be an IP address in the form of a string (e.g. "192.168.1.25").
bareJid BareJid of the account at the specified XMPP server. (e.g. "qxmpp.test1@gmail.com" or qxmpptest@jabber.org.)
passwd Password for the specified username
port Port number at which the XMPP server is listening. The default value is 5222.
initialPresence The initial presence which will be set for this user after establishing the session. The default value is QXmppPresence::Available
void QXmppClient::connectToServer ( const QString &  host,
const QString &  user,
const QString &  passwd,
const QString &  domain,
int  port = 5222,
const QXmppPresence initialPresence = QXmppPresence() 
)

Overloaded function.

Parameters:
host host name of the XMPP server where connection has to be made (e.g. "jabber.org" and "talk.google.com"). It can also be an IP address in the form of a string (e.g. "192.168.1.25").
user Username of the account at the specified XMPP server. It should be the name without the domain name. E.g. "qxmpp.test1" and not "qxmpp.test1@gmail.com"
passwd Password for the specified username
domain Domain name e.g. "gmail.com" and "jabber.org".
port Port number at which the XMPP server is listening. The default value is 5222.
initialPresence The initial presence which will be set for this user after establishing the session. The default value is QXmppPresence::Available
void QXmppClient::disconnected (  )  [signal]

This signal is emitted when the XMPP connection disconnects.

void QXmppClient::disconnectFromServer (  ) 

Disconnects the client and the current presence of client changes to QXmppPresence::Unavailable and status text changes to "Logged out".

Note:
Make sure that the clientPresence is changed to QXmppPresence::Available, if you are again calling connectToServer() after calling the disconnectFromServer() function.
void QXmppClient::elementReceived ( const QDomElement &  element,
bool &  handled 
) [signal]

This signal is emitted when a raw XML element is received. You can connect to this signal if you want to handle raw XML elements yourself.

WARNING: this signal is experimental and you can seriously disrupt packet handling when using it, so use with care and at your own risk.

Set 'handled' to true if you handled the element yourself and you wish to bypass normal handling for the element. If you do this, QXmpp will do absolutely no processing itself, so do not expect the usual signals to be emitted.

void QXmppClient::error ( QXmppClient::Error   )  [signal]

This signal is emitted when the XMPP connection encounters any error. The QXmppClient::Error parameter specifies the type of error occurred. It could be due to TCP socket or the xml stream or the stanza. Depending upon the type of error occurred use the respective get function to know the error.

void QXmppClient::iqReceived ( const QXmppIq  )  [signal]

Notifies that an XMPP iq stanza is received. The QXmppIq parameter contains the details of the iq sent to this client. IQ stanzas provide a structured request-response mechanism. Roster management, setting-getting vCards etc is done using iq stanzas.

bool QXmppClient::isConnected (  )  const

Returns true if the client is connected to the XMPP server.

void QXmppClient::messageReceived ( const QXmppMessage  )  [signal]

Notifies that an XMPP message stanza is received. The QXmppMessage parameter contains the details of the message sent to this client. In other words whenever someone sends you a message this signal is emitted.

QXmppMucManager & QXmppClient::mucManager (  ) 

Returns the reference to QXmppMucManager, implementation of XEP-0045. http://xmpp.org/extensions/xep-045.html

void QXmppClient::presenceReceived ( const QXmppPresence  )  [signal]

Notifies that an XMPP presence stanza is received. The QXmppPresence parameter contains the details of the presence sent to this client. This signal is emitted when someone login/logout or when someone's status changes Busy, Idle, Invisible etc.

QXmppReconnectionManager * QXmppClient::reconnectionManager (  ) 

Function to get reconnection manager. By default there exists a reconnection manager. See QXmppReconnectionManager for more details of the reconnection mechanism.

Returns:
Pointer to QXmppReconnectionManager
QXmppRosterManager & QXmppClient::rosterManager (  ) 

Returns the reference to QXmppRosterManager object of the client.

Returns:
Reference to the roster object of the connected client. Use this to get the list of friends in the roster and their presence information.
void QXmppClient::sendMessage ( const QString &  bareJid,
const QString &  message 
) [slot]

Utility function to send message to all the resources associated with the specified bareJid.

Parameters:
bareJid bareJid of the receiving entity
message Message string to be sent.
bool QXmppClient::sendPacket ( const QXmppPacket &  packet  )  [slot]

After successfully connecting to the server use this function to send stanzas to the server. This function can solely be used to send various kind of stanzas to the server. QXmppPacket is a parent class of all the stanzas QXmppMessage, QXmppPresence, QXmppIq, QXmppBind, QXmppRosterIq, QXmppSession and QXmppVCard.

Returns:
Returns true if the packet was sent, false otherwise.

Following code snippet illustrates how to send a message using this function:

 QXmppMessage message(from, to, message);
 client.sendPacket(message);
Parameters:
packet A valid XMPP stanza. It can be an iq, a message or a presence stanza.
void QXmppClient::setClientPresence ( const QXmppPresence presence  ) 

Changes the presence of the connected client.

The connection to the server will be updated accordingly:

  • If the presence type is QXmppPresence::Unavailable, the connection to the server will be closed.
  • Otherwise, the connection to the server will be established as needed.
Parameters:
presence QXmppPresence object
bool QXmppClient::setReconnectionManager ( QXmppReconnectionManager *  reconnectionManager  ) 

Sets the user defined reconnection manager.

Returns:
true if all the signal-slot connections are made correctly.
QAbstractSocket::SocketError QXmppClient::socketError (  ) 

Returns the socket error if error() is QXmppClient::SocketError.

QXmppTransferManager & QXmppClient::transferManager (  ) 

Returns the reference to QXmppTransferManager, implementation of:

XEP-0047: In-Band Bytestreams XEP-0095: Stream Initiation XEP-0096: SI File Transfer

QXmppVCardManager & QXmppClient::vCardManager (  ) 

Returns the reference to QXmppVCardManager, implimentation of XEP-0054. http://xmpp.org/extensions/xep-0054.html

QXmppStanza::Error::Condition QXmppClient::xmppStreamError (  ) 

Returns the XMPP stream error if QXmppClient::Error is QXmppClient::XmppStreamError.


The documentation for this class was generated from the following files:
 All Classes Functions Enumerations Enumerator

Generated on Sun Aug 22 16:04:13 2010 for QXmpp by  doxygen 1.6.1