]> Some of my projects - anidbudpclient.git/commitdiff
- Rename class AniDBUdpClient -> Client
authorAPTX <mail@example.com>
Mon, 10 Aug 2009 19:16:47 +0000 (21:16 +0200)
committerAPTX <mail@example.com>
Mon, 10 Aug 2009 19:16:47 +0000 (21:16 +0200)
14 files changed:
abstractcommand.cpp
abstractcommand.h
anidbudpclient.pro
anidbudpclient_global.h
authcommand.cpp
authcommand.h
client.cpp [moved from anidbudpclient.cpp with 83% similarity]
client.h [moved from anidbudpclient.h with 95% similarity]
mylistaddcommand.cpp
mylistaddcommand.h
mylistcommand.cpp
mylistcommand.h
uptimecommand.cpp
uptimecommand.h

index 790f256a9e19e61bde8155dfc1e6f9af31b30664..915e715093e4977100fffe73524a19a9a92279e2 100644 (file)
@@ -27,7 +27,7 @@ bool AbstractCommand::requiresSession() const
        return true;
 }
 
-void AbstractCommand::setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client)
+void AbstractCommand::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
 {
        Q_UNUSED(client);
        m_replyCode = replyCode;
@@ -39,7 +39,7 @@ QString AbstractCommand::rawReply() const
        return m_rawReply;
 }
 
-AbstractCommand::ReplyCode AbstractCommand::replyCode() const
+ReplyCode AbstractCommand::replyCode() const
 {
        return m_replyCode;
 }
index 48b2b332fdfccac0a20fe11acef9968cb5af5f38..8a2dc2a20a09ccc7dc566a56c4775cd5e64bbbc7 100644 (file)
@@ -2,6 +2,7 @@
 #define ABSTRACTCOMMAND_H
 
 #include "anidbudpclient_global.h"
