Public Member Functions | Public Attributes | Protected Member Functions

Swift::Client Class Reference

Provides the core functionality for writing XMPP client software. More...

Inheritance diagram for Swift::Client:
Collaboration diagram for Swift::Client:

List of all members.

Public Member Functions

 Client (const JID &jid, const SafeString &password, NetworkFactories *networkFactories, Storages *storages=NULL)
 Constructs a client for the given JID with the given password.
 ~Client ()
void setSoftwareVersion (const std::string &name, const std::string &version, const std::string &os="")
 Sets the software version of the client.
XMPPRostergetRoster () const
 Returns a representation of the roster.
void requestRoster ()
 Requests the roster from the server.
boost::shared_ptr< PresencegetLastPresence (const JID &jid) const
 Returns the last received presence for the given (full) JID.
boost::shared_ptr< PresencegetHighestPriorityPresence (const JID &bareJID) const
 Returns the presence with the highest priority received for the given JID.
PresenceOraclegetPresenceOracle () const
PresenceSendergetPresenceSender () const
MUCManagergetMUCManager () const
MUCRegistrygetMUCRegistry () const
VCardManagergetVCardManager () const
AvatarManagergetAvatarManager () const
EntityCapsProvidergetEntityCapsProvider () const
NickManager * getNickManager () const
NickResolvergetNickResolver () const
SubscriptionManagergetSubscriptionManager () const
ClientDiscoManagergetDiscoManager () const
FileTransferManager * getFileTransferManager () const
 Returns a FileTransferManager for the client.
void setAlwaysTrustCertificates ()
 Configures the client to always trust a non-validating TLS certificate from the server.
WhiteboardSessionManager * getWhiteboardSessionManager () const
void setCertificate (CertificateWithKey::ref certificate)
 Set a client certificate to use for strong authentication with the server.
void connect (const ClientOptions &=ClientOptions())
 Connects the client to the server.
void disconnect ()
 Disconnects the client from the server.
void sendMessage (boost::shared_ptr< Message >)
 Sends a message.
void sendPresence (boost::shared_ptr< Presence >)
 Sends a presence stanza.
void sendData (const std::string &data)
 Sends raw, unchecked data.
IQRoutergetIQRouter () const
 Returns the IQ router for this client.
bool isAvailable () const
 Checks whether the client is connected to the server, and stanzas can be sent.
bool isActive () const
 Checks whether the client is active.
const JIDgetJID () const
 Returns the JID of the client.
bool getStreamManagementEnabled () const
 Checks whether stream management is enabled.
bool isStreamEncrypted () const
 Checks whether stream encryption (TLS) is currently active.
StanzaChannelgetStanzaChannel () const
void setCertificateTrustChecker (CertificateTrustChecker *)
 Sets the certificate trust checker.

Public Attributes

boost::signal< void(boost::shared_ptr
< Presence >)> 
onPresenceChange
 This signal is emitted when a JID changes presence.
boost::signal< void(const
boost::optional< ClientError > &)> 
onDisconnected
 Emitted when the client was disconnected from the network.
boost::signal< void()> onConnected
 Emitted when the client is connected and authenticated, and stanzas can be sent.
boost::signal< void(const
SafeByteArray &)> 
onDataRead
 Emitted when the client receives data.
boost::signal< void(const
SafeByteArray &)> 
onDataWritten
 Emitted when the client sends data.
boost::signal< void(boost::shared_ptr
< Message >)> 
onMessageReceived
 Emitted when a message is received.
boost::signal< void(boost::shared_ptr
< Presence >) > 
onPresenceReceived
 Emitted when a presence stanza is received.
boost::signal< void(boost::shared_ptr
< Stanza >)> 
onStanzaAcked
 Emitted when the server acknowledges receipt of a stanza (if acknowledgements are available).

Protected Member Functions

void handleConnected ()
 Called before onConnected signal is emmitted.
boost::shared_ptr< ClientSession > getSession () const
NetworkFactories * getNetworkFactories () const

Detailed Description

