From 48db05496f919870f381f5b6612e8a78a5c1ae62 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 19 Jul 2012 17:59:18 +0200 Subject: move some classes to private header --- src/base/QXmppSaslAuth.cpp | 16 +++++++++ src/base/QXmppSaslAuth.h | 48 ++------------------------ src/base/QXmppSaslAuth_p.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 46 deletions(-) create mode 100644 src/base/QXmppSaslAuth_p.h (limited to 'src/base') diff --git a/src/base/QXmppSaslAuth.cpp b/src/base/QXmppSaslAuth.cpp index b42d71fa..b3758873 100644 --- a/src/base/QXmppSaslAuth.cpp +++ b/src/base/QXmppSaslAuth.cpp @@ -28,6 +28,7 @@ #include #include "QXmppSaslAuth.h" +#include "QXmppSaslAuth_p.h" #include "QXmppUtils.h" class QXmppSaslClientPrivate @@ -48,6 +49,21 @@ QXmppSaslClient::~QXmppSaslClient() delete d; } +QXmppSaslClient* QXmppSaslClient::create(const QString &mechanism) +{ + if (mechanism == "PLAIN") { + return new QXmppSaslClientPlain; + } else if (mechanism == "DIGEST-MD5") { + return new QXmppSaslClientDigestMd5; + } else if (mechanism == "ANONYMOUS") { + return new QXmppSaslClientAnonymous; + } else if (mechanism == "X-FACEBOOK-PLATFORM") { + return new QXmppSaslClientFacebook; + } else { + return 0; + } +} + /// Returns the server. QString QXmppSaslClient::server() const diff --git a/src/base/QXmppSaslAuth.h b/src/base/QXmppSaslAuth.h index 1ae20a37..cb6fc467 100644 --- a/src/base/QXmppSaslAuth.h +++ b/src/base/QXmppSaslAuth.h @@ -94,54 +94,10 @@ public: virtual QString mechanism() const = 0; virtual bool respond(const QByteArray &challenge, QByteArray &response) = 0; -private: - QXmppSaslClientPrivate *d; -}; - -class QXmppSaslClientAnonymous : public QXmppSaslClient -{ -public: - QXmppSaslClientAnonymous(); - QString mechanism() const; - bool respond(const QByteArray &challenge, QByteArray &response); - -private: - int m_step; -}; - -class QXmppSaslClientDigestMd5 : public QXmppSaslClient -{ -public: - QXmppSaslClientDigestMd5(); - QString mechanism() const; - bool respond(const QByteArray &challenge, QByteArray &response); - -private: - QXmppSaslDigestMd5 m_saslDigest; - int m_step; -}; - -class QXmppSaslClientFacebook : public QXmppSaslClient -{ -public: - QXmppSaslClientFacebook(); - QString mechanism() const; - bool respond(const QByteArray &challenge, QByteArray &response); + static QXmppSaslClient* create(const QString &mechanism); private: - int m_step; -}; - -class QXmppSaslClientPlain : public QXmppSaslClient -{ -public: - QXmppSaslClientPlain(); - QString mechanism() const; - bool respond(const QByteArray &challenge, QByteArray &response); - -private: - int m_step; + QXmppSaslClientPrivate *d; }; - #endif diff --git a/src/base/QXmppSaslAuth_p.h b/src/base/QXmppSaslAuth_p.h new file mode 100644 index 00000000..eee93322 --- /dev/null +++ b/src/base/QXmppSaslAuth_p.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2008-2012 The QXmpp developers + * + * Authors: + * Manjeet Dahiya + * Jeremy Lainé + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef QXMPPSASLAUTH_P_H +#define QXMPPSASLAUTH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the QXmpp API. It exists for the convenience +// of the QXmppSaslClient class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +class QXmppSaslClientAnonymous : public QXmppSaslClient +{ +public: + QXmppSaslClientAnonymous(); + QString mechanism() const; + bool respond(const QByteArray &challenge, QByteArray &response); + +private: + int m_step; +}; + +class QXmppSaslClientDigestMd5 : public QXmppSaslClient +{ +public: + QXmppSaslClientDigestMd5(); + QString mechanism() const; + bool respond(const QByteArray &challenge, QByteArray &response); + +private: + QXmppSaslDigestMd5 m_saslDigest; + int m_step; +}; + +class QXmppSaslClientFacebook : public QXmppSaslClient +{ +public: + QXmppSaslClientFacebook(); + QString mechanism() const; + bool respond(const QByteArray &challenge, QByteArray &response); + +private: + int m_step; +}; + +class QXmppSaslClientPlain : public QXmppSaslClient +{ +public: + QXmppSaslClientPlain(); + QString mechanism() const; + bool respond(const QByteArray &challenge, QByteArray &response); + +private: + int m_step; +}; + +#endif -- cgit v1.2.3