gloox  1.0.28
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
ClientBase Class Referenceabstract

#include <clientbase.h>

Inheritance diagram for ClientBase:
Inheritance graph
[legend]

Public Member Functions

 ClientBase (const std::string &ns, const std::string &server, int port=-1)
 
 ClientBase (const std::string &ns, const std::string &password, const std::string &server, int port=-1)
 
virtual ~ClientBase ()
 
bool connect (bool block=true)
 
virtual ConnectionError recv (int timeout=-1)
 
virtual const std::string & username () const
 
const JIDjid ()
 
void setSasl (bool sasl)
 
void setTls (TLSPolicy tls)
 
void setCompression (bool compression)
 
void setPort (int port)
 
void setServer (const std::string &server)
 
void setPassword (const std::string &password)
 
const std::string & server () const
 
bool sasl () const
 
TLSPolicy tls () const
 
bool compression () const
 
int port () const
 
virtual const std::string & password () const
 
virtual Discodisco () const
 
const std::string getID ()
 
void send (Tag *tag)
 
void send (IQ &iq, IqHandler *ih, int context, bool del=false)
 
void send (const IQ &iq)
 
void send (const Message &msg)
 
void send (const Subscription &sub)
 
void send (const Presence &pres)
 
bool authed () const
 
ConnectionState state () const
 
const std::string & xmlLang () const
 
void setXmlLang (const std::string &xmllang)
 
ConnectionBaseconnectionImpl () const
 
void setConnectionImpl (ConnectionBase *cb)
 
TLSBaseencryptionImpl () const
 
void setEncryptionImpl (TLSBase *tb)
 
CompressionBasecompressionImpl () const
 
void setCompressionImpl (CompressionBase *cb)
 
void whitespacePing ()
 
void xmppPing (const JID &to, EventHandler *eh)
 
void setAuthzid (const JID &authzid)
 
void setAuthcid (const std::string &authcid)
 
void setSASLMechanisms (int mechanisms)
 
void registerStanzaExtension (StanzaExtension *ext)
 
bool removeStanzaExtension (int ext)
 
void registerConnectionListener (ConnectionListener *cl)
 
void registerIqHandler (IqHandler *ih, int exttype)
 
void removeIDHandler (IqHandler *ih)
 
void registerMessageHandler (MessageHandler *mh)
 
void removeMessageHandler (MessageHandler *mh)
 
void registerMessageSession (MessageSession *session)
 
void disposeMessageSession (MessageSession *session)
 
void registerPresenceHandler (PresenceHandler *ph)
 
void registerPresenceHandler (const JID &jid, PresenceHandler *ph)
 
void registerSubscriptionHandler (SubscriptionHandler *sh)
 
void registerTagHandler (TagHandler *th, const std::string &tag, const std::string &xmlns)
 
void registerStatisticsHandler (StatisticsHandler *sh)
 
void removeConnectionListener (ConnectionListener *cl)
 
void removeIqHandler (IqHandler *ih, int exttype)
 
void removePresenceHandler (PresenceHandler *ph)
 
void removePresenceHandler (const JID &jid, PresenceHandler *ph)
 
void removeSubscriptionHandler (SubscriptionHandler *sh)
 
void removeTagHandler (TagHandler *th, const std::string &tag, const std::string &xmlns)
 
void removeStatisticsHandler ()
 
void setCACerts (const StringList &cacerts)
 
void setClientCert (const std::string &clientKey, const std::string &clientCerts)
 
void registerMessageSessionHandler (MessageSessionHandler *msh, int types=0)
 
LogSinklogInstance ()
 
StreamError streamError () const
 
const std::string & streamErrorText (const std::string &lang="default") const
 
const std::string & streamErrorCData () const
 
const TagstreamErrorAppCondition () const
 
AuthenticationError authError () const
 
StatisticsStruct getStatistics ()
 
void registerMUCInvitationHandler (MUCInvitationHandler *mih)
 
void removeMUCInvitationHandler ()
 
void addPresenceExtension (StanzaExtension *se)
 
bool removePresenceExtension (int type)
 
const StanzaExtensionListpresenceExtensions () const
 
const TagList sendQueue ()
 
virtual void handleTag (Tag *tag)
 
virtual void handleCompressedData (const std::string &data)
 
virtual void handleDecompressedData (const std::string &data)
 
virtual void handleReceivedData (const ConnectionBase *connection, const std::string &data)
 
virtual void handleConnect (const ConnectionBase *connection)
 
virtual void handleDisconnect (const ConnectionBase *connection, ConnectionError reason)
 
virtual void handleEncryptedData (const TLSBase *base, const std::string &data)
 
virtual void handleDecryptedData (const TLSBase *base, const std::string &data)
 
virtual void handleHandshakeResult (const TLSBase *base, bool success, CertInfo &certinfo)
 
- Public Member Functions inherited from TagHandler
virtual ~TagHandler ()
 
- Public Member Functions inherited from ConnectionDataHandler
virtual ~ConnectionDataHandler ()
 
- Public Member Functions inherited from CompressionDataHandler
virtual ~CompressionDataHandler ()
 
- Public Member Functions inherited from TLSHandler
virtual ~TLSHandler ()
 
- Public Member Functions inherited from IqHandler
virtual ~IqHandler ()
 

Protected Types

enum  SMContext {
  CtxSMInvalid , CtxSMFailed , CtxSMEnable , CtxSMResume ,
  CtxSMEnabled , CtxSMResumed
}
 

Protected Member Functions

void notifyOnResourceBindError (const Error *error)
 
void notifyOnResourceBind (const std::string &resource)
 
void notifyOnSessionCreateError (const Error *error)
 