+
 #include <QObject>
 #include <QPair>
 #include <QVariantMap>
 
 namespace AniDBUdpClient {
 
-class AniDBUdpClient;
+class Client;
 
 typedef QPair<QString, QVariantMap> Command;
 
 class ANIDBUDPCLIENTSHARED_EXPORT AbstractCommand : public QObject
 {
        Q_OBJECT
-       Q_ENUMS(ReplyCode State FileState);
 
        Q_PROPERTY(ReplyCode replyCode READ replyCode);
 
 public:
 
-       enum ReplyCode
-       {
-               CLIENT_DESTROYED                        = -1,
-               UNKNOWN_REPLY                           = 0,
-               // POSITIVE 2XX
-               LOGIN_ACCEPTED                          = 200, //a
-               LOGIN_ACCEPTED_NEW_VER          = 201, //a
-               LOGGED_OUT                                      = 203, //a
-               RESOURCE                                        = 205, //d
-               STATS                                           = 206, //b
-               TOP                                                     = 207, //b
-               UPTIME                                          = 208, //b
-               ENCRYPTION_ENABLED                      = 209, //c
-
-               MYLIST_ENTRY_ADDED                      = 210, //a
-               MYLIST_ENTRY_DELETED            = 211, //a
-
-               ADDED_FILE                                      = 214, //e
-               ADDED_STREAM                            = 215, //e
-
-               ENCODING_CHANGED                        = 219, //c
-
-               FILE                                            = 220, //a
-               MYLIST                                          = 221, //a
-               MYLIST_STATS                            = 222, //b
-
-               ANIME                                           = 230, //b
-               ANIME_BEST_MATCH                        = 231, //b
-               RANDOMANIME                                     = 232, //b
-               ANIME_DESCRIPTION                       = 233, //b
-
-               EPISODE                                         = 240, //b
-               PRODUCER                                        = 245, //b
-               GROUP                                           = 250, //b
-
-               BUDDY_LIST                                      = 253, //c
-               BUDDY_STATE                                     = 254, //c
-               BUDDY_ADDED                                     = 255, //c
-               BUDDY_DELETED                           = 256, //c
-               BUDDY_ACCEPTED                          = 257, //c
-               BUDDY_DENIED                            = 258, //c
-
-               VOTED                                           = 260, //b
-               VOTE_FOUND                                      = 261, //b
-               VOTE_UPDATED                            = 262, //b
-               VOTE_REVOKED                            = 263, //b
-
-               NOTIFICATION_ENABLED            = 270, //a
-               NOTIFICATION_NOTIFY                     = 271, //a
-               NOTIFICATION_MESSAGE            = 272, //a
-               NOTIFICATION_BUDDY                      = 273, //c
-               NOTIFICATION_SHUTDOWN           = 274, //c
-               PUSHACK_CONFIRMED                       = 280, //a
-               NOTIFYACK_SUCCESSFUL_M          = 281, //a
-               NOTIFYACK_SUCCESSFUL_N          = 282, //a
-               NOTIFICATION                            = 290, //a
-               NOTIFYLIST                                      = 291, //a
-               NOTIFYGET_MESSAGE                       = 292, //a
-               NOTIFYGET_NOTIFY                        = 293, //a
-
-               SENDMSG_SUCCESSFUL                      = 294, //a
-               USER                                            = 295, //d
-
-               // AFFIRMATIVE/NEGATIVE 3XX
-               PONG                                            = 300, //a
-               AUTHPONG                                        = 301, //c
-               NO_SUCH_RESOURCE                        = 305, //d
-               API_PASSWORD_NOT_DEFINED        = 309, //c
-
-               FILE_ALREADY_IN_MYLIST          = 310, //a
-               MYLIST_ENTRY_EDITED                     = 311, //a
-               MULTIPLE_MYLIST_ENTRIES         = 312, //e
-
-               SIZE_HASH_EXISTS                        = 314, //c
-               INVALID_DATA                            = 315, //c
-               STREAMNOID_USED                         = 316, //c
-
-               NO_SUCH_FILE                            = 320, //a
-               NO_SUCH_ENTRY                           = 321, //a
-               MULTIPLE_FILES_FOUND            = 322, //b
-
-               NO_SUCH_ANIME                           = 330, //b
-               NO_SUCH_ANIME_DESCRIPTION       = 333, //b
-               NO_SUCH_EPISODE                         = 340, //b
-               NO_SUCH_PRODUCER                        = 345, //b
-               NO_SUCH_GROUP                           = 350, //b
-
-               BUDDY_ALREADY_ADDED                     = 355, //c
-               NO_SUCH_BUDDY                           = 356, //c
-               BUDDY_ALREADY_ACCEPTED          = 357, //c
-               BUDDY_ALREADY_DENIED            = 358, //c
-
-               NO_SUCH_VOTE                            = 360, //b
-               INVALID_VOTE_TYPE                       = 361, //b
-               INVALID_VOTE_VALUE                      = 362, //b
-               PERMVOTE_NOT_ALLOWED            = 363, //b
-               ALREADY_PERMVOTED                       = 364, //b
-
-               NOTIFICATION_DISABLED           = 370, //a
-               NO_SUCH_PACKET_PENDING          = 380, //a
-               NO_SUCH_ENTRY_M                         = 381, //a
-               NO_SUCH_ENTRY_N                         = 382, //a
-
-               NO_SUCH_MESSAGE                         = 392, //a
-               NO_SUCH_NOTIFY                          = 393, //a
-               NO_SUCH_USER                            = 394, //a
-
-               // NEGATIVE 4XX
-               NOT_LOGGED_IN                           = 403, //a
-
-               NO_SUCH_MYLIST_FILE                     = 410, //a
-               NO_SUCH_MYLIST_ENTRY            = 411, //a
-
-
-               // CLIENT SIDE FAILURE 5XX
-               LOGIN_FAILED                            = 500, //a
-               LOGIN_FIRST                                     = 501, //a
-               ACCESS_DENIED                           = 502, //a
-               CLIENT_VERSION_OUTDATED         = 503, //a
-               CLIENT_BANNED                           = 504, //a
-               ILLEGAL_INPUT_OR_ACCESS_DENIED  = 505, //a
-               INVALID_SESSION                         = 506, //a
-               NO_SUCH_ENCRYPTION_TYPE         = 509, //c
-               ENCODING_NOT_SUPPORTED          = 519, //c
-
-               BANNED                                          = 555, //a
-               UNKNOWN_COMMAND                         = 598, //a
-
-
-               // SERVER SIDE FAILURE 6XX
-               INTERNAL_SERVER_ERROR           = 600, //a
-               ANIDB_OUT_OF_SERVICE            = 601, //a
-               SERVER_BUSY                                     = 602, //d
-               API_VIOLATION                           = 666, //a
-       };
-
-       enum State {
-               Unknown = 0,
-               OnHdd = 1,
-               OnCd = 2,
-               Deleted = 3
-       };
-
-       enum FileState {
-               Normal = 0,
-               Corrupted = 1,
-               SelfEdited = 2,
-               SelfRipped = 10,
-               OnDVD = 11,
-               OnVHS = 12,
-               OnTV = 13,
-               InTheatres = 14,
-               Streamed = 15,
-               Other = 100
-       };
-
        AbstractCommand(QObject *parent = 0);
        virtual ~AbstractCommand();
 
@@ -186,7 +30,7 @@ public:
        virtual bool waitForResult() const;
        virtual bool requiresSession() const;
 
-       virtual void setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client);
+       virtual void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
        virtual QString rawReply() const;
 
        virtual ReplyCode replyCode() const;
index 8e1b8c156b50dc907c5dba96ac55c56831ef1462..52a6bf0dc1818d0f45d369779e361e25f3702be0 100644 (file)
@@ -17,7 +17,7 @@ INCLUDEPATH += $$PWD
 DEPENDPATH += $$PWD
 QT *= network
 DEFINES += ANIDBUDPCLIENT_LIBRARY
-SOURCES += anidbudpclient.cpp \
+SOURCES += client.cpp \
     abstractcommand.cpp \
     authcommand.cpp \
     rawcommand.cpp \
@@ -25,7 +25,7 @@ SOURCES += anidbudpclient.cpp \
     logoutcommand.cpp \
     uptimecommand.cpp \
     mylistcommand.cpp
-HEADERS += anidbudpclient.h \
+HEADERS += client.h \
     anidbudpclient_global.h \
     abstractcommand.h \
     authcommand.h \
index d38c0584f7239bafa2f11cc24576ef68428d76db..2f5a1a48953a5aa3cee0d5c0e23d8869bb7b7773 100644 (file)
@@ -2,6 +2,7 @@
 #define ANIDBUDPCLIENT_GLOBAL_H
 
 #include <QtCore/qglobal.h>
+#include <QObject>
 
 #define CLIENT_NAME "anidbudpclient"
 #define CLIENT_VERSION 0x000002
@@ -34,6 +35,164 @@ namespace AniDBUdpClient
                ImmediateLogoutIdlePolicy,
                KeepAliveIdlePolicy,
        };
