]> Some of my projects - aniplayer-old.git/commitdiff
- Add FILE command
authorAPTX <APTX@.(none)>
Wed, 19 Aug 2009 11:04:40 +0000 (13:04 +0200)
committerAPTX <APTX@.(none)>
Wed, 19 Aug 2009 11:04:40 +0000 (13:04 +0200)
lib/anidbudpclient/anidbudpclient.pri
lib/anidbudpclient/anidbudpclient.pro
lib/anidbudpclient/anidbudpclient_global.h
lib/anidbudpclient/filecommand.cpp [new file with mode: 0644]
lib/anidbudpclient/filecommand.h [new file with mode: 0644]
lib/anidbudpclient/include/AniDBUdpClient/FileCommand [new file with mode: 0644]
lib/anidbudpclient/mylistcommand.cpp
lib/anidbudpclient/mylistcommand.h

index 3dcdb4bad9da57931a7a0b61155be5809ef8125b..40880faa9e1103057c4ac06485c91bae83251cc8 100644 (file)
@@ -1,4 +1,27 @@
-QT *= network script
+# 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
index 1aabbb393c0ac8b0a3f77c353d3b7c9a2ff74435..d4d0c5e47b861f7e3e19dde8e083eca709596100 100644 (file)
@@ -1,7 +1,8 @@
 # -------------------------------------------------
 # Project created by QtCreator 2009-03-22T14:53:52
 # -------------------------------------------------
-QT += network script
+QT += network \
+    script
 QT -= gui
 TEMPLATE = lib
 TARGET = anidbudpclient
@@ -15,16 +16,16 @@ static {
 }
 INCLUDEPATH += $$PWD
 DEPENDPATH += $$PWD
-
 DEFINES += ANIDBUDPCLIENT_LIBRARY
 SOURCES += client.cpp \
     abstractcommand.cpp \
     authcommand.cpp \
     rawcommand.cpp \
-       mylistaddcommand.cpp \
+    mylistaddcommand.cpp \
     logoutcommand.cpp \
     uptimecommand.cpp \
-    mylistcommand.cpp
+    mylistcommand.cpp \
+       filecommand.cpp
 HEADERS += client.h \
     anidbudpclient_global.h \
     abstractcommand.h \
@@ -33,13 +34,13 @@ HEADERS += client.h \
     mylistaddcommand.h \
     logoutcommand.h \
     uptimecommand.h \
-    mylistcommand.h
-
+    mylistcommand.h \
+       filecommand.h
 CONV_HEADERS += include/AniDBUdpClient/Client \
-       include/AniDBUdpClient/AbstractCommand \
-       include/AniDBUdpClient/RawCommand \
-       include/AniDBUdpClient/MyListCommand \
-       include/AniDBUdpClient/MyListAddCommand \
-       include/AniDBUdpClient/UptimeCommand
-
+    include/AniDBUdpClient/AbstractCommand \
+    include/AniDBUdpClient/RawCommand \
+    include/AniDBUdpClient/MyListCommand \
+    include/AniDBUdpClient/MyListAddCommand \
+    include/AniDBUdpClient/UptimeCommand \
+    include/AniDBUdpClient/FileCommand
 include(../../lib/qtstatemachine/src/qtstatemachine.pri)
index 2f5a1a48953a5aa3cee0d5c0e23d8869bb7b7773..933f87bd69c207fc9a2770dea7388a3e6e5b56ab 100644 (file)
@@ -193,6 +193,196 @@ namespace AniDBUdpClient
        };
 
        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,
+
+                       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);
+       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);
+       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;
 }
 
 #endif // ANIDBUDPCLIENT_GLOBAL_H
