QXmppConfiguration Class

The QXmppConfiguration class holds configuration options. More...

Header: #include <QXmppConfiguration.h>

Public Types

enum NonSASLAuthMechanism { NonSASLPlain, NonSASLDigest }
enum StreamSecurityMode { TLSEnabled, TLSDisabled, TLSRequired, LegacySSL }

Public Functions

QXmppConfiguration()
QXmppConfiguration(const QXmppConfiguration &other)
(since QXmpp 1.7) void addDisabledSaslMechanism(const QString &m)
bool autoAcceptSubscriptions() const
bool autoReconnectionEnabled() const
QList<QSslCertificate> caCertificates() const
(since QXmpp 1.8) QXmppCredentials credentials() const
(since QXmpp 1.7) QList<QString> disabledSaslMechanisms() const
QString domain() const
QString facebookAccessToken() const
QString facebookAppId() const
QString googleAccessToken() const
QString host() const
bool ignoreSslErrors() const
QString jid() const
QString jidBare() const
int keepAliveInterval() const
int keepAliveTimeout() const
(since QXmpp 1.15) QString locale() const
QNetworkProxy networkProxy() const
QXmppConfiguration::NonSASLAuthMechanism nonSASLAuthMechanism() const
QString password() const
(since QXmpp 1.8) quint16 port16() const
int port() const
QString resource() const
(since QXmpp 1.8) QString resourcePrefix() const
(since QXmpp 1.7) std::optional<QXmppSasl2UserAgent> sasl2UserAgent() const
QString saslAuthMechanism() const
void setAutoAcceptSubscriptions(bool value)
void setAutoReconnectionEnabled(bool value)
void setCaCertificates(const QList<QSslCertificate> &caCertificates)
(since QXmpp 1.8) void setCredentials(const QXmppCredentials &credentials)
(since QXmpp 1.7) void setDisabledSaslMechanisms(const QList<QString> &disabled)
void setDomain(const QString &domain)
void setFacebookAccessToken(const QString &accessToken)
void setFacebookAppId(const QString &appId)
void setGoogleAccessToken(const QString &accessToken)
void setHost(const QString &host)
void setIgnoreSslErrors(bool value)
void setJid(const QString &jid)
void setKeepAliveInterval(int secs)
void setKeepAliveTimeout(int secs)
(since QXmpp 1.15) void setLocale(const QString &locale)
void setNetworkProxy(const QNetworkProxy &proxy)
void setNonSASLAuthMechanism(QXmppConfiguration::NonSASLAuthMechanism mech)
void setPassword(const QString &password)
void setPort(int port)
void setResource(const QString &resource)
(since QXmpp 1.8) void setResourcePrefix(const QString &resourcePrefix)
(since QXmpp 1.7) void setSasl2UserAgent(const std::optional<QXmppSasl2UserAgent> &userAgent)
void setSaslAuthMechanism(const QString &mechanism)
void setStreamSecurityMode(QXmppConfiguration::StreamSecurityMode mode)
(since QXmpp 1.8) void setUseFastTokenAuthentication(bool useFast)
void setUseNonSASLAuthentication(bool useNonSASL)
void setUseSASLAuthentication(bool useSASL)
(since QXmpp 1.7) void setUseSasl2Authentication(bool enabled)
void setUser(const QString &user)
void setWindowsLiveAccessToken(const QString &accessToken)
QXmppConfiguration::StreamSecurityMode streamSecurityMode() const
(since QXmpp 1.8) bool useFastTokenAuthentication() const
bool useNonSASLAuthentication() const
bool useSASLAuthentication() const
bool useSasl2Authentication() const
QString user() const
QString windowsLiveAccessToken() const
QXmppConfiguration &operator=(const QXmppConfiguration &other)

Detailed Description

It can be passed to QXmppClient to specify the options when connecting to an XMPP server.

It is a container of all the settings, configuration required for connecting to an XMPP server. E.g. server name, username, port, type of authentication mechanism, type of security used by stream (encryption), etc..

Member Type Documentation