Provides the core functionality for writing XMPP client software.

Besides connecting to an XMPP server, this class also provides interfaces for performing most tasks on the XMPP network.

Definition at line 45 of file Client.h.


Constructor & Destructor Documentation

Swift::Client::Client ( const JID jid,
const SafeString password,
NetworkFactories *  networkFactories,
Storages storages = NULL 
)

Constructs a client for the given JID with the given password.

Parameters:
storages The interfaces for storing cache information etc. If this is NULL, all data will be stored in memory (and be lost on shutdown)
Swift::Client::~Client (  ) 

Member Function Documentation

void Swift::CoreClient::connect ( const ClientOptions &  = ClientOptions()  )  [inherited]

Connects the client to the server.

After the connection is established, the client will set initialize the stream and authenticate.

void Swift::CoreClient::disconnect (  )  [inherited]

Disconnects the client from the server.

AvatarManager* Swift::Client::getAvatarManager (  )  const [inline]

Definition at line 117 of file Client.h.

ClientDiscoManager* Swift::Client::getDiscoManager (  )  const [inline]

Definition at line 133 of file Client.h.

EntityCapsProvider* Swift::Client::getEntityCapsProvider (  )  const
FileTransferManager* Swift::Client::getFileTransferManager (  )  const

Returns a FileTransferManager for the client.

This is only available after the onConnected signal has been fired.

WARNING: File transfer will only work if Swiften is built in 'experimental' mode.

boost::shared_ptr<Presence> Swift::Client::getHighestPriorityPresence ( const JID bareJID  )  const

Returns the presence with the highest priority received for the given JID.

IQRouter* Swift::CoreClient::getIQRouter (  )  const [inline, inherited]

Returns the IQ router for this client.

Definition at line 96 of file CoreClient.h.

const JID& Swift::CoreClient::getJID (  )  const [inherited]

Returns the JID of the client.

After the session was initialized, this returns the bound JID.

boost::shared_ptr<Presence> Swift::Client::getLastPresence ( const JID jid  )  const

Returns the last received presence for the given (full) JID.

MUCManager* Swift::Client::getMUCManager (  )  const [inline]

Definition at line 105 of file Client.h.

MUCRegistry* Swift::Client::getMUCRegistry (  )  const [inline]

Definition at line 109 of file Client.h.

NetworkFactories* Swift::CoreClient::getNetworkFactories (  )  const [inline, protected, inherited]

Definition at line 200 of file CoreClient.h.

NickManager* Swift::Client::getNickManager (  )  const
NickResolver* Swift::Client::getNickResolver (  )  const [inline]

Definition at line 125 of file Client.h.

PresenceOracle* Swift::Client::getPresenceOracle (  )  const [inline]

Definition at line 99 of file Client.h.

PresenceSender* Swift::Client::getPresenceSender (  )  const
XMPPRoster* Swift::Client::getRoster (  )  const

Returns a representation of the roster.

The roster is initially empty. To populate it, call requestRoster(), which will request the roster from the server. When the roster has been requested, it will also be kept up to date when it is updated on the server side.

This pointer remains the same across the lifetime of Client. All changes to the roster (e.g. after the initial roster request, or after subsequent roster updates) are notified through the XMPPRoster's signals.

See also:
requestRoster()
boost::shared_ptr<ClientSession> Swift::CoreClient::getSession (  )  const [inline, protected, inherited]

Definition at line 196 of file CoreClient.h.

StanzaChannel* Swift::CoreClient::getStanzaChannel (  )  const [inherited]
bool Swift::CoreClient::getStreamManagementEnabled (  )  const [inherited]

Checks whether stream management is enabled.

If stream management is enabled, onStanzaAcked will be emitted when a stanza is received by the server.

See also:
onStanzaAcked
SubscriptionManager* Swift::Client::getSubscriptionManager (  )  const [inline]

Definition at line 129 of file Client.h.

VCardManager* Swift::Client::getVCardManager (  )  const [inline]

Definition at line 113 of file Client.h.