+
+       enum ReplyCode
+       {
+               CLIENT_DESTROYED                        = -1,
+               UNKNOWN_REPLY                           = 0,
+               // POSITIVE 2XX
+               LOGIN_ACCEPTED                          = 200, //a
+               LOGIN_ACCEPTED_NEW_VER          = 201, //a
+               LOGGED_OUT                                      = 203, //a
+               RESOURCE                                        = 205, //d
+               STATS                                           = 206, //b
+               TOP                                                     = 207, //b
+               UPTIME                                          = 208, //b
+               ENCRYPTION_ENABLED                      = 209, //c
+
+               MYLIST_ENTRY_ADDED                      = 210, //a
+               MYLIST_ENTRY_DELETED            = 211, //a
+
+               ADDED_FILE                                      = 214, //e
+               ADDED_STREAM                            = 215, //e
+
+               ENCODING_CHANGED                        = 219, //c
+
+               FILE                                            = 220, //a
+               MYLIST                                          = 221, //a
+               MYLIST_STATS                            = 222, //b
+
+               ANIME                                           = 230, //b
+               ANIME_BEST_MATCH                        = 231, //b
+               RANDOMANIME                                     = 232, //b
+               ANIME_DESCRIPTION                       = 233, //b
+
+               EPISODE                                         = 240, //b
+               PRODUCER                                        = 245, //b
+               GROUP                                           = 250, //b
+
+               BUDDY_LIST                                      = 253, //c
+               BUDDY_STATE                                     = 254, //c
+               BUDDY_ADDED                                     = 255, //c
+               BUDDY_DELETED                           = 256, //c
+               BUDDY_ACCEPTED                          = 257, //c
+               BUDDY_DENIED                            = 258, //c
+
+               VOTED                                           = 260, //b
+               VOTE_FOUND                                      = 261, //b
+               VOTE_UPDATED                            = 262, //b
+               VOTE_REVOKED                            = 263, //b
+
+               NOTIFICATION_ENABLED            = 270, //a
+               NOTIFICATION_NOTIFY                     = 271, //a
+               NOTIFICATION_MESSAGE            = 272, //a
+               NOTIFICATION_BUDDY                      = 273, //c
+               NOTIFICATION_SHUTDOWN           = 274, //c
+               PUSHACK_CONFIRMED                       = 280, //a
+               NOTIFYACK_SUCCESSFUL_M          = 281, //a
+               NOTIFYACK_SUCCESSFUL_N          = 282, //a
+               NOTIFICATION                            = 290, //a
+               NOTIFYLIST                                      = 291, //a
+               NOTIFYGET_MESSAGE                       = 292, //a
+               NOTIFYGET_NOTIFY                        = 293, //a
+
+               SENDMSG_SUCCESSFUL                      = 294, //a
+               USER                                            = 295, //d
+
+               // AFFIRMATIVE/NEGATIVE 3XX
+               PONG                                            = 300, //a
+               AUTHPONG                                        = 301, //c
+               NO_SUCH_RESOURCE                        = 305, //d
+               API_PASSWORD_NOT_DEFINED        = 309, //c
+
+               FILE_ALREADY_IN_MYLIST          = 310, //a
+               MYLIST_ENTRY_EDITED                     = 311, //a
+               MULTIPLE_MYLIST_ENTRIES         = 312, //e
+
+               SIZE_HASH_EXISTS                        = 314, //c
+               INVALID_DATA                            = 315, //c
+               STREAMNOID_USED                         = 316, //c
+
+               NO_SUCH_FILE                            = 320, //a
+               NO_SUCH_ENTRY                           = 321, //a
+               MULTIPLE_FILES_FOUND            = 322, //b
+
+               NO_SUCH_ANIME                           = 330, //b
+               NO_SUCH_ANIME_DESCRIPTION       = 333, //b
+               NO_SUCH_EPISODE                         = 340, //b
+               NO_SUCH_PRODUCER                        = 345, //b
+               NO_SUCH_GROUP                           = 350, //b
+
+               BUDDY_ALREADY_ADDED                     = 355, //c
+               NO_SUCH_BUDDY                           = 356, //c
+               BUDDY_ALREADY_ACCEPTED          = 357, //c
+               BUDDY_ALREADY_DENIED            = 358, //c
+
+               NO_SUCH_VOTE                            = 360, //b
+               INVALID_VOTE_TYPE                       = 361, //b
+               INVALID_VOTE_VALUE                      = 362, //b
+               PERMVOTE_NOT_ALLOWED            = 363, //b
+               ALREADY_PERMVOTED                       = 364, //b
+
+               NOTIFICATION_DISABLED           = 370, //a
+               NO_SUCH_PACKET_PENDING          = 380, //a
+               NO_SUCH_ENTRY_M                         = 381, //a
+               NO_SUCH_ENTRY_N                         = 382, //a
+
+               NO_SUCH_MESSAGE                         = 392, //a
+               NO_SUCH_NOTIFY                          = 393, //a
+               NO_SUCH_USER                            = 394, //a
+
+               // NEGATIVE 4XX
+               NOT_LOGGED_IN                           = 403, //a
+
+               NO_SUCH_MYLIST_FILE                     = 410, //a
+               NO_SUCH_MYLIST_ENTRY            = 411, //a
+
+
+               // CLIENT SIDE FAILURE 5XX
+               LOGIN_FAILED                            = 500, //a
+               LOGIN_FIRST                                     = 501, //a
+               ACCESS_DENIED                           = 502, //a
+               CLIENT_VERSION_OUTDATED         = 503, //a
+               CLIENT_BANNED                           = 504, //a
+               ILLEGAL_INPUT_OR_ACCESS_DENIED  = 505, //a
+               INVALID_SESSION                         = 506, //a
+               NO_SUCH_ENCRYPTION_TYPE         = 509, //c
+               ENCODING_NOT_SUPPORTED          = 519, //c
+
+               BANNED                                          = 555, //a
+               UNKNOWN_COMMAND                         = 598, //a
+
+
+               // SERVER SIDE FAILURE 6XX
+               INTERNAL_SERVER_ERROR           = 600, //a
+               ANIDB_OUT_OF_SERVICE            = 601, //a
+               SERVER_BUSY                                     = 602, //d
+               API_VIOLATION                           = 666, //a
+       };
+
+       enum State {
+               StateUnknown = 0,
+               StateOnHdd = 1,
+               StateOnCd = 2,
+               StateDeleted = 3
+       };
+
+       enum FileState {
+               FileStateNormal = 0,
+               FileStateCorrupted = 1,
+               FileStateSelfEdited = 2,
+               FileStateSelfRipped = 10,
+               FileStateOnDVD = 11,
+               FileStateOnVHS = 12,
+               FileStateOnTV = 13,
+               FileStateInTheatres = 14,
+               FileStateStreamed = 15,
+               FileStateOther = 100
+       };
+
+       Q_ENUMS(Error IdlePolicy ReplyCode State FileState);
 }
 
 #endif // ANIDBUDPCLIENT_GLOBAL_H
