diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-07-18 15:17:22 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-07-18 15:17:22 +0200 |
| commit | ef9f9a57f1dd2e70d29afa26fa0d1ab38a5e3aca (patch) | |
| tree | 2fe85d94ccefcbd24f83bc91e1bfe271beb6337b /src/client | |
| parent | 89a558dfbbbde668666e7d8af8f52c23fa61530b (diff) | |
| download | qxmpp-ef9f9a57f1dd2e70d29afa26fa0d1ab38a5e3aca.tar.gz | |
Make SASL mechanisms string based.
Deprecate QXmppConfiguration::setSASLAuthMechanism(), replaced by
the string-based QXmppConfiguration::setSaslAuthMechanism().
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/QXmppConfiguration.cpp | 58 | ||||
| -rw-r--r-- | src/client/QXmppConfiguration.h | 24 | ||||
| -rw-r--r-- | src/client/QXmppOutgoingClient.cpp | 16 |
3 files changed, 61 insertions, 37 deletions
diff --git a/src/client/QXmppConfiguration.cpp b/src/client/QXmppConfiguration.cpp index 544997be..62fa7a07 100644 --- a/src/client/QXmppConfiguration.cpp +++ b/src/client/QXmppConfiguration.cpp @@ -64,7 +64,7 @@ public: QXmppConfiguration::StreamSecurityMode streamSecurityMode; QXmppConfiguration::NonSASLAuthMechanism nonSASLAuthMechanism; - QXmppConfiguration::SASLAuthMechanism SASLAuthMechanism; + QString saslAuthMechanism; QNetworkProxy networkProxy; @@ -84,7 +84,7 @@ QXmppConfigurationPrivate::QXmppConfigurationPrivate() , ignoreSslErrors(true) , streamSecurityMode(QXmppConfiguration::TLSEnabled) , nonSASLAuthMechanism(QXmppConfiguration::NonSASLDigest) - , SASLAuthMechanism(QXmppConfiguration::SASLDigestMD5) + , saslAuthMechanism("DIGEST-MD5") { } @@ -447,25 +447,22 @@ void QXmppConfiguration::setNonSASLAuthMechanism( d->nonSASLAuthMechanism = mech; } -/// Returns the SASL authentication mechanism configuration. -/// -/// \return QXmppConfiguration::SASLAuthMechanism +/// Returns the preferred SASL authentication mechanism. /// +/// Default value: "DIGEST-MD5" -QXmppConfiguration::SASLAuthMechanism QXmppConfiguration::sASLAuthMechanism() const +QString QXmppConfiguration::saslAuthMechanism() const { - return d->SASLAuthMechanism; + return d->saslAuthMechanism; } -/// Hints the library the SASL authentication mechanism to be used for authentication. -/// -/// \param mech QXmppConfiguration::SASLAuthMechanism +/// Sets the preferred SASL authentication \a mechanism. /// +/// Valid values: "PLAIN", "DIGEST-MD5", "ANONYMOUS", "X-FACEBOOK-PLATFORM" -void QXmppConfiguration::setSASLAuthMechanism( - QXmppConfiguration::SASLAuthMechanism mech) +void QXmppConfiguration::setSaslAuthMechanism(const QString &mechanism) { - d->SASLAuthMechanism = mech; + d->saslAuthMechanism = mechanism; } /// Specifies the network proxy used for the connection made by QXmppClient. @@ -547,3 +544,38 @@ QList<QSslCertificate> QXmppConfiguration::caCertificates() const return d->caCertificates; } +// obsolete + +QXmppConfiguration::SASLAuthMechanism QXmppConfiguration::sASLAuthMechanism() const +{ + if (d->saslAuthMechanism == "PLAIN") + return SASLPlain; + else if (d->saslAuthMechanism == "DIGEST-MD5") + return SASLDigestMD5; + else if (d->saslAuthMechanism == "ANONYMOUS") + return SASLAnonymous; + else if (d->saslAuthMechanism == "X-FACEBOOK-PLATFORM") + return SASLXFacebookPlatform; + else + return SASLDigestMD5; +} + +void QXmppConfiguration::setSASLAuthMechanism( + QXmppConfiguration::SASLAuthMechanism mech) +{ + switch (mech) { + case QXmppConfiguration::SASLPlain: + d->saslAuthMechanism = "PLAIN"; + break; + case QXmppConfiguration::SASLDigestMD5: + d->saslAuthMechanism = "DIGEST-MD5"; + break; + case QXmppConfiguration::SASLAnonymous: + d->saslAuthMechanism = "ANONYMOUS"; + break; + case QXmppConfiguration::SASLXFacebookPlatform: + d->saslAuthMechanism = "X-FACEBOOK-PLATFORM"; + break; + } +} + diff --git a/src/client/QXmppConfiguration.h b/src/client/QXmppConfiguration.h index 9d6ce65f..c578cd74 100644 --- a/src/client/QXmppConfiguration.h +++ b/src/client/QXmppConfiguration.h @@ -72,13 +72,6 @@ public: /// The server may or may not allow any particular mechanism. So depending /// upon the availability of mechanisms on the server the library will choose /// a mechanism. - enum SASLAuthMechanism - { - SASLPlain = 0, ///< Plain - SASLDigestMD5, ///< Digest MD5 (default) - SASLAnonymous, ///< Anonymous - SASLXFacebookPlatform, ///< Facebook Platform - }; QXmppConfiguration(); QXmppConfiguration(const QXmppConfiguration &other); @@ -132,8 +125,8 @@ public: QXmppConfiguration::NonSASLAuthMechanism nonSASLAuthMechanism() const; void setNonSASLAuthMechanism(QXmppConfiguration::NonSASLAuthMechanism); - QXmppConfiguration::SASLAuthMechanism sASLAuthMechanism() const; - void setSASLAuthMechanism(QXmppConfiguration::SASLAuthMechanism); + QString saslAuthMechanism() const; + void setSaslAuthMechanism(const QString &mechanism); QNetworkProxy networkProxy() const; void setNetworkProxy(const QNetworkProxy& proxy); @@ -147,6 +140,19 @@ public: QList<QSslCertificate> caCertificates() const; void setCaCertificates(const QList<QSslCertificate> &); + /// \cond + // deprecated since 0.6.0 + enum SASLAuthMechanism + { + SASLPlain = 0, + SASLDigestMD5, + SASLAnonymous, + SASLXFacebookPlatform + }; + QXmppConfiguration::SASLAuthMechanism Q_DECL_DEPRECATED sASLAuthMechanism() const; + void Q_DECL_DEPRECATED setSASLAuthMechanism(QXmppConfiguration::SASLAuthMechanism); + /// \endcond + private: QSharedDataPointer<QXmppConfigurationPrivate> d; }; diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp index 10f82ad0..0d0da95a 100644 --- a/src/client/QXmppOutgoingClient.cpp +++ b/src/client/QXmppOutgoingClient.cpp @@ -339,21 +339,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv) { // supported and preferred SASL auth mechanisms const QStringList supportedMechanisms = QStringList() << "PLAIN" << "DIGEST-MD5" << "ANONYMOUS" << "X-FACEBOOK-PLATFORM"; - QString preferredMechanism; - switch (configuration().sASLAuthMechanism()) { - case QXmppConfiguration::SASLPlain: - preferredMechanism = "PLAIN"; - break; - case QXmppConfiguration::SASLDigestMD5: - preferredMechanism = "DIGEST-MD5"; - break; - case QXmppConfiguration::SASLAnonymous: - preferredMechanism = "ANONYMOUS"; - break; - case QXmppConfiguration::SASLXFacebookPlatform: - preferredMechanism = "X-FACEBOOK-PLATFORM"; - break; - } + const QString preferredMechanism = configuration().saslAuthMechanism(); // determine SASL Authentication mechanism to use QStringList commonMechanisms; |