enum QXmppConfiguration::NonSASLAuthMechanism

An enumeration for various Non-SASL authentication mechanisms available. The server may or may not allow QXmppConfiguration::Plain mechanism. So specifying the mechanism is just a hint to the library.

ConstantValueDescription
QXmppConfiguration::NonSASLPlain0Plain.
QXmppConfiguration::NonSASLDigest1Digest (default).

enum QXmppConfiguration::StreamSecurityMode

An enumeration for type of the Security Mode that is stream is encrypted or not. The server may or may not have TLS feature. Server may force the encryption. Depending upon all this user can specify following options.

ConstantValueDescription
QXmppConfiguration::TLSEnabled0Encryption is used if available (default).
QXmppConfiguration::TLSDisabled1No encryption even if the server offers it.
QXmppConfiguration::TLSRequired2Encryption must be available, otherwise the connection will not be established.
QXmppConfiguration::LegacySSL3Use direct TLS connection only and connect to configured host and port or domain and 5223 or 5222. No SRV records are looked up.

Member Function Documentation

QXmppConfiguration::QXmppConfiguration()

Creates a QXmppConfiguration object.

QXmppConfiguration::QXmppConfiguration(const QXmppConfiguration &other)

Creates a copy of other.

[since QXmpp 1.7] void QXmppConfiguration::addDisabledSaslMechanism(const QString &m)

Adds to the list of disabled SASL mechanisms.

Those mechanisms are not used by the client, even if no other mechanism is available.

m.

This function was introduced in QXmpp 1.7.

bool QXmppConfiguration::autoAcceptSubscriptions() const

Returns the auto-accept-subscriptions-request configuration: true means that auto-accept-subscriptions-request is enabled, else disabled for false.

See also setAutoAcceptSubscriptions().

bool QXmppConfiguration::autoReconnectionEnabled() const

Returns the auto-reconnect-on-disconnection-on-error configuration: true means that auto-reconnect is enabled, else disabled for false.

See also setAutoReconnectionEnabled().

QList<QSslCertificate> QXmppConfiguration::caCertificates() const

Returns the a list of trusted CA certificates.

See also setCaCertificates().

[since QXmpp 1.8] QXmppCredentials QXmppConfiguration::credentials() const

Returns the credentials of this configuration.

This function was introduced in QXmpp 1.8.

See also setCredentials().

[since QXmpp 1.7] QList<QString> QXmppConfiguration::disabledSaslMechanisms() const

Returns the list of disabled SASL mechanisms.

Those mechanisms are not used by the client, even if no other mechanism is available.

This function was introduced in QXmpp 1.7.

See also setDisabledSaslMechanisms().

QString QXmppConfiguration::domain() const

Returns the domain part of the JID.

See also setDomain().

QString QXmppConfiguration::facebookAccessToken() const

Returns the access token used for X-FACEBOOK-PLATFORM authentication.

See also setFacebookAccessToken().

QString QXmppConfiguration::facebookAppId() const

Returns the application ID used for X-FACEBOOK-PLATFORM authentication.

See also setFacebookAppId().

QString QXmppConfiguration::googleAccessToken() const

Returns the access token used for X-OAUTH2 authentication.

See also setGoogleAccessToken().

QString QXmppConfiguration::host() const

Returns the custom hostname to connect to.

See also setHost().

bool QXmppConfiguration::ignoreSslErrors() const

Returns whether SSL errors (such as certificate validation errors) are to be ignored when connecting to the XMPP server.

See also setIgnoreSslErrors().

QString QXmppConfiguration::jid() const

Returns the Jabber-ID (JID) (e.g. "qxmpp.test1@gmail.com/resource" or qxmpptest@jabber.org/QXmpp156).

See also setJid().

QString QXmppConfiguration::jidBare() const

Returns the bare jabber id (jid), without the resource identifier (e.g. "qxmpp.test1@gmail.com" or qxmpptest@jabber.org).

int QXmppConfiguration::keepAliveInterval() const

Returns the keep alive interval in seconds.

The default value is 60 seconds.