index fe2e2c129b3ee53fc5eb99562d3717c25b05f228..517aeb1e4506008079b3f2b57e8bbc3b6986b66c 100644 (file)
@@ -1,6 +1,6 @@
 #include "authcommand.h"
 
-#include "anidbudpclient.h"
+#include "client.h"
 
 namespace AniDBUdpClient {
 
@@ -78,15 +78,15 @@ Command AuthCommand::rawCommand() const
 
        command.second["user"] = m_user.toLower(); // All usernames are lower case
        command.second["pass"] = m_pass;
-       command.second["protover"] = AniDBUdpClient::protocolVersion;
-       command.second["client"] = AniDBUdpClient::clientName.constData();
-       command.second["clientver"] = AniDBUdpClient::clientVersion;
+       command.second["protover"] = Client::protocolVersion;
+       command.second["client"] = Client::clientName.constData();
+       command.second["clientver"] = Client::clientVersion;
        command.second["enc"] = "UTF8";
        command.second["comp"] = m_compression;
        return command;
 }
 
-void AuthCommand::setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client)
+void AuthCommand::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
 {
 qDebug() << replyCode;
        AbstractCommand::setRawReply(replyCode, reply, client);
index 972e7c674aedda7853065118d3ce1d4e0ace6131..b085318a1b4a8c449ed3848c1b7a96582e996bbf 100644 (file)
@@ -39,7 +39,7 @@ public:
        bool requiresSession() const;
 
        Command rawCommand() const;
-       void setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client);
+       void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
 
 private:
        QString m_user;