bool notifyOnTLSConnect (const CertInfo &info)
 
void notifyOnConnect ()
 
void notifyStreamEvent (StreamEvent event)
 
virtual void disconnect (ConnectionError reason)
 
void header ()
 
void setAuthed (bool authed)
 
void setAuthFailure (AuthenticationError e)
 
virtual bool checkStreamVersion (const std::string &version)
 
void startSASL (SaslMechanism type)
 
bool processSASLSuccess (const std::string &payload)
 
void processSASLChallenge (const std::string &challenge)
 
void processSASLError (Tag *tag)
 
void setNTLMDomain (const std::string &domain)
 
void startTls ()
 
bool hasTls ()
 
void send (const std::string &xml)
 
void checkQueue (int handled, bool resend)
 
int stanzasSent () const
 
std::string getRandom ()
 

Protected Attributes

JID m_jid
 
JID m_authzid
 
std::string m_authcid
 
ConnectionBasem_connection
 
TLSBasem_encryption
 
CompressionBasem_compression
 
Discom_disco
 
StanzaExtensionList m_presenceExtensions
 
GLOOX_DEPRECATED std::string m_selectedResource
 
std::string m_clientCerts
 
std::string m_clientKey
 
std::string m_namespace
 
std::string m_password
 
std::string m_xmllang
 
std::string m_server
 
std::string m_sid
 
bool m_compressionActive
 
bool m_encryptionActive
 
bool m_compress
 
bool m_authed
 
bool m_resourceBound
 
bool m_block
 
bool m_sasl
 
TLSPolicy m_tls
 
int m_port
 
int m_availableSaslMechs
 
SMContext m_smContext
 
int m_smHandled
 

Detailed Description

This is the common base class for a Jabber/XMPP Client and a Jabber Component.

It manages connection establishing, authentication, filter registration and invocation. You should normally use Client for client connections and Component for component connections.

Author
Jakob Schröter js@ca.nosp@m.maya.nosp@m..net
Since
0.3

Definition at line 76 of file clientbase.h.

Member Enumeration Documentation

◆ SMContext

enum SMContext
protected

An enum for the Stream Management state machine.

Enumerator
CtxSMInvalid 

Initial value.

CtxSMFailed 

Either of the below failed.

CtxSMEnable 

'enable' request sent

CtxSMResume 

'resume' request sent

CtxSMEnabled 

Stream Management successfully enabled.

CtxSMResumed 

Stream successfully resumed.

Definition at line 910 of file clientbase.h.

Constructor & Destructor Documentation

◆ ClientBase() [1/2]

ClientBase ( const std::string &  ns,
const std::string &  server,
int  port = -1 
)

Constructs a new ClientBase. You should not need to use this class directly. Use Client or Component instead.

Parameters
nsThe namespace which qualifies the stream. Either jabber:client or jabber:component:*
serverThe server to connect to.
portThe port to connect to. The default of -1 means to look up the port via DNS SRV or to use a default port of 5222 as defined in XMPP Core.

Definition at line 94 of file clientbase.cpp.

◆ ClientBase() [2/2]

ClientBase ( const std::string &  ns,
const std::string &  password,
const std::string &  server,
int  port = -1 
)

Constructs a new ClientBase. You should not need to use this class directly. Use Client or Component instead.

Parameters
nsThe namespace which qualifies the stream. Either jabber:client or jabber:component:*
passwordThe password to use for further authentication.
serverThe server to connect to.
portThe port to connect to. The default of -1 means to look up the port via DNS SRV or to use a default port of 5222 as defined in XMPP: Core.

Definition at line 111 of file clientbase.cpp.

◆ ~ClientBase()

~ClientBase ( )
virtual

Virtual destrcuctor.

Definition at line 155 of file clientbase.cpp.

Member Function Documentation

◆ addPresenceExtension()

void addPresenceExtension ( StanzaExtension se)

Adds a StanzaExtension that will be sent with every Presence stanza sent. Capabilities are included by default if you are using a Client.

Parameters
seA StanzaExtension to add. If an extension of the same type has been added previously it will be replaced by the new one. Use removePresenceExtension() to remove an extension.

Definition at line 1767 of file clientbase.cpp.

◆ authed()

bool authed ( ) const
inline

Returns whether authentication has taken place and was successful.

Returns
True if authentication has been carried out and was successful, false otherwise.

Definition at line 290 of file clientbase.h.

◆ authError()

AuthenticationError authError ( ) const
inline

Use this function to retrieve the type of the authentication error after it occurs and you received a ConnectionError of type ConnAuthenticationFailed from the ConnectionListener.

Returns
The type of the authentication, if any, AuthErrorUndefined otherwise.

Definition at line 640 of file clientbase.h.

◆ checkQueue()

void checkQueue ( int  handled,
bool  resend 
)
protected

This function checks if there are any unacknowledged Tags in the send queue and resends as necessary.

Parameters
handledThe sequence number of the last handled stanza.
resendWhether to resend unhandled stanzas.
Note
This function is part of XEP-0198. You should not need to use it directly.
Since
1.0.4

Definition at line 1049 of file clientbase.cpp.

◆ checkStreamVersion()

bool checkStreamVersion ( const std::string &  version)
protectedvirtual

Implementors of this function can check if they support the advertized stream version. The return value indicates whether or not the stream can be handled. A default implementation is provided.

Parameters
versionThe advertized stream version.
Returns
True if the stream can be handled, false otherwise.

Reimplemented in Component.

Definition at line 1180 of file clientbase.cpp.

◆ compression()

bool compression ( ) const
inline

Returns whether Stream Compression is currently enabled (not necessarily used).