See also setKeepAliveInterval().

int QXmppConfiguration::keepAliveTimeout() const

Returns the keep alive timeout in seconds.

The default value is 20 seconds.

See also setKeepAliveTimeout().

[since QXmpp 1.15] QString QXmppConfiguration::locale() const

Returns the preferred language for the XMPP stream.

If no locale has been explicitly set, this returns the system locale's BCP 47 language tag (e.g. "en", "de-DE").

The returned value is used as the xml:lang attribute on the XMPP stream element, as specified in RFC 6120 Section 4.7.4.

This function was introduced in QXmpp 1.15.

See also setLocale().

QNetworkProxy QXmppConfiguration::networkProxy() const

Returns the specified network proxy. The default value is QNetworkProxy::DefaultProxy that is the proxy is determined based on the application proxy set using QNetworkProxy::setApplicationProxy().

See also setNetworkProxy().

QXmppConfiguration::NonSASLAuthMechanism QXmppConfiguration::nonSASLAuthMechanism() const

Returns the Non-SASL authentication mechanism configuration.

See also setNonSASLAuthMechanism().

QString QXmppConfiguration::password() const

Returns the password.

See also setPassword().

[since QXmpp 1.8] quint16 QXmppConfiguration::port16() const

Returns the port number as quint16.

This function was introduced in QXmpp 1.8.

int QXmppConfiguration::port() const

Returns the port number.

See also setPort().

QString QXmppConfiguration::resource() const

Returns the resource identifier.

This is empty if no resource has been set explicitly and no connection has been established yet. In that case the resource is generated when connecting (see setResource() and setResourcePrefix()).

See also setResource().

[since QXmpp 1.8] QString QXmppConfiguration::resourcePrefix() const

Returns the resource prefix ('tag' for this client).

The prefix is used as the XEP-0386: Bind 2 tag if Bind 2 is available. If no resource is set and Bind 2 is not available, a resource of the form "<resource-prefix>.<random-string>" is generated from it.

The default value is "QXmpp".

This function was introduced in QXmpp 1.8.

See also setResourcePrefix().

[since QXmpp 1.7] std::optional<QXmppSasl2UserAgent> QXmppConfiguration::sasl2UserAgent() const

Returns the user-agent used for XEP-0388: Extensible SASL Profile.

If this is empty, no user-agent will be sent.

This function was introduced in QXmpp 1.7.

See also setSasl2UserAgent().

QString QXmppConfiguration::saslAuthMechanism() const

Returns the preferred SASL authentication mechanism.

See also setSaslAuthMechanism().

void QXmppConfiguration::setAutoAcceptSubscriptions(bool value)

Sets the auto-accept-subscriptions-request configuration. value true means that auto-accept-subscriptions-request is enabled, else disabled for false.

See also autoAcceptSubscriptions().

void QXmppConfiguration::setAutoReconnectionEnabled(bool value)

Sets the auto-reconnect-on-disconnection-on-error configuration. value true means that auto-reconnect is enabled, else disabled for false.

See also autoReconnectionEnabled().

void QXmppConfiguration::setCaCertificates(const QList<QSslCertificate> &caCertificates)

Specifies a list of trusted CA certificates.

caCertificates.

See also caCertificates().

[since QXmpp 1.8] void QXmppConfiguration::setCredentials(const QXmppCredentials &credentials)

Sets the credentials for this configuration.

credentials.

This function was introduced in QXmpp 1.8.

See also credentials().

[since QXmpp 1.7] void QXmppConfiguration::setDisabledSaslMechanisms(const QList<QString> &disabled)

Sets the list of disabled SASL mechanisms.

Those mechanisms are not used by the client, even if no other mechanism is available.

disabled.

This function was introduced in QXmpp 1.7.

See also disabledSaslMechanisms().

void QXmppConfiguration::setDomain(const QString &domain)

Sets the domain name to domain (e.g. "gmail.com" and "jabber.org").

Note: host name and domain name can be different for google domain name is gmail.com and host name is talk.google.com

See also domain().

