return true;
}
+bool AbstractCommand::isValid() const
+{
+ return true;
+}
+
// ===
AbstractReply::AbstractReply(const QByteArray &id, QObject *parent) : QObject(parent)
**/
virtual bool waitForResult() const;
virtual bool requiresSession() const;
+ virtual bool isValid() const;
};
#define REPLY_DEFINITION_HELPER_INTERNAL(name, constructor) \
enum ReplyCode
{
+ INVALID_COMMAND = -2,
CLIENT_DESTROYED = -1,
UNKNOWN_REPLY = 0,
void Client::sendCommand(AbstractReply *command, bool controlCommand)
{
+ if (!command->command().isValid())
+ {
+ command->setRawReply(INVALID_COMMAND, QString());
+ if (!command->command().waitForResult())
+ command->deleteLater();
+ return;
+ }
+
if (m_enableEncryption && command->command().requiresSession() && (m_salt.isEmpty() || !usingEncryption))
{
if (controlCommand)
return true;
}
+bool FileCommand::isValid() const
+{
+ const bool validAnameGE = !m_aname.isEmpty() && (!m_gname.isEmpty() && m_epno || m_gid && m_epno);
+ const bool validAidGE = m_aid && ((!m_gname.isEmpty() && m_epno) || (m_gid && m_epno));
+ return (m_fid || (!m_ed2k.isEmpty() && m_size) || validAnameGE || validAidGE);
+ // fmask & amask don't need to be checked as all invalid bits are removed
+}
+
Command FileCommand::rawCommand() const
{
Command cmd;
void setAmask(FileAnimeFlags amask);
bool waitForResult() const;
+ bool isValid() const;
Command rawCommand() const;
private:
return true;
}
+bool MyListAddCommand::isValid() const
+{
+ return m_fid || (!m_ed2k.isEmpty() && m_size) || (m_lid && m_edit);
+}
+
Command MyListAddCommand::rawCommand() const
{
Command cmd;
void setMyListState(const MyListState &state);
bool waitForResult() const;
+ bool isValid() const;
Command rawCommand() const;
\r
bool waitForResult() const;\r
Command rawCommand() const;\r
- void setRawReply(ReplyCode replyCode, const QString &reply, Client *client);\r
\r
private:\r
void init();\r
return true;
}
+bool VoteCommand::isValid() const
+{
+ return (m_id || !m_name.isEmpty())
+ && (m_epno && m_voteType == AnimeVote || !m_epno);
+ // Value is set to 0 if not in valid range
+}
+
Command VoteCommand::rawCommand() const
{
Command cmd;
void setEpno(int epno);
bool waitForResult() const;
+ bool isValid() const;
Command rawCommand() const;
private: