From: APTX Date: Mon, 10 Aug 2009 19:16:47 +0000 (+0200) Subject: - Rename class AniDBUdpClient -> Client X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=8dc26040157a58625ac3734ae0c713ce3b0fe818;p=aniplayer-old.git - Rename class AniDBUdpClient -> Client --- diff --git a/lib/anidbudpclient/abstractcommand.cpp b/lib/anidbudpclient/abstractcommand.cpp index 790f256..915e715 100644 --- a/lib/anidbudpclient/abstractcommand.cpp +++ b/lib/anidbudpclient/abstractcommand.cpp @@ -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; } diff --git a/lib/anidbudpclient/abstractcommand.h b/lib/anidbudpclient/abstractcommand.h index 48b2b33..8a2dc2a 100644 --- a/lib/anidbudpclient/abstractcommand.h +++ b/lib/anidbudpclient/abstractcommand.h @@ -2,6 +2,7 @@ #define ABSTRACTCOMMAND_H #include "anidbudpclient_global.h" + #include #include #include @@ -9,175 +10,18 @@ namespace AniDBUdpClient { -class AniDBUdpClient; +class Client; typedef QPair 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; diff --git a/lib/anidbudpclient/anidbudpclient.pro b/lib/anidbudpclient/anidbudpclient.pro index 8e1b8c1..52a6bf0 100644 --- a/lib/anidbudpclient/anidbudpclient.pro +++ b/lib/anidbudpclient/anidbudpclient.pro @@ -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 \ diff --git a/lib/anidbudpclient/anidbudpclient_global.h b/lib/anidbudpclient/anidbudpclient_global.h index d38c058..2f5a1a4 100644 --- a/lib/anidbudpclient/anidbudpclient_global.h +++ b/lib/anidbudpclient/anidbudpclient_global.h @@ -2,6 +2,7 @@ #define ANIDBUDPCLIENT_GLOBAL_H #include +#include #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 diff --git a/lib/anidbudpclient/authcommand.cpp b/lib/anidbudpclient/authcommand.cpp index fe2e2c1..517aeb1 100644 --- a/lib/anidbudpclient/authcommand.cpp +++ b/lib/anidbudpclient/authcommand.cpp @@ -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); diff --git a/lib/anidbudpclient/authcommand.h b/lib/anidbudpclient/authcommand.h index 972e7c6..b085318 100644 --- a/lib/anidbudpclient/authcommand.h +++ b/lib/anidbudpclient/authcommand.h @@ -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; diff --git a/lib/anidbudpclient/anidbudpclient.cpp b/lib/anidbudpclient/client.cpp similarity index 83% rename from lib/anidbudpclient/anidbudpclient.cpp rename to lib/anidbudpclient/client.cpp index 9e3dc61..c2da3cb 100644 --- a/lib/anidbudpclient/anidbudpclient.cpp +++ b/lib/anidbudpclient/client.cpp @@ -1,4 +1,4 @@ -#include "anidbudpclient.h" +#include "client.h" #include #include @@ -17,11 +17,11 @@ 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() diff --git a/lib/anidbudpclient/anidbudpclient.h b/lib/anidbudpclient/client.h similarity index 95% rename from lib/anidbudpclient/anidbudpclient.h rename to lib/anidbudpclient/client.h index 7db00a4..362fcb7 100644 --- a/lib/anidbudpclient/anidbudpclient.h +++ b/lib/anidbudpclient/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 -Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::AniDBUdpClient, QObject*); +Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::Client, QObject*); #endif // ANIDBUDPCLIENT_H diff --git a/lib/anidbudpclient/mylistaddcommand.cpp b/lib/anidbudpclient/mylistaddcommand.cpp index 8a50da2..e11a953 100644 --- a/lib/anidbudpclient/mylistaddcommand.cpp +++ b/lib/anidbudpclient/mylistaddcommand.cpp @@ -6,7 +6,7 @@ #include #include -#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); diff --git a/lib/anidbudpclient/mylistaddcommand.h b/lib/anidbudpclient/mylistaddcommand.h index 56f4268..18556cb 100644 --- a/lib/anidbudpclient/mylistaddcommand.h +++ b/lib/anidbudpclient/mylistaddcommand.h @@ -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(); diff --git a/lib/anidbudpclient/mylistcommand.cpp b/lib/anidbudpclient/mylistcommand.cpp index 4834e72..f486b32 100644 --- a/lib/anidbudpclient/mylistcommand.cpp +++ b/lib/anidbudpclient/mylistcommand.cpp @@ -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); diff --git a/lib/anidbudpclient/mylistcommand.h b/lib/anidbudpclient/mylistcommand.h index 3cdcf6c..aa164ed 100644 --- a/lib/anidbudpclient/mylistcommand.h +++ b/lib/anidbudpclient/mylistcommand.h @@ -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(); diff --git a/lib/anidbudpclient/uptimecommand.cpp b/lib/anidbudpclient/uptimecommand.cpp index 0b1f3de..503a7a3 100644 --- a/lib/anidbudpclient/uptimecommand.cpp +++ b/lib/anidbudpclient/uptimecommand.cpp @@ -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); diff --git a/lib/anidbudpclient/uptimecommand.h b/lib/anidbudpclient/uptimecommand.h index 0eb131e..b71b88f 100644 --- a/lib/anidbudpclient/uptimecommand.h +++ b/lib/anidbudpclient/uptimecommand.h @@ -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; diff --git a/src/videowindow.cpp b/src/videowindow.cpp index 444d333..eea3da4 100644 --- a/src/videowindow.cpp +++ b/src/videowindow.cpp @@ -23,7 +23,7 @@ #include "seekslider.h" #ifndef NO_ANIDBUDPCLIENT -# include +# include # include # include #endif @@ -45,7 +45,7 @@ VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent) destroyed = menuMoving = windowMoving = m_closeOnStop = false; #ifndef NO_ANIDBUDPCLIENT - anidb = new AniDBUdpClient::AniDBUdpClient(this); + anidb = new AniDBUdpClient::Client(this); addCommand = 0; m_marked = true; m_automark = 0; diff --git a/src/videowindow.h b/src/videowindow.h index 01aa553..70581e7 100644 --- a/src/videowindow.h +++ b/src/videowindow.h @@ -34,7 +34,7 @@ class DirectoryPlaylist; #ifndef NO_ANIDBUDPCLIENT namespace AniDBUdpClient { - class AniDBUdpClient; + class Client; class MylistAddCommand; } #endif @@ -148,7 +148,7 @@ private: #ifndef NO_ANIDBUDPCLIENT int m_automark; bool m_marked; - AniDBUdpClient::AniDBUdpClient *anidb; + AniDBUdpClient::Client *anidb; AniDBUdpClient::MylistAddCommand *addCommand; #endif