]> Some of my projects - anidbudpclient.git/commitdiff
Add MyListExport Command
authorAPTX <marek321@gmail.com>
Sat, 15 Dec 2012 19:59:34 +0000 (20:59 +0100)
committerAPTX <marek321@gmail.com>
Sat, 15 Dec 2012 19:59:34 +0000 (20:59 +0100)
anidbudpclient.pro
include/AniDBUdpClient/MyListExportCommand [new file with mode: 0644]
mylistexportcommand.cpp [new file with mode: 0644]
mylistexportcommand.h [new file with mode: 0644]

index d5d84f7a9331552a89d3debb9158fb59b550a7ae..81e5eb299fbb5b416f3bdf3908b5d1a34dbce3ff 100644 (file)
@@ -41,7 +41,8 @@ SOURCES += client.cpp \
        clientinterface.cpp \
        myliststate.cpp \
        episodecommand.cpp \
-       animecommand.cpp
+       animecommand.cpp \
+       mylistexportcommand.cpp
 
 HEADERS += client.h \
        anidbudpclient_global.h \
@@ -67,7 +68,8 @@ HEADERS += client.h \
        clientinterface.h \
        myliststate.h \
        episodecommand.h \
-       animecommand.h
+       animecommand.h \
+       mylistexportcommand.h
 
 CONV_HEADERS += include/AniDBUdpClient/Client \
        include/AniDBUdpClient/AbstractCommand \
@@ -80,6 +82,7 @@ CONV_HEADERS += include/AniDBUdpClient/Client \
        include/AniDBUdpClient/FileCommand \
        include/AniDBUdpClient/VoteCommand \
        include/AniDBUdpClient/UptimeCommand \
+       include/AniDBUdpClient/MyListExportCommand \
        include/AniDBUdpClient/File \
        include/AniDBUdpClient/Hash \
        include/AniDBUdpClient/ClientSentCommandsModel \
diff --git a/include/AniDBUdpClient/MyListExportCommand b/include/AniDBUdpClient/MyListExportCommand
new file mode 100644 (file)
index 0000000..6a6dd63
--- /dev/null
@@ -0,0 +1 @@
+#include "../../mylistexportcommand.h"
\ No newline at end of file
diff --git a/mylistexportcommand.cpp b/mylistexportcommand.cpp
new file mode 100644 (file)
index 0000000..1435ce7
--- /dev/null
@@ -0,0 +1,52 @@
+#include "mylistexportcommand.h"
+
+namespace AniDBUdpClient {
+
+MyListExportCommand::MyListExportCommand(QString templateName)
+       : m_templateName(templateName)
+{
+}
+
+MyListExportCommand::MyListExportCommand(bool )
+{
+}
+
+bool MyListExportCommand::waitForResult() const
+{
+       return true;
+}
+
+Command MyListExportCommand::rawCommand() const
+{
+       Command command;
+       command.first = "MYLISTEXPORT";
+       if (m_templateName.isEmpty())
+               command.second["cancel"] = 1;
+       else
+               command.second["template"] = m_templateName;
+
+       return command;
+}
+
+void MyListExportReply::setRawReply(ReplyCode replyCode, const QString &reply)
+{
+       AbstractReply::setRawReply(replyCode, reply);
+
+       switch (replyCode)
+       {
+               case EXPORT_QUEUED:
+               case EXPORT_CANCELLED:
+                       signalReplyReady(true);
+               break;
+               case EXPORT_NO_SUCH_TEMPLATE:
+               case EXPORT_ALREADY_IN_QUEUE:
+               case EXPORT_NO_EXPORT_QUEUED_OR_IS_PROCESSING:
+               default:
+                       signalReplyReady(false);
+               break;
+       }
+}
+
+// ==
+
+} // namespace AniDBUdpClient
diff --git a/mylistexportcommand.h b/mylistexportcommand.h
new file mode 100644 (file)
index 0000000..9017b25
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef MYLISTEXPORTCOMMAND_H
+#define MYLISTEXPORTCOMMAND_H
+
+#include "abstractcommand.h"
+
+namespace AniDBUdpClient {
+
+class ANIDBUDPCLIENTSHARED_EXPORT MyListExportReply;
+
+class MyListExportCommand : public AbstractCommand
+{
+public:
+       typedef MyListExportReply ReplyType;
+       // Empty templateName is equivalent to canceling.
+       explicit MyListExportCommand(QString templateName);
+       explicit MyListExportCommand(bool cancel);
+
+       bool waitForResult() const;
+       Command rawCommand() const;
+
+private:
+       QString m_templateName;
+};
+
+class ANIDBUDPCLIENTSHARED_EXPORT MyListExportReply : public AbstractReply
+{
+       Q_OBJECT
+       REPLY_DEFINITION_HELPER(MyListExport)
+public:
+       void setRawReply(ReplyCode replyCode, const QString &reply);
+};
+
+} // namespace AniDBUdpClient
+
+#endif // MYLISTEXPORTCOMMAND_H