void QXmppConfiguration::setFacebookAccessToken(const QString &accessToken)

Sets the access token used for X-FACEBOOK-PLATFORM authentication.

This token is returned by Facebook at the end of the OAuth authentication process.

accessToken.

See also facebookAccessToken().

void QXmppConfiguration::setFacebookAppId(const QString &appId)

Sets the application ID used for X-FACEBOOK-PLATFORM authentication.

appId.

See also facebookAppId().

void QXmppConfiguration::setGoogleAccessToken(const QString &accessToken)

Sets the access token used for X-OAUTH2 authentication.

This token is returned by Google at the end of the OAuth authentication process.

accessToken.

See also googleAccessToken().

void QXmppConfiguration::setHost(const QString &host)

Sets the host name.

host is the host name of the XMPP server where connection has to be made (e.g. "jabber.org" and "talk.google.com"). It can also be an IP address in the form of a string (e.g. "192.168.1.25").

See also host().

void QXmppConfiguration::setIgnoreSslErrors(bool value)

Specifies whether SSL errors (such as certificate validation errors) are to be ignored when connecting to an XMPP server.

value.

See also ignoreSslErrors().

void QXmppConfiguration::setJid(const QString &jid)

Sets the JID. If a full JID (i.e. one with a resource) is given, calling this method will update the username, domain and resource. Otherwise, only the username and the domain will be updated.

jid.

See also jid().

void QXmppConfiguration::setKeepAliveInterval(int secs)

Specifies the interval in seconds at which keep alive (ping) packets will be sent to the server.

If set to zero, no keep alive packets will be sent.

The default value is 60 seconds.

secs.

See also keepAliveInterval().

void QXmppConfiguration::setKeepAliveTimeout(int secs)

Specifies the maximum time in seconds to wait for a keep alive response from the server before considering we are disconnected.

If set to zero or a value larger than the keep alive interval, no timeout will occur.

The default value is 20 seconds.

secs.

See also keepAliveTimeout().

[since QXmpp 1.15] void QXmppConfiguration::setLocale(const QString &locale)

Sets the preferred language for the XMPP stream.

Pass an empty string to reset to auto-detection from the system locale.

locale.

This function was introduced in QXmpp 1.15.

See also locale().

void QXmppConfiguration::setNetworkProxy(const QNetworkProxy &proxy)

Specifies the network proxy used for the connection made by QXmppClient. The default value is QNetworkProxy::DefaultProxy that is the proxy is determined based on the application proxy set using QNetworkProxy::setApplicationProxy().

proxy.

See also networkProxy().

void QXmppConfiguration::setNonSASLAuthMechanism(QXmppConfiguration::NonSASLAuthMechanism mech)

Hints the library the Non-SASL authentication mechanism to be used for authentication.

mech.

See also nonSASLAuthMechanism().

void QXmppConfiguration::setPassword(const QString &password)

Sets the password for the specified username.

See also password().

void QXmppConfiguration::setPort(int port)

Sets the port number at which the XMPP server is listening. The default value is 5222.

See also port().

void QXmppConfiguration::setResource(const QString &resource)

Sets the resource identifier.

Multiple resources (e.g., devices or locations) may connect simultaneously to a server on behalf of each authorized client, with each resource differentiated by the resource identifier of an XMPP address (e.g. node@domain/home vs. node@domain/work)

If no resource is set, the resource is generated when connecting: the resource prefix (see setResourcePrefix()) is used as the XEP-0386: Bind 2 tag if Bind 2 is available, otherwise a resource of the form "<resource-prefix>.<random-string>" is generated.

resource is the resource identifier of the client in connection.

See also resource().

[since QXmpp 1.8] void QXmppConfiguration::setResourcePrefix(const QString &resourcePrefix)

Sets the resource prefix ('tag' for this client).

The prefix is used as the XEP-0386: Bind 2 tag if Bind 2 is available. If no resource is set and Bind 2 is not available, a resource of the form "<resource-prefix>.<random-string>" is generated from it.

The default value is "QXmpp".

resourcePrefix.