Returns
The current Stream Compression status.

Definition at line 214 of file clientbase.h.

◆ compressionImpl()

CompressionBase* compressionImpl ( ) const
inline

This function returns the concrete compression implementation currently in use.

Returns
The concrete compression implementation.
Since
0.9

Definition at line 349 of file clientbase.h.

◆ connect()

bool connect ( bool  block = true)

Initiates the connection to a server. This function blocks as long as a connection is established. You can have the connection block 'til the end of the connection, or you can have it return immediately. If you choose the latter, its your responsibility to call recv() every now and then to actually receive data from the socket and to feed the parser.

Parameters
blockTrue for blocking, false for non-blocking connect. Defaults to true.
Returns
False if prerequisits are not met (server not set) or if the connection was refused, true otherwise.
Note
Since 0.9 onDisconnect() is called in addition to a return value of false.

Definition at line 191 of file clientbase.cpp.

◆ connectionImpl()

ConnectionBase* connectionImpl ( ) const
inline

This function returns the concrete connection implementation currently in use.

Returns
The concrete connection implementation.
Since
0.9

Definition at line 317 of file clientbase.h.

◆ disco()

virtual Disco* disco ( ) const
inlinevirtual

This function gives access to the Disco object.

Returns
A pointer to the Disco object.

Definition at line 233 of file clientbase.h.

◆ disconnect()

void disconnect ( ConnectionError  reason)
protectedvirtual

Disconnects the underlying stream and broadcasts the given reason.

Parameters
reasonThe reason for the disconnect.

Definition at line 404 of file clientbase.cpp.

◆ disposeMessageSession()

void disposeMessageSession ( MessageSession session)

Removes the given MessageSession from the list of MessageSessions and deletes it.

Parameters
sessionThe MessageSession to be deleted.

Definition at line 1415 of file clientbase.cpp.

◆ encryptionImpl()

TLSBase* encryptionImpl ( ) const
inline

This function returns the concrete encryption implementation currently in use.

Returns
The concrete encryption implementation.
Since
0.9

Definition at line 333 of file clientbase.h.

◆ getID()

const std::string getID ( )

Creates a string which is unique in the current instance and can be used as an ID for queries.

Returns
A unique string suitable for query IDs.

Definition at line 1168 of file clientbase.cpp.

◆ getRandom()

std::string getRandom ( )
protected

Returns 32 octets of random characters.

Returns
Random characters.

Definition at line 1792 of file clientbase.cpp.

◆ getStatistics()

StatisticsStruct getStatistics ( )

Returns a StatisticsStruct containing byte and stanza counts for the current active connection.

Returns
A struct containing the current connection's statistics.

Definition at line 1118 of file clientbase.cpp.

◆ handleCompressedData()

void handleCompressedData ( const std::string &  data)
virtual

This function is called when compression is finished.

Parameters
dataThe compressed data.

Implements CompressionDataHandler.

Definition at line 319 of file clientbase.cpp.

◆ handleConnect()

void handleConnect ( const ConnectionBase connection)
virtual

This function is called when e.g. the raw TCP connection was established.

Parameters
connectionThe connection.

Implements ConnectionDataHandler.

Reimplemented in Client.

Definition at line 382 of file clientbase.cpp.

◆ handleDecompressedData()

void handleDecompressedData ( const std::string &  data)
virtual

This function is called when decompression is finished.

Parameters
dataThe decompressed data.

Implements CompressionDataHandler.

Definition at line 329 of file clientbase.cpp.

◆ handleDecryptedData()

void handleDecryptedData ( const TLSBase base,
const std::string &  data 
)
virtual

Reimplement this function to receive decrypted data from a TLSBase implementation.

Parameters
baseThe encryption implementation which called this function.
dataThe decrypted data (e.g. to parse).

Implements TLSHandler.

Definition at line 342 of file clientbase.cpp.

◆ handleDisconnect()

void handleDisconnect ( const ConnectionBase connection,
ConnectionError  reason 
)
virtual

This connection is called when e.g. the raw TCP connection was closed.

Parameters
connectionThe connection.
reasonThe reason for the disconnect.

Implements ConnectionDataHandler.

Definition at line 387 of file clientbase.cpp.

◆ handleEncryptedData()

void handleEncryptedData ( const TLSBase base,
const std::string &  data 
)
virtual

Reimplement this function to receive encrypted data from a TLSBase implementation.

Parameters
baseThe encryption implementation which called this function.
dataThe encrypted data (e.g. to send over the wire).

Implements TLSHandler.

Definition at line 334 of file clientbase.cpp.

◆ handleHandshakeResult()

void handleHandshakeResult ( const TLSBase base,
bool  success,
CertInfo certinfo 
)
virtual

Reimplement this function to receive the result of a TLS handshake.

Parameters
baseThe encryption implementation which called this function.
successWhether or not the handshake was successful.
certinfoInformation about the server's certificate.

Implements TLSHandler.

Definition at line 350 of file clientbase.cpp.

◆ handleReceivedData()

void handleReceivedData ( const ConnectionBase connection,
const std::string &  data 
)
virtual

This function is called for received from the underlying transport.

Parameters
connectionThe connection that received the data.
dataThe data received.

Implements ConnectionDataHandler.

Definition at line 372 of file clientbase.cpp.

◆ handleTag()

void handleTag ( Tag tag)
virtual

This function is called when a registered XML element arrives. As with every handler in gloox, the Tag is going to be deleted after this function returned. If you need a copy afterwards, create it using Tag::clone().

Parameters
tagThe complete Tag.

Implements TagHandler.

Definition at line 221 of file clientbase.cpp.

