|
| 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 |
|
void | setStreamManagement (bool enable=true, bool resume=true) |
|
void | ackStreamManagement () |
|
void | reqStreamManagement () |
|
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 () |
|
void | setActive () |
|
void | setInactive () |
|
bool | hasClientStateIndication () const |
|
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) |
|
virtual 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) |
|
TLSBase * | encryptionImpl () const |
|
void | setEncryptionImpl (TLSBase *tb) |
|
CompressionBase * | compressionImpl () 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) |
|
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 |
|
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 () |
|
This class implements a basic Jabber/XMPP 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.
- Note
- While the MessageHandler interface is still available (and will be in future versions) it is now recommended to use the new MessageSession for any serious messaging.
Simple usage example:
void TestProg::doIt()
{
Client* j =
new Client(
"user@server/resource",
"password" );
j->registerPresenceHandler( this );
j->disco()->setVersion( "TestProg", "1.0" );
j->disco()->setIdentity( "client", "bot" );
j->connect();
}
virtual void TestProg::presenceHandler( Presence*
presence )
{
}
Client(const std::string &server)
The namespace for the gloox library.
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:
- jabber:iq:roster: by default the server-side roster is fetched and handled. Use rosterManager() and RosterManager to interact with the Roster.
- XEP-0092 (Software Version): If no version is specified, a name of "based on gloox" with gloox's current version is announced.
- XEP-0030 (Service Discovery): All supported/available services are announced. No items are returned.
- Note
- As of gloox 0.9, by default a priority of 0 is sent along with the initial presence.
-
As of gloox 0.9, initial presence is automatically sent. Presence: available, Priority: 0. To disable sending of initial Presence use setPresence() with a value of Unavailable prior to connecting.
SASL Authentication
Besides the simple, IQ-based authentication (XEP-0078), gloox supports several SASL (Simple Authentication and Security Layer, RFC 2222) authentication mechanisms.
- DIGEST-MD5: This mechanism is preferred over all other mechanisms if username and password are provided to the Client instance. It is secure even without TLS encryption.
- PLAIN: This mechanism is used if DIGEST-MD5 is not available. It is not secure without encryption.
- ANONYMOUS This mechanism is used if neither username nor password are set. The server generates random, temporary username and resource and may restrict available services.
- EXTERNAL This mechanism is currently only available if client certificate and private key are provided. The server tries to figure out who the client is by external means – for instance, using the provided certificate or even the IP address. (The restriction to certificate/key availability is likely to be lifted in the future.)
Of course, all these mechanisms are not tried unless the server offers them.
Stream Management
To enable Stream Management (XEP-0198), call setStreamManagement() with the first parameter set to true at any time. This will tell the server to enable Stream Management, if the feature is available. Once switched on, Stream Management can not be disabled for a given active stream. However, setting the first parameter to false, it can be disabled inside gloox so that Stream Management will not be used for subsequent connections.
To enable the stream resumption feature, pass true as the second parameter to setStreamManagement(). Upon re-connect after an unexpected (i.e. neither user-triggered nor server-triggered) disconnect, gloox will try to resume the stream and re-send any non-acknowledged stanzas automatically. For stream resumption to work you have to re-connect using the very same Client instance.
After an unexpected disconnect you may check the send queue using sendQueue() . Stanzas in the queue have been sent but not yet acknowledged by the server. Depending on the circumstances of the disconnect, this does not mean that those stanzas have not been received by the recipient.
- Author
- Jakob Schröter js@ca.nosp@m.maya.nosp@m..net
Definition at line 116 of file client.h.