similarity index 83%
rename from anidbudpclient.cpp
rename to client.cpp
index 9e3dc6130884c157548a66ff789369420333bb5d..c2da3cbf1b07bec43bfcdf09b4619ed253f5434f 100644 (file)
@@ -1,4 +1,4 @@
-#include "anidbudpclient.h"
+#include "client.h"
 
 #include <QtStateMachine>
 #include <QtActionState>
 
 namespace AniDBUdpClient {
 
-const QByteArray AniDBUdpClient::clientName = CLIENT_NAME;
-const int AniDBUdpClient::clientVersion = CLIENT_VERSION;
-const int AniDBUdpClient::protocolVersion = PROTOCOL_VERSION;
+const QByteArray Client::clientName = CLIENT_NAME;
+const int Client::clientVersion = CLIENT_VERSION;
+const int Client::protocolVersion = PROTOCOL_VERSION;
 
-AniDBUdpClient::AniDBUdpClient(QObject *parent) : QObject(parent)
+Client::Client(QObject *parent) : QObject(parent)
 {
 qDebug() << "Api instance init!";
 
@@ -128,7 +128,7 @@ qDebug() << "Api instance init!";
        stateMachine->start();
 }
 
-AniDBUdpClient::~AniDBUdpClient()
+Client::~Client()
 {
        disconnect();
        clearCommandQueue();
@@ -142,7 +142,7 @@ AniDBUdpClient::~AniDBUdpClient()
                else
                {
                        // Send CLIENT_DESTROYED to indicate that no real reply will come.
-                       cmd->command->setRawReply(AbstractCommand::CLIENT_DESTROYED, "", this);
+                       cmd->command->setRawReply(CLIENT_DESTROYED, "", this);
                }
        }
        qDeleteAll(sentCommands);
@@ -157,12 +157,12 @@ AniDBUdpClient::~AniDBUdpClient()
        }
 }
 
-QString AniDBUdpClient::host() const
+QString Client::host() const
 {
        return m_host;
 }
 
-void AniDBUdpClient::setHost(const QString &host, quint16 port)
+void Client::setHost(const QString &host, quint16 port)
 {
        m_host = host;
        if (port)
@@ -170,101 +170,101 @@ void AniDBUdpClient::setHost(const QString &host, quint16 port)
        m_hostAddress = QHostAddress();
 }
 
-quint16 AniDBUdpClient::hostPort() const
+quint16 Client::hostPort() const
 {
        return m_hostPort;
 }
 
-void AniDBUdpClient::setHostPort(quint16 port)
+void Client::setHostPort(quint16 port)
 {
        m_hostPort = port;
 }
 
-quint16 AniDBUdpClient::localPort() const
+quint16 Client::localPort() const
 {
        return m_localPort;
 }
 
-void AniDBUdpClient::setLocalPort(quint16 port)
+void Client::setLocalPort(quint16 port)
 {
        m_localPort = port;
 }
 
-QString AniDBUdpClient::user() const
+QString Client::user() const
 {
        return m_user;
 }
 
-void AniDBUdpClient::setUser(const QString &user)
+void Client::setUser(const QString &user)
 {
        m_user = user;
 }
 
-QString AniDBUdpClient::pass() const
+QString Client::pass() const
 {
        return m_pass;
 }
 
-void AniDBUdpClient::setPass(const QString &pass)
+void Client::setPass(const QString &pass)
 {
        m_pass = pass;
 }
 
-bool AniDBUdpClient::compression() const
+bool Client::compression() const
 {
        return m_compression;
 }
 
-void AniDBUdpClient::setCompression(bool compress)
+void Client::setCompression(bool compress)
 {
        m_compression = compress;
 }
 
-int AniDBUdpClient::floodInterval() const
+int Client::floodInterval() const
 {
        return m_floodInterval;
 }
 
-void AniDBUdpClient::setFloodInterval(int interval)
+void Client::setFloodInterval(int interval)
 {
        m_floodInterval = interval * 1000;
 }
 
-IdlePolicy AniDBUdpClient::idlePolicy() const
+IdlePolicy Client::idlePolicy() const
 {
        return m_idlePolicy;
 }
 
-void AniDBUdpClient::setIdlePolicy(IdlePolicy policy)
+void Client::setIdlePolicy(IdlePolicy policy)
 {
        m_idlePolicy = policy;
 }
 
-Error AniDBUdpClient::error() const
+Error Client::error() const
 {
        return m_error;
 }
 
-QString AniDBUdpClient::errorString() const
+QString Client::errorString() const
 {
        return m_errorString;
 }
 
 // ------------------------------------------------------------------------------
 
-void AniDBUdpClient::enterErrorState()
+void Client::enterErrorState()
 {
 qDebug() << "Entering Error State";
 }
 
-void AniDBUdpClient::enterDisconnectedState()
+void Client::enterDisconnectedState()
 {
 qDebug() << "Entering Disconnected State";
        if (socket->state() == QAbstractSocket::BoundState)
                socket->disconnectFromHost();
 }
 
