From 68a6917824c88d333af2c88e34848a14c4d54ff7 Mon Sep 17 00:00:00 2001 From: APTX Date: Sat, 15 Dec 2012 20:59:34 +0100 Subject: [PATCH] Add MyListExport Command --- anidbudpclient.pro | 7 ++- include/AniDBUdpClient/MyListExportCommand | 1 + mylistexportcommand.cpp | 52 ++++++++++++++++++++++ mylistexportcommand.h | 35 +++++++++++++++ 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 include/AniDBUdpClient/MyListExportCommand create mode 100644 mylistexportcommand.cpp create mode 100644 mylistexportcommand.h diff --git a/anidbudpclient.pro b/anidbudpclient.pro index d5d84f7..81e5eb2 100644 --- a/anidbudpclient.pro +++ b/anidbudpclient.pro @@ -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 index 0000000..6a6dd63 --- /dev/null +++ b/include/AniDBUdpClient/MyListExportCommand @@ -0,0 +1 @@ +#include "../../mylistexportcommand.h" \ No newline at end of file diff --git a/mylistexportcommand.cpp b/mylistexportcommand.cpp new file mode 100644 index 0000000..1435ce7 --- /dev/null +++ b/mylistexportcommand.cpp @@ -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 index 0000000..9017b25 --- /dev/null +++ b/mylistexportcommand.h @@ -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 -- 2.52.0