Changeset View
Changeset View
Standalone View
Standalone View
libraries/win32/gloox/include/gloox/clientbase.h
Show All 11 Lines | |||||
#ifndef CLIENTBASE_H__ | #ifndef CLIENTBASE_H__ | ||||
#define CLIENTBASE_H__ | #define CLIENTBASE_H__ | ||||
#include "macros.h" | #include "macros.h" | ||||
#include "gloox.h" | #include "gloox.h" | ||||
// #include "connectionbase.h" | |||||
#include "eventdispatcher.h" | #include "eventdispatcher.h" | ||||
#include "iqhandler.h" | #include "iqhandler.h" | ||||
#include "jid.h" | #include "jid.h" | ||||
#include "logsink.h" | #include "logsink.h" | ||||
#include "mutex.h" | #include "mutex.h" | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | |||||
#include "pinghandler.h" | |||||
#endif // GLOOX_MINIMAL | |||||
#include "taghandler.h" | #include "taghandler.h" | ||||
#include "statisticshandler.h" | #include "statisticshandler.h" | ||||
#include "tlshandler.h" | #include "tlshandler.h" | ||||
#include "compressiondatahandler.h" | #include "compressiondatahandler.h" | ||||
#include "connectiondatahandler.h" | #include "connectiondatahandler.h" | ||||
#include "parser.h" | #include "parser.h" | ||||
#include "atomicrefcount.h" | #include "atomicrefcount.h" | ||||
#include <string> | #include <string> | ||||
#include <list> | #include <list> | ||||
#include <map> | #include <map> | ||||
#if defined( _WIN32 ) && !defined( __SYMBIAN32__ ) | #if defined( _WIN32 ) | ||||
#include <windows.h> | #include <windows.h> | ||||
#define SECURITY_WIN32 | #define SECURITY_WIN32 | ||||
#include <security.h> | #include <security.h> | ||||
#endif | #endif | ||||
namespace gloox | namespace gloox | ||||
{ | { | ||||
class Disco; | class Disco; | ||||
class EventHandler; | class EventHandler; | ||||
class Event; | class Event; | ||||
class Tag; | class Tag; | ||||
class IQ; | class IQ; | ||||
class Message; | class Message; | ||||
class Presence; | class Presence; | ||||
class Subscription; | class Subscription; | ||||
class MessageSessionHandler; | |||||
class ConnectionListener; | class ConnectionListener; | ||||
class MessageHandler; | class MessageHandler; | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) | |||||
class MessageSession; | class MessageSession; | ||||
class MessageSessionHandler; | |||||
#endif // GLOOX_MINIMAL | |||||
class PresenceHandler; | class PresenceHandler; | ||||
class SubscriptionHandler; | class SubscriptionHandler; | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) | |||||
class MUCInvitationHandler; | class MUCInvitationHandler; | ||||
#endif // GLOOX_MINIMAL | |||||
class TagHandler; | class TagHandler; | ||||
class TLSBase; | class TLSBase; | ||||
class ConnectionBase; | class ConnectionBase; | ||||
class CompressionBase; | class CompressionBase; | ||||
class StanzaExtensionFactory; | class StanzaExtensionFactory; | ||||
/** | /** | ||||
* @brief This is the common base class for a Jabber/XMPP Client and a Jabber Component. | * @brief This is the common base class for a Jabber/XMPP Client and a Jabber Component. | ||||
* | * | ||||
* It manages connection establishing, authentication, filter registration and invocation. | * It manages connection establishing, authentication, filter registration and invocation. | ||||
* You should normally use Client for client connections and Component for component connections. | * You should normally use Client for client connections and Component for component connections. | ||||
* | * | ||||
* @author Jakob Schröter <js@camaya.net> | * @author Jakob Schröter <js@camaya.net> | ||||
* @since 0.3 | * @since 0.3 | ||||
*/ | */ | ||||
class GLOOX_API ClientBase : public TagHandler, public ConnectionDataHandler, | class GLOOX_API ClientBase : public TagHandler, public ConnectionDataHandler, | ||||
public CompressionDataHandler, public TLSHandler, | public CompressionDataHandler, public TLSHandler, | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | |||||
public PingHandler, | |||||
#endif // GLOOX_MINIMAL | |||||
public IqHandler | public IqHandler | ||||
{ | { | ||||
friend class RosterManager; | friend class RosterManager; | ||||
public: | public: | ||||
/** | /** | ||||
* Constructs a new ClientBase. | * Constructs a new ClientBase. | ||||
* You should not need to use this class directly. Use Client or Component instead. | * You should not need to use this class directly. Use Client or Component instead. | ||||
* @param ns The namespace which qualifies the stream. Either jabber:client or jabber:component:* | * @param ns The namespace which qualifies the stream. Either jabber:client or jabber:component:* | ||||
Show All 22 Lines | public: | ||||
/** | /** | ||||
* Initiates the connection to a server. This function blocks as long as a connection is | * Initiates the connection to a server. This function blocks as long as a connection is | ||||
* established. | * established. | ||||
* You can have the connection block 'til the end of the connection, or you can have it return | * 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 @ref recv() every now | * immediately. If you choose the latter, its your responsibility to call @ref recv() every now | ||||
* and then to actually receive data from the socket and to feed the parser. | * and then to actually receive data from the socket and to feed the parser. | ||||
* @param block @b True for blocking, @b false for non-blocking connect. Defaults to @b true. | * @param block @b True for blocking, @b false for non-blocking connect. Defaults to @b true. | ||||
* @param timeout The timeout in microseconds to use for select(). Default of -1 means blocking. | |||||
* @return @b False if prerequisits are not met (server not set) or if the connection was refused, | * @return @b False if prerequisits are not met (server not set) or if the connection was refused, | ||||
* @b true otherwise. | * @b true otherwise. | ||||
* @note Since 0.9 @link ConnectionListener::onDisconnect() onDisconnect() @endlink is called | * @note Since 0.9 @link ConnectionListener::onDisconnect() onDisconnect() @endlink is called | ||||
* in addition to a return value of @b false. | * in addition to a return value of @b false. | ||||
*/ | */ | ||||
bool connect( bool block = true ); | bool connect( bool block = true, int timeout = -1 ); | ||||
/** | /** | ||||
* Use this periodically to receive data from the socket and to feed the parser. You need to use | * 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. | * this only if you chose to connect in non-blocking mode. | ||||
* @param timeout The timeout in microseconds to use for select. Default of -1 means blocking | * @param timeout The timeout in microseconds to use for select. Default of -1 means blocking. | ||||
* until data was available. | * until data was available. | ||||
* @return The state of the connection. | * @return The state of the connection. | ||||
*/ | */ | ||||
virtual ConnectionError recv( int timeout = -1 ); | virtual ConnectionError recv( int timeout = -1 ); | ||||
/** | /** | ||||
* Reimplement this function to provide a username for connection purposes. | * Reimplement this function to provide a username for connection purposes. | ||||
* @return The username. | * @return The username. | ||||
*/ | */ | ||||
virtual const std::string& username() const { return m_jid.username(); } | virtual const std::string& username() const { return m_jid.username(); } | ||||
/** | /** | ||||
* Returns the current Jabber ID. If an authorization ID has been set (using setAuthzid()) | * Returns the current Jabber ID. If an authorization ID has been set (using setAuthzid()) | ||||
* this authzid is returned. | * this authzid is returned. | ||||
* @return A reference to the Jabber ID. | * @return A reference to the Jabber ID. | ||||
* @note If you change the server part of the JID, the server of the connection is not synced. | * @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 @ref setServer(). | * You have to do that manually using @ref setServer(). | ||||
*/ | */ | ||||
const JID& jid() { return m_authzid ? m_authzid : m_jid; } | const JID& jid() { return m_authzid ? m_authzid : m_jid; } | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_WEBSOCKET ) | |||||
/** | |||||
* Switches usage of websocket transport on/off. Default: off. | |||||
* @param ws Whether to switch websocket transport usage on or off. | |||||
*/ | |||||
void setWebsocket( bool ws ) { m_websocket = ws; } | |||||
#endif // GLOOX_MINIMAL | |||||
/** | /** | ||||
* Switches usage of SASL on/off. Default: on. SASL should only be disabled if there are | * 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. | * problems with using it, and if an alternative authentication method exists. | ||||
* @param sasl Whether to switch SASL usage on or off. | * @param sasl Whether to switch SASL usage on or off. | ||||
*/ | */ | ||||
void setSasl( bool sasl ) { m_sasl = sasl; } | void setSasl( bool sasl ) { m_sasl = sasl; } | ||||
/** | /** | ||||
* Sets the TLS policy. Default: TLS will be used if available. TLS should only be | * Sets the TLS policy. Default: TLS will be used if available. TLS should only be | ||||
* disabled if there are problems with using it. | * disabled if there are problems with using it. Also sets the minimum required/requested | ||||
* TLS version for the connection. | |||||
* @param tls The TLS policy. | * @param tls The TLS policy. | ||||
* @param tlsVersion The TLS version to require/request. Default: TLS v1. | |||||
*/ | */ | ||||
void setTls( TLSPolicy tls ) { m_tls = tls; } | void setTls( TLSPolicy tls, TLSVersion tlsVersion = TLSv1 ) { m_tls = tls; m_tlsVersion = tlsVersion; } | ||||
/** | /** | ||||
* Switches usage of Stream Compression on/off (if available). Default: on if available. Stream | * 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. | * Compression should only be disabled if there are problems with using it. | ||||
* @param compression Whether to switch Stream Compression usage on or off. | * @param compression Whether to switch Stream Compression usage on or off. | ||||
*/ | */ | ||||
void setCompression( bool compression ) { m_compress = compression; } | void setCompression( bool compression ) { m_compress = compression; } | ||||
Show All 33 Lines | #endif // GLOOX_MINIMAL | ||||
/** | /** | ||||
* Returns whether TLS is currently enabled (not necessarily used). | * Returns whether TLS is currently enabled (not necessarily used). | ||||
* @return The current TLS status. | * @return The current TLS status. | ||||
*/ | */ | ||||
TLSPolicy tls() const { return m_tls; } | TLSPolicy tls() const { return m_tls; } | ||||
/** | /** | ||||
* Returns the minimum required TLS version (not necessarily the one in use). | |||||
* @return The TLS version. | |||||
*/ | |||||
TLSVersion tlsVersion() const { return m_tlsVersion; } | |||||
/** | |||||
* Returns whether Stream Compression is currently enabled (not necessarily used). | * Returns whether Stream Compression is currently enabled (not necessarily used). | ||||
* @return The current Stream Compression status. | * @return The current Stream Compression status. | ||||
*/ | */ | ||||
bool compression() const { return m_compress; } | bool compression() const { return m_compress; } | ||||
/** | /** | ||||
* Returns the port. The default of -1 means that the actual port will be looked up using | * 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. | * SRV records, or the XMPP default port of 5222 will be used. | ||||
* @return The port used to connect. | * @return The port used to connect. | ||||
*/ | */ | ||||
int port() const { return m_port; } | int port() const { return m_port; } | ||||
/** | /** | ||||
* Returns the current password. | * Returns the current password. | ||||
* @return The password used to connect. | * @return The password used to connect. | ||||
*/ | */ | ||||
virtual const std::string& password() const { return m_password; } | virtual const std::string& password() const { return m_password; } | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_DISCO ) | |||||
/** | /** | ||||
* This function gives access to the @c Disco object. | * This function gives access to the @c Disco object. | ||||
* @return A pointer to the Disco object. | * @return A pointer to the Disco object. | ||||
*/ | */ | ||||
virtual Disco* disco() const { return m_disco; } | virtual Disco* disco() const { return m_disco; } | ||||
#endif // GLOOX_MINIMAL | |||||
/** | /** | ||||
* Creates a string which is unique in the current instance and | * Creates a string which is unique in the current instance and | ||||
* can be used as an ID for queries. | * can be used as an ID for queries. | ||||
* @return A unique string suitable for query IDs. | * @return A unique string suitable for query IDs. | ||||
*/ | */ | ||||
const std::string getID(); | const std::string getID(); | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | #endif // GLOOX_MINIMAL | ||||
* Use this function if you have a class supporting some fancy compression algorithm. | * 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 | * This should be called before calling connect(). If there already is a | ||||
* compression implementation set (either manually or automatically), it gets deleted. | * compression implementation set (either manually or automatically), it gets deleted. | ||||
* @param cb The compression implementation to use. | * @param cb The compression implementation to use. | ||||
* @since 0.9 | * @since 0.9 | ||||
*/ | */ | ||||
void setCompressionImpl( CompressionBase* cb ); | void setCompressionImpl( CompressionBase* cb ); | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | |||||
/** | /** | ||||
* Sends a whitespace ping to the server. | * Sends a whitespace ping to the server. | ||||
* @since 0.9 | * @since 0.9 | ||||
*/ | */ | ||||
void whitespacePing(); | void whitespacePing(); | ||||
/** | /** | ||||
* Sends a XMPP Ping (@xep{0199}) to the given JID. | * Sends a XMPP Ping (@xep{0199}) to the given JID. | ||||
* @param to Then entity to ping. | * @param to Then entity to ping. | ||||
* @param eh An EventHandler to inform about the reply. | * @param eh An EventHandler to inform about the reply. | ||||
* @since 0.9 | * @since 0.9 | ||||
*/ | */ | ||||
void xmppPing( const JID& to, EventHandler* eh ); | void xmppPing( const JID& to, EventHandler* eh ); | ||||
#endif // GLOOX_MINIMAL | |||||
/** | /** | ||||
* Use this function to set an authorization ID (authzid). Provided the server supports it | * 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@example.net but | * and the user has sufficient rights, they could then authenticate as bob@example.net but | ||||
* act as alice@example.net. | * act as alice@example.net. | ||||
* @param authzid The JID to authorize as. Only the bare JID is used. | * @param authzid The JID to authorize as. Only the bare JID is used. | ||||
* @since 0.9 | * @since 0.9 | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | #endif // GLOOX_MINIMAL | ||||
void registerMessageHandler( MessageHandler* mh ); | void registerMessageHandler( MessageHandler* mh ); | ||||
/** | /** | ||||
* Removes the given object from the list of message handlers. | * Removes the given object from the list of message handlers. | ||||
* @param mh The object to remove from the list. | * @param mh The object to remove from the list. | ||||
*/ | */ | ||||
void removeMessageHandler( MessageHandler* mh ); | void removeMessageHandler( MessageHandler* mh ); | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | |||||
/** | |||||
* Registers @c ph as object that receives Ping stanza notifications. | |||||
* @param ph The object to receive Ping stanza notifications. | |||||
*/ | |||||
void registerPingHandler( PingHandler* ph ); | |||||
/** | |||||
* Clears the current ping handler. The ping handler does not get deleted. | |||||
*/ | |||||
void removePingHandler(); | |||||
#endif // GLOOX_MINIMAL | |||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) | |||||
/** | /** | ||||
* Registers the given MessageSession to receive Messages incoming from the session's | * Registers the given MessageSession to receive Messages incoming from the session's | ||||
* target JID. | * target JID. | ||||
* @note The ClientBase instance becomes the owner of the MessageSession, it will be deleted | * @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(). | * in ClientBase's destructor. To get rid of the session before that, use disposeMessageSession(). | ||||
* @param session The MessageSession to register. | * @param session The MessageSession to register. | ||||
* @note Since a MessageSession automatically registers itself with the ClientBase, there is no | * @note Since a MessageSession automatically registers itself with the ClientBase, there is no | ||||
* need to call this function directly. | * need to call this function directly. | ||||
*/ | */ | ||||
void registerMessageSession( MessageSession* session ); | void registerMessageSession( MessageSession* session ); | ||||
/** | /** | ||||
* Removes the given MessageSession from the list of MessageSessions and deletes it. | * Removes the given MessageSession from the list of MessageSessions and deletes it. | ||||
* @param session The MessageSession to be deleted. | * @param session The MessageSession to be deleted. | ||||
*/ | */ | ||||
void disposeMessageSession( MessageSession* session ); | void disposeMessageSession( MessageSession* session ); | ||||
/** | /** | ||||
* 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.<br> | |||||
* A MessageSession will be created for every incoming | |||||
* message stanza if there is no MessageHandler registered for the originating JID. | |||||
* @param msh The MessageSessionHandler that will receive the newly created MessageSession. | |||||
* @param types ORed 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). | |||||
*/ | |||||
void registerMessageSessionHandler( MessageSessionHandler* msh, int types = 0 ); | |||||
#endif // GLOOX_MINIMAL | |||||
/** | |||||
* Registers @c ph as object that receives Presence stanza notifications. | * Registers @c ph as object that receives Presence stanza notifications. | ||||
* @param ph The object to receive Presence stanza notifications. | * @param ph The object to receive Presence stanza notifications. | ||||
*/ | */ | ||||
void registerPresenceHandler( PresenceHandler* ph ); | void registerPresenceHandler( PresenceHandler* ph ); | ||||
/** | /** | ||||
* Registers a new PresenceHandler for the given JID. Presences received for this | * Registers a new PresenceHandler for the given JID. Presences received for this | ||||
* particular JID will not be forwarded to the generic PresenceHandler (and therefore | * particular JID will not be forwarded to the generic PresenceHandler (and therefore | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | #endif // GLOOX_MINIMAL | ||||
* @note These certificates are not necessarily the same as those used to verify the server's | * @note These certificates are not necessarily the same as those used to verify the server's | ||||
* certificate. | * certificate. | ||||
* @param clientKey The absolute path to the user's private key in PEM format. | * @param clientKey The absolute path to the user's private key in PEM format. | ||||
* @param clientCerts A path to a certificate bundle in PEM format. | * @param clientCerts A path to a certificate bundle in PEM format. | ||||
*/ | */ | ||||
void setClientCert( const std::string& clientKey, const std::string& clientCerts ); | void setClientCert( const std::string& clientKey, const std::string& clientCerts ); | ||||
/** | /** | ||||
* 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.<br> | |||||
* A MessageSession will be created for every incoming | |||||
* message stanza if there is no MessageHandler registered for the originating JID. | |||||
* @param msh The MessageSessionHandler that will receive the newly created MessageSession. | |||||
* @param types ORed 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). | |||||
*/ | |||||
void registerMessageSessionHandler( MessageSessionHandler* msh, int types = 0 ); | |||||
/** | |||||
* Returns the LogSink instance for this ClientBase and all related objects. | * Returns the LogSink instance for this ClientBase and all related objects. | ||||
* @return The LogSink instance used in the current ClientBase. | * @return The LogSink instance used in the current ClientBase. | ||||
*/ | */ | ||||
LogSink& logInstance() { return m_logInstance; } | LogSink& logInstance() { return m_logInstance; } | ||||
/** | /** | ||||
* Use this function to retrieve the type of the stream error after it occurs and you received a | * Use this function to retrieve the type of the stream error after it occurs and you received a | ||||
* ConnectionError of type @b ConnStreamError from the ConnectionListener. | * ConnectionError of type @b ConnStreamError from the ConnectionListener. | ||||
Show All 37 Lines | #endif // GLOOX_MINIMAL | ||||
/** | /** | ||||
* Returns a StatisticsStruct containing byte and stanza counts for the current | * Returns a StatisticsStruct containing byte and stanza counts for the current | ||||
* active connection. | * active connection. | ||||
* @return A struct containing the current connection's statistics. | * @return A struct containing the current connection's statistics. | ||||
*/ | */ | ||||
StatisticsStruct getStatistics(); | StatisticsStruct getStatistics(); | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) | |||||
/** | /** | ||||
* Registers a MUCInvitationHandler with the ClientBase. | * Registers a MUCInvitationHandler with the ClientBase. | ||||
* @param mih The MUCInvitationHandler to register. | * @param mih The MUCInvitationHandler to register. | ||||
*/ | */ | ||||
void registerMUCInvitationHandler( MUCInvitationHandler* mih ); | void registerMUCInvitationHandler( MUCInvitationHandler* mih ); | ||||
/** | /** | ||||
* Removes the currently registered MUCInvitationHandler. | * Removes the currently registered MUCInvitationHandler. | ||||
*/ | */ | ||||
void removeMUCInvitationHandler(); | void removeMUCInvitationHandler(); | ||||
#endif // GLOOX_MINIMAL | |||||
/** | /** | ||||
* Adds a StanzaExtension that will be sent with every Presence stanza | * Adds a StanzaExtension that will be sent with every Presence stanza | ||||
* sent. Capabilities are included by default if you are using a Client. | * sent. Capabilities are included by default if you are using a Client. | ||||
* @param se A StanzaExtension to add. If an extension of the same type | * @param se A StanzaExtension to add. If an extension of the same type | ||||
* has been added previously it will be replaced by the new one. | * has been added previously it will be replaced by the new one. | ||||
* Use removePresenceExtension() to remove an extension. | * Use removePresenceExtension() to remove an extension. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | #endif // GLOOX_MINIMAL | ||||
virtual void handleEncryptedData( const TLSBase* base, const std::string& data ); | virtual void handleEncryptedData( const TLSBase* base, const std::string& data ); | ||||
// reimplemented from TLSHandler | // reimplemented from TLSHandler | ||||
virtual void handleDecryptedData( const TLSBase* base, const std::string& data ); | virtual void handleDecryptedData( const TLSBase* base, const std::string& data ); | ||||
// reimplemented from TLSHandler | // reimplemented from TLSHandler | ||||
virtual void handleHandshakeResult( const TLSBase* base, bool success, CertInfo &certinfo ); | virtual void handleHandshakeResult( const TLSBase* base, bool success, CertInfo &certinfo ); | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | |||||
// reimplemented from PingHandler | |||||
virtual void handlePing( PingType type, const std::string& body ); | |||||
#endif // GLOOX_MINIMAL | |||||
protected: | protected: | ||||
#ifdef CLIENTBASE_TEST | #if defined( CLIENTBASE_TEST ) || defined( ENABLE_SEND_RAW_XML ) | ||||
public: | public: | ||||
#endif | #endif | ||||
/** | /** | ||||
* This function is called when resource binding yieled an error. | * This function is called when resource binding yieled an error. | ||||
* @param error A pointer to an Error object that contains more | * @param error A pointer to an Error object that contains more | ||||
* information. May be 0. | * information. May be 0. | ||||
*/ | */ | ||||
void notifyOnResourceBindError( const Error* error ); | void notifyOnResourceBindError( const Error* error ); | ||||
Show All 32 Lines | #endif | ||||
void notifyStreamEvent( StreamEvent event ); | void notifyStreamEvent( StreamEvent event ); | ||||
/** | /** | ||||
* Disconnects the underlying stream and broadcasts the given reason. | * Disconnects the underlying stream and broadcasts the given reason. | ||||
* @param reason The reason for the disconnect. | * @param reason The reason for the disconnect. | ||||
*/ | */ | ||||
virtual void disconnect( ConnectionError reason ); | virtual void disconnect( ConnectionError reason ); | ||||
/** | |||||
* Sends the stream header. | |||||
*/ | |||||
void header(); | |||||
/** | /** | ||||
* Tells ClientBase that authentication was successful (or not). | * Tells ClientBase that authentication was successful (or not). | ||||
* @param authed Whether or not authentication was successful. | * @param authed Whether or not authentication was successful. | ||||
*/ | */ | ||||
void setAuthed( bool authed ) { m_authed = authed; } | void setAuthed( bool authed ) { m_authed = authed; } | ||||
/** | /** | ||||
Show All 17 Lines | #endif | ||||
* @param type A SASL mechanism to use for authentication. | * @param type A SASL mechanism to use for authentication. | ||||
*/ | */ | ||||
void startSASL( SaslMechanism type ); | void startSASL( SaslMechanism type ); | ||||
/** | /** | ||||
* Verifies the server response after successful authentication (if applicable) and | * Verifies the server response after successful authentication (if applicable) and | ||||
* releases SASL related resources (if applicable). | * releases SASL related resources (if applicable). | ||||
* @param payload The server's verification string. | * @param payload The server's verification string. | ||||
* @return @b True if verification is not supported by the chosen SASL mechanism or could be completed successfully, | * @return @b True if verification is not supported by the chosen SASL mechanism or could be | ||||
* @b false if verification failed. | * completed successfully, @b false if verification failed. | ||||
*/ | */ | ||||
bool processSASLSuccess( const std::string& payload ); | bool processSASLSuccess( const std::string& payload ); | ||||
/** | /** | ||||
* Processes the given SASL challenge and sends a response. | * Processes the given SASL challenge and sends a response. | ||||
* @param challenge The SASL challenge to process. | * @param challenge The SASL challenge to process. | ||||
*/ | */ | ||||
void processSASLChallenge( const std::string& challenge ); | void processSASLChallenge( const std::string& challenge ); | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | #endif | ||||
std::string getRandom(); | std::string getRandom(); | ||||
JID m_jid; /**< The 'self' JID. */ | JID m_jid; /**< The 'self' JID. */ | ||||
JID m_authzid; /**< An optional authorization ID. See setAuthzid(). */ | JID m_authzid; /**< An optional authorization ID. See setAuthzid(). */ | ||||
std::string m_authcid; /**< An alternative authentication ID. See setAuthcid(). */ | std::string m_authcid; /**< An alternative authentication ID. See setAuthcid(). */ | ||||
ConnectionBase* m_connection; /**< The transport connection. */ | ConnectionBase* m_connection; /**< The transport connection. */ | ||||
TLSBase* m_encryption; /**< Used for connection encryption. */ | TLSBase* m_encryption; /**< Used for connection encryption. */ | ||||
CompressionBase* m_compression; /**< Used for connection compression. */ | CompressionBase* m_compression; /**< Used for connection compression. */ | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_DISCO ) | |||||
Disco* m_disco; /**< The local Service Discovery client. */ | Disco* m_disco; /**< The local Service Discovery client. */ | ||||
#endif // GLOOX_MINIMAL | |||||
/** A list of permanent presence extensions. */ | /** A list of permanent presence extensions. */ | ||||
StanzaExtensionList m_presenceExtensions; | StanzaExtensionList m_presenceExtensions; | ||||
GLOOX_DEPRECATED std::string m_selectedResource; /**< 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 */ | |||||
std::string m_clientCerts; /**< TLS client certificates. */ | std::string m_clientCerts; /**< TLS client certificates. */ | ||||
std::string m_clientKey; /**< TLS client private key. */ | std::string m_clientKey; /**< TLS client private key. */ | ||||
std::string m_namespace; /**< Default namespace. */ | std::string m_namespace; /**< Default namespace. */ | ||||
std::string m_password; /**< Client's password. */ | std::string m_password; /**< Client's password. */ | ||||
std::string m_xmllang; /**< Default value of the xml:lang attribute. */ | std::string m_xmllang; /**< Default value of the xml:lang attribute. */ | ||||
std::string m_server; /**< The server to connect to, if different from the | std::string m_server; /**< The server to connect to, if different from the | ||||
* JID's server. */ | * JID's server. */ | ||||
std::string m_sid; /**< The stream ID. */ | std::string m_sid; /**< The stream ID. */ | ||||
bool m_compressionActive; /**< Indicates whether or not stream compression | bool m_compressionActive; /**< Indicates whether or not stream compression | ||||
* is currently activated. */ | * is currently activated. */ | ||||
bool m_encryptionActive; /**< Indicates whether or not stream encryption | bool m_encryptionActive; /**< Indicates whether or not stream encryption | ||||
* is currently activated. */ | * is currently activated. */ | ||||
bool m_compress; /**< Whether stream compression | bool m_compress; /**< Whether stream compression | ||||
* is desired at all. */ | * is desired at all. */ | ||||
bool m_authed; /**< Whether authentication has been completed successfully. */ | bool m_authed; /**< Whether authentication has been completed successfully. */ | ||||
bool m_resourceBound; /**< Whether resource binding has been completed successfully. */ | bool m_resourceBound; /**< Whether resource binding has been completed successfully. */ | ||||
bool m_block; /**< Whether blocking connection is wanted. */ | bool m_block; /**< Whether blocking connection is wanted. */ | ||||
bool m_sasl; /**< Whether SASL authentication is wanted. */ | bool m_sasl; /**< Whether SASL authentication is wanted. */ | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_WEBSOCKET ) | |||||
bool m_websocket; /**< Whether connection is done over websocket. */ | |||||
#endif // GLOOX_MINIMAL | |||||
TLSPolicy m_tls; /**< The current TLS policy. */ | TLSPolicy m_tls; /**< The current TLS policy. */ | ||||
TLSVersion m_tlsVersion; /**< The minimum TLS version to require/request. */ | |||||
int m_port; /**< The port to connect to, if not to be determined | int m_port; /**< The port to connect to, if not to be determined | ||||
* by querying the server's SRV records. */ | * by querying the server's SRV records. */ | ||||
int m_availableSaslMechs; /**< The SASL mechanisms the server offered. */ | int m_availableSaslMechs; /**< The SASL mechanisms the server offered. */ | ||||
/** | /** | ||||
* An enum for the Stream Management state machine. | * An enum for the Stream Management state machine. | ||||
*/ | */ | ||||
enum SMContext | enum SMContext | ||||
{ | { | ||||
CtxSMInvalid, /**< Initial value. */ | CtxSMInvalid, /**< Initial value. */ | ||||
CtxSMFailed, /**< Either of the below failed. */ | CtxSMFailed, /**< Either of the below failed. */ | ||||
CtxSMEnable, /**< 'enable' request sent */ | CtxSMEnable, /**< 'enable' request sent */ | ||||
CtxSMResume, /**< 'resume' request sent */ | CtxSMResume, /**< 'resume' request sent */ | ||||
CtxSMEnabled, /**< Stream Management successfully enabled. */ | CtxSMEnabled, /**< Stream Management successfully enabled. */ | ||||
CtxSMResumed /**< Stream successfully resumed. */ | CtxSMResumed /**< Stream successfully resumed. */ | ||||
}; | }; | ||||
SMContext m_smContext; /**< The Stream Management state. Used in @xep{0198}. */ | SMContext m_smContext; /**< The Stream Management state. Used in @xep{0198}. */ | ||||
int m_smHandled; /**< The number of handled stanzas. Used in @xep{0198}. | int m_smHandled; /**< The number of handled stanzas. Used in @xep{0198}. | ||||
* You should NOT mess with this. */ | * You should NOT mess with this. */ | ||||
private: | private: | ||||
#ifdef CLIENTBASE_TEST | #if defined( CLIENTBASE_TEST ) || defined( ENABLE_SEND_RAW_XML ) | ||||
public: | public: | ||||
#endif | #endif | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | |||||
/** | /** | ||||
* @brief This is an implementation of an XMPP Ping (@xep{0199}). | * @brief This is an implementation of an XMPP Ping (@xep{0199}). | ||||
* | * | ||||
* @author Jakob Schröter <js@camaya.net> | * @author Jakob Schröter <js@camaya.net> | ||||
* @since 1.0 | * @since 1.0 | ||||
*/ | */ | ||||
class Ping : public StanzaExtension | class Ping : public StanzaExtension | ||||
{ | { | ||||
Show All 27 Lines | #if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | ||||
// reimplemented from StanzaExtension | // reimplemented from StanzaExtension | ||||
virtual StanzaExtension* clone() const | virtual StanzaExtension* clone() const | ||||
{ | { | ||||
return new Ping(); | return new Ping(); | ||||
} | } | ||||
}; | }; | ||||
#endif // GLOOX_MINIMAL | |||||
private: | |||||
ClientBase( const ClientBase& ); | ClientBase( const ClientBase& ); | ||||
ClientBase& operator=( const ClientBase& ); | ClientBase& operator=( const ClientBase& ); | ||||
#if defined( CLIENTBASE_TEST ) || defined( ENABLE_SEND_RAW_XML ) | |||||
public: | |||||
#endif | |||||
/** | /** | ||||
* This function is called right after the opening <stream:stream> was received. | * This function is called right after the opening <stream:stream> was received. | ||||
* @param start The complete stream opening tag. Note that the XML representation (Tag::xml()) | * @param start The complete stream opening tag. Note that the XML representation (Tag::xml()) | ||||
* will contain a closed stream tag. The original is open. | * will contain a closed stream tag. The original is open. | ||||
*/ | */ | ||||
virtual void handleStartNode( const Tag* start ) = 0; | virtual void handleStartNode( const Tag* start ) = 0; | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | #endif | ||||
}; | }; | ||||
typedef std::list<ConnectionListener*> ConnectionListenerList; | typedef std::list<ConnectionListener*> ConnectionListenerList; | ||||
typedef std::multimap<const std::string, IqHandler*> IqHandlerMapXmlns; | typedef std::multimap<const std::string, IqHandler*> IqHandlerMapXmlns; | ||||
typedef std::multimap<const int, IqHandler*> IqHandlerMap; | typedef std::multimap<const int, IqHandler*> IqHandlerMap; | ||||
typedef std::map<const std::string, TrackStruct> IqTrackMap; | typedef std::map<const std::string, TrackStruct> IqTrackMap; | ||||
typedef std::map<const std::string, MessageHandler*> MessageHandlerMap; | typedef std::map<const std::string, MessageHandler*> MessageHandlerMap; | ||||
typedef std::map<int, Tag*> SMQueueMap; | typedef std::map<int, Tag*> SMQueueMap; | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) | |||||
typedef std::list<MessageSession*> MessageSessionList; | typedef std::list<MessageSession*> MessageSessionList; | ||||
#endif // GLOOX_MINIMAL | |||||
typedef std::list<MessageHandler*> MessageHandlerList; | typedef std::list<MessageHandler*> MessageHandlerList; | ||||
typedef std::list<PresenceHandler*> PresenceHandlerList; | typedef std::list<PresenceHandler*> PresenceHandlerList; | ||||
typedef std::list<JidPresHandlerStruct> PresenceJidHandlerList; | typedef std::list<JidPresHandlerStruct> PresenceJidHandlerList; | ||||
typedef std::list<SubscriptionHandler*> SubscriptionHandlerList; | typedef std::list<SubscriptionHandler*> SubscriptionHandlerList; | ||||
typedef std::list<TagHandlerStruct> TagHandlerList; | typedef std::list<TagHandlerStruct> TagHandlerList; | ||||
ConnectionListenerList m_connectionListeners; | ConnectionListenerList m_connectionListeners; | ||||
IqHandlerMapXmlns m_iqNSHandlers; | IqHandlerMapXmlns m_iqNSHandlers; | ||||
IqHandlerMap m_iqExtHandlers; | IqHandlerMap m_iqExtHandlers; | ||||
IqTrackMap m_iqIDHandlers; | IqTrackMap m_iqIDHandlers; | ||||
SMQueueMap m_smQueue; | SMQueueMap m_smQueue; | ||||
MessageSessionList m_messageSessions; | |||||
MessageHandlerList m_messageHandlers; | MessageHandlerList m_messageHandlers; | ||||
PresenceHandlerList m_presenceHandlers; | PresenceHandlerList m_presenceHandlers; | ||||
PresenceJidHandlerList m_presenceJidHandlers; | PresenceJidHandlerList m_presenceJidHandlers; | ||||
SubscriptionHandlerList m_subscriptionHandlers; | SubscriptionHandlerList m_subscriptionHandlers; | ||||
TagHandlerList m_tagHandlers; | TagHandlerList m_tagHandlers; | ||||
StringList m_cacerts; | StringList m_cacerts; | ||||
StatisticsHandler * m_statisticsHandler; | StatisticsHandler * m_statisticsHandler; | ||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) | |||||
MUCInvitationHandler * m_mucInvitationHandler; | MUCInvitationHandler * m_mucInvitationHandler; | ||||
#endif // GLOOX_MINIMAL | |||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) | |||||
MessageSessionList m_messageSessions; | |||||
MessageSessionHandler * m_messageSessionHandlerChat; | MessageSessionHandler * m_messageSessionHandlerChat; | ||||
MessageSessionHandler * m_messageSessionHandlerGroupchat; | MessageSessionHandler * m_messageSessionHandlerGroupchat; | ||||
MessageSessionHandler * m_messageSessionHandlerHeadline; | MessageSessionHandler * m_messageSessionHandlerHeadline; | ||||
MessageSessionHandler * m_messageSessionHandlerNormal; | MessageSessionHandler * m_messageSessionHandlerNormal; | ||||
#endif // GLOOX_MINIMAL | |||||
#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) | |||||
PingHandler * m_pingHandler; | |||||
#endif // GLOOX_MINIMAL | |||||
util::Mutex m_iqHandlerMapMutex; | util::Mutex m_iqHandlerMapMutex; | ||||
util::Mutex m_iqExtHandlerMapMutex; | util::Mutex m_iqExtHandlerMapMutex; | ||||
util::Mutex m_queueMutex; | util::Mutex m_queueMutex; | ||||
Parser m_parser; | Parser m_parser; | ||||
LogSink m_logInstance; | LogSink m_logInstance; | ||||
StanzaExtensionFactory* m_seFactory; | StanzaExtensionFactory* m_seFactory; | ||||
Show All 15 Lines | #endif // GLOOX_MINIMAL | ||||
std::string m_ntlmDomain; | std::string m_ntlmDomain; | ||||
bool m_customConnection; | bool m_customConnection; | ||||
std::string m_uniqueBaseId; | std::string m_uniqueBaseId; | ||||
util::AtomicRefCount m_nextId; | util::AtomicRefCount m_nextId; | ||||
int m_smSent; | int m_smSent; | ||||
#if defined( _WIN32 ) && !defined( __SYMBIAN32__ ) | #if defined( _WIN32 ) | ||||
CredHandle m_credHandle; | CredHandle m_credHandle; | ||||
CtxtHandle m_ctxtHandle; | CtxtHandle m_ctxtHandle; | ||||
#endif | #endif | ||||
}; | }; | ||||
} | } | ||||
#endif // CLIENTBASE_H__ | #endif // CLIENTBASE_H__ |
Wildfire Games · Phabricator