From: APTX Date: Thu, 12 Jan 2012 16:51:21 +0000 (+0100) Subject: Make File send less commands. Don't try adding to MyList if lid is known. Don't set... X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=a80ae49ac7a77182e6cd9150d1498b9bd16a7410;p=anidbudpclient.git Make File send less commands. Don't try adding to MyList if lid is known. Don't set state if file was just added. --- diff --git a/file.cpp b/file.cpp index 982d930..e1f2191 100644 --- a/file.cpp +++ b/file.cpp @@ -263,6 +263,20 @@ qDebug() << "finishRenaming"; return; } + { + bool ok; + m_lid = fileReply->value(FileFlag::Lid).toInt(&ok); + + if (!ok) + m_lid = 0; + } + + if (m_lid && actionsQueue.removeAll(Adding)) + { + updateStatus(Adding, Success); + AniDBUdpClient::Client::instance()->cancel(addReply); + } + QString name = fileReply->value(FileAnimeFlag::RomajiName).toString(); if (name.isEmpty()) name = fileReply->value(FileAnimeFlag::EnglishName).toString(); @@ -320,7 +334,15 @@ void File::finishAdding(bool success) updateStatus(Adding, Failure); return; } + + m_lid = addReply->lid(); + updateStatus(Adding, Success); + + if ((addReply->replyCode() == MYLIST_ENTRY_ADDED + || addReply->replyCode() == MYLIST_ENTRY_EDITED) + && actionsQueue.removeAll(SettingState)) + updateStatus(SettingState, Success); } void File::finishMarking(bool success) @@ -462,7 +484,7 @@ qDebug() << "startRenaming"; if (m_renameDelegate) { fileCommand.setAmask(m_renameDelegate->requiredAMask()); - fileCommand.setFmask(m_renameDelegate->requiredFMask()); + fileCommand.setFmask(m_renameDelegate->requiredFMask() | FileFlag::Lid); } fileReply = clientInstance()->send(fileCommand); @@ -479,6 +501,12 @@ void File::startAdding() return; } + if (m_lid) + { + updateStatus(Adding, Success); + return; + } + if (addReply) delete addReply; @@ -505,8 +533,8 @@ void File::startMarking() } MyListAddCommand markCommand; - if (addReply->lid()) - markCommand = MyListAddCommand(addReply->lid()); + if (m_lid) + markCommand = MyListAddCommand(m_lid); else markCommand = MyListAddCommand(m_ed2k, size(), true); markCommand.setViewed(true); @@ -526,8 +554,8 @@ void File::startSetState() } MyListAddCommand setStateCommand; - if (addReply && addReply->lid()) - setStateCommand = MyListAddCommand(addReply->lid()); + if (m_lid) + setStateCommand = MyListAddCommand(m_lid); else setStateCommand = MyListAddCommand(m_ed2k, size(), true); @@ -547,6 +575,8 @@ void File::init() { staticInit(); + m_lid = 0; + m_size = 0; hashResult = 0; diff --git a/file.h b/file.h index f302b62..77a77ed 100644 --- a/file.h +++ b/file.h @@ -129,6 +129,8 @@ private: bool canContinue(ActionState state); void updateStatus(Action action, ActionState actionState); + int m_lid; + QQueue actionsQueue; QFileInfo m_file;