gloox
1.1-svn
|
#include <client.h>
Public Member Functions | |
Client (const std::string &server) | |
Client (const JID &jid, const std::string &password, int port=-1) | |
virtual | ~Client () |
bool | bindResource (const std::string &resource) |
bool | selectResource (const std::string &resource) |
bool | hasResourceBind () const |
bool | unbindResource (const std::string &resource) |
const std::string & | resource () const |
int | priority () const |
void | setUsername (const std::string &username) |
void | setResource (const std::string &resource) |
void | setPresence (const JID &to, Presence::PresenceType pres, int priority, const std::string &status=EmptyString) |
void | setPresence (Presence::PresenceType pres, int priority, const std::string &status=EmptyString) |
void | setPresence () |
Presence & | presence () |
GLOOX_DEPRECATED void | setForceNonSasl (bool force=true) |
void | disableRoster () |
RosterManager * | rosterManager () |
void | disconnect () |
bool | login () |
![]() | |
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) |
ConnectionError | recv (int timeout=-1) |
virtual const std::string & | username () const |
const JID & | jid () |
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 Disco * | disco () 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) |
ConnectionBase * | connectionImpl () const |
void | setConnectionImpl (ConnectionBase *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) |
LogSink & | logInstance () |
StreamError | streamError () const |
const std::string & | streamErrorText (const std::string &lang="default") const |
const std::string & | streamErrorCData () const |
const Tag * | streamErrorAppCondition () const |
AuthenticationError | authError () const |
StatisticsStruct | getStatistics () |
void | registerMUCInvitationHandler (MUCInvitationHandler *mih) |
void | removeMUCInvitationHandler () |
void | addPresenceExtension (StanzaExtension *se) |
bool | removePresenceExtension (int type) |
const StanzaExtensionList & | presenceExtensions () const |
virtual void | handleTag (Tag *tag) |
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 *, const std::string &) |
virtual void | handleDecryptedData (const TLSBase *, const std::string &) |
virtual void | handleHandshakeResult (const TLSBase *base, bool success, CertInfo &certinfo) |
![]() | |
virtual | ~TagHandler () |
![]() | |
virtual | ~ConnectionDataHandler () |
![]() | |
virtual | ~IqHandler () |
virtual bool | handleIq (const IQ &iq)=0 |
virtual void | handleIqID (const IQ &iq, int context)=0 |
![]() | |
virtual | ~TLSHandler () |
Protected Member Functions | |
void | nonSaslLogin () |
![]() | |
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) |
void | processSASLSuccess () |
void | processSASLChallenge (const std::string &challenge) |
void | processSASLError (Tag *tag) |
void | setNTLMDomain (const std::string &domain) |
void | startTls () |
bool | hasTls () |
Additional Inherited Members | |
![]() | |
JID | m_jid |
JID | m_authzid |
std::string | m_authcid |
ConnectionBase * | m_connection |
ConnectionTLS * | m_encryption |
ConnectionCompression * | m_compression |
Disco * | m_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_block |
bool | m_sasl |
TLSPolicy | m_tls |
int | m_port |
int | m_availableSaslMechs |
This class implements a basic Jabber Client.
It supports SASL Authentication as well as TLS (Encryption), which can be switched on/off separately. They are used automatically if the server supports them.
To use, create a new Client instance and feed it connection credentials, either in the Constructor or afterwards using the setters. You should then register packet handlers implementing the corresponding Interfaces (ConnectionListener, PresenceHandler, MessageHandler, IqHandler, SubscriptionHandler), and call connect() to establish the connection to the server.
Simple usage example:
However, you can skip the presence handling stuff if you make use of the RosterManager.
By default, the library handles a few (incoming) IQ namespaces on the application's behalf. These include:
Besides the simple, IQ-based authentication (XEP-0078), gloox supports several SASL (Simple Authentication and Security Layer, RFC 2222) authentication mechanisms.
Of course, all these mechanisms are not tried unless the server offers them.
Client | ( | const std::string & | server | ) |
Constructs a new Client which can be used for account registration only. SASL and TLS are on by default. The port will be determined by looking up SRV records. Alternatively, you can set the port explicitly by calling setPort().
server | The server to connect to. |
Definition at line 106 of file client.cpp.
Constructs a new Client. SASL and TLS are on by default. This should be the default constructor for most use cases. The server address will be taken from the JID. The actual host will be resolved using SRV records. The domain part of the JID is used as a fallback in case no SRV record is found, or you can set the server address separately by calling setServer().
jid | A full Jabber ID used for connecting to the server. |
password | The password used for authentication. |
port | The port to connect to. The default of -1 means to look up the port via DNS SRV. |
Definition at line 117 of file client.cpp.
|
virtual |
Virtual destructor.
Definition at line 129 of file client.cpp.
|
inline |
Use this function to bind an additional resource or to re-try to bind a resource in case previous binding failed and you were notified by means of ConnectionListener::onResourceBindError(). Use hasResourceBind() to find out if the server supports binding of multiple resources. bindResource() is a NOOP if it doesn't.
resource | The resource identifier to bind. May be empty. In that case the server will assign a unique resource identifier. |
void disableRoster | ( | ) |
Disables the automatic roster management. You have to keep track of incoming presence yourself if you want to have a roster.
Definition at line 561 of file client.cpp.
void disconnect | ( | ) |
Disconnects from the server.
Definition at line 601 of file client.cpp.
|
inline |
bool login | ( | ) |
Initiates a login attempt (currently SASL External not supported). This is useful after registering a new account. Simply use setUsername() and setPassword(), and call login().
Definition at line 399 of file client.cpp.
|
protected |
Initiates non-SASL login.
Definition at line 568 of file client.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
This function gives access to the RosterManager
object.
bool selectResource | ( | const std::string & | resource | ) |
Use this function to select a resource identifier that has been bound previously by means of bindResource(). It is not necessary to call this function if only one resource is bound. Use hasResourceBind() to find out if the server supports binding of multiple resources.
resource | A resource string that has been bound previously. |
Definition at line 456 of file client.cpp.
|
inline |
This is a temporary hack to enforce Non-SASL login. You should not need to use it.
force | Whether to force non-SASL auth. Default true. |
void setPresence | ( | const JID & | to, |
Presence::PresenceType | pres, | ||
int | priority, | ||
const std::string & | status = EmptyString |
||
) |
Sends directed presence to the given JID. This is a NOOP if there's no active connection. To broadcast presence use setPresence( Presence::PresenceType, int, const std::string& ).
to | The JID to send directed Presence to. |
pres | The presence to send. |
priority | The priority to include. Legal values: -128 <= priority <= 127 |
status | The optional status message to include. |
Definition at line 546 of file client.cpp.
void setPresence | ( | Presence::PresenceType | pres, |
int | priority, | ||
const std::string & | status = EmptyString |
||
) |
Use this function to set the entity's presence, that is, to broadcast presence to all subscribed entities. To send directed presence, use setPresence( const JID&, Presence::PresenceType, int, const std::string& ). If used prior to establishing a connection, the set values will be sent with the initial presence stanza. If used while a connection already is established, a presence stanza will be sent out immediately.
pres | The Presence value to set. |
priority | An optional priority value. Legal values: -128 <= priority <= 127 |
status | An optional message describing the presence state. |
Definition at line 537 of file client.cpp.
|
inline |
Use this function to broadcast the entity's presence to all subscribed entities. This is a NOOP if there's no active connection. To send directed presence, use setPresence( const JID&, Presence::PresenceType, int, const std::string& ). If used while a connection already is established a repective presence stanza will be sent out immediately. Use presence() to modify the Presence object.
|
inline |
void setUsername | ( | const std::string & | username | ) |
Sets the username to use to connect to the XMPP server.
username | The username to authenticate with. |
Definition at line 144 of file client.cpp.
|
inline |
Use this function to unbind a resource identifier that has been bound previously by means of bindResource(). Use hasResourceBind() to find out if the server supports binding of multiple resources. unbindResource() is a NOOP if it doesn't.
resource | A resource string that has been bound previously. |