This function was introduced in QXmpp 1.8.

See also resourcePrefix().

[since QXmpp 1.7] void QXmppConfiguration::setSasl2UserAgent(const std::optional<QXmppSasl2UserAgent> &userAgent)

Sets the user-agent used for XEP-0388: Extensible SASL Profile.

If this is empty, no user-agent will be sent.

userAgent.

This function was introduced in QXmpp 1.7.

See also sasl2UserAgent().

void QXmppConfiguration::setSaslAuthMechanism(const QString &mechanism)

Sets the preferred SASL authentication mechanism.

Valid values: "SCRAM-SHA-256", "SCRAM-SHA-1", "DIGEST-MD5", "PLAIN", "ANONYMOUS",

See also saslAuthMechanism().

void QXmppConfiguration::setStreamSecurityMode(QXmppConfiguration::StreamSecurityMode mode)

Specifies the specified security mode for the stream. The default value is QXmppConfiguration::TLSEnabled.

mode.

See also streamSecurityMode().

[since QXmpp 1.8] void QXmppConfiguration::setUseFastTokenAuthentication(bool useFast)

Sets whether to use FAST token-based authentication from XEP-0484: Fast Authentication Streamlining Tokens if available.

Note that FAST requires a valid SASL 2 user-agent to be set.

useFast.

This function was introduced in QXmpp 1.8.

See also useFastTokenAuthentication().

void QXmppConfiguration::setUseNonSASLAuthentication(bool useNonSASL)

Sets whether to make use of non-SASL authentication.

useNonSASL.

See also useNonSASLAuthentication().

void QXmppConfiguration::setUseSASLAuthentication(bool useSASL)

Sets whether to make use of SASL authentication.

useSASL.

See also useSASLAuthentication().

[since QXmpp 1.7] void QXmppConfiguration::setUseSasl2Authentication(bool enabled)

Sets whether to use SASL 2 (XEP-0388: Extensible SASL Profile) authentication if available.

enabled.

This function was introduced in QXmpp 1.7.

See also useSasl2Authentication().

void QXmppConfiguration::setUser(const QString &user)

Sets the username.

user is the username of the account at the specified XMPP server. It should be the name without the domain name. E.g. "qxmpp.test1" and not "qxmpp.test1@gmail.com".

See also user().

void QXmppConfiguration::setWindowsLiveAccessToken(const QString &accessToken)

Sets the access token used for X-MESSENGER-OAUTH2 authentication.

This token is returned by Windows Live at the end of the OAuth authentication process.

accessToken.

See also windowsLiveAccessToken().

QXmppConfiguration::StreamSecurityMode QXmppConfiguration::streamSecurityMode() const

Returns the specified security mode for the stream. The default value is QXmppConfiguration::TLSEnabled.

See also setStreamSecurityMode().

[since QXmpp 1.8] bool QXmppConfiguration::useFastTokenAuthentication() const

Returns whether to use FAST token-based authentication from XEP-0484: Fast Authentication Streamlining Tokens if available.

Note that FAST requires a valid SASL 2 user-agent to be set.

This function was introduced in QXmpp 1.8.

See also setUseFastTokenAuthentication().

bool QXmppConfiguration::useNonSASLAuthentication() const

Returns whether to make use of non-SASL authentication.

See also setUseNonSASLAuthentication().

bool QXmppConfiguration::useSASLAuthentication() const

Returns whether to make use of SASL authentication.

See also setUseSASLAuthentication().

bool QXmppConfiguration::useSasl2Authentication() const

Returns whether SASL 2 (XEP-0388: Extensible SASL Profile) authentication is used if available.

See also setUseSasl2Authentication().

QString QXmppConfiguration::user() const

Returns the localpart of the JID.

See also setUser().

QString QXmppConfiguration::windowsLiveAccessToken() const

Returns the access token used for X-MESSENGER-OAUTH2 authentication.

See also setWindowsLiveAccessToken().

QXmppConfiguration &QXmppConfiguration::operator=(const QXmppConfiguration &other)

Assigns other to this QXmppConfiguration.