-void AniDBUdpClient::enterConnectingState()
+void Client::enterConnectingState()
 {
 qDebug() << "Entering Connecting State";
 
@@ -286,7 +286,7 @@ qDebug() << QString("Bind on Address: %1 port: %2 failed").arg(m_hostAddress.toS
        QHostInfo::lookupHost(m_host, this, SLOT(lookedUp(QHostInfo)));
 }
 
-void AniDBUdpClient::lookedUp(QHostInfo hostInfo)
+void Client::lookedUp(QHostInfo hostInfo)
 {
 qDebug() << "Host lookup finished";
        if (hostInfo.error() != QHostInfo::NoError)
@@ -303,13 +303,13 @@ qDebug() << "Host lookup finished";
        enterConnectingState();
 }
 
-void AniDBUdpClient::enterConnectedState()
+void Client::enterConnectedState()
 {
 qDebug() << "Entering Connected State";
        emit connected();
 }
 
-void AniDBUdpClient::enterAuthenticatingState()
+void Client::enterAuthenticatingState()
 {
 qDebug() << "Entering Authenticating State";
 
@@ -325,7 +325,7 @@ qDebug() << "Entering Authenticating State";
        emit authenticated();
 }
 
-void AniDBUdpClient::doAuthenticate(bool success)
+void Client::doAuthenticate(bool success)
 {
 qDebug() << "doAuthenticate init";
        if (success)
@@ -342,7 +342,7 @@ qDebug() << "success!";
        emit connectionError();
 }
 
-void AniDBUdpClient::enterSendState()
+void Client::enterSendState()
 {
 qDebug() << "Entering Send State";
 
@@ -373,7 +373,7 @@ qDebug() << "Sending Control Command";
        emit commandSent();
 }
 
-void AniDBUdpClient::enterWaitState()
+void Client::enterWaitState()
 {
 qDebug() << "Entering Wait State";
 
@@ -382,7 +382,7 @@ qDebug() << "Entering Wait State";
                commandTimer->start(m_floodInterval);
 }
 
-void AniDBUdpClient::enterIdleState()
+void Client::enterIdleState()
 {
 qDebug() << "Entering Idle State";
 qDebug() << m_idlePolicy;
@@ -407,13 +407,13 @@ qDebug() << m_idlePolicy;
        }
 }
 
-void AniDBUdpClient::exitIdleState()
+void Client::exitIdleState()
 {
 qDebug() << "Exiting Idle State";
        idleTimer->stop();
 }
 
-void AniDBUdpClient::enterIdleTiemoutState()
+void Client::enterIdleTiemoutState()
 {
 qDebug() << "Entering IdleTiemout State";
        switch (m_idlePolicy)
@@ -428,7 +428,7 @@ qDebug() << "Entering IdleTiemout State";
        }
 }
 
-void AniDBUdpClient::enterRecieveState()
+void Client::enterRecieveState()
 {
 qDebug() << "Entering Recieve State";
        while (socket->hasPendingDatagrams())
@@ -482,10 +482,10 @@ qDebug() << "COMPRESSED DATAGRAM = " << tmp;
 
                bool ok;
                int replyCodeInt = replyCodeText.toInt(&ok);
-               AbstractCommand::ReplyCode replyCode = AbstractCommand::UNKNOWN_REPLY;
+               ReplyCode replyCode = UNKNOWN_REPLY;
                if (ok)
                {
-                       replyCode = AbstractCommand::ReplyCode(replyCodeInt);
+                       replyCode = ReplyCode(replyCodeInt);
                }
 
                CommandData *commandData = sentCommands.take(commandId);
@@ -496,8 +496,8 @@ qDebug() << "COMPRESSED DATAGRAM = " << tmp;
                // Requeue command and reauthenticate if not logged in.
                switch (replyCode)
                {
-                       case AbstractCommand::LOGIN_FIRST:
-                       case AbstractCommand::INVALID_SESSION:
+                       case LOGIN_FIRST:
+                       case INVALID_SESSION:
 qDebug() << "LOGIN FIRST required, authing";
                                m_sessionId = "";
                                if (controlCommand)
@@ -507,28 +507,28 @@ qDebug() << "LOGIN FIRST required, authing";
                                emit startAuthentication();
                                goto continueLoop;
                        break;
-                       case AbstractCommand::LOGGED_OUT:
+                       case LOGGED_OUT:
                                m_sessionId = "";
                        break;
-                       case AbstractCommand::BANNED:
+                       case BANNED:
                                m_error = BannedError;
                                m_errorString = reply.mid(10);
                                emit connectionError();
                                goto endLoop;
                        break;
-                       case AbstractCommand::INTERNAL_SERVER_ERROR:
+                       case INTERNAL_SERVER_ERROR:
                                m_error = ServerError;
                                m_errorString = tr("Internal Server Error");
                                emit connectionError();
                                goto endLoop;
                        break;
-                       case AbstractCommand::ANIDB_OUT_OF_SERVICE:
+                       case ANIDB_OUT_OF_SERVICE:
                                m_error = ServerError;
                                m_errorString = tr("AniDB out of service");
                                emit connectionError();
                                goto endLoop;
                        break;
-                       case AbstractCommand::SERVER_BUSY:
+                       case SERVER_BUSY:
                                m_error = ServerError;
                                m_errorString = tr("Server busy. Try again later. Wait at least 30 minutes.");
                                emit connectionError();
@@ -551,14 +551,14 @@ endLoop:
        ;
 }
 
-void AniDBUdpClient::enterRecieveFailState()
+void Client::enterRecieveFailState()
 {
 qDebug() << "Entering RecieveFail State";
 }
 
 // -------------------------------------------------------------------------------------
 
-void AniDBUdpClient::clearCommandQueue()
+void Client::clearCommandQueue()
 {
        // Delete all unsent commands that are managed by the client.
        while (!controlCommandQueue.isEmpty())
@@ -572,7 +572,7 @@ void AniDBUdpClient::clearCommandQueue()
                else
                {
                        // Send CLIENT_DESTROYED to indicate that no real reply will come.
-                       cmd->setRawReply(AbstractCommand::CLIENT_DESTROYED, "", this);
+                       cmd->setRawReply(CLIENT_DESTROYED, "", this);
                }
        }
 
@@ -587,18 +587,18 @@ void AniDBUdpClient::clearCommandQueue()
                else
                {
                        // Send CLIENT_DESTROYED to indicate that no real reply will come.
-                       cmd->setRawReply(AbstractCommand::CLIENT_DESTROYED, "", this);
+                       cmd->setRawReply(CLIENT_DESTROYED, "", this);
                }
        }
 }
 
