--- /dev/null
+#include "mylistcommand.h"
+
+#include <QStringList>
+
+MyListCommand::MyListCommand(QObject *parent) : AbstractCommand(parent)
+{
+ init();
+}
+
+MyListCommand::MyListCommand(int lid, QObject *parent) : AbstractCommand(parent)
+{
+ init();
+ m_lid = lid;
+}
+
+MyListCommand::MyListCommand(int fid, bool isFid, QObject *parent) : AbstractCommand(parent)
+{
+ Q_UNUSED(isFid);
+ init();
+ m_fid = fid;
+}
+
+MyListCommand::MyListCommand(const QByteArray &ed2k, qint64 size, QObject *parent) : AbstractCommand(parent)
+{
+ init();
+ m_ed2k = ed2k;
+ m_size = size;
+}
+
+MyListCommand::MyListCommand(const QString &aname, const QString &gname, int epno, QObject *parent) : AbstractCommand(parent)
+{
+ init();
+ m_aname = aname;
+ m_gname = gname;
+ m_epno = epno;
+}
+
+MyListCommand::MyListCommand(const QString &aname, int gid, int epno, QObject *parent) : AbstractCommand(parent)
+{
+ init();
+ m_aname = aname;
+ m_gid = gid;
+ m_epno = epno;
+}
+
+MyListCommand::MyListCommand(int aid, const QString &gname, int epno, QObject *parent) : AbstractCommand(parent)
+{
+ m_aid = aid;
+ m_gname = gname;
+ m_epno = epno;
+}
+
+MyListCommand::MyListCommand(int aid, int gid, int epno, QObject *parent) : AbstractCommand(parent)
+{
+ m_aid = aid;
+ m_gid = gid;
+ m_epno = epno;
+}
+
+int MyListCommand::lid() const
+{
+ return m_lid;
+}
+
+void MyListCommand::setLid(int lid)
+{
+ m_lid = lid;
+}
+
+int MyListCommand::fid() const
+{
+ return m_fid;
+}
+
+void MyListCommand::setFid(int fid)
+{
+ m_fid = fid;
+}
+
+QByteArray MyListCommand::ed2k() const
+{
+ return m_ed2k;
+}
+
+void MyListCommand::setEd2k(const QByteArray &ed2k)
+{
+ m_ed2k = ed2k;
+}
+
+qint64 MyListCommand::size() const
+{
+ return m_size;
+}
+
+void MyListCommand::setSize(qint64 size)
+{
+ m_size = size;
+}
+
+QString MyListCommand::aname() const
+{
+ return m_aname;
+}
+
+void MyListCommand::setAname(const QString &aname)
+{
+ m_aname = aname;
+}
+
+int MyListCommand::aid() const
+{
+ return m_aid;
+}
+
+void MyListCommand::setAid(int aid)
+{
+ m_aid = aid;
+}
+
+QString MyListCommand::gname() const
+{
+ return m_gname;
+}
+
+void MyListCommand::setGname(const QString &gname)
+{
+ m_gname = gname;
+}
+
+int MyListCommand::gid() const
+{
+ return m_gid;
+}
+
+void MyListCommand::setGid(int gid)
+{
+ m_gid = gid;
+}
+
+
+int MyListCommand::epno() const
+{
+ return m_epno;
+}
+
+void MyListCommand::setEpno(int epno)
+{
+ m_epno = epno;
+}
+
+bool MyListCommand::isValid() const
+{
+ return m_lid || m_fid || m_aid
+ || !m_aname.isEmpty()
+ || (!m_ed2k.isEmpty() && m_size);
+}
+
+int MyListCommand::eid() const
+{
+ return m_eid;
+}
+
+QDateTime MyListCommand::date() const
+{
+ return m_date;
+}
+
+AbstractCommand::State MyListCommand::state() const
+{
+ return m_state;
+}
+
+QDateTime MyListCommand::viewDate() const
+{
+ return m_viewDate;
+}
+
+QString MyListCommand::storage() const
+{
+ return m_storage;
+}
+
+QString MyListCommand::source() const
+{
+ return m_source;
+}
+
+QString MyListCommand::other() const
+{
+ return m_other;
+}
+
+AbstractCommand::FileState MyListCommand::fileState() const
+{
+ return m_fileState;
+}
+
+QStringList MyListCommand::multipleEntries() const
+{
+ return m_multipleEntries;
+}
+
+bool MyListCommand::waitForResult() const
+{
+ return true;
+}
+
+Command MyListCommand::rawCommand() const
+{
+ Command cmd;
+
+ cmd.first = "MYLIST";
+
+ if (m_lid)
+ {
+ cmd.second["lid"] = m_lid;
+ }
+ else 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
+ {
+ // TODO WTF NOW?!?
+ }
+ return cmd;
+}
+
+void MyListCommand::setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client)
+{
+ AbstractCommand::setRawReply(replyCode, reply, client);
+
+ switch (replyCode)
+ {
+ case MYLIST:
+ {
+ QStringList parts = reply.mid(reply.indexOf("\n")).split('|', QString::KeepEmptyParts);
+ bool ok;
+ m_lid = parts[0].toInt(&ok, 10);
+ m_fid = parts[1].toInt(&ok, 10);
+ m_eid = parts[2].toInt(&ok, 10);
+ m_aid = parts[3].toInt(&ok, 10);
+ m_gid = parts[4].toInt(&ok, 10);
+ m_date = QDateTime::fromTime_t(parts[5].toUInt(&ok, 10));
+ m_state = State(parts[6].toInt(&ok, 10));
+ m_viewDate = QDateTime::fromTime_t(parts[7].toUInt(&ok, 10));
+ m_storage = parts[8];
+ m_source = parts[9];
+ m_other = parts[10];
+ m_fileState = FileState(parts[11].toInt(&ok, 10));
+ emit replyReady(true);
+ }
+ break;
+ case MULTIPLE_MYLIST_ENTRIES:
+ {
+ m_multipleEntries = reply.mid(reply.indexOf("\n")).split('|', QString::KeepEmptyParts);
+ emit replyReady(true);
+ }
+ break;
+ case NO_SUCH_ENTRY:
+ default:
+ emit replyReady(false);
+ break;
+ }
+}
+
+void MyListCommand::init()
+{
+ m_lid = 0;
+ m_fid = 0;
+ m_aid = 0;
+ m_gid = 0;
+ m_eid = 0;
+
+ m_size = 0;
+ m_epno = 0;
+
+ m_state = State(0);
+ m_fileState = FileState(0);
+}
--- /dev/null
+#ifndef MYLISTCOMMAND_H
+#define MYLISTCOMMAND_H
+
+#include <QDateTime>
+#include <QStringList>
+
+#include "abstractcommand.h"
+
+class ANIDBUDPCLIENTSHARED_EXPORT MyListCommand : public AbstractCommand
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int lid READ lid WRITE setLid);
+ 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(bool valid READ isValid);
+
+ Q_PROPERTY(int eid READ eid);
+ Q_PROPERTY(QDateTime date READ date);
+ Q_PROPERTY(State state READ state);
+ Q_PROPERTY(QDateTime viewDate READ viewDate);
+ Q_PROPERTY(QString storage READ storage);
+ Q_PROPERTY(QString source READ source);
+ Q_PROPERTY(QString other READ other);
+ Q_PROPERTY(FileState fileState READ fileState);
+
+ Q_PROPERTY(QStringList multipleEntries READ multipleEntries);
+public:
+ MyListCommand(QObject *parent = 0);
+ MyListCommand(int lid, QObject *parent = 0);
+ MyListCommand(int fid, bool isFid, QObject *parent = 0);
+ MyListCommand(const QByteArray &ed2k, qint64 size, QObject *parent = 0);
+ MyListCommand(const QString &aname, const QString &gname, int epno, QObject *parent = 0);
+ MyListCommand(const QString &aname, int gid, int epno, QObject *parent = 0);
+ MyListCommand(int aid, const QString &gname, int epno, QObject *parent = 0);
+ MyListCommand(int aid, int gid, int epno, QObject *parent = 0);
+
+ int lid() const;
+ void setLid(int lid);
+ 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);
+
+ bool isValid() const;
+
+
+ int eid() const;
+ QDateTime date() const;
+ State state() const;
+ QDateTime viewDate() const;
+ QString storage() const;
+ QString source() const;
+ QString other() const;
+ FileState fileState() const;
+
+ QStringList multipleEntries() const;
+
+ bool waitForResult() const;
+ Command rawCommand() const;
+ void setRawReply(ReplyCode replyCode, const QString &reply, AniDBUdpClient *client);
+
+private:
+ void init();
+
+ int m_lid;
+ int m_fid;
+
+ QByteArray m_ed2k;
+ qint64 m_size;
+
+ QString m_aname;
+ int m_aid;
+ QString m_gname;
+ int m_gid;
+ int m_epno;
+
+ int m_eid;
+ QDateTime m_date;
+ State m_state;
+ QDateTime m_viewDate;
+ QString m_storage;
+ QString m_source;
+ QString m_other;
+ FileState m_fileState;
+
+ QStringList m_multipleEntries;
+
+};
+
+#endif // MYLISTCOMMAND_H