◆ hasTls()

bool hasTls ( )
protected

Indicates whether or not TLS is supported.

Returns
True if TLS is supported, false otherwise.

Definition at line 458 of file clientbase.cpp.

◆ header()

void header ( )
protected

Sends the stream header.

Definition at line 449 of file clientbase.cpp.

◆ jid()

const JID& jid ( )
inline

Returns the current Jabber ID. If an authorization ID has been set (using setAuthzid()) this authzid is returned.

Returns
A reference to the Jabber ID.
Note
If you change the server part of the JID, the server of the connection is not synced. You have to do that manually using setServer().

Definition at line 147 of file clientbase.h.

◆ logInstance()

LogSink& logInstance ( )
inline

Returns the LogSink instance for this ClientBase and all related objects.

Returns
The LogSink instance used in the current ClientBase.

Definition at line 599 of file clientbase.h.

◆ notifyOnConnect()

void notifyOnConnect ( )
protected

This function is called to notify about successful connection.

Definition at line 1527 of file clientbase.cpp.

◆ notifyOnResourceBind()

void notifyOnResourceBind ( const std::string &  resource)
protected

This function is called when binding a resource succeeded.

Parameters
resourceThe bound resource.

Definition at line 1551 of file clientbase.cpp.

◆ notifyOnResourceBindError()

void notifyOnResourceBindError ( const Error error)
protected

This function is called when resource binding yieled an error.

Parameters
errorA pointer to an Error object that contains more information. May be 0.

Definition at line 1546 of file clientbase.cpp.

◆ notifyOnSessionCreateError()

void notifyOnSessionCreateError ( const Error error)
protected

This function is called when session creation yieled an error.

Parameters
errorA pointer to an Error object that contains more information. May be 0.

Definition at line 1556 of file clientbase.cpp.

◆ notifyOnTLSConnect()

bool notifyOnTLSConnect ( const CertInfo info)
protected

This function is called when the TLS handshake completed correctly. The return value is used to determine whether or not the client accepted the server's certificate. If false is returned the connection is closed.

Parameters
infoInformation on the server's certificate.
Returns
True if the certificate seems trustworthy, false otherwise.

Definition at line 1538 of file clientbase.cpp.

◆ notifyStreamEvent()

void notifyStreamEvent ( StreamEvent  event)
protected

This function is used to notify subscribers of stream events.

Parameters
eventThe event to publish.

Definition at line 1561 of file clientbase.cpp.

◆ password()

virtual const std::string& password ( ) const
inlinevirtual

Returns the current password.

Returns
The password used to connect.

Definition at line 227 of file clientbase.h.

◆ port()

int port ( ) const
inline

Returns the port. The default of -1 means that the actual port will be looked up using SRV records, or the XMPP default port of 5222 will be used.

Returns
The port used to connect.

Definition at line 221 of file clientbase.h.

◆ presenceExtensions()

const StanzaExtensionList& presenceExtensions ( ) const
inline

Returns the current list of Presence StanzaExtensions.

Returns
The current list of Presence StanzaExtensions.

Definition at line 680 of file clientbase.h.

◆ processSASLChallenge()

void processSASLChallenge ( const std::string &  challenge)
protected

Processes the given SASL challenge and sends a response.

Parameters
challengeThe SASL challenge to process.

Definition at line 707 of file clientbase.cpp.

◆ processSASLError()

void processSASLError ( Tag tag)
protected

Examines the given Tag for SASL errors.

Parameters
tagThe Tag to parse.

Definition at line 899 of file clientbase.cpp.

◆ processSASLSuccess()

bool processSASLSuccess ( const std::string &  payload)
protected

Verifies the server response after successful authentication (if applicable) and releases SASL related resources (if applicable).

Parameters
payloadThe server's verification string.
Returns
True if verification is not supported by the chosen SASL mechanism or could be completed successfully, false if verification failed.

Definition at line 927 of file clientbase.cpp.

◆ recv()

ConnectionError recv ( int  timeout = -1)
virtual

Use this periodically to receive data from the socket and to feed the parser. You need to use this only if you chose to connect in non-blocking mode.

Parameters
timeoutThe timeout in microseconds to use for select. Default of -1 means blocking until data was available.
Returns
The state of the connection.

Reimplemented in Client.

Definition at line 183 of file clientbase.cpp.

◆ registerConnectionListener()

void registerConnectionListener ( ConnectionListener cl)

Registers cl as object that receives connection notifications.

Parameters
clThe object to receive connection notifications.

Definition at line 1515 of file clientbase.cpp.

◆ registerIqHandler()

void registerIqHandler ( IqHandler ih,
int  exttype 
)

Registers ih as object that receives notifications for IQ stanzas that contain StanzaExtensions of the given type. The number of handlers per extension type is not limited.

Parameters
ihThe object to receive IQ stanza notifications.
exttypeThe extension type. See StanzaExtension and StanzaExtensionType .
Since
1.0

Definition at line 1374 of file clientbase.cpp.

◆ registerMessageHandler()

void registerMessageHandler ( MessageHandler mh)

Registers mh as object that receives Message stanza notifications.

Parameters
mhThe object to receive Message stanza notifications.

Definition at line 1430 of file clientbase.cpp.

◆ registerMessageSession()

void registerMessageSession ( MessageSession session)

Registers the given MessageSession to receive Messages incoming from the session's target JID.

Note
The ClientBase instance becomes the owner of the MessageSession, it will be deleted in ClientBase's destructor. To get rid of the session before that, use disposeMessageSession().
Parameters
sessionThe MessageSession to register.
Note
Since a MessageSession automatically registers itself with the ClientBase, there is no need to call this function directly.

