namespace AniDBUdpClient {
+
+MyListAddCommand::MyListAddCommand(int fid, bool edit, QObject *parent) : AbstractCommand(parent)
+{
+ init();
+ m_fid = fid;
+ m_edit = edit;
+}
+
+MyListAddCommand::MyListAddCommand(const QByteArray &ed2k, qint64 size, bool edit, QObject *parent) : AbstractCommand(parent)
+{
+ init();
+ m_ed2k = ed2k;
+ m_size = size;
+ m_edit = edit;
+}
+
+MyListAddCommand::MyListAddCommand(int lid, QObject *parent) : AbstractCommand(parent)
+{
+ 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::setRawReply(ReplyCode replyCode, const QString &reply, Client *client)
+{
+ AbstractCommand::setRawReply(replyCode, reply, client);
+
+ switch (replyCode)
+ {
+ case MYLIST_ENTRY_ADDED:
+ {
+ QString lid = reply.mid(reply.indexOf('\n')).trimmed();
+ if (!m_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 MyListAddCommand::init()
+{
+ m_fid = 0;
+ m_lid = 0;
+
+ m_state = StateUnknown;
+ m_viewed = Unset;
+}
+
+
+// ===================================================================================
+
+
MylistAddCommand::MylistAddCommand(QString file, QObject *parent) : AbstractCommand(parent)
{
m_file = file;
}
break;
}
-
-
}
void MylistAddCommand::hash()
namespace AniDBUdpClient {
+class ANIDBUDPCLIENTSHARED_EXPORT MyListAddCommand : public AbstractCommand
+{
+ Q_ENUMS(ViewedState);
+
+ Q_OBJECT
+
+ 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:
+
+ enum ViewedState {
+ Unset = -1,
+ NotViewed = 0,
+ Viewed = 1,
+ };
+
+ MyListAddCommand(int fid, bool edit, QObject *parent = 0);
+ MyListAddCommand(const QByteArray &ed2k, qint64 size, bool edit, QObject *parent = 0);
+ explicit MyListAddCommand(int lid, QObject *parent = 0);
+
+ 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;
+
+ void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);
+
+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 MylistAddCommand : public AbstractCommand
{
Q_OBJECT