diff --git a/lib/anidbudpclient/filecommand.cpp b/lib/anidbudpclient/filecommand.cpp
new file mode 100644 (file)
index 0000000..b396a2e
--- /dev/null
@@ -0,0 +1,327 @@
+#include "filecommand.h"
+
+#include <QStringList>
+
+#include <QDebug>
+
+namespace AniDBUdpClient {
+
+FileCommand::FileCommand(QObject *parent) : AbstractCommand(parent)
+{
+       init();
+}
+
+FileCommand::FileCommand(int fid, FileFlags fmask, FileAnimeFlags amask, QObject *parent) : AbstractCommand(parent)
+{
+       init();
+       m_fid = fid;
+       m_fmask = fmask;
+       m_amask = amask;
+}
+
+FileCommand::FileCommand(const QByteArray &ed2k, qint64 size, FileFlags fmask, FileAnimeFlags amask, QObject *parent) : AbstractCommand(parent)
+{
+       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, QObject *parent) : AbstractCommand(parent)
+{
+       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, QObject *parent) : AbstractCommand(parent)
+{
+       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, QObject *parent) : AbstractCommand(parent)
+{
+       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, QObject *parent) : AbstractCommand(parent)
+{
+       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;
+}
+
+QVariant FileCommand::value(FileFlags f) const
+{
+       return fileFlagData.value(f);
+}
+
+QVariant FileCommand::value(FileAnimeFlags f) const
+{
+       return fileAnimeFlagData.value(f);
+}
+
+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;
+       }
+
+       cmd.second["fmask"] = QString::number(m_fmask, 16);
+       // Clear any bits which aren't known.
+       cmd.second["amask"] = QString::number(m_amask & FileAnimeFlag::AllData, 16);
+
+       return cmd;
+}
+
+
+void FileCommand::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
+{
+       AbstractCommand::setRawReply(replyCode, reply, client);
+
+       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 FileCommand::readReplyData(const QString &reply)
+{
+       QString d = reply.mid(reply.indexOf('\n'));
+
+       QList<QString> parts = d.split('|', QString::KeepEmptyParts);
+
+       m_fid = parts[0].toInt();
+
+       if (m_fmask == 0 && m_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 = 0;
+       for (int i = 0, flag = 1; i < 32; ++i, flag <<= 1)
+       {
+               if (parts.size() >= partNo)
+               {
+qDebug() << "Not enough parts in reply.";
+                       continue;
+               }
+               if (m_fmask & flag)
+               {
+                       fileFlagData.insert(FileFlags(flag), parts[partNo]);
+                       ++partNo;
+               }
+       }
+
+       for (int i = 0, flag = 1; i < 32; ++i, flag <<= 1)
+       {
+               if (parts.size() >= partNo)
+               {
+qDebug() << "Not enough parts in reply.";
+                       continue;
+               }
+               if (m_amask & flag)
+               {
+                       fileAnimeFlagData.insert(FileAnimeFlags(flag), parts[partNo]);
+                       ++partNo;
+               }
+       }
+}
+
+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);
+}
+
+} // namespace AniDBUdpClient
diff --git a/lib/anidbudpclient/filecommand.h b/lib/anidbudpclient/filecommand.h
new file mode 100644 (file)
index 0000000..7fdef4b
--- /dev/null
@@ -0,0 +1,99 @@
+#ifndef FILECOMMAND_H
+#define FILECOMMAND_H
+
+#include "anidbudpclient_global.h"
+#include "abstractcommand.h"
+
+#include <QVariant>
+
+namespace AniDBUdpClient {
+
+class ANIDBUDPCLIENTSHARED_EXPORT FileCommand : public AbstractCommand
+{
+       Q_OBJECT
+
+       Q_PROPERTY(int fid READ fid WRITE setFid);
+
+       Q_PROPERTY(QByteArray ed2k READ ed2k WRITE setEd2k);
+       Q_PROPERTY(qint64 size READ size WRITE setSize);
+
+       Q_PROPERTY(QString aname READ aname WRITE setAname);
+       Q_PROPERTY(int aid READ aid WRITE setAid);
+       Q_PROPERTY(QString gname READ gname WRITE setGname);
+       Q_PROPERTY(int gid READ gid WRITE setGid);
+       Q_PROPERTY(int epno READ epno WRITE setEpno);
+
+       Q_PROPERTY(FileFlags fmask READ fmask WRITE setFmask);
+       Q_PROPERTY(FileAnimeFlags amask READ amask WRITE setAmask);
+
+public:
+       FileCommand(QObject *parent = 0);
+       FileCommand(int fid, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0), QObject *parent = 0);
+       FileCommand(const QByteArray &ed2k, qint64 size, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0), QObject *parent = 0);
+       FileCommand(const QString &aname, const QString &gname, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0), QObject *parent = 0);
+       FileCommand(const QString &aname, int gid, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0), QObject *parent = 0);
+       FileCommand(int aid, const QString &gname, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0), QObject *parent = 0);
+       FileCommand(int aid, int gid, int epno, FileFlags fmask = FileFlags(0), FileAnimeFlags = FileAnimeFlags(0), QObject *parent = 0);
+
+       int fid() const;
+       void setFid(int fid);
+
+       QByteArray ed2k() const;
+       void setEd2k(const QByteArray &ed2k);
+       qint64 size() const;
+       void setSize(qint64 size);
+
+       QString aname() const;
+       void setAname(const QString &aname);
+       int aid() const;
+       void setAid(int aid);
+       QString gname() const;
+       void setGname(const QString &gname);
+       int gid() const;
+       void setGid(int gid);
+       int epno() const;
+       void setEpno(int epno);
+
+       FileFlags fmask() const;
+       void setFmask(FileFlags fmask);
+       FileAnimeFlags amask() const;
+       void setAmask(FileAnimeFlags amask);
+
+
+       QVariant value(FileFlags f) const;
+       QVariant value(FileAnimeFlags f) const;
+
+
+       bool waitForResult() const;
+       Command rawCommand() const;
+       void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
+
+
+private:
+       void readReplyData(const QString &reply);
+       void init();
+
+       int m_fid;
+
+       QByteArray m_ed2k;
+       qint64 m_size;
+
+       QString m_aname;
+       int m_aid;
+       QString m_gname;
+       int m_gid;
+       int m_epno;
+
+       FileFlags m_fmask;
+       FileAnimeFlags m_amask;
+
+       QMap<FileFlags, QVariant> fileFlagData;
+       QMap<FileAnimeFlags, QVariant> fileAnimeFlagData;
+};
+
+} // namespace AniDBUdpClient
+
+#include <QScriptEngine>
+Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::FileCommand, QObject*);
+
+#endif // FILECOMMAND_H
diff --git a/lib/anidbudpclient/include/AniDBUdpClient/FileCommand b/lib/anidbudpclient/include/AniDBUdpClient/FileCommand
new file mode 100644 (file)
index 0000000..cf757bf
--- /dev/null
@@ -0,0 +1 @@
+#include "../../filecommand.h"
\ No newline at end of file
index f486b3224fbc28396f8372f3fb9ea959fb34311f..4e1c566561c55bc0df1204fa931a0fcadeca52ac 100644 (file)
@@ -47,6 +47,7 @@ MyListCommand::MyListCommand(const QString &aname, int gid, int epno, QObject *p
 
 MyListCommand::MyListCommand(int aid, const QString &gname, int epno, QObject *parent) : AbstractCommand(parent)
 {
+       init();
        m_aid = aid;
        m_gname = gname;
        m_epno = epno;
@@ -54,6 +55,7 @@ MyListCommand::MyListCommand(int aid, const QString &gname, int epno, QObject *p
 
 MyListCommand::MyListCommand(int aid, int gid, int epno, QObject *parent) : AbstractCommand(parent)
 {
+       init();
        m_aid = aid;
        m_gid = gid;
        m_epno = epno;
index aa164edf16fb48ebf1e8912cf6db3a0c4a399404..7d8487e7d7df362def49f62e53d585d4f64d665e 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MYLISTCOMMAND_H
 #define MYLISTCOMMAND_H
 
+#include "anidbudpclient_global.h"
 #include "abstractcommand.h"
 
 #include <QDateTime>