summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-12 14:20:37 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-12 14:20:37 (GMT)
commitf54e84afa9ed217939ba9f99197a6ecc1e8973db (patch)
treea2efce7a6e82dd81df92e3a3de20c125b8ae37be
parentb85ad65bfd594f90164b0cf725764f3049743bc3 (diff)
Check if we must remove message on server if we didn't download message
from server
-rw-r--r--resources/pop3/pop3resource.cpp26
-rw-r--r--resources/pop3/pop3resource.h1
2 files changed, 24 insertions, 3 deletions
diff --git a/resources/pop3/pop3resource.cpp b/resources/pop3/pop3resource.cpp
index 0657d69..da4068e 100644
--- a/resources/pop3/pop3resource.cpp
+++ b/resources/pop3/pop3resource.cpp
@@ -376,7 +376,7 @@ void POP3Resource::doStateStep()
fetchJob->start();
} else {
- advanceState(Save);
+ advanceState(CheckRemovingMessage);
}
}
break;
@@ -417,12 +417,30 @@ void POP3Resource::doStateStep()
break;
}
case CheckRemovingMessage: {
+ checkRemovingMessageFromServer();
break;
}
}
}
+void POP3Resource::checkRemovingMessageFromServer()
+{
+ const QList<int> idToDeleteMessage = shouldDeleteId(-1);
+ if (!idToDeleteMessage.isEmpty()) {
+ mIdsWaitingToDelete << idToDeleteMessage;
+ if (!mDeleteJob) {
+ mDeleteJob = new DeleteJob(mPopSession);
+ mDeleteJob->setDeleteIds(mIdsWaitingToDelete);
+ mIdsWaitingToDelete.clear();
+ connect(mDeleteJob, &DeleteJob::result, this, &POP3Resource::deleteJobResult);
+ mDeleteJob->start();
+ }
+ } else {
+ advanceState(Save);
+ }
+}
+
void POP3Resource::localFolderRequestJobFinished(KJob *job)
{
if (job->error()) {
@@ -762,11 +780,13 @@ QList<int> POP3Resource::shouldDeleteId(int downloadedId) const
foreach (int idToSave, mIdsToSave) {
idsToDeleteFromServer.removeAll(idToSave);
}
- if (!mIdsToSave.contains(downloadedId)) {
+ if (downloadedId != -1 && !mIdsToSave.contains(downloadedId)) {
idsToDeleteFromServer << downloadedId;
}
} else {
- idsToDeleteFromServer << downloadedId;
+ if (downloadedId != -1) {
+ idsToDeleteFromServer << downloadedId;
+ }
}
return idsToDeleteFromServer;
}
diff --git a/resources/pop3/pop3resource.h b/resources/pop3/pop3resource.h
index 21a08e3..544b25b 100644
--- a/resources/pop3/pop3resource.h
+++ b/resources/pop3/pop3resource.h
@@ -142,6 +142,7 @@ private:
void updateIntervalTimer();
void showPasswordDialog(const QString &queryText);
QString buildLabelForPasswordDialog(const QString &detailedError) const;
+ void checkRemovingMessageFromServer();
void finish();
bool shouldAdvanceToQuitState() const;