-void AniDBUdpClient::connect()
+void Client::connect()
 {
 qDebug() << "Conneting";
        emit startConnecting();
 }
 
-void AniDBUdpClient::disconnect(bool graceful)
+void Client::disconnect(bool graceful)
 {
 qDebug() << "Disconneting" << (graceful ? "gracefully" : "");
        if (graceful)
@@ -609,26 +609,26 @@ qDebug() << "Disconneting" << (graceful ? "gracefully" : "");
        emit startDisconnecting();
 }
 
-void AniDBUdpClient::send(AbstractCommand *command)
+void Client::send(AbstractCommand *command)
 {
        connect();
 
        enqueueCommand(command);
 }
 
-void AniDBUdpClient::sendRaw(QByteArray command)
+void Client::sendRaw(QByteArray command)
 {
 qDebug() << QString("Sending RAW command: %1").arg(command.constData());
        enqueueCommand(new RawCommand(command));
 }
 
-void AniDBUdpClient::logout()
+void Client::logout()
 {
        if (!m_sessionId.isEmpty())
                enqueueControlCommand(logoutCommand);
 }
 
-void AniDBUdpClient::commandTimeout(const QByteArray &commandId)
+void Client::commandTimeout(const QByteArray &commandId)
 {
 qDebug() << commandId << "timed out";
        if (!sentCommands.contains(commandId))
@@ -648,7 +648,7 @@ qDebug() << commandId << "timed out";
        emit sendFailed();
 }
 