Definition at line 1409 of file clientbase.cpp.

◆ registerMessageSessionHandler()

void registerMessageSessionHandler ( MessageSessionHandler msh,
int  types = 0 
)

Use this function to register a MessageSessionHandler with the Client. Optionally the MessageSessionHandler can receive only MessageSessions with a given message type. There can be only one handler per message type.
A MessageSession will be created for every incoming message stanza if there is no MessageHandler registered for the originating JID.

Parameters
mshThe MessageSessionHandler that will receive the newly created MessageSession.
typesORed StanzaSubType's that describe the desired message types the handler shall receive. Only StanzaMessage* types are valid. A value of 0 means any type (default).

Definition at line 1305 of file clientbase.cpp.

◆ registerMUCInvitationHandler()

void registerMUCInvitationHandler ( MUCInvitationHandler mih)

Registers a MUCInvitationHandler with the ClientBase.

Parameters
mihThe MUCInvitationHandler to register.

Definition at line 1500 of file clientbase.cpp.

◆ registerPresenceHandler() [1/2]

void registerPresenceHandler ( const JID jid,
PresenceHandler ph 
)

Registers a new PresenceHandler for the given JID. Presences received for this particular JID will not be forwarded to the generic PresenceHandler (and therefore the Roster). This functionality is primarily intended for the MUC implementation.

Parameters
jidThe JID to 'watch'.
phThe PresenceHandler to inform about presence changes from jid.
Since
0.9

Definition at line 1332 of file clientbase.cpp.

◆ registerPresenceHandler() [2/2]

void registerPresenceHandler ( PresenceHandler ph)

Registers ph as object that receives Presence stanza notifications.

Parameters
phThe object to receive Presence stanza notifications.

Definition at line 1320 of file clientbase.cpp.

◆ registerStanzaExtension()

void registerStanzaExtension ( StanzaExtension ext)

Registers a new StanzaExtension with the StanzaExtensionFactory.

Parameters
extThe extension to register.

Definition at line 1102 of file clientbase.cpp.

◆ registerStatisticsHandler()

void registerStatisticsHandler ( StatisticsHandler sh)

Registers sh as object that receives up-to-date connection statistics each time a Stanza is received or sent. Alternatively, you can use getStatistics() manually. Only one StatisticsHandler per ClientBase at a time is possible.

Parameters
shThe StatisticsHandler to register.

Definition at line 1489 of file clientbase.cpp.

◆ registerSubscriptionHandler()

void registerSubscriptionHandler ( SubscriptionHandler sh)

Registers sh as object that receives Subscription stanza notifications.

Parameters
shThe object to receive Subscription stanza notifications.

Definition at line 1442 of file clientbase.cpp.

◆ registerTagHandler()

void registerTagHandler ( TagHandler th,
const std::string &  tag,
const std::string &  xmlns 
)

Registers th as object that receives incoming packts with a given root tag qualified by the given namespace.

Parameters
thThe object to receive Subscription packet notifications.
tagThe element's name.
xmlnsThe element's namespace.

Definition at line 1454 of file clientbase.cpp.

◆ removeConnectionListener()

void removeConnectionListener ( ConnectionListener cl)

Removes the given object from the list of connection listeners.

Parameters
clThe object to remove from the list.

Definition at line 1521 of file clientbase.cpp.

◆ removeIDHandler()

void removeIDHandler ( IqHandler ih)

Removes the given IqHandler from the list of handlers of pending operations, added using send( IQ&, IqHandler*, int, bool ). Necessary, for example, when closing a GUI element that has an operation pending.

Parameters
ihThe IqHandler to remove.
Since
0.8.7

Definition at line 1359 of file clientbase.cpp.

◆ removeIqHandler()

void removeIqHandler ( IqHandler ih,
int  exttype 
)

Removes the given IQ handler for the given extension type.

Parameters
ihThe IqHandler.
exttypeThe extension type. See StanzaExtensionType .
Since
1.0

Definition at line 1391 of file clientbase.cpp.

◆ removeMessageHandler()

void removeMessageHandler ( MessageHandler mh)

Removes the given object from the list of message handlers.

Parameters
mhThe object to remove from the list.

Definition at line 1436 of file clientbase.cpp.

◆ removeMUCInvitationHandler()

void removeMUCInvitationHandler ( )

Removes the currently registered MUCInvitationHandler.

Definition at line 1509 of file clientbase.cpp.

◆ removePresenceExtension()

bool removePresenceExtension ( int  type)

Removes the StanzaExtension of the given type from the list of Presence StanzaExtensions. Use addPresenceExtension() to replace an already added type.

Definition at line 1776 of file clientbase.cpp.

◆ removePresenceHandler() [1/2]

void removePresenceHandler ( const JID jid,
PresenceHandler ph 
)

Removes the given object from the list of presence handlers for the given JID.

Parameters
jidThe JID to remove the PresenceHandler(s) for.
phThe PresenceHandler to remove from the list. If ph is 0, all handlers for the given JID will be removed.

Definition at line 1343 of file clientbase.cpp.

◆ removePresenceHandler() [2/2]

void removePresenceHandler ( PresenceHandler ph)

Removes the given object from the list of presence handlers.

Parameters
phThe object to remove from the list.

Definition at line 1326 of file clientbase.cpp.

◆ removeStanzaExtension()

bool removeStanzaExtension ( int  ext)

Removes the given StanzaExtension type from the StanzaExtensionFactory.

Parameters
extThe extension type.
Returns
True if the given type was found (and removed), false otherwise.

Definition at line 1110 of file clientbase.cpp.