WhiteboardSessionManager* Swift::Client::getWhiteboardSessionManager (  )  const
void Swift::Client::handleConnected (  )  [protected, virtual]

Called before onConnected signal is emmitted.

Reimplemented from Swift::CoreClient.

bool Swift::CoreClient::isActive (  )  const [inherited]

Checks whether the client is active.

A client is active when it is connected or connecting to the server.

bool Swift::CoreClient::isAvailable (  )  const [inherited]

Checks whether the client is connected to the server, and stanzas can be sent.

bool Swift::CoreClient::isStreamEncrypted (  )  const [inherited]

Checks whether stream encryption (TLS) is currently active.

void Swift::Client::requestRoster (  ) 

Requests the roster from the server.

See also:
getRoster()
void Swift::CoreClient::sendData ( const std::string &  data  )  [inherited]

Sends raw, unchecked data.

void Swift::CoreClient::sendMessage ( boost::shared_ptr< Message  )  [inherited]

Sends a message.

void Swift::CoreClient::sendPresence ( boost::shared_ptr< Presence  )  [inherited]

Sends a presence stanza.

void Swift::Client::setAlwaysTrustCertificates (  ) 

Configures the client to always trust a non-validating TLS certificate from the server.

This is equivalent to setting a BlindCertificateTrustChecker using setCertificateTrustChecker().

void Swift::CoreClient::setCertificate ( CertificateWithKey::ref  certificate  )  [inherited]

Set a client certificate to use for strong authentication with the server.

Ensure that it is of the correct type for the TLS engine in use. This means, largely, PKCS12Certificate for OpenSSL and CAPICertificate for CAPI.

void Swift::CoreClient::setCertificateTrustChecker ( CertificateTrustChecker  )  [inherited]

Sets the certificate trust checker.

This checker will be called when the server sends a TLS certificate that does not validate. If the trust checker says the certificate is trusted, then connecting will proceed; if not, the connection will end with an error.

void Swift::Client::setSoftwareVersion ( const std::string &  name,
const std::string &  version,
const std::string &  os = "" 
)

Sets the software version of the client.

This will be used to respond to version queries from other entities.


Member Data Documentation

boost::signal<void ()> Swift::CoreClient::onConnected [inherited]

Emitted when the client is connected and authenticated, and stanzas can be sent.

Definition at line 159 of file CoreClient.h.

boost::signal<void (const SafeByteArray&)> Swift::CoreClient::onDataRead [inherited]

Emitted when the client receives data.

This signal is emitted before the XML data is parsed, so this data is unformatted.

Definition at line 167 of file CoreClient.h.

boost::signal<void (const SafeByteArray&)> Swift::CoreClient::onDataWritten [inherited]

Emitted when the client sends data.

This signal is emitted after the XML was serialized, and is unformatted.

Definition at line 175 of file CoreClient.h.

boost::signal<void (const boost::optional<ClientError>&)> Swift::CoreClient::onDisconnected [inherited]

Emitted when the client was disconnected from the network.

If the connection was due to a non-recoverable error, the type of error will be passed as a parameter.

Definition at line 153 of file CoreClient.h.

boost::signal<void (boost::shared_ptr<Message>)> Swift::CoreClient::onMessageReceived [inherited]

Emitted when a message is received.

Definition at line 180 of file CoreClient.h.

boost::signal<void (boost::shared_ptr<Presence>)> Swift::Client::onPresenceChange

This signal is emitted when a JID changes presence.

Definition at line 159 of file Client.h.

boost::signal<void (boost::shared_ptr<Presence>) > Swift::CoreClient::onPresenceReceived [inherited]

Emitted when a presence stanza is received.

Definition at line 185 of file CoreClient.h.

boost::signal<void (boost::shared_ptr<Stanza>)> Swift::CoreClient::onStanzaAcked [inherited]

Emitted when the server acknowledges receipt of a stanza (if acknowledgements are available).

See also:
getStreamManagementEnabled()

Definition at line 193 of file CoreClient.h.