]> Some of my projects - aniplayer-old.git/commitdiff
Remove anidbudpclient from repo
authorAPTX <marek321@gmail.com>
Mon, 31 May 2010 18:16:54 +0000 (20:16 +0200)
committerAPTX <marek321@gmail.com>
Mon, 31 May 2010 18:16:54 +0000 (20:16 +0200)
39 files changed:
lib/anidbudpclient/abstractcommand.cpp [deleted file]
lib/anidbudpclient/abstractcommand.h [deleted file]
lib/anidbudpclient/anidbudpclient.pri [deleted file]
lib/anidbudpclient/anidbudpclient.pro [deleted file]
lib/anidbudpclient/anidbudpclient_global.h [deleted file]
lib/anidbudpclient/authcommand.cpp [deleted file]
lib/anidbudpclient/authcommand.h [deleted file]
lib/anidbudpclient/circularbuffer.h [deleted file]
lib/anidbudpclient/client.cpp [deleted file]
lib/anidbudpclient/client.h [deleted file]
lib/anidbudpclient/file.cpp [deleted file]
lib/anidbudpclient/file.h [deleted file]
lib/anidbudpclient/filecommand.cpp [deleted file]
lib/anidbudpclient/filecommand.h [deleted file]
lib/anidbudpclient/hash.cpp [deleted file]
lib/anidbudpclient/hash.h [deleted file]
lib/anidbudpclient/hashconsumer.cpp [deleted file]
lib/anidbudpclient/hashconsumer.h [deleted file]
lib/anidbudpclient/hashproducer.cpp [deleted file]
lib/anidbudpclient/hashproducer.h [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/AbstractCommand [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/Client [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/File [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/FileCommand [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/Hash [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/MyListAddCommand [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/MyListCommand [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/RawCommand [deleted file]
lib/anidbudpclient/include/AniDBUdpClient/UptimeCommand [deleted file]
lib/anidbudpclient/logoutcommand.cpp [deleted file]
lib/anidbudpclient/logoutcommand.h [deleted file]
lib/anidbudpclient/mylistaddcommand.cpp [deleted file]
lib/anidbudpclient/mylistaddcommand.h [deleted file]
lib/anidbudpclient/mylistcommand.cpp [deleted file]
lib/anidbudpclient/mylistcommand.h [deleted file]
lib/anidbudpclient/rawcommand.cpp [deleted file]
lib/anidbudpclient/rawcommand.h [deleted file]
lib/anidbudpclient/uptimecommand.cpp [deleted file]
lib/anidbudpclient/uptimecommand.h [deleted file]

diff --git a/lib/anidbudpclient/abstractcommand.cpp b/lib/anidbudpclient/abstractcommand.cpp
deleted file mode 100644 (file)
index bf2d151..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "abstractcommand.h"
-
-namespace AniDBUdpClient {
-
-AbstractCommand::AbstractCommand()
-{
-}
-
-AbstractCommand::~AbstractCommand()
-{
-}
-
-Command AbstractCommand::rawCommand() const
-{
-       return Command("", QVariantMap());
-}
-
-bool AbstractCommand::waitForResult() const
-{
-       return false;
-}
-
-bool AbstractCommand::requiresSession() const
-{
-       return true;
-}
-
-// ===
-
-AbstractReply::AbstractReply(const QByteArray &id, Client *client, QObject *parent) : QObject(parent)
-{
-       m_replyCode = UNKNOWN_REPLY;
-       m_id = id;
-       m_client = client;
-       m_commandPtr = 0;
-}
-
-AbstractReply::~AbstractReply()
-{
-
-}
-
-const AbstractCommand &AbstractReply::command() const
-{
-       return m_commandPtr == 0 ? m_command : *m_commandPtr;
-}
-
-void AbstractReply::setRawReply(ReplyCode replyCode, const QString &reply)
-{
-       m_replyCode = replyCode;
-       m_rawReply = reply;
-}
-
-QString AbstractReply::rawReply() const
-{
-       return m_rawReply;
-}
-
-ReplyCode AbstractReply::replyCode() const
-{
-       return m_replyCode;
-}
-
-QByteArray AbstractReply::id() const
-{
-       return m_id;
-}
-
-void AbstractReply::setId(const QByteArray &id)
-{
-       m_id = id;
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/abstractcommand.h b/lib/anidbudpclient/abstractcommand.h
deleted file mode 100644 (file)
index 62cad54..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-#ifndef ABSTRACTCOMMAND_H
-#define ABSTRACTCOMMAND_H
-
-#include "anidbudpclient_global.h"
-
-#include <QObject>
-#include <QPair>
-#include <QVariantMap>
-
-
-namespace AniDBUdpClient {
-
-class Client;
-
-typedef QPair<QString, QVariantMap> Command;
-
-class AbstractReply;
-
-class ANIDBUDPCLIENTSHARED_EXPORT AbstractCommand
-{
-       friend class Client;
-public:
-       typedef AbstractReply ReplyType;
-       AbstractCommand();
-       virtual ~AbstractCommand();
-
-       virtual Command rawCommand() const;
-
-       /**
-         If it's false the client takes ownership of the request!
-        **/
-       virtual bool waitForResult() const;
-       virtual bool requiresSession() const;
-};
-
-#define REPLY_DEFINITION_HELPER_INTERNAL(name, constructor) \
-friend class Client; \
-public: \
-typedef name##Command CommandType; \
-private: \
-CommandType m_command; \
-Client *m_client; \
-name##Reply(const CommandType command, const QByteArray &id, Client *client, QObject *parent) : m_command(command), m_client(client), AbstractReply(id, client, parent) {constructor} \
-inline const CommandType &command() const { return m_command; }
-
-#define REPLY_DEFINITION_HELPER(name) \
-               REPLY_DEFINITION_HELPER_INTERNAL(name, m_commandPtr = &m_command;)
-
-#define REPLY_DEFINITION_HELPER2(name) \
-               REPLY_DEFINITION_HELPER_INTERNAL(name, m_commandPtr = &m_command; init();)
-
-class ANIDBUDPCLIENTSHARED_EXPORT AbstractReply : public QObject
-{
-       friend class Client;
-
-       Q_OBJECT
-
-       Q_PROPERTY(QByteArray id READ id);
-       Q_PROPERTY(ReplyCode replyCode READ replyCode);
-
-public:
-       typedef AbstractCommand CommandType;
-
-       AbstractReply(const QByteArray &id, Client *client, QObject *parent = 0);
-       virtual ~AbstractReply();
-
-       const CommandType &command() const;
-
-       virtual void setRawReply(ReplyCode replyCode, const QString &reply);
-       virtual QString rawReply() const;
-
-       virtual ReplyCode replyCode() const;
-       virtual QByteArray id() const;
-
-signals:
-       void replyReady(bool success = false);
-
-protected:
-       void setId(const QByteArray &id);
-
-       QString m_rawReply;
-       ReplyCode m_replyCode;
-       QByteArray m_id;
-       Client *m_client;
-
-       AbstractCommand *m_commandPtr;
-       AbstractCommand m_command;
-};
-
-} // namespace AniDBUdpClient
-
-#endif // ABSTRACTCOMMAND_H
diff --git a/lib/anidbudpclient/anidbudpclient.pri b/lib/anidbudpclient/anidbudpclient.pri
deleted file mode 100644 (file)
index 40880fa..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# Avoiding symbol clash with other instances of the Qt library
-# (ref. developingplugins.html in the doc.):
-# For Qt 4.4 and later, just configure Qt to use a separate namespace:
-# configure -qtnamespace SomeNamespace
-# For Qt 4.3: Uncomment the line below.
-# It makes the dynamic linker prefer our own Qt symbols for the plugin,
-# provided that our Qt is statically built and linked into the
-# plugin. Note that to force the linker to prefer the static Qt
-# libraries (.a files), the dynamic libraries (.so) files must not
-# be present in the lib directory.
-# QMAKE_LFLAGS += -Wl,-Bsymbolic
-# Avoiding symbol clash with other instances of the Qt library
-# (ref. developingplugins.html in the doc.):
-# For Qt 4.4 and later, just configure Qt to use a separate namespace:
-# configure -qtnamespace SomeNamespace
-# For Qt 4.3: Uncomment the line below.
-# It makes the dynamic linker prefer our own Qt symbols for the plugin,
-# provided that our Qt is statically built and linked into the
-# plugin. Note that to force the linker to prefer the static Qt
-# libraries (.a files), the dynamic libraries (.so) files must not
-# be present in the lib directory.
-# QMAKE_LFLAGS += -Wl,-Bsymbolic
-QT *= network \
-    script
-INCLUDEPATH += $$PWD/include
-DEPENDPATH += $$PWD
-LIBS += -lanidbudpclient
-LIBS += -L$$DESTDIR
diff --git a/lib/anidbudpclient/anidbudpclient.pro b/lib/anidbudpclient/anidbudpclient.pro
deleted file mode 100644 (file)
index 9f2968b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-# -------------------------------------------------
-# Project created by QtCreator 2009-03-22T14:53:52
-# -------------------------------------------------
-QT += network \
-    script
-QT -= gui
-TEMPLATE = lib
-TARGET = anidbudpclient
-static { 
-    message(anidbpudpclinet: Static build)
-    DESTDIR = ../../build-static
-}
-!static { 
-    message(anidbpudpclinet: Dynamic build)
-    DESTDIR = ../../build
-}
-INCLUDEPATH += $$PWD
-DEPENDPATH += $$PWD
-DEFINES += ANIDBUDPCLIENT_LIBRARY
-SOURCES += client.cpp \
-    abstractcommand.cpp \
-    authcommand.cpp \
-    rawcommand.cpp \
-    mylistaddcommand.cpp \
-    logoutcommand.cpp \
-    uptimecommand.cpp \
-       mylistcommand.cpp \
-       filecommand.cpp \
-       file.cpp \
-    hash.cpp \
-    hashproducer.cpp \
-       hashconsumer.cpp
-
-HEADERS += client.h \
-    anidbudpclient_global.h \
-    abstractcommand.h \
-    authcommand.h \
-    rawcommand.h \
-    mylistaddcommand.h \
-    logoutcommand.h \
-    uptimecommand.h \
-       mylistcommand.h \
-       filecommand.h \
-       file.h \
-    hash.h \
-    hashproducer.h \
-    hashconsumer.h \
-       circularbuffer.h
-
-CONV_HEADERS += include/AniDBUdpClient/Client \
-    include/AniDBUdpClient/AbstractCommand \
-    include/AniDBUdpClient/RawCommand \
-    include/AniDBUdpClient/MyListCommand \
-    include/AniDBUdpClient/MyListAddCommand \
-       include/AniDBUdpClient/FileCommand \
-       include/AniDBUdpClient/File \
-       include/AniDBUdpClient/UptimeCommand \
-       include/AniDBUdpClient/Hash \
-    include/AniDBUdpClient/UptimeCommand \
diff --git a/lib/anidbudpclient/anidbudpclient_global.h b/lib/anidbudpclient/anidbudpclient_global.h
deleted file mode 100644 (file)
index ff6787c..0000000
+++ /dev/null
@@ -1,408 +0,0 @@
-#ifndef ANIDBUDPCLIENT_GLOBAL_H
-#define ANIDBUDPCLIENT_GLOBAL_H
-
-#include <QObject>
-#include <QMetaType>
-#include <QFileInfo>
-
-#define CLIENT_NAME "anidbudpclient"
-#define CLIENT_VERSION 0x000003
-#define PROTOCOL_VERSION 3
-
-#if defined(ANIDBUDPCLIENT_LIBRARY)
-#  define ANIDBUDPCLIENTSHARED_EXPORT Q_DECL_EXPORT
-#else
-#  define ANIDBUDPCLIENTSHARED_EXPORT Q_DECL_IMPORT
-#endif
-
-namespace AniDBUdpClient
-{
-       enum Error
-       {
-               NoError,
-               BindError,
-               HostLookupError,
-               HostUnreachableError,
-               AuthenticationError,
-               BannedError,
-               ClientBannedError,
-               ClientVersionOutdatedError,
-               ServerError,
-               UnknownError,
-       };
-
-       enum IdlePolicy
-       {
-               DoNothingIdlePolicy,
-               LogoutIdlePolicy,
-               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);
-
-       namespace FileFlag {
-               enum FileFlag {
-                       AniDBFileName           = 0x00000001,
-               //      Unused                          = 0x00000002,
-               //      Unused                          = 0x00000004,
-                       AiredDate                       = 0x00000008,
-                       Description                     = 0x00000010,
-                       LengthInSeconds         = 0x00000020,
-                       SubLanguage                     = 0x00000040,
-                       DubLanguage                     = 0x00000080,
-
-                       FileType                        = 0x00000100,
-                       VideoResolution         = 0x00000200,
-                       VideoBitrate            = 0x00000400,
-                       VideoCodec                      = 0x00000800,
-                       AudioBitrate            = 0x00001000,
-                       AudioCodec                      = 0x00002000,
-                       Source                          = 0x00004000,
-                       Quality                         = 0x00008000,
-
-               //      Reserved                        = 0x00010000,
-               //      Unused                          = 0x00020000,
-               //      Unused                          = 0x00040000,
-                       Crc32                           = 0x00080000,
-                       Sha1                            = 0x00100000,
-                       Md5                                     = 0x00200000,
-                       Ed2k                            = 0x00400000,
-                       Size                            = 0x00800000,
-
-                       State                           = 0x01000000,
-                       IsDeprecated            = 0x02000000,
-                       OtherEpisodes           = 0x04000000,
-                       Lid                                     = 0x08000000,
-                       Gid                                     = 0x10000000,
-                       Eid                                     = 0x20000000,
-                       Aid                                     = 0x40000000,
-               //      Unused                          = 0x80000000,
-
-                       Extension                       = FileType,
-
-                       Byte4                           = AniDBFileName | AiredDate | Description
-                                                                 | LengthInSeconds | SubLanguage | DubLanguage,
-                       Byte3                           = FileType | VideoResolution | VideoBitrate
-                                                                 | VideoCodec | AudioBitrate | AudioCodec
-                                                                 | Source | Quality,
-                       Byte2                           = Crc32 | Sha1 | Md5 | Ed2k,
-                       Byte1                           = State | IsDeprecated | OtherEpisodes
-                                                                 | Lid | Gid | Eid | Aid,
-                       AllData                         = Byte1 | Byte2 | Byte3 | Byte4,
-                       InvalidBits                     = ~AllData
-               };
-       }
-
-       Q_FLAGS(FileFlag::FileFlag);
-       Q_DECLARE_FLAGS(FileFlags, FileFlag::FileFlag);
-       Q_DECLARE_OPERATORS_FOR_FLAGS(FileFlags);
-       typedef FileFlags FMask;
-
-       namespace FileAnimeFlag {
-               enum FileAnimeFlag {
-                       DateAidRecordUpdated    = 0x00000001,
-               //      Unused                                  = 0x00000002,
-               //      Unused                                  = 0x00000004,
-               //      Unused                                  = 0x00000008,
-               //      Unused                                  = 0x00000010,
-               //      Unused                                  = 0x00000020,
-                       GroupShortName                  = 0x00000040,
-                       GroupName                               = 0x00000080,
-
-               //      Unused                                  = 0x00000100,
-               //      Unused                                  = 0x00000200,
-                       EpisodeVoteCount                = 0x00000400,
-                       EpisodeRating                   = 0x00000800,
-                       EpKanjiName                             = 0x00001000,
-                       EpRomajiName                    = 0x00002000,
-                       EpName                                  = 0x00004000,
-                       EpNo                                    = 0x00008000,
-
-               //      Retired                                 = 0x00010000,
-               //      Retired                                 = 0x00020000,
-                       SynonymList                             = 0x00040000,
-                       ShortNameList                   = 0x00080000,
-                       OtherName                               = 0x00100000,
-                       EnglishName                             = 0x00200000,
-                       KanjiName                               = 0x00400000,
-                       RomajiName                              = 0x00800000,
-
-               //      Reserved                                = 0x01000000,
-                       CateogryList                    = 0x02000000,
-                       RelatedAidType                  = 0x04000000,
-                       RelatedAidList                  = 0x08000000,
-                       Type                                    = 0x10000000,
-                       Year                                    = 0x20000000,
-                       HighestEpisodeNumber    = 0x40000000,
-                       AnimeTotalEpisodes              = 0x80000000,
-
-                       Byte4                                   = DateAidRecordUpdated | GroupShortName
-                                                                         | GroupName,
-                       Byte3                                   = EpisodeVoteCount | EpisodeRating
-                                                                         | EpKanjiName | EpRomajiName | EpName
-                                                                         | EpNo,
-                       Byte2                                   = SynonymList | ShortNameList
-                                                                         | OtherName | EnglishName | KanjiName
-                                                                         | RomajiName,
-                       Byte1                                   = CateogryList | RelatedAidType
-                                                                         | RelatedAidList | Type | Year
-                                                                         | HighestEpisodeNumber
-                                                                         | AnimeTotalEpisodes,
-                       AllData                                 = Byte1 | Byte2 | Byte3 | Byte4,
-                       InvalidBits                             = ~AllData
-               };
-       }
-
-       Q_FLAGS(FileAnimeFlag::FileAnimeFlag);
-       Q_DECLARE_FLAGS(FileAnimeFlags, FileAnimeFlag::FileAnimeFlag);
-       Q_DECLARE_OPERATORS_FOR_FLAGS(FileAnimeFlags);
-       typedef FileAnimeFlag::FileAnimeFlag FileAMask;
-
-       namespace AnimeFlag {
-               static const qint64 CategoryWeightList  = Q_INT64_C(0x0000000000000001);
-               static const qint64 CategoryList                = Q_INT64_C(0x0000000000000002);
-               static const qint64 RelatedAidType              = Q_INT64_C(0x0000000000000004);
-               static const qint64 RelatedAidList              = Q_INT64_C(0x0000000000000008);
-               static const qint64 Type                                = Q_INT64_C(0x0000000000000010);
-               static const qint64 Year                                = Q_INT64_C(0x0000000000000020);
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000000000000040);
-               static const qint64 Aid                                 = Q_INT64_C(0x0000000000000080);
-
-       //      static const qint64 Retired                             = Q_INT64_C(0x0000000000000100);
-       //      static const qint64 Retired                             = Q_INT64_C(0x0000000000000200);
-               static const qint64 SynonymList                 = Q_INT64_C(0x0000000000000400);
-               static const qint64 ShortNameList               = Q_INT64_C(0x0000000000000800);
-               static const qint64 OtherName                   = Q_INT64_C(0x0000000000001000);
-               static const qint64 EnglishName                 = Q_INT64_C(0x0000000000002000);
-               static const qint64 KanjiName                   = Q_INT64_C(0x0000000000004000);
-               static const qint64 RomajiName                  = Q_INT64_C(0x0000000000008000);
-
-               static const qint64 CategoryIdList              = Q_INT64_C(0x0000000000010000);
-               static const qint64 PicName                             = Q_INT64_C(0x0000000000020000);
-               static const qint64 Url                                 = Q_INT64_C(0x0000000000040000);
-               static const qint64 EndDate                             = Q_INT64_C(0x0000000000080000);
-               static const qint64 AirDate                             = Q_INT64_C(0x0000000000100000);
-               static const qint64 SpecialEpCount              = Q_INT64_C(0x0000000000200000);
-               static const qint64 NormalEpCount               = Q_INT64_C(0x0000000000400000);
-               static const qint64 Episodes                    = Q_INT64_C(0x0000000000800000);
-
-               static const qint64 Is18Restricted              = Q_INT64_C(0x0000000001000000);
-               static const qint64 AwardList                   = Q_INT64_C(0x0000000002000000);
-               static const qint64 ReviewCount                 = Q_INT64_C(0x0000000004000000);
-               static const qint64 AverageReviewRating = Q_INT64_C(0x0000000008000000);
-               static const qint64 TempVoteCount               = Q_INT64_C(0x0000000010000000);
-               static const qint64 TempRating                  = Q_INT64_C(0x0000000020000000);
-               static const qint64 VoteCount                   = Q_INT64_C(0x0000000040000000);
-               static const qint64 Rating                              = Q_INT64_C(0x0000000080000000);
-
-               static const qint64 DateRecordUpdated   = Q_INT64_C(0x0000000100000000);
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000000200000000);
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000000400000000);
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000000800000000);
-               static const qint64 AniemNfoId                  = Q_INT64_C(0x0000001000000000);
-               static const qint64 AllCinemaId                 = Q_INT64_C(0x0000002000000000);
-               static const qint64 ANNId                               = Q_INT64_C(0x0000004000000000);
-               static const qint64 AnimePlanetId               = Q_INT64_C(0x0000008000000000);
-
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000010000000000);
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000020000000000);
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000040000000000);
-       //      static const qint64 Unused                              = Q_INT64_C(0x0000080000000000);
-               static const qint64 ProducerNameList    = Q_INT64_C(0x0000100000000000);
-               static const qint64 ProducerIdList              = Q_INT64_C(0x0000200000000000);
-               static const qint64 CreatorIdList               = Q_INT64_C(0x0000400000000000);
-               static const qint64 CharacterIdList             = Q_INT64_C(0x0000800000000000);
-
-               static const qint64 Byte1                               = CategoryWeightList | CategoryList | RelatedAidType
-                                                                                                 | RelatedAidList | Type | Year | Aid;
-               static const qint64 Byte2                               = SynonymList | ShortNameList | OtherName
-                                                                                                 | EnglishName | KanjiName | RomajiName;
-               static const qint64 Byte3                               = CategoryIdList | PicName | Url | EndDate | AirDate
-                                                                                                 | SpecialEpCount | NormalEpCount | Episodes;
-               static const qint64 Byte4                               = Is18Restricted | AwardList | ReviewCount
-                                                                                                 | AverageReviewRating | TempVoteCount | TempRating
-                                                                                                 | VoteCount | Rating;
-               static const qint64 Byte5                               = DateRecordUpdated | AniemNfoId | AllCinemaId
-                                                                                                 | ANNId | AnimePlanetId;
-               static const qint64 Byte6                               = ProducerNameList | ProducerIdList | CreatorIdList
-                                                                                                 | CharacterIdList;
-               static const qint64 AllData                             = Byte1 | Byte2 | Byte3 | Byte4
-                                                                                                 | Byte5 | Byte6;
-               static const qint64 InvalidBits                 = ~AllData;
-       }
-
-       typedef qint64 AnimeFlags;
-       typedef AnimeFlags AMask;
-
-       namespace HashPrivate {
-               static const qint64 ED2K_PART_SIZE = 9728000;
-       }
-}
-
-Q_DECLARE_METATYPE(AniDBUdpClient::Error);
-Q_DECLARE_METATYPE(AniDBUdpClient::IdlePolicy);
-Q_DECLARE_METATYPE(AniDBUdpClient::ReplyCode);
-Q_DECLARE_METATYPE(AniDBUdpClient::State);
-Q_DECLARE_METATYPE(AniDBUdpClient::FileState);
-
-Q_DECLARE_METATYPE(QFileInfo);
-
-#endif // ANIDBUDPCLIENT_GLOBAL_H
diff --git a/lib/anidbudpclient/authcommand.cpp b/lib/anidbudpclient/authcommand.cpp
deleted file mode 100644 (file)
index 6153b66..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#include "authcommand.h"
-
-#include "client.h"
-
-namespace AniDBUdpClient {
-
-AuthCommand::AuthCommand() : AbstractCommand()
-{
-       m_compression = false;
-}
-
-AuthCommand::AuthCommand(const QString &user, const QString &pass) : AbstractCommand()
-{
-       m_user = user;
-       m_pass = pass;
-       m_compression = false;
-}
-
-QString AuthCommand::user() const
-{
-       return m_user;
-}
-
-void AuthCommand::setUser(const QString &user)
-{
-       m_user = user;
-}
-
-QString AuthCommand::pass() const
-{
-       return m_pass;
-}
-
-void AuthCommand::setPass(const QString &pass)
-{
-       m_pass = pass;
-}
-
-bool AuthCommand::compression() const
-{
-       return m_compression;
-}
-
-void AuthCommand::setCompression(bool compress)
-{
-       m_compression = compress;
-}
-
-bool AuthCommand::waitForResult() const
-{
-       return true;
-}
-
-bool AuthCommand::requiresSession() const
-{
-       return false;
-}
-
-Command AuthCommand::rawCommand() const
-{
-       Command command;
-
-       command.first = "AUTH";
-
-       command.second["user"] = m_user.toLower(); // All usernames are lower case
-       command.second["pass"] = m_pass;
-       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;
-}
-
-// ===
-
-QString AuthReply::sessionId() const
-{
-       return m_sessionId;
-}
-
-QString AuthReply::errorString() const
-{
-       return m_errorString;
-}
-
-void AuthReply::clearError()
-{
-       m_errorString = "";
-}
-
-void AuthReply::setRawReply(ReplyCode replyCode, const QString &reply)
-{
-qDebug() << replyCode;
-       AbstractReply::setRawReply(replyCode, reply);
-
-       switch(replyCode)
-       {
-
-               case LOGIN_ACCEPTED:
-               case LOGIN_ACCEPTED_NEW_VER:
-                       m_errorString = "";
-                       m_sessionId = m_rawReply.mid(0, m_rawReply.indexOf(" "));
-                       emit replyReady(true);
-               break;
-               case LOGIN_FAILED:
-                       m_errorString = tr("Username and/or password incorrect");
-                       emit replyReady(false);
-               break;
-               case CLIENT_VERSION_OUTDATED:
-                       m_errorString = tr("Client version outdated");
-                       emit replyReady(false);
-               break;
-               case CLIENT_BANNED:
-                       m_errorString = tr("Banned: %1").arg(m_rawReply.mid(m_rawReply.indexOf("BANNED") + 1));
-                       emit replyReady(false);
-               break;
-               default:
-qDebug() << "ERROR CODE: " << replyCode;
-                       m_errorString = tr("Unknown errorString (CODE: %1)").arg(m_replyCode);
-                       emit replyReady(false);
-       }
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/authcommand.h b/lib/anidbudpclient/authcommand.h
deleted file mode 100644 (file)
index 806e5ed..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef AUTHCOMMAND_H\r
-#define AUTHCOMMAND_H\r
-\r
-#include "abstractcommand.h"\r
-\r
-namespace AniDBUdpClient {\r
-\r
-class AuthReply;\r
-\r
-class AuthCommand : public AbstractCommand\r
-{\r
-/*\r
-       Q_PROPERTY(QString user READ user WRITE setUser);\r
-       Q_PROPERTY(QString pass READ pass WRITE setPass);\r
-       Q_PROPERTY(bool compression READ compression WRITE setCompression);\r
-*/\r
-public:\r
-       typedef AuthReply ReplyType;\r
-       AuthCommand();\r
-       AuthCommand(const QString &user, const QString &pass);\r
-\r
-       QString user() const;\r
-       void setUser(const QString &user);\r
-\r
-       QString pass() const;\r
-       void setPass(const QString &pass);\r
-\r
-       bool compression() const;\r
-       void setCompression(bool compress);\r
-\r
-\r
-       bool waitForResult() const;\r
-       bool requiresSession() const;\r
-\r
-       Command rawCommand() const;\r
-\r
-private:\r
-       QString m_user;\r
-       QString m_pass;\r
-\r
-       bool m_compression;\r
-};\r
-\r
-class AuthReply : public AbstractReply\r
-{\r
-       Q_OBJECT\r
-       REPLY_DEFINITION_HELPER(Auth)\r
-\r
-       Q_PROPERTY(QString sessionId READ sessionId);\r
-       Q_PROPERTY(QString errorString READ errorString RESET clearError);\r
-\r
-public:\r
-\r
-       QString sessionId() const;\r
-       QString errorString() const;\r
-       void clearError();\r
-\r
-       void setRawReply(ReplyCode replyCode, const QString &reply);\r
-\r
-private:\r
-       QString m_sessionId;\r
-       QString m_errorString;\r
-};\r
-\r
-} // namespace AniDBUdpClient\r
-\r
-#endif // AUTHCOMMAND_H\r
diff --git a/lib/anidbudpclient/circularbuffer.h b/lib/anidbudpclient/circularbuffer.h
deleted file mode 100644 (file)
index 4973e26..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef CIRCULARBUFFER_H
-#define CIRCULARBUFFER_H
-
-#include <QSemaphore>
-namespace AniDBUdpClient {
-namespace HashPrivate {
-
-template<typename T, int SIZE> class CircularBuffer
-{
-public:
-       CircularBuffer()
-       {
-               // Set N to SIZE
-               free.release(SIZE);
-               r = w = 0;
-               m_end = false;
-       }
-
-       bool put(T data, bool last = false, int timeout = SEMAPHORE_ACQUIRE_TIMEOUT)
-       {
-               if (m_end) return false;
-
-               if (!free.tryAcquire(1, timeout))
-                       return false;
-               buffer[w] = data;
-               m_end = last;
-               ++w;
-               w %= SIZE;
-               used.release();
-
-               return true;
-       }
-
-       bool get(T *data, int timeout = SEMAPHORE_ACQUIRE_TIMEOUT)
-       {
-               if (!used.tryAcquire(1, timeout))
-                       return false;
-               *data = buffer[r];
-               ++r;
-               r %= SIZE;
-               free.release();
-               return true;
-       }
-
-       bool end() const
-       {
-               return m_end && used.available() == 0;
-       }
-
-       bool reset()
-       {
-               if (!end())
-                       return false;
-
-               m_end = false;
-               r = w = 0;
-               return true;
-       }
-
-private:
-       T buffer[SIZE];
-       QSemaphore free;
-       QSemaphore used;
-
-       int r;
-       int w;
-       bool m_end;
-
-       static const int SEMAPHORE_ACQUIRE_TIMEOUT = 100;
-};
-
-typedef CircularBuffer<QByteArray, 2> Buffer;
-
-} // namespace HashPrivate
-} // namesapce AniDBUdpClient
-
-#endif // CIRCULARBUFFER_H
diff --git a/lib/anidbudpclient/client.cpp b/lib/anidbudpclient/client.cpp
deleted file mode 100644 (file)
index e55c025..0000000
+++ /dev/null
@@ -1,879 +0,0 @@
-#include "client.h"
-
-#include <QStateMachine>
-#include <QHistoryState>
-#include <QState>
-
-#include <QCoreApplication>
-#include <QUdpSocket>
-#include <QTimer>
-#include <QRegExp>
-
-#include "rawcommand.h"
-#include "logoutcommand.h"
-#include "uptimecommand.h"
-#include "hash.h"
-
-#include <QtDebug>
-
-namespace AniDBUdpClient {
-
-const QByteArray Client::clientName = CLIENT_NAME;
-const int Client::clientVersion = CLIENT_VERSION;
-const int Client::protocolVersion = PROTOCOL_VERSION;
-
-Client::Client(QObject *parent) : QObject(parent)
-{
-qDebug() << "Api instance init!";
-
-       authReply = 0;
-       uptimeReply = 0;
-
-       m_error = NoError;
-       m_idlePolicy = DoNothingIdlePolicy;
-
-       disconnecting = false;
-       commandsTimedOut = 0;
-
-       socket = new QUdpSocket(this);
-
-       commandTimer = new QTimer(this);
-       commandTimer->setSingleShot(true);
-
-       idleTimer = new QTimer(this);
-       idleTimer->setSingleShot(true);
-
-       m_localPort = 9001;
-       m_host = "api.anidb.info";
-       m_hostPort = 9000;
-
-       setFloodInterval(3);
-
-       stateMachine = new QStateMachine(this);
-
-       errorState = new QState;
-       disconnectedState = new QState;
-       connectingState = new QState;
-       connectedState = new QState;
-       authenticatingState = new QState(connectedState);
-       idleState = new QState(connectedState);
-       idleTimeoutState = new QState(connectedState);
-       sendState = new QState(connectedState);
-       waitState = new QState(connectedState);
-       recieveState = new QState;
-       recieveFailState = new QState;
-       connectedHistoryState = new QHistoryState(connectedState);
-
-       stateMachine->addState(errorState);
-       stateMachine->addState(disconnectedState);
-       stateMachine->addState(connectingState);
-       stateMachine->addState(connectedState);
-       stateMachine->addState(recieveState);
-       stateMachine->addState(recieveFailState);
-       stateMachine->setInitialState(disconnectedState);
-
-       connectedState->setInitialState(sendState);
-       connectedHistoryState->setDefaultState(sendState);
-
-       // ------------- Transitions ---------------------
-       connectedState->addTransition(this, SIGNAL(startDisconnecting()), disconnectedState);
-       connectedState->addTransition(socket, SIGNAL(readyRead()), recieveState);
-       connectedState->addTransition(this, SIGNAL(sendFailed()), recieveFailState);
-
-       disconnectedState->addTransition(this, SIGNAL(startConnecting()), connectingState);
-
-       connectingState->addTransition(this, SIGNAL(connected()), connectedState);
-
-       authenticatingState->addTransition(this, SIGNAL(startSending()), sendState);
-       authenticatingState->addTransition(this, SIGNAL(authenticated()), sendState);
-
-       sendState->addTransition(this, SIGNAL(queueEmpty()), idleState);
-       sendState->addTransition(this, SIGNAL(commandSent()), waitState);
-       sendState->addTransition(this, SIGNAL(startAuthentication()), authenticatingState);
-
-       waitState->addTransition(commandTimer, SIGNAL(timeout()), sendState);
-
-       idleState->addTransition(this, SIGNAL(startSending()), sendState);
-       idleState->addTransition(idleTimer, SIGNAL(timeout()), idleTimeoutState);
-
-       idleTimeoutState->addTransition(this, SIGNAL(startSending()), sendState);
-
-       recieveState->addTransition(this, SIGNAL(authenticated()), authenticatingState);
-       recieveState->addTransition(this, SIGNAL(connectionError()), errorState);
-       recieveState->addTransition(this, SIGNAL(replyRecieved()), connectedHistoryState);
-
-
-       recieveFailState->addTransition(this, SIGNAL(connectionError()), errorState);
-
-       recieveFailState->addTransition(sendState);
-       // ------------ END Transitions -------------------
-
-       // ------------- Methods ---------------------
-       QObject::connect(errorState, SIGNAL(entered()), this, SLOT(enterErrorState()));
-       QObject::connect(disconnectedState, SIGNAL(entered()), this, SLOT(enterDisconnectedState()));
-       QObject::connect(connectingState, SIGNAL(entered()), this, SLOT(enterConnectingState()));
-       QObject::connect(connectedState, SIGNAL(entered()), this, SLOT(enterConnectedState()));
-       QObject::connect(authenticatingState, SIGNAL(entered()), this, SLOT(enterAuthenticatingState()));
-       QObject::connect(sendState, SIGNAL(entered()), this, SLOT(enterSendState()));
-       QObject::connect(waitState, SIGNAL(entered()), this, SLOT(enterWaitState()));
-       QObject::connect(idleState, SIGNAL(entered()), this, SLOT(enterIdleState()));
-       QObject::connect(idleState, SIGNAL(exited()), this, SLOT(exitIdleState()));
-       QObject::connect(idleTimeoutState, SIGNAL(entered()), this, SLOT(enterIdleTiemoutState()));
-
-       QObject::connect(recieveState, SIGNAL(entered()), this, SLOT(enterRecieveState()));
-       QObject::connect(recieveFailState, SIGNAL(entered()), this, SLOT(enterRecieveFailState()));
-       // ------------ END Methods -------------------
-
-       stateMachine->start();
-       // Process the event that starts the state machine.
-       QCoreApplication::processEvents();
-}
-
-Client::~Client()
-{
-       foreach (CommandData *cmd, sentCommands)
-       {
-               // Send CLIENT_DESTROYED to indicate that no real reply will come.
-               cmd->command->setRawReply(CLIENT_DESTROYED, "");
-       }
-       sentCommands.clear();
-
-       clearCommandQueue();
-
-       if (!m_sessionId.isEmpty())
-       {
-               while (commandTimer->isActive())
-                       QCoreApplication::processEvents();
-
-               logout(true);
-               socket->waitForBytesWritten(5);
-       }
-       disconnect();
-
-       if (authReply)
-       {
-               delete authReply;
-               authReply = 0;
-       }
-       if (uptimeReply)
-       {
-               delete uptimeReply;
-               uptimeReply = 0;
-       }
-}
-
-QString Client::host() const
-{
-       return m_host;
-}
-
-void Client::setHost(const QString &host, quint16 port)
-{
-       m_host = host;
-       if (port)
-               m_hostPort = port;
-       m_hostAddress = QHostAddress();
-}
-
-quint16 Client::hostPort() const
-{
-       return m_hostPort;
-}
-
-void Client::setHostPort(quint16 port)
-{
-       m_hostPort = port;
-}
-
-quint16 Client::localPort() const
-{
-       return m_localPort;
-}
-
-void Client::setLocalPort(quint16 port)
-{
-       m_localPort = port;
-}
-
-QString Client::user() const
-{
-       return authCommand.user();
-}
-
-void Client::setUser(const QString &user)
-{
-       authCommand.setUser(user);
-}
-
-QString Client::pass() const
-{
-       return authCommand.pass();
-}
-
-void Client::setPass(const QString &pass)
-{
-       authCommand.setPass(pass);
-}
-
-bool Client::compression() const
-{
-       return authCommand.compression();
-}
-
-void Client::setCompression(bool compress)
-{
-       authCommand.setCompression(compress);
-}
-
-int Client::floodInterval() const
-{
-       return m_floodInterval;
-}
-
-void Client::setFloodInterval(int interval)
-{
-       m_floodInterval = interval * 1000;
-}
-
-IdlePolicy Client::idlePolicy() const
-{
-       return m_idlePolicy;
-}
-
-void Client::setIdlePolicy(IdlePolicy policy)
-{
-       m_idlePolicy = policy;
-}
-
-Error Client::error() const
-{
-       return m_error;
-}
-
-QString Client::errorString() const
-{
-       return m_errorString;
-}
-
-// ------------------------------------------------------------------------------
-
-void Client::enterErrorState()
-{
-qDebug() << "Entering Error State";
-       disconnect();
-}
-
-void Client::enterDisconnectedState()
-{
-qDebug() << "Entering Disconnected State";
-       if (socket->state() == QAbstractSocket::BoundState)
-               socket->disconnectFromHost();
-}
-
-void Client::enterConnectingState()
-{
-qDebug() << "Entering Connecting State";
-
-       if (!m_hostAddress.isNull())
-       {
-               if (socket->bind(QHostAddress::Any, m_localPort))
-               {
-qDebug() << "Successful connection";
-                       emit connected();
-                       return;
-               }
-
-               m_error = BindError;
-               m_errorString = socket->errorString();
-qDebug() << QString("Bind on Address: %1 port: %2 failed").arg(m_hostAddress.toString()).arg(m_localPort);
-               emit connectionError();
-               return;
-       }
-       QHostInfo::lookupHost(m_host, this, SLOT(lookedUp(QHostInfo)));
-}
-
-void Client::lookedUp(QHostInfo hostInfo)
-{
-qDebug() << "Host lookup finished";
-       if (hostInfo.error() != QHostInfo::NoError)
-       {
-               qDebug() << "Lookup failed:" << hostInfo.errorString();
-               m_error = HostLookupError;
-               m_errorString = hostInfo.errorString();
-               emit connectionError();
-               return;
-       }
-       m_hostAddress = hostInfo.addresses()[0];
-
-       // TODO could it be nicer?
-       enterConnectingState();
-}
-
-void Client::enterConnectedState()
-{
-qDebug() << "Entering Connected State";
-       emit connected();
-}
-
-void Client::enterAuthenticatingState()
-{
-qDebug() << "Entering Authenticating State";
-
-       if (m_sessionId.isEmpty())
-       {
-               if (authReply != 0) authReply->deleteLater();
-               authReply = createReply(authCommand);
-               QObject::connect(authReply, SIGNAL(replyReady(bool)), this, SLOT(doAuthenticate(bool)));
-               enqueueControlCommand(authReply, true);
-               return;
-       }
-       emit authenticated();
-}
-
-void Client::doAuthenticate(bool success)
-{
-qDebug() << "doAuthenticate init";
-       if (success)
-       {
-qDebug() << "success!";
-               m_sessionId = authReply->sessionId().toUtf8();
-               emit authenticated();
-               return;
-       }
-
-       m_error = AuthenticationError;
-       m_errorString = authReply->errorString();
-
-       emit connectionError();
-}
-
-void Client::enterSendState()
-{
-qDebug() << "Entering Send State";
-
-       // Do not send commands if wait time didn't end
-       // Happens if sendState is entered from recv* states.
-       if (commandTimer->isActive())
-       {
-qDebug() << "commandTimer activein sendState";
-               emit commandSent();
-               return;
-       }
-
-       // Control commands (auth and such) have priority over any other commands.
-       if (!controlCommandQueue.isEmpty())
-       {
-qDebug() << "Sending Control Command";
-               sendCommand(controlCommandQueue.dequeue(), true);
-               emit commandSent();
-               return;
-       }
-
-       if (commandQueue.isEmpty())
-       {
-               emit queueEmpty();
-               return;
-       }
-       sendCommand(commandQueue.dequeue());
-       emit commandSent();
-}
-
-void Client::enterWaitState()
-{
-qDebug() << "Entering Wait State";
-
-       // Do not restart timer if it is active
-       if (!commandTimer->isActive())
-               commandTimer->start(m_floodInterval);
-}
-
-void Client::enterIdleState()
-{
-qDebug() << "Entering Idle State";
-qDebug() << m_idlePolicy;
-
-       // If not loogged in, nothing has to be done in idle state.
-       if (m_sessionId.isEmpty())
-               return;
-
-       switch (m_idlePolicy)
-       {
-               case LogoutIdlePolicy:
-                       idleTimer->start(UDP_API_INACTIVITY_LOGOUT * 1000);
-               break;
-               case KeepAliveIdlePolicy:
-                       idleTimer->start(UDP_API_INACTIVITY_UPDATE * 1000);
-               break;
-               case ImmediateLogoutIdlePolicy:
-                       logout(true);
-               break;
-               default:
-               break;
-       }
-}
-
-void Client::exitIdleState()
-{
-qDebug() << "Exiting Idle State";
-       idleTimer->stop();
-}
-
-void Client::enterIdleTiemoutState()
-{
-qDebug() << "Entering IdleTiemout State";
-       switch (m_idlePolicy)
-       {
-               case DoNothingIdlePolicy:
-                       m_sessionId = "";
-               break;
-               case KeepAliveIdlePolicy:
-                       enqueueControlCommand(uptimeReply);
-               default:
-               break;
-       }
-}
-
-void Client::enterRecieveState()
-{
-qDebug() << "Entering Recieve State";
-       while (socket->hasPendingDatagrams())
-       {
-               char data[UDP_DATAGRAM_MAXIMUM_SIZE];
-               int size;
-               QHostAddress sender;
-               quint16 senderPort;
-               size = socket->readDatagram(data, UDP_DATAGRAM_MAXIMUM_SIZE, &sender, &senderPort);
-
-               QByteArray tmp(data, size);
-
-               if (sender != m_hostAddress)
-               {
-                       qDebug() << QString("Recieved datagram from unknown host: %1 port: %2\nRaw datagram contents:%3\nDiscarding datagram.")
-                                       .arg(sender.toString())
-                                       .arg(senderPort)
-                                       .arg(tmp.constData());
-                       continue;
-               }
-
-               if (authCommand.compression() && tmp.mid(0, 2) == "00")
-               {
-qDebug() << "COMPRESSED DATAGRAM = " << tmp;
-                       tmp = qUncompress(tmp);
-               }
-
-               QString reply = QString::fromUtf8(tmp);
-
-               qDebug() << QString("Recieved datagram from [%1]:%2\nRaw datagram contents:%3")
-                               .arg(m_host)
-                               .arg(senderPort)
-                               .arg(reply);
-
-
-               // Check if it is a 6xx error.
-               {
-                       QRegExp rx("(?:50[34]|555|6[0-9]{2}) ");
-                       if (rx.exactMatch(tmp.mid(0, 4)))
-                       {
-                       
-                               int replyCode = tmp.mid(0, 3).toInt();
-                               switch (replyCode)
-                               {
-                                       case INTERNAL_SERVER_ERROR:
-                                               m_error = ServerError;
-                                               m_errorString = tr("Internal Server Error");
-                                               emit connectionError();
-                                               goto endLoop;
-                                       break;
-                                       case ANIDB_OUT_OF_SERVICE:
-                                               m_error = ServerError;
-                                               m_errorString = tr("AniDB out of service");
-                                               emit connectionError();
-                                               goto endLoop;
-                                       break;
-                                       case SERVER_BUSY:
-                                               m_error = ServerError;
-                                               m_errorString = tr("Server busy. Try again later. Wait at least 30 minutes.");
-                                               emit connectionError();
-                                               goto endLoop;
-                                       default:
-                                               if (replyCode > 601 && replyCode < 700)
-                                               {
-                                                       qDebug() << QString("SERVER ERROR %1").arg(replyCode);
-                                               }
-                                               emit connectionError();
-                                               goto endLoop;
-                                       break;
-                               }
-                               continue;
-                       }
-               }
-
-               QByteArray commandId = tmp.mid(0, 5);
-
-               commandsTimedOut = 0;
-
-               // Do not parse reply for unknown commands.
-               if (!sentCommands.contains(commandId))
-               {
-qDebug() << QString("Unknown command with id: %1, discarding")
-               .arg(commandId.constData());
-                       continue;
-               }
-qDebug() << QString("Sending reply to command with id: %1")
-               .arg(commandId.constData());
-
-               // tag + space = 5 + 1
-               QByteArray replyCodeText = tmp.mid(6, 3);
-
-               bool ok;
-               int replyCodeInt = replyCodeText.toInt(&ok);
-               ReplyCode replyCode = UNKNOWN_REPLY;
-               if (ok)
-               {
-                       replyCode = ReplyCode(replyCodeInt);
-               }
-
-               CommandData *commandData = sentCommands.take(commandId);
-               AbstractReply *cmd = commandData->command;
-               bool controlCommand = commandData->controlCommand;
-               delete commandData;
-
-               // Requeue command and reauthenticate if not logged in.
-               switch (replyCode)
-               {
-                       case LOGIN_FIRST:
-                       case INVALID_SESSION:
-qDebug() << "LOGIN FIRST required, authing";
-                               m_sessionId.clear();
-                               if (controlCommand)
-                                       enqueueControlCommand(cmd);
-                               else
-                                       enqueueCommand(cmd);
-                               emit startAuthentication();
-                               goto continueLoop;
-                       break;
-                       case LOGGED_OUT:
-                               m_sessionId.clear();
-                       break;
-                       case CLIENT_VERSION_OUTDATED:
-                               m_error = ClientVersionOutdatedError;
-                               m_errorString = tr("Client version outdated");
-                               emit connectionError();
-                               goto endLoop;
-                       break;
-                       case CLIENT_BANNED:
-                               m_error = ClientBannedError;
-                               m_errorString = tr("UDP Client banned");
-                               emit connectionError();
-                               goto endLoop;
-                       break;
-                       case BANNED:
-                               m_error = BannedError;
-                               m_errorString = tr("User banned from UDP API: %1").arg(reply.mid(10));
-                               emit connectionError();
-                               goto endLoop;
-                       break;
-                       case INTERNAL_SERVER_ERROR:
-                               m_error = ServerError;
-                               m_errorString = tr("Internal Server Error");
-                               emit connectionError();
-                               goto endLoop;
-                       break;
-                       case ANIDB_OUT_OF_SERVICE:
-                               m_error = ServerError;
-                               m_errorString = tr("AniDB out of service");
-                               emit connectionError();
-                               goto endLoop;
-                       break;
-                       case SERVER_BUSY:
-                               m_error = ServerError;
-                               m_errorString = tr("Server busy. Try again later. Wait at least 30 minutes.");
-                               emit connectionError();
-                               goto endLoop;
-                       break;
-                       default:
-                               if (replyCode > 601 && replyCode < 700)
-                               {
-                                       qDebug() << QString("SERVER ERROR %1").arg(replyCode);
-                                       emit connectionError();
-                               }
-                       break;
-               }
-               // tag + space + replyCode + space = 5 + 1 + 3 + 1
-               reply = reply.mid(10);
-
-               cmd->setRawReply(replyCode, reply);
-
-               // Delete if command is owned by the client.
-               if (!cmd->command().waitForResult())
-                       delete cmd;
-continueLoop:
-               ;
-       }
-       // replyRecieved() should be emitted on success
-       // all connection errors go directly to endLoops
-       emit replyRecieved();
-endLoop:
-       ;
-}
-
-void Client::enterRecieveFailState()
-{
-qDebug() << "Entering RecieveFail State";
-}
-
-// -------------------------------------------------------------------------------------
-
-void Client::clearCommandQueue()
-{
-       // Delete all unsent commands that are managed by the client.
-       while (!controlCommandQueue.isEmpty())
-       {
-               AbstractReply *reply = commandQueue.dequeue();
-               if (!reply->command().waitForResult())
-               {
-                       // These are owned by the client
-                       delete reply;
-               }
-               else
-               {
-                       // Send CLIENT_DESTROYED to indicate that no real reply will come.
-                       reply->setRawReply(CLIENT_DESTROYED, "");
-               }
-       }
-
-       while (!commandQueue.isEmpty())
-       {
-               AbstractReply *reply = commandQueue.dequeue();
-               if (!reply->command().waitForResult())
-               {
-                       // These are owned by the client
-                       delete reply;
-               }
-               else
-               {
-                       // Send CLIENT_DESTROYED to indicate that no real reply will come.
-                       reply->setRawReply(CLIENT_DESTROYED, "");
-               }
-       }
-}
-
-Client *Client::instance()
-{
-       if (!m_instance)
-               m_instance = new Client;
-
-       return m_instance;
-}
-
-void Client::destroy()
-{
-       delete m_instance;
-       m_instance = 0;
-}
-
-void Client::connect()
-{
-qDebug() << "Connecting";
-       emit startConnecting();
-}
-
-void Client::disconnect(bool graceful)
-{
-qDebug() << "Disconnecting" << (graceful ? "gracefully" : "");
-       if (graceful)
-       {
-               disconnecting = true;
-               return;
-       }
-       emit startDisconnecting();
-}
-
-void Client::send(AbstractReply *command)
-{
-       connect();
-
-       QObject::connect(command, SIGNAL(destroyed(QObject*)), this, SLOT(removeDeletedFromQueue(QObject*)));
-       enqueueCommand(command);
-}
-
-void Client::sendRaw(QByteArray command)
-{
-qDebug() << QString("Sending RAW command: %1").arg(command.constData());
-       enqueueCommand(createReply(RawCommand(command)));
-}
-
-void Client::cancel(AbstractReply *reply)
-{
-       commandQueue.removeAll(reply);
-       if (reply)
-               sentCommands.remove(reply->id());
-}
-
-void Client::logout()
-{
-       logout(false);
-}
-
-void Client::logout(bool force)
-{
-       if (m_sessionId.isEmpty())
-               return;
-       enqueueControlCommand(createReply(LogoutCommand()), force);
-}
-
-void Client::commandTimeout(const QByteArray &commandId)
-{
-qDebug() << commandId << "timed out";
-       if (!sentCommands.contains(commandId))
-               return;
-
-       CommandData *cmd = sentCommands.take(commandId);
-
-       // Regenerate ID.
-       cmd->command->setId(nextCommandId());
-
-       if (cmd->controlCommand)
-               enqueueControlCommand(cmd->command);
-       else
-               enqueueCommand(cmd->command);
-
-       delete cmd;
-
-       ++commandsTimedOut;
-
-       emit sendFailed();
-}
-
-void Client::enqueueCommand(AbstractReply *command, bool first)
-{
-       if (first)
-       {
-               commandQueue.push_front(command);
-       }
-       else
-       {
-               commandQueue.enqueue(command);
-       }
-
-       emit startSending();
-}
-
-void Client::enqueueControlCommand(AbstractReply *command, bool first)
-{
-       if (first)
-       {
-               controlCommandQueue.push_front(command);
-       }
-       else
-       {
-               controlCommandQueue.enqueue(command);
-       }
-
-       emit startSending();
-}
-
-void Client::sendCommand(AbstractReply *command, bool controlCommand)
-{
-       if (m_sessionId.isEmpty() && command->command().requiresSession())
-       {
-               if (controlCommand)
-                       enqueueControlCommand(command, true);
-               else
-                       enqueueCommand(command, true);
-               emit startAuthentication();
-               return;
-       }
-
-       Command cmdPair = command->command().rawCommand();
-       QByteArray datagram = buildCmd(cmdPair.first, cmdPair.second);
-
-       QByteArray commandId = command->id();
-
-       datagram += datagram.contains(" ") ? "&" : " ";
-       datagram += "tag=" + commandId;
-
-       if (m_sessionId.length())
-               datagram += "&s=" + m_sessionId;
-
-       CommandData *cmd = new CommandData(command, commandId, controlCommand);
-       QObject::connect(cmd, SIGNAL(timeout(QByteArray)), this, SLOT(commandTimeout(QByteArray)));
-
-       sentCommands[commandId] = cmd;
-
-qDebug() << QString("SENDING datagram:\n\t%1\nto: %2 ([%3]:%4)")
-               .arg(datagram.constData())
-               .arg(m_host)
-               .arg(m_hostAddress.toString())
-               .arg(m_hostPort);
-
-       socket->writeDatagram(datagram, m_hostAddress, m_hostPort);
-}
-
-void Client::removeDeletedFromQueue(QObject *object)
-{
-       AbstractReply *cmd = qobject_cast<AbstractReply *>(object);
-       if (cmd) cancel(cmd);
-}
-
-QByteArray Client::buildCmd(const QString &cmd, const QVariantMap &args)
-{
-       QString result = cmd;
-       for (QVariantMap::const_iterator it = args.constBegin(); it != args.constEnd(); ++it)
-       {
-               if (!it.value().canConvert(QVariant::String))
-               {
-                       qWarning("Passed value cannot be converted to string!");
-                       continue;
-               }
-
-               // The string version of bool is "true" or "false", but the API expects 1 or 0
-               QString value;
-               if (it.value().type() == QVariant::Bool)
-               {
-                       value = it.value().toBool() ? "1" : "0";
-               }
-               else
-               {
-                       value = it.value().toString();
-               }
-
-               if (it == args.constBegin())
-                       result += QString(" %1=%2").arg(it.key(), value);
-               else
-                       result += QString("&%1=%2").arg(it.key(), value);
-       }
-       return result.toUtf8();
-}
-
-QByteArray Client::nextCommandId(int len)
-{
-       static const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
-       static const int numChars = sizeof(chars) - 1;
-
-       QByteArray result(len, '-');
-       while (len--)
-               result[len] = chars[qrand() % numChars];
-
-qDebug() << QString("Generated id %1").arg(result.constData());
-       return result;
-}
-
-Client *Client::m_instance = 0;
-
-CommandData::CommandData(AbstractReply *command, const QByteArray &commandId, bool controlCommand) : QObject()
-{
-       this->command = command;
-       this->controlCommand = controlCommand;
-       this->commandId = commandId;
-
-       connect(&timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
-       timer.start(Client::UDP_API_COMMAND_TIMEOUT * 1000);
-}
-
-void CommandData::timerTimeout()
-{
-       emit timeout(commandId);
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/client.h b/lib/anidbudpclient/client.h
deleted file mode 100644 (file)
index 1d197ff..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-#ifndef ANIDBUDPCLIENT_H
-#define ANIDBUDPCLIENT_H
-
-#include "anidbudpclient_global.h"
-#include <QObject>
-#include <QQueue>
-#include <QTimer>
-#include <QHostAddress>
-#include <QHostInfo>
-#include <QVariantMap>
-
-#include "anidbudpclient_global.h"
-#include "authcommand.h"
-
-class QStateMachine;
-class QState;
-class QHistoryState;
-
-class QUdpSocket;
-class QTimer;
-
-namespace AniDBUdpClient {
-
-class AbstractCommand;
-class LogoutReply;
-class UptimeReply;
-
-class CommandData;
-
-class ANIDBUDPCLIENTSHARED_EXPORT Client : public QObject
-{
-       friend class CommandData;
-       friend class AbstractReply;
-
-       Q_OBJECT
-       Q_ENUMS(AniDBUdpClient::State AniDBUdpClient::Error AniDBUdpClient::IdlePolicy AniDBUdpClient::ReplyCode);
-
-       Q_PROPERTY(QString host READ host WRITE setHost);
-       Q_PROPERTY(quint16 hostPort READ hostPort WRITE setHostPort);
-       Q_PROPERTY(quint16 localPort READ localPort WRITE setLocalPort);
-
-       Q_PROPERTY(QString user READ user WRITE setUser);
-       Q_PROPERTY(QString pass READ pass WRITE setPass);
-
-       /*
-         Send commands in \interval seconds intervals
-       */
-       Q_PROPERTY(int floodInterval READ floodInterval WRITE setFloodInterval);
-       Q_PROPERTY(IdlePolicy idlePolicy READ idlePolicy WRITE setIdlePolicy);
-       Q_PROPERTY(Error error READ error);
-       Q_PROPERTY(QString errorString READ errorString);
-
-public:
-       static const QByteArray clientName;
-       static const int clientVersion;
-       static const int protocolVersion;
-
-protected:
-       Client(QObject *parent = 0);
-       virtual ~Client();
-
-public:
-       // ------------------ Properties ------------------
-       QString host() const;
-       void setHost(const QString &host, quint16 port = 0);
-       quint16 hostPort() const;
-       void setHostPort(quint16 port);
-       quint16 localPort() const;
-       void setLocalPort(quint16 port);
-
-       QString user() const;
-       void setUser(const QString &user);
-       QString pass() const;
-       void setPass(const QString &user);
-
-       bool compression() const;
-       void setCompression(bool compress);
-
-       int floodInterval() const;
-       void setFloodInterval(int interval);
-
-       IdlePolicy idlePolicy() const;
-       void setIdlePolicy(IdlePolicy policy);
-
-       Error error() const;
-       QString errorString() const;
-
-       // ---------------- END Properties ----------------
-
-       void clearCommandQueue();
-
-       static Client *instance();
-       static void destroy();
-
-public slots:
-       void connect();
-
-       /*
-         Disconnect from host.
-         If \graceful is true send all enququed messages first.
-       */
-       void disconnect(bool graceful = false);
-
-public:
-       template<typename T> typename T::ReplyType *send(const T &command, QObject *parent = 0)
-       {
-               typename T::ReplyType *reply = createReply(command, parent);
-               send(reply);
-               return reply;
-       }
-
-private:
-       template<typename T> typename T::ReplyType *createReply(const T &command, QObject *parent = 0)
-       {
-               return new T::ReplyType(command, nextCommandId(), this, parent);
-       }
-public slots:
-
-       void send(AbstractReply *reply);
-
-       void sendRaw(QByteArray command);
-       void cancel(AbstractReply *command);
-
-signals:
-
-       void startConnecting();
-       void connected();
-       void startDisconnecting();
-       void disconnected();
-
-       void startAuthentication();
-       void authenticated();
-       void authenticationFailure();
-
-       void startSending();
-       void commandSent();
-       void queueEmpty();
-
-       void replyRecieved();
-       void sendFailed();
-
-       void connectionError();
-
-private slots:
-       void enterErrorState();
-       void enterDisconnectedState();
-
-       void enterConnectingState();
-       void lookedUp(QHostInfo hostInfo);
-
-       void enterConnectedState();
-
-       void enterAuthenticatingState();
-       void doAuthenticate(bool success);
-
-       void enterSendState();
-       void enterWaitState();
-       void enterIdleState();
-       void exitIdleState();
-       void enterIdleTiemoutState();
-
-       void enterRecieveState();
-       void enterRecieveFailState();
-
-       void logout();
-
-       void commandTimeout(const QByteArray &commandId);
-
-       void removeDeletedFromQueue(QObject *object);
-
-private:
-       void enqueueCommand(AbstractReply *command, bool first = false);
-       void enqueueControlCommand(AbstractReply *command, bool first = false);
-       void sendCommand(AbstractReply *command, bool controlCommand = false);
-
-       void logout(bool force);
-
-       QByteArray buildCmd(const QString &cmd, const QVariantMap &args);
-       QByteArray nextCommandId(int len = 5);
-
-       QTimer *commandTimer;
-       QTimer *idleTimer;
-       QTimer *replyTimeoutTimer;
-
-       QQueue<AbstractReply *> commandQueue;
-       QQueue<AbstractReply *> controlCommandQueue;
-       QMap<QByteArray, CommandData *> sentCommands;
-       QUdpSocket *socket;
-
-
-
-       // Connection params
-       QString m_host;
-       QHostAddress m_hostAddress;
-       quint16 m_hostPort;
-       quint16 m_localPort;
-
-       int m_floodInterval;
-
-       QByteArray m_sessionId;
-
-       // Misc params
-       IdlePolicy m_idlePolicy;
-       Error m_error;
-       QString m_errorString;
-
-       bool disconnecting;
-
-       int commandsTimedOut;
-
-       AuthCommand authCommand;
-       AuthReply *authReply;
-       UptimeReply *uptimeReply;
-
-       static Client *m_instance;
-
-       static const int UDP_DATAGRAM_MAXIMUM_SIZE = 1400;
-
-       // These are in seconds
-       static const int UDP_API_INACTIVITY_UPDATE = 30 * 60;
-       static const int UDP_API_INACTIVITY_LOGOUT = 35 * 60;
-
-       static const int UDP_API_COMMAND_TIMEOUT = 30;
-
-       QStateMachine *stateMachine;
-       QState *errorState;
-       QState *disconnectedState;
-       QState *connectingState;
-       QState *connectedState;
-       QState *authenticatingState;
-
-       QState *idleState;
-       QState *idleTimeoutState;
-       QState *sendState;
-       QState *waitState;
-
-       QState *recieveState;
-       QState *recieveFailState;
-
-       QHistoryState *connectedHistoryState;
-};
-
-class CommandData : QObject
-{
-       friend class Client;
-
-       Q_OBJECT
-public:
-       AbstractReply *command;
-       bool controlCommand;
-       QByteArray commandId;
-       QTimer timer;
-
-       CommandData(AbstractReply *command, const QByteArray &commandId, bool controlCommand = false);
-signals:
-       void timeout(QByteArray commandId);
-private slots:
-       void timerTimeout();
-};
-
-} // namespace AniDBUdpClient
-
-#include <QScriptEngine>
-//Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::Client, QObject*);
-
-#endif // ANIDBUDPCLIENT_H
diff --git a/lib/anidbudpclient/file.cpp b/lib/anidbudpclient/file.cpp
deleted file mode 100644 (file)
index c8acde7..0000000
+++ /dev/null
@@ -1,402 +0,0 @@
-#include "file.h"
-
-#include <QRegExp>
-#include "client.h"
-#include "hash.h"
-
-#include <QDebug>
-
-namespace AniDBUdpClient {
-
-File::File(QObject *parent) : QObject(parent)
-{
-       init();
-}
-
-File::File(const QFileInfo &file, QObject *parent) : QObject(parent)
-{
-       m_file = file;
-       init();
-}
-
-File::~File()
-{
-       if (markReply)
-       {
-               delete markReply;
-               markReply = 0;
-       }
-       if (fileReply)
-       {
-               delete fileReply;
-               fileReply = 0;
-       }
-       if (addReply)
-       {
-               delete addReply;
-               addReply = 0;
-       }
-       if (hashResult)
-       {
-               delete hashResult;
-               hashResult = 0;
-       }
-}
-
-QFileInfo File::file() const
-{
-       return m_file;
-}
-
-void File::setFile(const QFileInfo &file)
-{
-       if (m_file == file)
-               return;
-
-       m_file = file;
-}
-
-qint64 File::size()
-{
-       return m_file.size();
-}
-
-QByteArray File::ed2k()
-{
-       return m_ed2k;
-}
-
-File::ActionState File::hashingState() const
-{
-       return m_hashingState;
-}
-
-File::ActionState File::renamingState() const
-{
-       return m_renamingState;
-}
-
-File::ActionState File::addingState() const
-{
-       return m_addingState;
-}
-
-File::ActionState File::markingState() const
-{
-       return m_markingState;
-}
-
-
-void File::hash()
-{
-       if (m_hashingState != Success)
-               actionsQueue.enqueue(Hashing);
-
-       if (notWorking) work();
-}
-
-bool File::rename()
-{
-       if (m_renamingState == Success)
-               return true;
-
-       if (m_hashingState != Success)
-               actionsQueue.enqueue(Hashing);
-
-       actionsQueue.enqueue(Renaming);
-
-       if (notWorking) work();
-       return true;
-}
-
-bool File::addToMyList()
-{
-       if (!canContinue(m_addingState))
-               return false;
-       if (m_hashingState != Success)
-               actionsQueue.enqueue(Hashing);
-
-       actionsQueue.enqueue(Adding);
-
-       if (notWorking) work();
-       return true;
-}
-
-bool File::markWatched()
-{
-       if (m_markingState == Success)
-               return true;
-
-       if (m_hashingState != Success)
-               actionsQueue.enqueue(Hashing);
-
-       if (m_addingState != Success)
-               actionsQueue.enqueue(Adding);
-
-       actionsQueue.enqueue(MarkingWatched);
-
-       if (notWorking) work();
-       return true;
-}
-
-
-void File::finishHashing()
-{
-qDebug() << "finishHashing";
-       m_ed2k = hashResult->hash();
-qDebug() << m_ed2k;
-       hashResult->deleteLater();
-       hashResult = 0;
-
-       updateStatus(Hashing, Success);
-}
-
-void File::finishRenaming(bool success)
-{
-qDebug() << "finishRenaming";
-       if (!success)
-       {
-               updateStatus(Renaming, Failure);
-               return;
-       }
-
-       QString name = fileReply->value(FileAnimeFlag::RomajiName).toString();
-       if (name.isEmpty())
-               name = fileReply->value(FileAnimeFlag::EnglishName).toString();
-
-       QString newFileName = tr("%1 - %2 - %3 - [%4](%5).%6")
-                                          .arg(name)
-                                          .arg(fileReply->value(FileAnimeFlag::EpNo).toString())
-                                          .arg(fileReply->value(FileAnimeFlag::EpName).toString())
-                                          .arg(fileReply->value(FileAnimeFlag::GroupShortName).toString())
-                                          .arg(fileReply->value(FileFlag::Crc32).toString())
-                                          .arg(fileReply->value(FileFlag::FileType).toString());
-
-       newFileName.replace('"', "'");
-       newFileName.replace(QRegExp("[\\/]"), "-");
-       newFileName.replace(QRegExp("[\\/:*?\"<>|]"), "");
-qDebug() << newFileName;
-
-
-       QFile file(m_file.absoluteFilePath());
-
-       if (file.fileName() == newFileName)
-       {
-               updateStatus(Renaming, Success);
-               return;
-       }
-
-       if (file.rename(m_file.absolutePath() + "/" + newFileName))
-       {
-               m_file.setFile(file);
-qDebug() << m_file.absoluteFilePath();
-               updateStatus(Renaming, Success);
-       }
-       else
-       {
-qDebug() << file.errorString();
-               updateStatus(Renaming, Failure);
-       }
-}
-
-void File::finishAdding(bool success)
-{
-       if (!success)
-       {
-               updateStatus(Adding, Failure);
-               return;
-       }
-       updateStatus(Adding, Success);
-}
-
-void File::finishMarking(bool success)
-{
-       if (!success)
-       {
-               updateStatus(MarkingWatched, Failure);
-               return;
-       }
-       updateStatus(MarkingWatched, Success);
-}
-
-void File::work()
-{
-qDebug() << "work";
-qDebug() << actionsQueue;
-
-       notWorking = false;
-
-       if (actionsQueue.isEmpty())
-       {
-               emit statusUpdate(All, Finished);
-               emit finished();
-               notWorking = true;
-               return;
-       }
-
-       Action a = actionsQueue.dequeue();
-
-qDebug() << "Next work:" << a;
-
-       switch (a)
-       {
-               case Hashing:
-                       startHashing();
-               break;
-               case Renaming:
-                       startRenaming();
-               break;
-               case Adding:
-                       startAdding();
-               break;
-               case MarkingWatched:
-                       startMarking();
-               break;
-               default:
-               break;
-       }
-}
-
-void File::workOnFinished(Action action, ActionState actionState)
-{
-       Q_UNUSED(action);
-
-       switch (actionState)
-       {
-               case Success:
-               case Failure:
-                       work();
-               default:
-               break;
-       }
-}
-
-void File::startHashing()
-{
-qDebug() << "startHashing";
-
-       if (!m_ed2k.isEmpty())
-       {
-               work();
-               return;
-       }
-
-       if (hashResult)
-               hashResult->deleteLater();
-
-       hashResult = Hash::instance()->hashFile(m_file);
-       connect(hashResult, SIGNAL(resultReady()), this, SLOT(finishHashing()));
-
-       updateStatus(Hashing, InProgress);
-}
-
-void File::startRenaming()
-{
-qDebug() << "startRenaming";
-
-       if (!canContinue(m_renamingState))
-       {
-               work();
-               return;
-       }
-
-       if (fileReply)
-               delete fileReply;
-
-       FileCommand fileCommand(m_ed2k,
-                                                 size(),
-                                                 FileFlag::Crc32
-                                                 | FileFlag::FileType
-                                                 | FileFlag::Lid,
-                                                 FileAnimeFlag::EnglishName
-                                                 | FileAnimeFlag::RomajiName
-                                                 | FileAnimeFlag::KanjiName
-                                                 | FileAnimeFlag::EpNo
-                                                 | FileAnimeFlag::EpName
-                                                 | FileAnimeFlag::GroupShortName);
-       fileReply = Client::instance()->send(fileCommand);
-       connect(fileReply, SIGNAL(replyReady(bool)), this, SLOT(finishRenaming(bool)));
-
-       updateStatus(Renaming, InProgress);
-}
-
-void File::startAdding()
-{
-       if (!canContinue(m_addingState))
-       {
-               work();
-               return;
-       }
-
-       if (addReply)
-               delete addReply;
-
-       MyListAddCommand addCommand(m_ed2k, size(), false);
-       addCommand.setState(StateOnHdd);
-
-       addReply = Client::instance()->send(addCommand);
-
-       connect(addReply, SIGNAL(replyReady(bool)), this, SLOT(finishAdding(bool)));
-
-
-       updateStatus(Adding, InProgress);
-}
-
-void File::startMarking()
-{
-       if (!canContinue(m_markingState))
-       {
-               work();
-               return;
-       }
-       MyListAddCommand markCommand(0);
-       if (addReply->lid())
-               markCommand = MyListAddCommand(addReply->lid());
-       else
-               markCommand = MyListAddCommand(m_ed2k, size(), true);
-       markCommand.setViewed(true);
-
-       if (markReply) markReply->deleteLater();
-       markReply = Client::instance()->send(markCommand);
-       connect(markReply, SIGNAL(replyReady(bool)), this, SLOT(finishMarking(bool)));
-
-       updateStatus(MarkingWatched, InProgress);
-}
-
-void File::init()
-{
-       hashResult = 0;
-       fileReply = 0;
-       addReply = 0;
-       markReply = 0;
-       m_hashingState = m_renamingState = m_addingState = m_markingState = NotStarted;
-       notWorking = true;
-
-       connect(this, SIGNAL(statusUpdate(AniDBUdpClient::File::Action,AniDBUdpClient::File::ActionState)), this, SLOT(workOnFinished(AniDBUdpClient::File::Action,AniDBUdpClient::File::ActionState)));
-}
-
-bool File::canContinue(ActionState state)
-{
-       return state & OkToContinue;
-}
-
-void File::updateStatus(Action action, ActionState actionState)
-{
-       switch (action)
-       {
-               case Hashing:
-                       m_hashingState = actionState;
-               break;
-               case Renaming:
-                       m_renamingState = actionState;
-               break;
-               case Adding:
-                       m_addingState = actionState;
-               break;
-               case MarkingWatched:
-                       m_markingState = actionState;
-       }
-       emit statusUpdate(action, actionState);
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/file.h b/lib/anidbudpclient/file.h
deleted file mode 100644 (file)
index 0d83544..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-#ifndef FILE_H
-#define FILE_H
-
-#include "anidbudpclient_global.h"
-#include <QObject>
-
-#include <QFileInfo>
-#include <QQueue>
-
-#include "filecommand.h"
-#include "mylistaddcommand.h"
-
-namespace AniDBUdpClient {
-
-class FileCommand;
-class MyListCommand;
-class HashResult;
-
-class ANIDBUDPCLIENTSHARED_EXPORT File : public QObject
-{
-       Q_OBJECT
-
-       Q_PROPERTY(QFileInfo file READ file WRITE setFile);
-
-       Q_PROPERTY(qint64 size READ size);
-       Q_PROPERTY(QByteArray ed2k READ ed2k);
-
-       Q_PROPERTY(ActionState hashingState READ hashingState);
-       Q_PROPERTY(ActionState renamingState READ renamingState);
-       Q_PROPERTY(ActionState addingState READ addingState);
-       Q_PROPERTY(ActionState markingState READ markingState);
-public:
-
-       enum Action {
-               Hashing,
-               Renaming,
-               Adding,
-               MarkingWatched,
-
-               All = -1,
-       };
-
-       enum ActionState {
-               NotStarted      = 0x00000001,
-               InProgress      = 0x00000002,
-               Success         = 0x00000004,
-               Failure         = 0x00000008,
-
-               Finished        = 0x00000010,
-
-               OkToContinue = NotStarted | Failure,
-       };
-
-       Q_ENUMS(Action ActionState);
-
-       File(QObject *parent = 0);
-       File(const QFileInfo &file, QObject *parent = 0);
-       ~File();
-
-       QFileInfo file() const;
-       void setFile(const QFileInfo &file);
-
-       qint64 size();
-       QByteArray ed2k();
-
-
-       ActionState hashingState() const;
-       ActionState renamingState() const;
-       ActionState addingState() const;
-       ActionState markingState() const;
-
-public slots:
-       void hash();
-       bool rename();
-       bool addToMyList();
-       bool markWatched();
-
-signals:
-       void statusUpdate(AniDBUdpClient::File::Action action, AniDBUdpClient::File::ActionState state);
-       void finished();
-
-private slots:
-       void finishHashing();
-       void finishRenaming(bool success);
-       void finishAdding(bool success);
-       void finishMarking(bool success);
-
-       void work();
-       void workOnFinished(AniDBUdpClient::File::Action action, AniDBUdpClient::File::ActionState actionState);
-
-private:
-
-       void startHashing();
-       void startRenaming();
-       void startAdding();
-       void startMarking();
-
-       void init();
-
-       bool canContinue(ActionState state);
-       void updateStatus(Action action, ActionState actionState);
-
-       QQueue<Action> actionsQueue;
-
-       QFileInfo m_file;
-       QByteArray m_ed2k;
-
-       bool notWorking;
-
-       ActionState m_hashingState;
-       ActionState m_renamingState;
-       ActionState m_addingState;
-       ActionState m_markingState;
-
-       HashResult *hashResult;
-       FileReply *fileReply;
-       MyListAddReply *addReply;
-       MyListAddReply *markReply;
-
-};
-
-} // namespace AniDBUdpClient
-
-Q_DECLARE_METATYPE(AniDBUdpClient::File::Action);
-Q_DECLARE_METATYPE(AniDBUdpClient::File::ActionState);
-
-#endif // FILE_H
diff --git a/lib/anidbudpclient/filecommand.cpp b/lib/anidbudpclient/filecommand.cpp
deleted file mode 100644 (file)
index 5dcf719..0000000
+++ /dev/null
@@ -1,340 +0,0 @@
-#include "filecommand.h"
-
-#include <QStringList>
-
-#include <QDebug>
-
-namespace AniDBUdpClient {
-
-FileCommand::FileCommand() : AbstractCommand()
-{
-       init();
-}
-
-FileCommand::FileCommand(int fid, FileFlags fmask, FileAnimeFlags amask) : AbstractCommand()
-{
-       init();
-       m_fid = fid;
-       m_fmask = fmask;
-       m_amask = amask;
-}
-
-FileCommand::FileCommand(const QByteArray &ed2k, qint64 size, FileFlags fmask, FileAnimeFlags amask) : AbstractCommand()
-{
-       init();
-       m_ed2k = ed2k;
-       m_size = size;
-       m_fmask = fmask;
-       m_amask = amask;
-}
-
-FileCommand::FileCommand(const QString &aname, const QString &gname, int epno, FileFlags fmask, FileAnimeFlags amask) : AbstractCommand()
-{
-       init();
-       m_aname = aname;
-       m_gname = gname;
-       m_epno = epno;
-       m_fmask = fmask;
-       m_amask = amask;
-}
-
-FileCommand::FileCommand(const QString &aname, int gid, int epno, FileFlags fmask, FileAnimeFlags amask) : AbstractCommand()
-{
-       init();
-       m_aname = aname;
-       m_gid = gid;
-       m_epno = epno;
-       m_fmask = fmask;
-       m_amask = amask;
-}
-
-FileCommand::FileCommand(int aid, const QString &gname, int epno, FileFlags fmask, FileAnimeFlags amask) : AbstractCommand()
-{
-       init();
-       m_aid = aid;
-       m_gname = gname;
-       m_epno = epno;
-       m_fmask = fmask;
-       m_amask = amask;
-}
-
-FileCommand::FileCommand(int aid, int gid, int epno, FileFlags fmask, FileAnimeFlags amask) : AbstractCommand()
-{
-       init();
-       m_aid = aid;
-       m_gid = gid;
-       m_epno = epno;
-       m_fmask = fmask;
-       m_amask = amask;
-}
-
-int FileCommand::fid() const
-{
-       return m_fid;
-}
-
-void FileCommand::setFid(int fid)
-{
-       m_fid = fid;
-}
-
-QByteArray FileCommand::ed2k() const
-{
-       return m_ed2k;
-}
-
-void FileCommand::setEd2k(const QByteArray &ed2k)
-{
-       m_ed2k = ed2k;
-}
-
-qint64 FileCommand::size() const
-{
-       return m_size;
-}
-
-void FileCommand::setSize(qint64 size)
-{
-       m_size = size;
-}
-
-QString FileCommand::aname() const
-{
-       return m_aname;
-}
-
-void FileCommand::setAname(const QString &aname)
-{
-       m_aname = aname;
-}
-
-int FileCommand::aid() const
-{
-       return m_aid;
-}
-
-void FileCommand::setAid(int aid)
-{
-       m_aid = aid;
-}
-
-QString FileCommand::gname() const
-{
-       return m_gname;
-}
-
-void FileCommand::setGname(const QString &gname)
-{
-       m_gname = gname;
-}
-
-int FileCommand::gid() const
-{
-       return m_gid;
-}
-
-void FileCommand::setGid(int gid)
-{
-       m_gid = gid;
-}
-
-
-int FileCommand::epno() const
-{
-       return m_epno;
-}
-
-void FileCommand::setEpno(int epno)
-{
-       m_epno = epno;
-}
-
-FileFlags FileCommand::fmask() const
-{
-       return m_fmask;
-}
-
-void FileCommand::setFmask(FileFlags fmask)
-{
-       m_fmask = fmask;
-}
-
-FileAnimeFlags FileCommand::amask() const
-{
-       return m_amask;
-}
-
-void FileCommand::setAmask(FileAnimeFlags amask)
-{
-       m_amask = amask;
-}
-
-bool FileCommand::waitForResult() const
-{
-       return true;
-}
-
-Command FileCommand::rawCommand() const
-{
-       Command cmd;
-
-       cmd.first = "FILE";
-
-       if (m_fid)
-       {
-               cmd.second["fid"] = m_fid;
-       }
-       else if (!m_ed2k.isEmpty() && m_size)
-       {
-               cmd.second["ed2k"] = m_ed2k;
-               cmd.second["size"] = m_size;
-       }
-       else if (!m_aname.isEmpty())
-       {
-               cmd.second["aname"] = m_aname;
-               if (!m_gname.isEmpty() && m_epno)
-               {
-                       cmd.second["gname"] = m_gname;
-                       cmd.second["epno"] = m_epno;
-               }
-               else if (m_gid && m_epno)
-               {
-                       cmd.second["gid"] = m_gid;
-                       cmd.second["epno"] = m_epno;
-               }
-       }
-       else if (m_aid)
-       {
-               cmd.second["aid"] = m_aid;
-               if (!m_gname.isEmpty() && m_epno)
-               {
-                       cmd.second["gname"] = m_gname;
-                       cmd.second["epno"] = m_epno;
-               }
-               else if (m_gid && m_epno)
-               {
-                       cmd.second["gid"] = m_gid;
-                       cmd.second["epno"] = m_epno;
-               }
-       }
-       else
-       {
-               cmd.second["fid"] = m_fid;
-       }
-
-       // Clear any bits which aren't known and pad to 8 characters
-       cmd.second["fmask"] = QString::number(m_fmask & FileFlag::AllData, 16)
-                                                 .rightJustified(8, QLatin1Char('0'));
-       cmd.second["amask"] = QString::number(m_amask & FileAnimeFlag::AllData, 16)
-                                                 .rightJustified(8, QLatin1Char('0'));
-
-       return cmd;
-}
-
-void FileCommand::init()
-{
-       m_fid = 0;
-       m_aid = 0;
-       m_gid = 0;
-
-       m_size = 0;
-       m_epno = 0;
-
-       m_fmask = FileFlags(0);
-       m_amask = AnimeFlags(0);
-}
-
-// ===
-
-int FileReply::fid() const
-{
-       return m_fid;
-}
-
-QVariant FileReply::value(FileFlags f) const
-{
-       return fileFlagData.value(f);
-}
-
-QVariant FileReply::value(FileAnimeFlags f) const
-{
-       return fileAnimeFlagData.value(f);
-}
-
-void FileReply::setRawReply(ReplyCode replyCode, const QString &reply)
-{
-       AbstractReply::setRawReply(replyCode, reply);
-
-       switch (replyCode)
-       {
-               case FILE:
-                       readReplyData(reply);
-                       emit replyReady(true);
-               break;
-               case MULTIPLE_FILES_FOUND:
-                       // TODO
-                       emit replyReady(true);
-               break;
-               case NO_SUCH_FILE:
-               default:
-                       emit replyReady(false);
-               break;
-       }
-}
-
-void FileReply::readReplyData(const QString &reply)
-{
-       QString d = reply.mid(reply.indexOf('\n')).trimmed();
-qDebug() << d;
-       QList<QString> parts = d.split('|', QString::KeepEmptyParts);
-qDebug() << parts;
-       m_fid = parts[0].toInt();
-
-       if (command().fmask() == 0 && command().amask() == 0)
-       {
-               fileFlagData.insert(FileFlag::Aid,                              parts[1].toInt());
-               fileFlagData.insert(FileFlag::Eid,                              parts[2].toInt());
-               fileFlagData.insert(FileFlag::Gid,                              parts[3].toInt());
-               fileFlagData.insert(FileFlag::State,                    parts[4].toInt());
-               fileFlagData.insert(FileFlag::Size,                             parts[5].toInt());
-               fileFlagData.insert(FileFlag::Ed2k,                             parts[6]);
-               fileFlagData.insert(FileFlag::AniDBFileName,    parts[7]);
-               return;
-       }
-
-       int partNo = 1;
-       for (int i = 0, flag = 1 << 31; i < 32; ++i, flag = (flag >> 1) & ~(1 << 31))
-       {
-               if (command().fmask() & flag)
-               {
-                       if (partNo >= parts.size())
-                       {
-qDebug() << "Not enough parts in reply.";
-                               continue;
-                       }
-                       fileFlagData.insert(FileFlags(flag), parts[partNo]);
-                       ++partNo;
-               }
-       }
-
-       for (int i = 0, flag = 1 << 31; i < 32; ++i, flag = (flag >> 1) & ~(1 << 31))
-       {
-               if (command().amask() & flag)
-               {
-                       if (partNo >= parts.size())
-                       {
-qDebug() << "Not enough parts in reply.";
-                               continue;
-                       }
-                       fileAnimeFlagData.insert(FileAnimeFlags(flag), parts[partNo]);
-                       ++partNo;
-               }
-       }
-}
-
-void FileReply::init()
-{
-       m_fid = 0;
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/filecommand.h b/lib/anidbudpclient/filecommand.h
deleted file mode 100644 (file)
index dabc761..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef FILECOMMAND_H\r
-#define FILECOMMAND_H\r
-\r
-#include "anidbudpclient_global.h"\r
-#include "abstractcommand.h"\r
-\r
-#include <QVariant>\r
-\r
-namespace AniDBUdpClient {\r
-\r
-class FileReply;\r
-\r
-class ANIDBUDPCLIENTSHARED_EXPORT FileCommand : public AbstractCommand\r
-{\r
-/*\r
-       Q_PROPERTY(int fid READ fid WRITE setFid);\r
-\r
-       Q_PROPERTY(QByteArray ed2k READ ed2k WRITE setEd2k);\r
-       Q_PROPERTY(qint64 size READ size WRITE setSize);\r
-\r
-       Q_PROPERTY(QString aname READ aname WRITE setAname);\r
-       Q_PROPERTY(int aid READ aid WRITE setAid);\r
-       Q_PROPERTY(QString gname READ gname WRITE setGname);\r
-       Q_PROPERTY(int gid READ gid WRITE setGid);\r
-       Q_PROPERTY(int epno READ epno WRITE setEpno);\r
-\r
-       Q_PROPERTY(FileFlags fmask READ fmask WRITE setFmask);\r
-       Q_PROPERTY(FileAnimeFlags amask READ amask WRITE setAmask);\r
-*/\r
-public:\r
-       typedef FileReply ReplyType;\r
-       FileCommand();\r
-       FileCommand(int fid, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0));\r
-       FileCommand(const QByteArray &ed2k, qint64 size, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0));\r
-       FileCommand(const QString &aname, const QString &gname, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0));\r
-       FileCommand(const QString &aname, int gid, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0));\r
-       FileCommand(int aid, const QString &gname, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0));\r
-       FileCommand(int aid, int gid, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0));\r
-\r
-       int fid() const;\r
-       void setFid(int fid);\r
-\r
-       QByteArray ed2k() const;\r
-       void setEd2k(const QByteArray &ed2k);\r
-       qint64 size() const;\r
-       void setSize(qint64 size);\r
-\r
-       QString aname() const;\r
-       void setAname(const QString &aname);\r
-       int aid() const;\r
-       void setAid(int aid);\r
-       QString gname() const;\r
-       void setGname(const QString &gname);\r
-       int gid() const;\r
-       void setGid(int gid);\r
-       int epno() const;\r
-       void setEpno(int epno);\r
-\r
-       FileFlags fmask() const;\r
-       void setFmask(FileFlags fmask);\r
-       FileAnimeFlags amask() const;\r
-       void setAmask(FileAnimeFlags amask);\r
-\r
-       bool waitForResult() const;\r
-       Command rawCommand() const;\r
-\r
-private:\r
-       void init();\r
-\r
-       int m_fid;\r
-\r
-       QByteArray m_ed2k;\r
-       qint64 m_size;\r
-\r
-       QString m_aname;\r
-       int m_aid;\r
-       QString m_gname;\r
-       int m_gid;\r
-       int m_epno;\r
-\r
-       FileFlags m_fmask;\r
-       FileAnimeFlags m_amask;\r
-};\r
-\r
-class ANIDBUDPCLIENTSHARED_EXPORT FileReply : public AbstractReply\r
-{\r
-       Q_OBJECT\r
-       REPLY_DEFINITION_HELPER2(File)\r
-\r
-       Q_PROPERTY(int fid READ fid);\r
-\r
-public:\r
-       int fid() const;\r
-\r
-       QVariant value(FileFlags f) const;\r
-       QVariant value(FileAnimeFlags f) const;\r
-\r
-       void setRawReply(ReplyCode replyCode, const QString &reply);\r
-\r
-private:\r
-       void readReplyData(const QString &reply);\r
-       void init();\r
-\r
-       int m_fid;\r
-\r
-       QMap<FileFlags, QVariant> fileFlagData;\r
-       QMap<FileAnimeFlags, QVariant> fileAnimeFlagData;\r
-};\r
-\r
-} // namespace AniDBUdpClient\r
-\r
-#endif // FILECOMMAND_H\r
diff --git a/lib/anidbudpclient/hash.cpp b/lib/anidbudpclient/hash.cpp
deleted file mode 100644 (file)
index 3b2ada2..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-#include "hash.h"
-
-#include <QDebug>
-
-namespace AniDBUdpClient {
-
-Hash::Hash(QObject *parent) : QObject(parent)
-{
-       producer = 0;
-       consumer = 0;
-       buffer = 0;
-       hashing = false;
-       setUp();
-       totalFileSize = 0;
-       hashedFileSize = 0;
-}
-
-Hash::~Hash()
-{
-       tearDown();
-}
-
-Hash *Hash::instance()
-{
-       if (!m_instance)
-               m_instance = new Hash();
-
-       return m_instance;
-}
-
-void Hash::destroy()
-{
-       delete m_instance;
-       m_instance = 0;
-}
-
-HashResult *Hash::hashFile(const HashRequest &file)
-{
-qDebug() << "Hash::hashFile";
-
-       HashResult *result = new HashResult(file);
-
-       fileQueue.enqueue(result);
-       totalFileSize += file.fileInfo().size();
-
-       if (hashing)
-               return result;
-
-       totalTime.start();
-       startHashing();
-       return result;
-}
-
-void Hash::endHashing(const QByteArray &hash)
-{
-qDebug() << "Hash::endHashing";
-       HashResult *r = fileQueue.dequeue();
-
-       int fileElapsed = fileTime.elapsed();
-
-qDebug() << "File:" << r->fileInfo().fileName() << "Hash:" << hash << "Time:" << fileElapsed;
-
-       hashedFileSize += r->fileInfo().size();
-
-       r->setHash(hash);
-       emit resultReady(r);
-
-       if (!fileQueue.isEmpty())
-       {
-               startHashing();
-       }
-       else
-       {
-               hashing = false;
-               int totalElapsed = totalTime.elapsed();
-               emit finished();
-qDebug() << "Total time:" << totalElapsed;
-               hashedFileSize = totalFileSize = 0;
-       }
-
-}
-
-void Hash::reportProgress(qint64 read, qint64 total)
-{
-       int filePercent = (read * 100) / total;
-       emit fileProgress(filePercent);
-
-       int totalPercent = ((hashedFileSize + read) * 100) / totalFileSize;
-       emit progress(totalPercent);
-}
-
-void Hash::startHashing()
-{
-       QString file = fileQueue.first()->fileInfo().absoluteFilePath();
-
-       fileTime.start();
-
-       producer->readFile(file);
-       consumer->hashFile(file);
-}
-
-void Hash::setUp()
-{
-       if (producer || consumer || buffer)
-               return;
-qDebug() << "MAIN thread id is: " << QThread::currentThreadId();
-       buffer = new HashPrivate::Buffer;
-       producer = new HashPrivate::HashProducer(buffer, this);
-       consumer = new HashPrivate::HashConsumer(buffer, this);
-       connect(consumer, SIGNAL(finishedHashing(QByteArray)), this, SLOT(endHashing(QByteArray)));
-       connect(consumer, SIGNAL(progress(qint64,qint64)), this, SLOT(reportProgress(qint64,qint64)));
-}
-
-void Hash::tearDown()
-{
-       if (!producer || !consumer || !buffer)
-               return;
-
-       delete producer;
-       delete consumer;
-       delete buffer;
-
-       producer = 0;
-       consumer = 0;
-       buffer = 0;
-}
-
-Hash *Hash::m_instance = 0;
-
-// -----------------------------------------------------------------------------------
-
-HashRequest::HashRequest(const QFileInfo &fileInfo)
-{
-qDebug() << "HashRequest::HashRequest(const QFileInfo &fileInfo)";
-       m_fileInfo = fileInfo;
-}
-
-HashRequest::HashRequest(const HashRequest &other)
-{
-qDebug() << "HashRequest::HashRequest(const HashRequest &other)";
-       m_fileInfo = other.m_fileInfo;
-qDebug() << m_fileInfo.absoluteFilePath();
-}
-
-HashRequest &HashRequest::operator=(const HashRequest &other)
-{
-qDebug() << "HashRequest &HashRequest::operator=(const HashRequest &other)";
-       m_fileInfo = other.m_fileInfo;
-       return *this;
-}
-
-QFileInfo HashRequest::fileInfo() const
-{
-       return m_fileInfo;
-}
-
-void HashRequest::setFileInfo(const QFileInfo &fileInfo)
-{
-       m_fileInfo = fileInfo;
-}
-
-// -----------------------------------------------------------------------------------
-
-HashResult::HashResult(const HashRequest &request) : QObject()
-{
-       this->request = request;
-}
-
-QFileInfo HashResult::fileInfo() const
-{
-       return request.fileInfo();
-}
-
-QByteArray HashResult::hash() const
-{
-       return m_hash;
-}
-
-void HashResult::setHash(const QByteArray &hash)
-{
-       m_hash = hash;
-       emit resultReady();
-}
-
-} // namesapce AniDBUdpClient
diff --git a/lib/anidbudpclient/hash.h b/lib/anidbudpclient/hash.h
deleted file mode 100644 (file)
index 232a2aa..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifndef HASH_H
-#define HASH_H
-
-#include "anidbudpclient_global.h"
-#include <QObject>
-#include <QQueue>
-#include <QMap>
-#include <QFileInfo>
-#include <QTime>
-
-#include "hashproducer.h"
-#include "hashconsumer.h"
-
-namespace AniDBUdpClient {
-
-class HashRequest;
-class HashResult;
-
-class ANIDBUDPCLIENTSHARED_EXPORT Hash : public QObject
-{
-       Q_OBJECT
-
-protected:
-       Hash(QObject *parent = 0);
-       ~Hash();
-
-public:
-       HashResult *hashFile(const HashRequest &file);
-
-       static Hash *instance();
-       static void destroy();
-
-signals:
-       void resultReady(HashResult *result);
-       void fileProgress(int percent);
-       void progress(int percent);
-       void finished();
-
-private slots:
-       void endHashing(const QByteArray &hash);
-
-       void reportProgress(qint64 read, qint64 total);
-
-private:
-       void startHashing();
-       void setUp();
-       void tearDown();
-
-       HashPrivate::Buffer *buffer;
-       HashPrivate::HashProducer *producer;
-       HashPrivate::HashConsumer *consumer;
-
-       QQueue<HashResult *> fileQueue;
-
-       bool hashing;
-
-       qint64 hashedFileSize;
-       qint64 totalFileSize;
-
-       QTime fileTime;
-       QTime totalTime;
-
-       static Hash *m_instance;
-};
-
-class ANIDBUDPCLIENTSHARED_EXPORT HashRequest
-{
-public:
-       HashRequest(const QFileInfo &fileInfo = QFileInfo());
-       HashRequest(const HashRequest &other);
-
-       HashRequest &operator=(const HashRequest &other);
-
-       QFileInfo fileInfo() const;
-       void setFileInfo(const QFileInfo &fileInfo);
-
-private:
-       QFileInfo m_fileInfo;
-};
-
-class ANIDBUDPCLIENTSHARED_EXPORT HashResult : public QObject
-{
-       friend class Hash;
-
-       Q_OBJECT
-       Q_PROPERTY(QFileInfo fileInfo READ fileInfo);
-       Q_PROPERTY(QByteArray hash READ hash);
-
-       HashResult(const HashRequest &request);
-
-public:
-       QFileInfo fileInfo() const;
-       QByteArray hash() const;
-
-signals:
-       void resultReady();
-
-private:
-       void setHash(const QByteArray &hash);
-
-       HashRequest request;
-       QByteArray m_hash;
-};
-
-} // namesapce AniDBUdpClient
-
-#endif // HASH_H
diff --git a/lib/anidbudpclient/hashconsumer.cpp b/lib/anidbudpclient/hashconsumer.cpp
deleted file mode 100644 (file)
index 9fcaaf9..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "hashconsumer.h"
-
-#include <QCryptographicHash>
-
-#include <QDebug>
-
-namespace AniDBUdpClient {
-namespace HashPrivate {
-
-HashConsumer::HashConsumer(Buffer *buffer, QObject *parent) : QThread(parent)
-{
-       this->buffer = buffer;
-
-       restart = false;
-       abort = false;
-}
-
-HashConsumer::~HashConsumer()
-{
-       mutex.lock();
-       abort = true;
-       condition.wakeOne();
-       mutex.unlock();
-
-       wait();
-}
-
-void HashConsumer::hashFile(const QString &file)
-{
-       QMutexLocker locker(&mutex);
-       fileSize = QFileInfo(file).size();
-
-       if (!isRunning())
-               start();
-       else
-               condition.wakeOne();
-}
-
-void HashConsumer::run()
-{
-qDebug() << "Starting thread consumer";
-qDebug() << "Thread consumer id is: " << QThread::currentThreadId();
-
-       forever
-       {
-               mutex.lock();
-               qint64 totalSize = fileSize;
-               qint64 read = 0;
-               mutex.unlock();
-
-               QCryptographicHash hash(QCryptographicHash::Md4);
-
-               while (!(buffer->end() || abort))
-               {
-                       QByteArray data;
-
-                       while (!(buffer->get(&data) || abort));
-
-                       hash.addData(QCryptographicHash::hash(data, QCryptographicHash::Md4));
-
-                       read += data.size();
-                       emit progress(read, totalSize);
-               }
-               buffer->reset();
-
-               if (abort)
-                       return;
-
-               mutex.lock();
-               if (!restart)
-               {
-                       emit finishedHashing(hash.result().toHex());
-                       condition.wait(&mutex);
-               }
-               restart = false;
-               mutex.unlock();
-
-               hash.reset();
-       }
-qDebug() << "Thread consumer is stopping";
-}
-
-} // namespace HashPrivate
-} // namesapce AniDBUdpClient
diff --git a/lib/anidbudpclient/hashconsumer.h b/lib/anidbudpclient/hashconsumer.h
deleted file mode 100644 (file)
index c70df4f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef HASHCONSUMER_H
-#define HASHCONSUMER_H
-
-#include "anidbudpclient_global.h"
-#include <QThread>
-#include <QFile>
-#include <QFileInfo>
-#include <QMutex>
-#include <QWaitCondition>
-
-#include "circularbuffer.h"
-
-namespace AniDBUdpClient {
-namespace HashPrivate {
-
-class HashConsumer : public QThread
-{
-       Q_OBJECT
-public:
-       HashConsumer(Buffer *buffer, QObject *parent = 0);
-       ~HashConsumer();
-
-public slots:
-       void hashFile(const QString &file);
-
-protected:
-       void run();
-
-signals:
-       void progress(qint64 done, qint64 total);
-       void finishedHashing(QByteArray hash);
-
-private:
-       Buffer *buffer;
-       qint64 fileSize;
-
-       bool m_stop;
-       bool restart;
-       bool abort;
-
-       QMutex mutex;
-       QWaitCondition condition;
-};
-
-} // namespace HashPrivate
-} // namesapce AniDBUdpClient
-
-#endif // HASHCONSUMER_H
diff --git a/lib/anidbudpclient/hashproducer.cpp b/lib/anidbudpclient/hashproducer.cpp
deleted file mode 100644 (file)
index 3d78a0b..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "hashproducer.h"
-
-#include <QTimer>
-
-#include <QDebug>
-
-namespace AniDBUdpClient {
-namespace HashPrivate {
-
-HashProducer::HashProducer(Buffer *buffer, QObject *parent) : QThread(parent)
-{
-       this->buffer = buffer;
-       restart = false;
-       abort = false;
-}
-
-HashProducer::~HashProducer()
-{
-       mutex.lock();
-       abort = true;
-       condition.wakeOne();
-       mutex.unlock();
-
-       wait();
-}
-
-void HashProducer::readFile(const QString &file)
-{
-qDebug() << "readFile";
-qDebug() << "Thread id is: " << QThread::currentThreadId();
-
-       QMutexLocker locker(&mutex);
-
-       fileName = file;
-
-       if (!isRunning())
-               start();
-       else
-               condition.wakeOne();
-
-}
-
-void HashProducer::run()
-{
-qDebug() << "Starting thread producer";
-qDebug() << "Thread producer id is: " << QThread::currentThreadId();
-
-       forever
-       {
-               mutex.lock();
-qDebug() << "Obtaining new file name";
-               QFile file(fileName);
-               mutex.unlock();
-
-               if (file.exists())
-               {
-                       qDebug() << "File exists, opening";
-                       if (file.open(QIODevice::ReadOnly))
-                       {
-                               while (!file.atEnd())
-                               {
-                                       if (abort)
-                                               return;
-//                                     qDebug() << "read->while(" << (!file.atEnd()) << ")";
-                                       QByteArray data = file.read(ED2K_PART_SIZE);
-                                       while (!(buffer->put(data, file.atEnd()) || abort));
-                               }
-                       }
-               }
-
-               file.close();
-               if (abort)
-                       return;
-
-               mutex.lock();
-               if (!restart)
-                       condition.wait(&mutex);
-               restart = false;
-               mutex.unlock();
-       }
-qDebug() << "Thread producer is stopping";
-}
-
-} // namespace HashPrivate
-} // namesapce AniDBUdpClient
diff --git a/lib/anidbudpclient/hashproducer.h b/lib/anidbudpclient/hashproducer.h
deleted file mode 100644 (file)
index 3b0ddab..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef HASHPRODUCER_H
-#define HASHPRODUCER_H
-
-#include "anidbudpclient_global.h"
-#include <QThread>
-#include <QFile>
-#include <QFileInfo>
-#include <QMutex>
-#include <QWaitCondition>
-
-#include "circularbuffer.h"
-
-namespace AniDBUdpClient {
-namespace HashPrivate {
-
-class HashProducer : public QThread
-{
-       Q_OBJECT
-
-public:
-       HashProducer(Buffer *buffer, QObject *parent = 0);
-       ~HashProducer();
-
-public slots:
-       void readFile(const QString &file);
-
-protected:
-       void run();
-
-private:
-       Buffer *buffer;
-
-       QString fileName;
-       QFile file;
-       qint64 fileSize;
-
-       bool m_stop;
-       bool restart;
-       bool abort;
-
-       QMutex mutex;
-       QWaitCondition condition;
-};
-
-} // namespace HashPrivate
-} // namesapce AniDBUdpClient
-
-#endif // HASHPRODUCER_H
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/AbstractCommand b/lib/anidbudpclient/include/AniDBUdpClient/AbstractCommand
deleted file mode 100644 (file)
index 1e4030b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../abstractcommand.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/Client b/lib/anidbudpclient/include/AniDBUdpClient/Client
deleted file mode 100644 (file)
index 73445b3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../client.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/File b/lib/anidbudpclient/include/AniDBUdpClient/File
deleted file mode 100644 (file)
index 6431d6c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../file.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/FileCommand b/lib/anidbudpclient/include/AniDBUdpClient/FileCommand
deleted file mode 100644 (file)
index cf757bf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../filecommand.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/Hash b/lib/anidbudpclient/include/AniDBUdpClient/Hash
deleted file mode 100644 (file)
index 4ae187b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../hash.h"
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/MyListAddCommand b/lib/anidbudpclient/include/AniDBUdpClient/MyListAddCommand
deleted file mode 100644 (file)
index 51dd0f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../mylistaddcommand.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/MyListCommand b/lib/anidbudpclient/include/AniDBUdpClient/MyListCommand
deleted file mode 100644 (file)
index 5bf1b59..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../mylistcommand.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/RawCommand b/lib/anidbudpclient/include/AniDBUdpClient/RawCommand
deleted file mode 100644 (file)
index 03bcb16..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rawcommand.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/UptimeCommand b/lib/anidbudpclient/include/AniDBUdpClient/UptimeCommand
deleted file mode 100644 (file)
index 24e18a1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../uptimecommand.h"
\ No newline at end of file
diff --git a/lib/anidbudpclient/logoutcommand.cpp b/lib/anidbudpclient/logoutcommand.cpp
deleted file mode 100644 (file)
index 63372f7..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "logoutcommand.h"
-
-namespace AniDBUdpClient {
-
-LogoutCommand::LogoutCommand() : AbstractCommand()
-{
-}
-
-Command LogoutCommand::rawCommand() const
-{
-       Command command;
-       command.first = "LOGOUT";
-
-       return command;
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/logoutcommand.h b/lib/anidbudpclient/logoutcommand.h
deleted file mode 100644 (file)
index f3afab5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef LOGOUTCOMMAND_H
-#define LOGOUTCOMMAND_H
-
-#include "abstractcommand.h"
-
-namespace AniDBUdpClient {
-
-class LogoutReply;
-
-class ANIDBUDPCLIENTSHARED_EXPORT LogoutCommand : public AbstractCommand
-{
-public:
-       typedef LogoutReply ReplyType;
-
-       LogoutCommand();
-       Command rawCommand() const;
-};
-
-class ANIDBUDPCLIENTSHARED_EXPORT LogoutReply : public AbstractReply
-{
-       Q_OBJECT
-       REPLY_DEFINITION_HELPER(Logout)
-public:
-};
-
-} // namespace AniDBUdpClient
-
-#endif // LOGOUTCOMMAND_H
diff --git a/lib/anidbudpclient/mylistaddcommand.cpp b/lib/anidbudpclient/mylistaddcommand.cpp
deleted file mode 100644 (file)
index a22f0a6..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-#include "mylistaddcommand.h"
-
-#include <QFileInfo>
-#include <QCryptographicHash>
-#include <QtConcurrentRun>
-#include <QStringList>
-#include <QThread>
-
-#include "client.h"
-
-namespace AniDBUdpClient {
-
-
-MyListAddCommand::MyListAddCommand(int fid, bool edit) : AbstractCommand()
-{
-       init();
-       m_fid = fid;
-       m_edit = edit;
-}
-
-MyListAddCommand::MyListAddCommand(const QByteArray &ed2k, qint64 size, bool edit) : AbstractCommand()
-{
-       init();
-       m_ed2k = ed2k;
-       m_size = size;
-       m_edit = edit;
-}
-
-MyListAddCommand::MyListAddCommand(int lid) : AbstractCommand()
-{
-       init();
-       m_lid = lid;
-       m_edit = true;
-}
-
-int MyListAddCommand::fid() const
-{
-       return m_fid;
-}
-
-void MyListAddCommand::setFid(int fid)
-{
-       m_fid = fid;
-}
-
-int MyListAddCommand::lid() const
-{
-       return m_lid;
-}
-
-void MyListAddCommand::setLid(int lid)
-{
-       m_lid = lid;
-}
-
-QByteArray MyListAddCommand::ed2k() const
-{
-       return m_ed2k;
-}
-
-void MyListAddCommand::setEd2k(const QByteArray &ed2k)
-{
-       m_ed2k = ed2k;
-}
-
-qint64 MyListAddCommand::size() const
-{
-       return m_size;
-}
-
-void MyListAddCommand::setSize(qint64 size)
-{
-       m_size = size;
-}
-
-bool MyListAddCommand::edit() const
-{
-       return m_edit;
-}
-
-void MyListAddCommand::setEdit(bool edit)
-{
-       m_edit = edit;
-}
-
-State MyListAddCommand::state() const
-{
-       return m_state;
-}
-
-void MyListAddCommand::setState(State state)
-{
-       m_state = state;
-}
-
-MyListAddCommand::ViewedState MyListAddCommand::viewed() const
-{
-       return m_viewed;
-}
-
-void MyListAddCommand::setViewed(MyListAddCommand::ViewedState viewed)
-{
-       m_viewed = viewed;
-}
-
-void MyListAddCommand::setViewed(bool viewed)
-{
-       m_viewed = viewed ? Viewed : NotViewed;
-}
-
-QDateTime MyListAddCommand::viewDate() const
-{
-       return m_viewDate;
-}
-
-void MyListAddCommand::setViewDate(QDateTime viewDate)
-{
-       m_viewDate = viewDate;
-}
-
-QString MyListAddCommand::source() const
-{
-       return m_source;
-}
-
-void MyListAddCommand::setSource(QString source)
-{
-       m_source = source;
-}
-
-QString MyListAddCommand::storage() const
-{
-       return m_storage;
-}
-
-void MyListAddCommand::setStorage(QString storage)
-{
-       m_storage = storage;
-}
-
-QString MyListAddCommand::other() const
-{
-       return m_other;
-}
-
-void MyListAddCommand::setOther(QString other)
-{
-       m_other = other;
-}
-
-bool MyListAddCommand::waitForResult() const
-{
-       return true;
-}
-
-Command MyListAddCommand::rawCommand() const
-{
-       Command cmd;
-
-       cmd.first = "MYLISTADD";
-
-       if (m_fid)
-       {
-               cmd.second["fid"] = m_fid;
-       }
-       else if (!m_ed2k.isEmpty() && m_size)
-       {
-               cmd.second["ed2k"] = m_ed2k;
-               cmd.second["size"] = m_size;
-       }
-       else if (m_lid)
-       {
-               cmd.second["lid"] = m_lid;
-       }
-
-       if (m_edit)
-       {
-               cmd.second["edit"] = true;
-       }
-
-       if (m_state)
-       {
-               cmd.second["state"] = m_state;
-       }
-
-       switch (m_viewed)
-       {
-               case Viewed:
-                       cmd.second["viewed"] = true;
-               break;
-               case NotViewed:
-                       cmd.second["viewed"] = false;
-               break;
-               default:
-               break;
-       }
-
-       if (!m_viewDate.isNull())
-       {
-               cmd.second["viewdate"] = m_viewDate.toTime_t();
-       }
-
-       if (!m_source.isEmpty())
-       {
-               cmd.second["source"] = m_source;
-       }
-
-       if (!m_storage.isEmpty())
-       {
-               cmd.second["storage"] = m_storage;
-       }
-
-       if (!m_other.isEmpty())
-       {
-               cmd.second["other"] = m_other;
-       }
-
-       return cmd;
-}
-
-void MyListAddCommand::init()
-{
-       m_fid = 0;
-       m_lid = 0;
-
-       m_state = StateUnknown;
-       m_viewed = Unset;
-}
-
-// ===
-
-int MyListAddReply::lid() const
-{
-       return m_lid;
-}
-
-void MyListAddReply::setRawReply(ReplyCode replyCode, const QString &reply)
-{
-       AbstractReply::setRawReply(replyCode, reply);
-
-       switch (replyCode)
-       {
-               case MYLIST_ENTRY_ADDED:
-               {
-                       QString lid = reply.mid(reply.indexOf('\n')).trimmed();
-                       if (!command().edit())
-                       {
-                               m_lid = lid.toInt();
-                       }
-                       emit replyReady(true);
-               }
-               break;
-               case MYLIST_ENTRY_EDITED:
-               case FILE_ALREADY_IN_MYLIST:
-                       emit replyReady(true);
-               break;
-               case NO_SUCH_MYLIST_ENTRY:
-               case NO_SUCH_FILE:
-               case NO_SUCH_ANIME:
-               case NO_SUCH_GROUP:
-               default:
-                       emit replyReady(false);
-               break;
-       }
-}
-
-void MyListAddReply::init()
-{
-       m_lid = 0;
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/mylistaddcommand.h b/lib/anidbudpclient/mylistaddcommand.h
deleted file mode 100644 (file)
index 0187487..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef MYLISTADDCOMMAND_H
-#define MYLISTADDCOMMAND_H
-
-#include "abstractcommand.h"
-
-#include <QFuture>
-#include <QFutureWatcher>
-#include <QTime>
-
-namespace AniDBUdpClient {
-
-class MyListAddReply;
-
-class ANIDBUDPCLIENTSHARED_EXPORT MyListAddCommand : public AbstractCommand
-{
-/*
-       Q_ENUMS(ViewedState);
-
-       Q_PROPERTY(int fid READ fid WRITE setFid);
-       Q_PROPERTY(int lid READ lid WRITE setLid);
-
-       Q_PROPERTY(QByteArray ed2k READ ed2k WRITE setEd2k);
-       Q_PROPERTY(qint64 size READ size WRITE setSize);
-
-       Q_PROPERTY(bool edit READ edit WRITE setEdit);
-
-       Q_PROPERTY(State state READ state WRITE setState);
-       Q_PROPERTY(ViewedState viewed READ viewed WRITE setViewed);
-       Q_PROPERTY(QDateTime viewDate READ viewDate WRITE setViewDate);
-       Q_PROPERTY(QString source READ source WRITE setSource);
-       Q_PROPERTY(QString storage READ storage WRITE setStorage);
-       Q_PROPERTY(QString other READ other WRITE setOther);
-*/
-public:
-       typedef MyListAddReply ReplyType;
-       enum ViewedState {
-               Unset = -1,
-               NotViewed = 0,
-               Viewed = 1,
-       };
-
-       MyListAddCommand(int fid, bool edit);
-       MyListAddCommand(const QByteArray &ed2k, qint64 size, bool edit);
-       explicit MyListAddCommand(int lid);
-
-       int fid() const;
-       void setFid(int fid);
-
-       int lid() const;
-       void setLid(int lid);
-
-       QByteArray ed2k() const;
-       void setEd2k(const QByteArray &ed2k);
-
-       qint64 size() const;
-       void setSize(qint64 size);
-
-       bool edit() const;
-       void setEdit(bool edit);
-
-       State state() const;
-       void setState(State state);
-
-       ViewedState viewed() const;
-       void setViewed(ViewedState viewed);
-       void setViewed(bool viewed);
-
-       QDateTime viewDate() const;
-       void setViewDate(QDateTime viewDate);
-
-       QString source() const;
-       void setSource(QString source);
-
-       QString storage() const;
-       void setStorage(QString storage);
-
-       QString other() const;
-       void setOther(QString other);
-
-       bool waitForResult() const;
-
-       Command rawCommand() const;
-
-private:
-       void init();
-
-       int m_fid;
-       int m_lid;
-
-       QByteArray m_ed2k;
-       qint64 m_size;
-
-       bool m_edit;
-
-       State m_state;
-       ViewedState m_viewed;
-       QDateTime m_viewDate;
-       QString m_source;
-       QString m_storage;
-       QString m_other;
-};
-
-class ANIDBUDPCLIENTSHARED_EXPORT MyListAddReply : public AbstractReply
-{
-       Q_OBJECT
-       REPLY_DEFINITION_HELPER2(MyListAdd)
-
-       Q_PROPERTY(int lid READ lid);
-
-public:
-       int lid() const;
-
-       void setRawReply(ReplyCode replyCode, const QString &reply);
-
-private:
-       void init();
-
-       int m_lid;
-};
-
-} // namespace AniDBUdpClient
-
-#endif // MYLISTADDCOMMAND_H
diff --git a/lib/anidbudpclient/mylistcommand.cpp b/lib/anidbudpclient/mylistcommand.cpp
deleted file mode 100644 (file)
index a37bef1..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-#include "mylistcommand.h"\r
-\r
-#include <QStringList>\r
-\r
-namespace AniDBUdpClient {\r
-\r
-MyListCommand::MyListCommand() : AbstractCommand()\r
-{\r
-       init();\r
-}\r
-\r
-MyListCommand::MyListCommand(int lid) : AbstractCommand()\r
-{\r
-       init();\r
-       m_lid = lid;\r
-}\r
-\r
-MyListCommand::MyListCommand(int fid, bool isFid) : AbstractCommand()\r
-{\r
-       Q_UNUSED(isFid);\r
-       init();\r
-       m_fid = fid;\r
-}\r
-\r
-MyListCommand::MyListCommand(const QByteArray &ed2k, qint64 size) : AbstractCommand()\r
-{\r
-       init();\r
-       m_ed2k = ed2k;\r
-       m_size = size;\r
-}\r
-\r
-MyListCommand::MyListCommand(const QString &aname, const QString &gname, int epno) : AbstractCommand()\r
-{\r
-       init();\r
-       m_aname = aname;\r
-       m_gname = gname;\r
-       m_epno = epno;\r
-}\r
-\r
-MyListCommand::MyListCommand(const QString &aname, int gid, int epno) : AbstractCommand()\r
-{\r
-       init();\r
-       m_aname = aname;\r
-       m_gid = gid;\r
-       m_epno = epno;\r
-}\r
-\r
-MyListCommand::MyListCommand(int aid, const QString &gname, int epno) : AbstractCommand()\r
-{\r
-       init();\r
-       m_aid = aid;\r
-       m_gname = gname;\r
-       m_epno = epno;\r
-}\r
-\r
-MyListCommand::MyListCommand(int aid, int gid, int epno) : AbstractCommand()\r
-{\r
-       init();\r
-       m_aid = aid;\r
-       m_gid = gid;\r
-       m_epno = epno;\r
-}\r
-\r
-int MyListCommand::lid() const\r
-{\r
-       return m_lid;\r
-}\r
-\r
-void MyListCommand::setLid(int lid)\r
-{\r
-       m_lid = lid;\r
-}\r
-\r
-int MyListCommand::fid() const\r
-{\r
-       return m_fid;\r
-}\r
-\r
-void MyListCommand::setFid(int fid)\r
-{\r
-       m_fid = fid;\r
-}\r
-\r
-QByteArray MyListCommand::ed2k() const\r
-{\r
-       return m_ed2k;\r
-}\r
-\r
-void MyListCommand::setEd2k(const QByteArray &ed2k)\r
-{\r
-       m_ed2k = ed2k;\r
-}\r
-\r
-qint64 MyListCommand::size() const\r
-{\r
-       return m_size;\r
-}\r
-\r
-void MyListCommand::setSize(qint64 size)\r
-{\r
-       m_size = size;\r
-}\r
-\r
-QString MyListCommand::aname() const\r
-{\r
-       return m_aname;\r
-}\r
-\r
-void MyListCommand::setAname(const QString &aname)\r
-{\r
-       m_aname = aname;\r
-}\r
-\r
-int MyListCommand::aid() const\r
-{\r
-       return m_aid;\r
-}\r
-\r
-void MyListCommand::setAid(int aid)\r
-{\r
-       m_aid = aid;\r
-}\r
-\r
-QString MyListCommand::gname() const\r
-{\r
-       return m_gname;\r
-}\r
-\r
-void MyListCommand::setGname(const QString &gname)\r
-{\r
-       m_gname = gname;\r
-}\r
-\r
-int MyListCommand::gid() const\r
-{\r
-       return m_gid;\r
-}\r
-\r
-void MyListCommand::setGid(int gid)\r
-{\r
-       m_gid = gid;\r
-}\r
-\r
-\r
-int MyListCommand::epno() const\r
-{\r
-       return m_epno;\r
-}\r
-\r
-void MyListCommand::setEpno(int epno)\r
-{\r
-       m_epno = epno;\r
-}\r
-\r
-bool MyListCommand::isValid() const\r
-{\r
-       return m_lid || m_fid || m_aid\r
-                       || !m_aname.isEmpty()\r
-                       || (!m_ed2k.isEmpty() && m_size);\r
-}\r
-\r
-bool MyListCommand::waitForResult() const\r
-{\r
-       return true;\r
-}\r
-\r
-Command MyListCommand::rawCommand() const\r
-{\r
-       Command cmd;\r
-\r
-       cmd.first = "MYLIST";\r
-\r
-       if (m_lid)\r
-       {\r
-               cmd.second["lid"] = m_lid;\r
-       }\r
-       else if (m_fid)\r
-       {\r
-               cmd.second["fid"] = m_fid;\r
-       }\r
-       else if (!m_ed2k.isEmpty() && m_size)\r
-       {\r
-               cmd.second["ed2k"] = m_ed2k;\r
-               cmd.second["size"] = m_size;\r
-       }\r
-       else if (!m_aname.isEmpty())\r
-       {\r
-               cmd.second["aname"] = m_aname;\r
-               if (!m_gname.isEmpty() && m_epno)\r
-               {\r
-                       cmd.second["gname"] = m_gname;\r
-                       cmd.second["epno"] = m_epno;\r
-               }\r
-               else if (m_gid && m_epno)\r
-               {\r
-                       cmd.second["gid"] = m_gid;\r
-                       cmd.second["epno"] = m_epno;\r
-               }\r
-       }\r
-       else if (m_aid)\r
-       {\r
-               cmd.second["aid"] = m_aid;\r
-               if (!m_gname.isEmpty() && m_epno)\r
-               {\r
-                       cmd.second["gname"] = m_gname;\r
-                       cmd.second["epno"] = m_epno;\r
-               }\r
-               else if (m_gid && m_epno)\r
-               {\r
-                       cmd.second["gid"] = m_gid;\r
-                       cmd.second["epno"] = m_epno;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               // TODO WTF NOW?!?\r
-       }\r
-       return cmd;\r
-}\r
-\r
-void MyListCommand::init()\r
-{\r
-       m_lid = 0;\r
-       m_fid = 0;\r
-       m_aid = 0;\r
-       m_gid = 0;\r
-\r
-       m_size = 0;\r
-       m_epno = 0;\r
-}\r
-\r
-\r
-// ===\r
-\r
-int MyListReply::lid() const\r
-{\r
-       return m_lid;\r
-}\r
-\r
-int MyListReply::fid() const\r
-{\r
-       return m_fid;\r
-}\r
-\r
-int MyListReply::aid() const\r
-{\r
-       return m_aid;\r
-}\r
-\r
-\r
-int MyListReply::gid() const\r
-{\r
-       return m_gid;\r
-}\r
-\r
-\r
-int MyListReply::eid() const\r
-{\r
-       return m_eid;\r
-}\r
-\r
-QDateTime MyListReply::date() const\r
-{\r
-       return m_date;\r
-}\r
-\r
-State MyListReply::state() const\r
-{\r
-       return m_state;\r
-}\r
-\r
-QDateTime MyListReply::viewDate() const\r
-{\r
-       return m_viewDate;\r
-}\r
-\r
-QString MyListReply::storage() const\r
-{\r
-       return m_storage;\r
-}\r
-\r
-QString MyListReply::source() const\r
-{\r
-       return m_source;\r
-}\r
-\r
-QString MyListReply::other() const\r
-{\r
-       return m_other;\r
-}\r
-\r
-FileState MyListReply::fileState() const\r
-{\r
-       return m_fileState;\r
-}\r
-\r
-QStringList MyListReply::multipleEntries() const\r
-{\r
-       return m_multipleEntries;\r
-}\r
-\r
-void MyListReply::setRawReply(ReplyCode replyCode, const QString &reply)\r
-{\r
-       AbstractReply::setRawReply(replyCode, reply);\r
-\r
-       switch (replyCode)\r
-       {\r
-               case MYLIST:\r
-               {\r
-                       QStringList parts = reply.mid(reply.indexOf("\n")).split('|', QString::KeepEmptyParts);\r
-                       bool ok;\r
-                       m_lid = parts[0].toInt(&ok, 10);\r
-                       m_fid = parts[1].toInt(&ok, 10);\r
-                       m_eid = parts[2].toInt(&ok, 10);\r
-                       m_aid = parts[3].toInt(&ok, 10);\r
-                       m_gid = parts[4].toInt(&ok, 10);\r
-                       m_date = QDateTime::fromTime_t(parts[5].toUInt(&ok, 10));\r
-                       m_state = State(parts[6].toInt(&ok, 10));\r
-                       m_viewDate = QDateTime::fromTime_t(parts[7].toUInt(&ok, 10));\r
-                       m_storage = parts[8];\r
-                       m_source = parts[9];\r
-                       m_other = parts[10];\r
-                       m_fileState = FileState(parts[11].toInt(&ok, 10));\r
-                       emit replyReady(true);\r
-               }\r
-               break;\r
-               case MULTIPLE_MYLIST_ENTRIES:\r
-               {\r
-                       m_multipleEntries = reply.mid(reply.indexOf("\n")).split('|', QString::KeepEmptyParts);\r
-                       emit replyReady(true);\r
-               }\r
-               break;\r
-               case NO_SUCH_ENTRY:\r
-               default:\r
-                       emit replyReady(false);\r
-               break;\r
-       }\r
-}\r
-\r
-void MyListReply::init()\r
-{\r
-       m_lid = 0;\r
-       m_fid = 0;\r
-       m_aid = 0;\r
-       m_gid = 0;\r
-       m_eid = 0;\r
-\r
-       m_state = State(0);\r
-       m_fileState = FileState(0);\r
-}\r
-\r
-} // namespace AniDBUdpClient\r
diff --git a/lib/anidbudpclient/mylistcommand.h b/lib/anidbudpclient/mylistcommand.h
deleted file mode 100644 (file)
index 336b1bf..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-#ifndef MYLISTCOMMAND_H\r
-#define MYLISTCOMMAND_H\r
-\r
-#include "anidbudpclient_global.h"\r
-#include "abstractcommand.h"\r
-\r
-#include <QDateTime>\r
-#include <QStringList>\r
-\r
-namespace AniDBUdpClient {\r
-\r
-class MyListReply;\r
-\r
-class ANIDBUDPCLIENTSHARED_EXPORT MyListCommand : public AbstractCommand\r
-{\r
-public:\r
-       typedef MyListReply ReplyType;\r
-       MyListCommand();\r
-       MyListCommand(int lid);\r
-       MyListCommand(int fid, bool isFid);\r
-       MyListCommand(const QByteArray &ed2k, qint64 size);\r
-       MyListCommand(const QString &aname, const QString &gname, int epno);\r
-       MyListCommand(const QString &aname, int gid, int epno);\r
-       MyListCommand(int aid, const QString &gname, int epno);\r
-       MyListCommand(int aid, int gid, int epno);\r
-\r
-       int lid() const;\r
-       void setLid(int lid);\r
-       int fid() const;\r
-       void setFid(int fid);\r
-\r
-       QByteArray ed2k() const;\r
-       void setEd2k(const QByteArray &ed2k);\r
-       qint64 size() const;\r
-       void setSize(qint64 size);\r
-\r
-       QString aname() const;\r
-       void setAname(const QString &aname);\r
-       int aid() const;\r
-       void setAid(int aid);\r
-       QString gname() const;\r
-       void setGname(const QString &gname);\r
-       int gid() const;\r
-       void setGid(int gid);\r
-       int epno() const;\r
-       void setEpno(int epno);\r
-\r
-       bool isValid() const;\r
-\r
-       bool waitForResult() const;\r
-       Command rawCommand() const;\r
-       void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);\r
-\r
-private:\r
-       void init();\r
-\r
-       int m_lid;\r
-       int m_fid;\r
-\r
-       QByteArray m_ed2k;\r
-       qint64 m_size;\r
-\r
-       QString m_aname;\r
-       int m_aid;\r
-       QString m_gname;\r
-       int m_gid;\r
-       int m_epno;\r
-\r
-};\r
-\r
-class ANIDBUDPCLIENTSHARED_EXPORT MyListReply : public AbstractReply\r
-{\r
-       Q_OBJECT\r
-       REPLY_DEFINITION_HELPER2(MyList)\r
-\r
-       Q_PROPERTY(int lid READ lid);\r
-       Q_PROPERTY(int fid READ fid);\r
-\r
-       Q_PROPERTY(int aid READ aid);\r
-       Q_PROPERTY(int gid READ gid);\r
-\r
-       Q_PROPERTY(int eid READ eid);\r
-       Q_PROPERTY(QDateTime date READ date);\r
-       Q_PROPERTY(State state READ state);\r
-       Q_PROPERTY(QDateTime viewDate READ viewDate);\r
-       Q_PROPERTY(QString storage READ storage);\r
-       Q_PROPERTY(QString source READ source);\r
-       Q_PROPERTY(QString other READ other);\r
-       Q_PROPERTY(FileState fileState READ fileState);\r
-\r
-       Q_PROPERTY(QStringList multipleEntries READ multipleEntries);\r
-\r
-public:\r
-\r
-       int lid() const;\r
-       int fid() const;\r
-\r
-       int aid() const;\r
-       int gid() const;\r
-\r
-\r
-       int eid() const;\r
-       QDateTime date() const;\r
-       State state() const;\r
-       QDateTime viewDate() const;\r
-       QString storage() const;\r
-       QString source() const;\r
-       QString other() const;\r
-       FileState fileState() const;\r
-\r
-       QStringList multipleEntries() const;\r
-\r
-       void setRawReply(ReplyCode replyCode, const QString &reply);\r
-\r
-private:\r
-       void init();\r
-\r
-       int m_lid;\r
-       int m_fid;\r
-\r
-       int m_aid;\r
-       int m_gid;\r
-       int m_epno;\r
-\r
-       int m_eid;\r
-       QDateTime m_date;\r
-       State m_state;\r
-       QDateTime m_viewDate;\r
-       QString m_storage;\r
-       QString m_source;\r
-       QString m_other;\r
-       FileState m_fileState;\r
-\r
-       QStringList m_multipleEntries;\r
-\r
-};\r
-\r
-} // namespace AniDBUdpClient\r
-\r
-#endif // MYLISTCOMMAND_H\r
diff --git a/lib/anidbudpclient/rawcommand.cpp b/lib/anidbudpclient/rawcommand.cpp
deleted file mode 100644 (file)
index 50f7660..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "rawcommand.h"
-
-namespace AniDBUdpClient {
-
-RawCommand::RawCommand(const QString &command) : AbstractCommand()
-{
-       m_command = command;
-}
-
-Command RawCommand::rawCommand() const
-{
-       return Command(m_command, QVariantMap());
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/rawcommand.h b/lib/anidbudpclient/rawcommand.h
deleted file mode 100644 (file)
index 0795cc5..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef RAWCOMMAND_H
-#define RAWCOMMAND_H
-
-#include "abstractcommand.h"
-
-namespace AniDBUdpClient {
-
-class RawReply;
-
-class ANIDBUDPCLIENTSHARED_EXPORT RawCommand : public AbstractCommand
-{
-public:
-       typedef RawReply ReplyType;
-       RawCommand(const QString &command);
-
-       Command rawCommand() const;
-
-private:
-       QString m_command;
-};
-
-class ANIDBUDPCLIENTSHARED_EXPORT RawReply : public AbstractReply
-{
-       Q_OBJECT
-       REPLY_DEFINITION_HELPER(Raw)
-public:
-};
-
-} // namespace AniDBUdpClient
-
-#endif // RAWCOMMAND_H
diff --git a/lib/anidbudpclient/uptimecommand.cpp b/lib/anidbudpclient/uptimecommand.cpp
deleted file mode 100644 (file)
index f45ebaa..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "uptimecommand.h"
-
-namespace AniDBUdpClient {
-
-UptimeCommand::UptimeCommand() : AbstractCommand()
-{
-}
-
-bool UptimeCommand::waitForResult() const
-{
-       return true;
-}
-
-Command UptimeCommand::rawCommand() const
-{
-       Command command;
-       command.first = "UPTIME";
-       return command;
-}
-
-// ==
-
-int UptimeReply::uptime()
-{
-       return m_uptime;
-}
-
-void UptimeReply::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
-{
-       Q_UNUSED(client);
-
-       switch (replyCode)
-       {
-               case UPTIME:
-               {
-                       QString uptimeText = reply.mid(reply.indexOf('\n'));
-                       bool ok = false;
-                       m_uptime = uptimeText.toInt(&ok, 10);
-                       if (!ok)
-                               m_uptime = 0;
-
-                       emit replyReady(ok);
-               }
-               break;
-               default:
-                       emit replyReady(false);
-               break;
-       }
-}
-
-void UptimeReply::init()
-{
-       m_uptime = 0;
-}
-
-} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/uptimecommand.h b/lib/anidbudpclient/uptimecommand.h
deleted file mode 100644 (file)
index 4a01766..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef UPTIMECOMMAND_H
-#define UPTIMECOMMAND_H
-
-#include "abstractcommand.h"
-
-namespace AniDBUdpClient {
-
-class UptimeReply;
-
-class ANIDBUDPCLIENTSHARED_EXPORT UptimeCommand : public AbstractCommand
-{
-public:
-       typedef UptimeReply ReplyType;
-       UptimeCommand();
-
-       bool waitForResult() const;
-       Command rawCommand() const;
-};
-
-class ANIDBUDPCLIENTSHARED_EXPORT UptimeReply : public AbstractReply
-{
-       Q_OBJECT
-       REPLY_DEFINITION_HELPER2(Uptime)
-
-       Q_PROPERTY(int uptime READ uptime);
-public:
-
-       int uptime();
-
-       void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
-
-private:
-       void init();
-       int m_uptime;
-};
-
-
-} // namespace AniDBUdpClient
-
-#endif // UPTIMECOMMAND_H