◆ removeStatisticsHandler()

void removeStatisticsHandler ( )

Removes the current StatisticsHandler.

Definition at line 1495 of file clientbase.cpp.

◆ removeSubscriptionHandler()

void removeSubscriptionHandler ( SubscriptionHandler sh)

Removes the given object from the list of subscription handlers.

Parameters
shThe object to remove from the list.

Definition at line 1448 of file clientbase.cpp.

◆ removeTagHandler()

void removeTagHandler ( TagHandler th,
const std::string &  tag,
const std::string &  xmlns 
)

Removes the given object from the list of tag handlers for the given element and namespace.

Parameters
thThe object to remove from the list.
tagThe element to remove the handler for.
xmlnsThe namespace qualifying the element.

Definition at line 1466 of file clientbase.cpp.

◆ sasl()

bool sasl ( ) const
inline

Returns whether SASL is currently enabled (not necessarily used).

Returns
The current SASL status.

Definition at line 202 of file clientbase.h.

◆ send() [1/7]

void send ( const IQ iq)

A convenience function that sends the given IQ stanza.

Parameters
iqThe IQ stanza to send.

Definition at line 965 of file clientbase.cpp.

◆ send() [2/7]

void send ( const Message msg)

A convenience function that sends the given Message stanza.

Parameters
msgThe Message stanza to send.

Definition at line 974 of file clientbase.cpp.

◆ send() [3/7]

void send ( const Presence pres)

A convenience function that sends the given Presence stanza.

Parameters
presThe Presence stanza to send.

Definition at line 992 of file clientbase.cpp.

◆ send() [4/7]

void send ( const std::string &  xml)
protected

Sends the given data unchecked over the underlying transport connection. Use at your own risk. The server will check any data received anyway and disconnect if something is wrong.

Parameters
xmlThe data to send.

Definition at line 1034 of file clientbase.cpp.

◆ send() [5/7]

void send ( const Subscription sub)

A convenience function that sends the given Subscription stanza.

Parameters
subThe Subscription stanza to send.

Definition at line 983 of file clientbase.cpp.

◆ send() [6/7]

void send ( IQ iq,
IqHandler ih,
int  context,
bool  del = false 
)

Sends the given IQ stanza. The given IqHandler is registered to be notified of replies. This, of course, only works for IQs of type get or set. An ID is added if necessary.

Parameters
iqThe IQ stanza to send.
ihThe handler to register for replies.
contextA value that allows for restoring context.
delWhether or not delete the IqHandler object after its being called. Default: false.

Definition at line 946 of file clientbase.cpp.

◆ send() [7/7]

void send ( Tag tag)

Sends the given Tag over an established connection. The ClientBase object becomes the owner of this Tag and will delete it after sending it. You should not rely on the existance of the Tag after it's been sent. If you still need it after sending it, use Tag::clone() to create a deep copy.

Parameters
tagThe Tag to send.

Definition at line 1004 of file clientbase.cpp.

◆ sendQueue()

const TagList sendQueue ( )

Returns a list of Tags that are currently in the send queue. You should not rely on the currentness of this data when there is an established connection.

Returns
A 'decoupled' list of Tags (deep copies) in the send queue. The caller is responsible for deleting the tags.
Since
1.0.6

Definition at line 1075 of file clientbase.cpp.

◆ server()

const std::string& server ( ) const
inline

Returns the current prepped server.

Returns
The server used to connect.

Definition at line 196 of file clientbase.h.

◆ setAuthcid()

void setAuthcid ( const std::string &  authcid)
inline

Use this function to set an authentication ID (authcid) for SASL PLAIN. The default authcid is the username, i.e. the JID's node part. This should work in most cases. If this is not what you want to use for authentication, use this function.

Parameters
authcidThe authentication ID.
Since
1.0
Note
Right now this is used for SASL PLAIN authentication only.

Definition at line 391 of file clientbase.h.

◆ setAuthed()

void setAuthed ( bool  authed)
inlineprotected

Tells ClientBase that authentication was successful (or not).

Parameters
authedWhether or not authentication was successful.

Definition at line 777 of file clientbase.h.

◆ setAuthFailure()

void setAuthFailure ( AuthenticationError  e)
inlineprotected

If authentication failed, this function tells ClientBase the reason.

Parameters
eThe reason for the authentication failure.

Definition at line 784 of file clientbase.h.

◆ setAuthzid()

void setAuthzid ( const JID authzid)
inline

Use this function to set an authorization ID (authzid). Provided the server supports it and the user has sufficient rights, they could then authenticate as bob@e.nosp@m.xamp.nosp@m.le.ne.nosp@m.t but act as alice.nosp@m.@exa.nosp@m.mple..nosp@m.net.

Parameters
authzidThe JID to authorize as. Only the bare JID is used.
Since
0.9

Definition at line 381 of file clientbase.h.

◆ setCACerts()

void setCACerts ( const StringList cacerts)
inline

Use this function to set a number of trusted root CA certificates which shall be used to verify a servers certificate.

Parameters
cacertsA list of absolute paths to CA root certificate files in PEM format.

Definition at line 568 of file clientbase.h.

◆ setClientCert()

void setClientCert ( const std::string &  clientKey,
const std::string &  clientCerts 
)

Use this function to set the user's certificate and private key. The certificate will be presented to the server upon request and can be used for SASL EXTERNAL authentication. The user's certificate file should be a bundle of more than one certificate in PEM format. The first one in the file should be the user's certificate, each cert following that one should have signed the previous one.

Note
These certificates are not necessarily the same as those used to verify the server's certificate.
Parameters
clientKeyThe absolute path to the user's private key in PEM format.
clientCertsA path to a certificate bundle in PEM format.