-void AniDBUdpClient::enqueueCommand(AbstractCommand *command, bool first)
+void Client::enqueueCommand(AbstractCommand *command, bool first)
 {
        if (first)
        {
@@ -662,7 +662,7 @@ void AniDBUdpClient::enqueueCommand(AbstractCommand *command, bool first)
        emit startSending();
 }
 
-void AniDBUdpClient::enqueueControlCommand(AbstractCommand *command, bool first)
+void Client::enqueueControlCommand(AbstractCommand *command, bool first)
 {
        if (first)
        {
@@ -676,7 +676,7 @@ void AniDBUdpClient::enqueueControlCommand(AbstractCommand *command, bool first)
        emit startSending();
 }
 
-void AniDBUdpClient::sendCommand(AbstractCommand *command, bool controlCommand)
+void Client::sendCommand(AbstractCommand *command, bool controlCommand)
 {
        if (m_sessionId.isEmpty() && command->requiresSession())
        {
@@ -713,7 +713,7 @@ qDebug() << QString("SENDING datagram:\n\t%1\nto: %2 ([%3]:%4)")
        socket->writeDatagram(datagram, m_hostAddress, m_hostPort);
 }
 
-QByteArray AniDBUdpClient::buildCmd(const QString &cmd, const QVariantMap &args)
+QByteArray Client::buildCmd(const QString &cmd, const QVariantMap &args)
 {
        QString result = cmd;
        for (QVariantMap::const_iterator it = args.constBegin(); it != args.constEnd(); ++it)
@@ -743,7 +743,7 @@ QByteArray AniDBUdpClient::buildCmd(const QString &cmd, const QVariantMap &args)
        return result.toUtf8();
 }
 
-QByteArray AniDBUdpClient::nextCommandId(int len)
+QByteArray Client::nextCommandId(int len)
 {
        static const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
        static const int numChars = sizeof(chars) - 1;
@@ -763,7 +763,7 @@ CommandData::CommandData(AbstractCommand *command, const QByteArray &commandId,
        this->commandId = commandId;
 
        connect(&timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
-       timer.start(AniDBUdpClient::UDP_API_COMMAND_TIMEOUT * 1000);
+       timer.start(Client::UDP_API_COMMAND_TIMEOUT * 1000);
 }
 
 void CommandData::timerTimeout()
similarity index 95%
rename from anidbudpclient.h
rename to client.h
index 7db00a4f582d855538a75a8027d1fbae73f20c41..362fcb75120571afad053176db984cae6a309806 100644 (file)
+++ b/client.h
@@ -28,7 +28,7 @@ class UptimeCommand;
 
 class CommandData;
 
-class ANIDBUDPCLIENTSHARED_EXPORT AniDBUdpClient : public QObject
+class ANIDBUDPCLIENTSHARED_EXPORT Client : public QObject
 {
        friend class CommandData;
 
@@ -55,8 +55,8 @@ public:
        static const int clientVersion;
        static const int protocolVersion;
 
-       AniDBUdpClient(QObject *parent = 0);
-       virtual ~AniDBUdpClient();
+       Client(QObject *parent = 0);
+       virtual ~Client();
 
        // ------------------ Properties ------------------
        QString host() const;
@@ -222,7 +222,7 @@ private:
 
 class CommandData : QObject
 {
-       friend class AniDBUdpClient;
+       friend class Client;
 
        Q_OBJECT
 public:
@@ -241,6 +241,6 @@ private slots:
 } // namespace AniDBUdpClient
 
 #include <QScriptEngine>
-Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::AniDBUdpClient, QObject*);
+Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::Client, QObject*);
 
 #endif // ANIDBUDPCLIENT_H
index 8a50da223cae546a89cafc1b2435e58ace9275ce..e11a9534ad5c95763e86198a1c2141a3d5b49646 100644 (file)
@@ -6,7 +6,7 @@
 #include <QStringList>
 #include <QThread>
 
-#include "anidbudpclient.h"
+#include "client.h"
 
 namespace AniDBUdpClient {
 
@@ -78,7 +78,7 @@ Command MylistAddCommand::rawCommand() const
        }
 }
 
-void MylistAddCommand::setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client)
+void MylistAddCommand::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
 {
        AbstractCommand::setRawReply(replyCode, reply, client);
 
index 56f42682f1491142a9f47d8032bd4d1206fed0dd..18556cb2635b2b41e29dccd9392f0387628f4f34 100644 (file)
@@ -27,7 +27,7 @@ public:
 
        Command rawCommand() const;
 
-       void setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client);
+       void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
 
        void hash();
 
index 4834e72766a1492e5a7a51b8444f64c47e9cd82b..f486b3224fbc28396f8372f3fb9ea959fb34311f 100644 (file)
@@ -167,7 +167,7 @@ QDateTime MyListCommand::date() const
        return m_date;
 }
 
-AbstractCommand::State MyListCommand::state() const
+State MyListCommand::state() const
 {
        return m_state;
 }
@@ -192,7 +192,7 @@ QString MyListCommand::other() const
        return m_other;
 }
 
-AbstractCommand::FileState MyListCommand::fileState() const
+FileState MyListCommand::fileState() const
 {
        return m_fileState;
 }
@@ -261,7 +261,7 @@ Command MyListCommand::rawCommand() const
        return cmd;
 }
 
-void MyListCommand::setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client)
+void MyListCommand::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
 {
        AbstractCommand::setRawReply(replyCode, reply, client);
 
index 3cdcf6c1078b0d28d6a83bf40002c35a315d6c9c..aa164edf16fb48ebf1e8912cf6db3a0c4a399404 100644 (file)
@@ -84,7 +84,7 @@ public:
 
        bool waitForResult() const;
        Command rawCommand() const;
-       void setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client);
+       void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
 
 private:
        void init();
index 0b1f3dec73db6ebf04d2df23a2b689fc2207141d..503a7a3cbc6efd3ecd1fb60a429f09d3f0e9a4ab 100644 (file)
@@ -19,7 +19,7 @@ Command UptimeCommand::rawCommand() const
        return command;
 }
 
-void UptimeCommand::setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client)
+void UptimeCommand::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
 {
        Q_UNUSED(client);
 
index 0eb131e22585cb12e2b784d376525726659c4961..b71b88f6bbdca748bea6e5e0c267545296703d9f 100644 (file)
@@ -16,7 +16,7 @@ public:
        int uptime();
 
        Command rawCommand() const;
-       void setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client);
+       void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
 
 private:
        int m_uptime;