From: APTX Date: Mon, 10 Aug 2009 18:43:06 +0000 (+0200) Subject: - Add AniDBUdpClient namespace X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=abd7a80c92ee8216300a3a5cb3ce5e5164bc1ecc;p=anidbudpclient.git - Add AniDBUdpClient namespace --- diff --git a/abstractcommand.cpp b/abstractcommand.cpp index ba529de..790f256 100644 --- a/abstractcommand.cpp +++ b/abstractcommand.cpp @@ -1,5 +1,7 @@ #include "abstractcommand.h" +namespace AniDBUdpClient { + AbstractCommand::AbstractCommand(QObject *parent) : QObject(parent) { m_replyCode = UNKNOWN_REPLY; @@ -41,3 +43,5 @@ AbstractCommand::ReplyCode AbstractCommand::replyCode() const { return m_replyCode; } + +} // namespace AniDBUdpClient diff --git a/abstractcommand.h b/abstractcommand.h index 91587a3..48b2b33 100644 --- a/abstractcommand.h +++ b/abstractcommand.h @@ -6,6 +6,9 @@ #include #include + +namespace AniDBUdpClient { + class AniDBUdpClient; typedef QPair Command; @@ -196,7 +199,9 @@ protected: ReplyCode m_replyCode; }; +} // namespace AniDBUdpClient + #include -Q_SCRIPT_DECLARE_QMETAOBJECT(AbstractCommand, QObject*); +Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::AbstractCommand, QObject*); #endif // ABSTRACTCOMMAND_H diff --git a/anidbudpclient.cpp b/anidbudpclient.cpp index 5b9d207..9e3dc61 100644 --- a/anidbudpclient.cpp +++ b/anidbudpclient.cpp @@ -9,12 +9,14 @@ #include #include -#include -#include -#include +#include "rawcommand.h" +#include "logoutcommand.h" +#include "uptimecommand.h" #include +namespace AniDBUdpClient { + const QByteArray AniDBUdpClient::clientName = CLIENT_NAME; const int AniDBUdpClient::clientVersion = CLIENT_VERSION; const int AniDBUdpClient::protocolVersion = PROTOCOL_VERSION; @@ -228,7 +230,7 @@ void AniDBUdpClient::setFloodInterval(int interval) m_floodInterval = interval * 1000; } -AniDBUdpClient::IdlePolicy AniDBUdpClient::idlePolicy() const +IdlePolicy AniDBUdpClient::idlePolicy() const { return m_idlePolicy; } @@ -238,7 +240,7 @@ void AniDBUdpClient::setIdlePolicy(IdlePolicy policy) m_idlePolicy = policy; } -AniDBUdpClient::Error AniDBUdpClient::error() const +Error AniDBUdpClient::error() const { return m_error; } @@ -768,3 +770,5 @@ void CommandData::timerTimeout() { emit timeout(commandId); } + +} // namespace AniDBUdpClient diff --git a/anidbudpclient.h b/anidbudpclient.h index f688439..7db00a4 100644 --- a/anidbudpclient.h +++ b/anidbudpclient.h @@ -9,16 +9,18 @@ #include #include +#include "anidbudpclient_global.h" #include "authcommand.h" class QtStateMachine; class QtState; class QtHistoryState; - class QUdpSocket; class QTimer; +namespace AniDBUdpClient { + class AbstractCommand; class AuthCommand; class LogoutCommand; @@ -53,26 +55,6 @@ public: static const int clientVersion; static const int protocolVersion; - enum Error - { - NoError, - BindError, - HostLookupError, - HostUnreachableError, - AuthenticationError, - BannedError, - ServerError, - UnknownError, - }; - - enum IdlePolicy - { - DoNothingIdlePolicy, - LogoutIdlePolicy, - ImmediateLogoutIdlePolicy, - KeepAliveIdlePolicy, - }; - AniDBUdpClient(QObject *parent = 0); virtual ~AniDBUdpClient(); @@ -256,7 +238,9 @@ private slots: void timerTimeout(); }; +} // namespace AniDBUdpClient + #include -Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient, QObject*); +Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::AniDBUdpClient, QObject*); #endif // ANIDBUDPCLIENT_H diff --git a/anidbudpclient_global.h b/anidbudpclient_global.h index 2f39cda..d38c058 100644 --- a/anidbudpclient_global.h +++ b/anidbudpclient_global.h @@ -13,4 +13,27 @@ # define ANIDBUDPCLIENTSHARED_EXPORT Q_DECL_IMPORT #endif +namespace AniDBUdpClient +{ + enum Error + { + NoError, + BindError, + HostLookupError, + HostUnreachableError, + AuthenticationError, + BannedError, + ServerError, + UnknownError, + }; + + enum IdlePolicy + { + DoNothingIdlePolicy, + LogoutIdlePolicy, + ImmediateLogoutIdlePolicy, + KeepAliveIdlePolicy, + }; +} + #endif // ANIDBUDPCLIENT_GLOBAL_H diff --git a/authcommand.cpp b/authcommand.cpp index 3b942c6..fe2e2c1 100644 --- a/authcommand.cpp +++ b/authcommand.cpp @@ -2,6 +2,8 @@ #include "anidbudpclient.h" +namespace AniDBUdpClient { + AuthCommand::AuthCommand(QObject *parent) : AbstractCommand(parent) { m_compression = false; @@ -113,3 +115,5 @@ qDebug() << "ERROR CODE: " << replyCode; emit replyReady(false); } } + +} // namespace AniDBUdpClient diff --git a/authcommand.h b/authcommand.h index b22d10d..972e7c6 100644 --- a/authcommand.h +++ b/authcommand.h @@ -3,6 +3,8 @@ #include "abstractcommand.h" +namespace AniDBUdpClient { + class AuthCommand : public AbstractCommand { Q_OBJECT @@ -39,8 +41,6 @@ public: Command rawCommand() const; void setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client); - - private: QString m_user; QString m_pass; @@ -50,4 +50,6 @@ private: bool m_compression; }; +} // namespace AniDBUdpClient + #endif // AUTHCOMMAND_H diff --git a/logoutcommand.cpp b/logoutcommand.cpp index a6671e8..dfac7a1 100644 --- a/logoutcommand.cpp +++ b/logoutcommand.cpp @@ -1,5 +1,7 @@ #include "logoutcommand.h" +namespace AniDBUdpClient { + LogoutCommand::LogoutCommand(QObject *parent) : AbstractCommand(parent) { } @@ -11,3 +13,5 @@ Command LogoutCommand::rawCommand() const return command; } + +} // namespace AniDBUdpClient diff --git a/logoutcommand.h b/logoutcommand.h index bb4350b..9495561 100644 --- a/logoutcommand.h +++ b/logoutcommand.h @@ -3,6 +3,8 @@ #include "abstractcommand.h" +namespace AniDBUdpClient { + class ANIDBUDPCLIENTSHARED_EXPORT LogoutCommand : public AbstractCommand { Q_OBJECT @@ -11,4 +13,6 @@ public: Command rawCommand() const; }; +} // namespace AniDBUdpClient + #endif // LOGOUTCOMMAND_H diff --git a/mylistaddcommand.cpp b/mylistaddcommand.cpp index 2ec8708..8a50da2 100644 --- a/mylistaddcommand.cpp +++ b/mylistaddcommand.cpp @@ -8,6 +8,8 @@ #include "anidbudpclient.h" +namespace AniDBUdpClient { + MylistAddCommand::MylistAddCommand(QString file, QObject *parent) : AbstractCommand(parent) { m_file = file; @@ -164,3 +166,5 @@ qDebug() << "hashing..."; qDebug() << "hashing... complete!"; return ed2k.result().toHex(); } + +} // namespace AniDBUdpClient diff --git a/mylistaddcommand.h b/mylistaddcommand.h index 002625b..56f4268 100644 --- a/mylistaddcommand.h +++ b/mylistaddcommand.h @@ -1,12 +1,12 @@ #ifndef MYLISTADDCOMMAND_H #define MYLISTADDCOMMAND_H -#include "anidbudpclient_global.h" #include "abstractcommand.h" #include #include +namespace AniDBUdpClient { class ANIDBUDPCLIENTSHARED_EXPORT MylistAddCommand : public AbstractCommand { @@ -53,4 +53,6 @@ private: static const qint64 ED2K_PART_SIZE = 9728000; }; +} // namespace AniDBUdpClient + #endif // MYLISTADDCOMMAND_H diff --git a/mylistcommand.cpp b/mylistcommand.cpp index bab42c5..4834e72 100644 --- a/mylistcommand.cpp +++ b/mylistcommand.cpp @@ -2,6 +2,8 @@ #include +namespace AniDBUdpClient { + MyListCommand::MyListCommand(QObject *parent) : AbstractCommand(parent) { init(); @@ -311,3 +313,5 @@ void MyListCommand::init() m_state = State(0); m_fileState = FileState(0); } + +} // namespace AniDBUdpClient diff --git a/mylistcommand.h b/mylistcommand.h index 67d4ec1..3cdcf6c 100644 --- a/mylistcommand.h +++ b/mylistcommand.h @@ -1,10 +1,12 @@ #ifndef MYLISTCOMMAND_H #define MYLISTCOMMAND_H +#include "abstractcommand.h" + #include #include -#include "abstractcommand.h" +namespace AniDBUdpClient { class ANIDBUDPCLIENTSHARED_EXPORT MyListCommand : public AbstractCommand { @@ -34,6 +36,7 @@ class ANIDBUDPCLIENTSHARED_EXPORT MyListCommand : public AbstractCommand Q_PROPERTY(FileState fileState READ fileState); Q_PROPERTY(QStringList multipleEntries READ multipleEntries); + public: MyListCommand(QObject *parent = 0); MyListCommand(int lid, QObject *parent = 0); @@ -111,8 +114,9 @@ private: }; +} // namespace AniDBUdpClient #include -Q_SCRIPT_DECLARE_QMETAOBJECT(MyListCommand, QObject*); +Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::MyListCommand, QObject*); #endif // MYLISTCOMMAND_H diff --git a/rawcommand.cpp b/rawcommand.cpp index 2b3ebf9..982ac87 100644 --- a/rawcommand.cpp +++ b/rawcommand.cpp @@ -1,5 +1,7 @@ #include "rawcommand.h" +namespace AniDBUdpClient { + RawCommand::RawCommand(const QString &command, QObject *parent) : AbstractCommand(parent) { m_command = command; @@ -9,3 +11,5 @@ Command RawCommand::rawCommand() const { return Command(m_command, QVariantMap()); } + +} // namespace AniDBUdpClient diff --git a/rawcommand.h b/rawcommand.h index 990ffa4..fb18ab4 100644 --- a/rawcommand.h +++ b/rawcommand.h @@ -1,20 +1,23 @@ #ifndef RAWCOMMAND_H #define RAWCOMMAND_H -#include "anidbudpclient_global.h" #include "abstractcommand.h" +namespace AniDBUdpClient { + class ANIDBUDPCLIENTSHARED_EXPORT RawCommand : public AbstractCommand { Q_OBJECT public: - RawCommand(const QString &command, QObject *parent = 0); Command rawCommand() const; + private: QString m_command; }; +} // namespace AniDBUdpClient + #endif // RAWCOMMAND_H diff --git a/uptimecommand.cpp b/uptimecommand.cpp index 7e2aa73..0b1f3de 100644 --- a/uptimecommand.cpp +++ b/uptimecommand.cpp @@ -1,5 +1,7 @@ #include "uptimecommand.h" +namespace AniDBUdpClient { + UptimeCommand::UptimeCommand(QObject *parent) : AbstractCommand(parent) { m_uptime = 0; @@ -39,3 +41,5 @@ void UptimeCommand::setRawReply(ReplyCode replyCode, const QString &reply, AniDB break; } } + +} // namespace AniDBUdpClient diff --git a/uptimecommand.h b/uptimecommand.h index 6b1f07b..0eb131e 100644 --- a/uptimecommand.h +++ b/uptimecommand.h @@ -3,6 +3,8 @@ #include "abstractcommand.h" +namespace AniDBUdpClient { + class ANIDBUDPCLIENTSHARED_EXPORT UptimeCommand : public AbstractCommand { Q_OBJECT @@ -20,7 +22,9 @@ private: int m_uptime; }; +} // namespace AniDBUdpClient + #include -Q_SCRIPT_DECLARE_QMETAOBJECT(UptimeCommand, QObject*); +Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::UptimeCommand, QObject*); #endif // UPTIMECOMMAND_H