Definition at line 479 of file clientbase.cpp.

◆ setCompression()

void setCompression ( bool  compression)
inline

Switches usage of Stream Compression on/off (if available). Default: on if available. Stream Compression should only be disabled if there are problems with using it.

Parameters
compressionWhether to switch Stream Compression usage on or off.

Definition at line 168 of file clientbase.h.

◆ setCompressionImpl()

void setCompressionImpl ( CompressionBase cb)

Use this function if you have a class supporting some fancy compression algorithm. This should be called before calling connect(). If there already is a compression implementation set (either manually or automatically), it gets deleted.

Parameters
cbThe compression implementation to use.
Since
0.9

Definition at line 1216 of file clientbase.cpp.

◆ setConnectionImpl()

void setConnectionImpl ( ConnectionBase cb)

Use this function if you have a class implementing a UDP, SCTP (or whatever) connection. This should be called before calling connect(). If there already is a connection implementation set (either manually or automatically), it gets deleted.

Parameters
cbThe connection to use.
Since
0.9

Definition at line 1199 of file clientbase.cpp.

◆ setEncryptionImpl()

void setEncryptionImpl ( TLSBase tb)

Use this function if you have a class supporting hardware encryption (or whatever). This should be called before calling connect(). If there already is a encryption implementation set (either manually or automatically), it gets deleted.

Parameters
tbThe encryption implementation to use.
Since
0.9

Definition at line 1208 of file clientbase.cpp.

◆ setNTLMDomain()

void setNTLMDomain ( const std::string &  domain)
inlineprotected

Sets the domain to use in SASL NTLM authentication.

Parameters
domainThe domain.

Definition at line 826 of file clientbase.h.

◆ setPassword()

void setPassword ( const std::string &  password)
inline

Sets the password to use to connect to the XMPP server.

Parameters
passwordThe password to use for authentication.

Definition at line 190 of file clientbase.h.

◆ setPort()

void setPort ( int  port)
inline

Sets the port to connect to. This is not necessary if either the default port (5222) is used or SRV records exist which will be resolved.

Parameters
portThe port to connect to.

Definition at line 175 of file clientbase.h.

◆ setSasl()

void setSasl ( bool  sasl)
inline

Switches usage of SASL on/off. Default: on. SASL should only be disabled if there are problems with using it, and if an alternative authentication method exists.

Parameters
saslWhether to switch SASL usage on or off.

Definition at line 154 of file clientbase.h.

◆ setSASLMechanisms()

void setSASLMechanisms ( int  mechanisms)
inline

Use this function to limit SASL mechanisms gloox can use. By default, all supported mechanisms are allowed. To exclude one (or more) mechanisms, remove it from SaslMechAll like so:

@ SaslMechDigestMd5
Definition: gloox.h:761
@ SaslMechAll
Definition: gloox.h:768
Parameters
mechanismsBitwise ORed SaslMechanism.
Since
0.9

Definition at line 403 of file clientbase.h.

◆ setServer()

void setServer ( const std::string &  server)

Sets the XMPP server to connect to.

Parameters
serverThe server to connect to. Either IP or fully qualified domain name.
Note
If you change the server, the server part of the JID is not synced. You have to do that manually using jid() and JID::setServer().
This function also sets the server of the Connection(Base) in use.

Definition at line 472 of file clientbase.cpp.

◆ setTls()

void setTls ( TLSPolicy  tls)
inline

Sets the TLS policy. Default: TLS will be used if available. TLS should only be disabled if there are problems with using it.

Parameters
tlsThe TLS policy.

Definition at line 161 of file clientbase.h.

◆ setXmlLang()

void setXmlLang ( const std::string &  xmllang)
inline

Sets the value for the xml:lang attribute of the initial stream.

Parameters
xmllangThe language identifier for the stream. It must conform to section 2.12 of the XML specification and RFC 3066. Default is 'en'.

Definition at line 310 of file clientbase.h.

◆ stanzasSent()

int stanzasSent ( ) const
inlineprotected

Returns the number of sent stanzas, if Stream Management is enabled.

Returns
The number of sent stanzas.

Definition at line 860 of file clientbase.h.

◆ startSASL()

void startSASL ( SaslMechanism  type)
protected

Starts authentication using the given SASL mechanism.

Parameters
typeA SASL mechanism to use for authentication.

Definition at line 485 of file clientbase.cpp.

◆ startTls()

void startTls ( )
protected

Starts the TLS handshake.

Definition at line 467 of file clientbase.cpp.

◆ state()

ConnectionState state ( ) const

Returns the current connection status.

Returns
The status of the connection.

Definition at line 1126 of file clientbase.cpp.

◆ streamError()

StreamError streamError ( ) const
inline

Use this function to retrieve the type of the stream error after it occurs and you received a ConnectionError of type ConnStreamError from the ConnectionListener.

Returns
The StreamError.
Note
The return value is only meaningful when called from ConnectionListener::onDisconnect().

Definition at line 607 of file clientbase.h.

◆ streamErrorAppCondition()

const Tag* streamErrorAppCondition ( ) const
inline

This function can be used to retrieve the application-specific error condition of a stream error.

Returns
The application-specific error element of a stream error. 0 if no respective element was found or no error occured.

Definition at line 633 of file clientbase.h.

◆ streamErrorCData()

const std::string& streamErrorCData ( ) const
inline

In case the defined-condition element of an stream error contains XML character data you can use this function to retrieve it. RFC 3920 only defines one condition (see-other-host)where this is possible.

Returns
The cdata of the stream error's text element (only for see-other-host).

Definition at line 626 of file clientbase.h.

◆ streamErrorText()

const std::string & streamErrorText ( const std::string &  lang = "default") const

Returns the text of a stream error for the given language if available. If the requested language is not available, the default text (without a xml:lang attribute) will be returned.

Parameters
langThe language identifier for the desired language. It must conform to section 2.12 of the XML specification and RFC 3066. If empty, the default body will be returned, if any.
Returns
The describing text of a stream error. Empty if no stream error occured.

Definition at line 1299 of file clientbase.cpp.

◆ tls()

TLSPolicy tls ( ) const
inline

Returns whether TLS is currently enabled (not necessarily used).

Returns
The current TLS status.

Definition at line 208 of file clientbase.h.

◆ username()

virtual const std::string& username ( ) const
inlinevirtual

Reimplement this function to provide a username for connection purposes.

Returns
The username.

Definition at line 138 of file clientbase.h.

◆ whitespacePing()

void whitespacePing ( )

Sends a whitespace ping to the server.

Since
0.9

Definition at line 1131 of file clientbase.cpp.

◆ xmlLang()

const std::string& xmlLang ( ) const
inline

Retrieves the value of the xml:lang attribute of the initial stream. Default is 'en', i.e. if not changed by a call to setXmlLang().

Definition at line 302 of file clientbase.h.

◆ xmppPing()

void xmppPing ( const JID to,
EventHandler eh 
)

Sends a XMPP Ping (XEP-0199) to the given JID.

Parameters
toThen entity to ping.
ehAn EventHandler to inform about the reply.
Since
0.9

Definition at line 1136 of file clientbase.cpp.

Member Data Documentation

◆ m_authcid

std::string m_authcid
protected

An alternative authentication ID. See setAuthcid().

Definition at line 870 of file clientbase.h.

◆ m_authed

bool m_authed
protected

Whether authentication has been completed successfully.

Definition at line 897 of file clientbase.h.

◆ m_authzid

JID m_authzid
protected

An optional authorization ID. See setAuthzid().

Definition at line 869 of file clientbase.h.

◆ m_availableSaslMechs

int m_availableSaslMechs
protected

The SASL mechanisms the server offered.

Definition at line 905 of file clientbase.h.

◆ m_block

bool m_block
protected

Whether blocking connection is wanted.

Definition at line 899 of file clientbase.h.

◆ m_clientCerts

std::string m_clientCerts
protected

TLS client certificates.

Definition at line 883 of file clientbase.h.

◆ m_clientKey

std::string m_clientKey
protected

TLS client private key.

Definition at line 884 of file clientbase.h.

◆ m_compress

bool m_compress
protected

Whether stream compression is desired at all.

Definition at line 895 of file clientbase.h.

◆ m_compression

CompressionBase* m_compression
protected

Used for connection compression.

Definition at line 873 of file clientbase.h.

◆ m_compressionActive

bool m_compressionActive
protected

Indicates whether or not stream compression is currently activated.

Definition at line 891 of file clientbase.h.

◆ m_connection

ConnectionBase* m_connection
protected

The transport connection.

Definition at line 871 of file clientbase.h.

◆ m_disco

Disco* m_disco
protected

The local Service Discovery client.

Definition at line 874 of file clientbase.h.

◆ m_encryption

TLSBase* m_encryption
protected

Used for connection encryption.

Definition at line 872 of file clientbase.h.

◆ m_encryptionActive

bool m_encryptionActive
protected

Indicates whether or not stream encryption is currently activated.

Definition at line 893 of file clientbase.h.

◆ m_jid

JID m_jid
protected

The 'self' JID.

Definition at line 868 of file clientbase.h.

◆ m_namespace

std::string m_namespace
protected

Default namespace.

Definition at line 885 of file clientbase.h.

◆ m_password

std::string m_password
protected

Client's password.

Definition at line 886 of file clientbase.h.

◆ m_port

int m_port
protected

The port to connect to, if not to be determined by querying the server's SRV records.

Definition at line 902 of file clientbase.h.

◆ m_presenceExtensions

StanzaExtensionList m_presenceExtensions
protected

A list of permanent presence extensions.

Definition at line 877 of file clientbase.h.

◆ m_resourceBound

bool m_resourceBound
protected

Whether resource binding has been completed successfully.

Definition at line 898 of file clientbase.h.

◆ m_sasl

bool m_sasl
protected

Whether SASL authentication is wanted.

Definition at line 900 of file clientbase.h.

◆ m_selectedResource

GLOOX_DEPRECATED std::string m_selectedResource
protected

The currently selected resource. See Client::selectResource() and Client::bindRessource().

Deprecated:
Not used anymore. Will be removed for 1.1.
Todo:
Remove for 1.1

Definition at line 879 of file clientbase.h.

◆ m_server

std::string m_server
protected

The server to connect to, if different from the JID's server.

Definition at line 888 of file clientbase.h.

◆ m_sid

std::string m_sid
protected

The stream ID.

Definition at line 890 of file clientbase.h.

◆ m_smContext

SMContext m_smContext
protected

The Stream Management state. Used in XEP-0198.

Definition at line 920 of file clientbase.h.

◆ m_smHandled

int m_smHandled
protected

The number of handled stanzas. Used in XEP-0198. You should NOT mess with this.

Definition at line 921 of file clientbase.h.

◆ m_tls

TLSPolicy m_tls
protected

The current TLS policy.

Definition at line 901 of file clientbase.h.

◆ m_xmllang

std::string m_xmllang
protected

Default value of the xml:lang attribute.

Definition at line 887 of file clientbase.h.


The documentation for this class was generated from the following files: