mail_daemon: IMAP delete messages on the server only when delete_remote_when_local setting is set

Change-Id: I88fcc7a185cede080af7c3b85f9466a02f895809
Reviewed-on: https://review.haiku-os.org/674
Reviewed-by: Stephan Aßmus <[email protected]>
This commit is contained in:
Peter Kosyh
2018-11-05 17:30:09 +00:00
committed by Stephan Aßmus
parent 7c96721b51
commit eef12cec97
3 changed files with 11 additions and 3 deletions
@@ -247,7 +247,8 @@ IMAPFolder::SyncMessageFlags(uint32 uid, uint32 mailboxFlags)
// The message does not exist anymore locally, delete it on the // The message does not exist anymore locally, delete it on the
// server // server
// TODO: copy it to the trash directory first! // TODO: copy it to the trash directory first!
fProtocol.UpdateMessageFlags(*this, uid, IMAP::kDeleted); if (fProtocol.Settings()->DeleteRemoteWhenLocal())
fProtocol.UpdateMessageFlags(*this, uid, IMAP::kDeleted);
return; return;
} }
if (status == B_OK) if (status == B_OK)
@@ -49,6 +49,7 @@ public:
read_flags flags = B_READ); read_flags flags = B_READ);
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
const ::Settings* Settings() const { return &fSettings; };
protected: protected:
virtual status_t HandleFetchBody(const entry_ref& ref, virtual status_t HandleFetchBody(const entry_ref& ref,
@@ -66,7 +67,7 @@ protected:
typedef std::map<IMAPFolder*, IMAPConnectionWorker*> WorkerMap; typedef std::map<IMAPFolder*, IMAPConnectionWorker*> WorkerMap;
typedef std::map<ino_t, IMAPFolder*> FolderNodeMap; typedef std::map<ino_t, IMAPFolder*> FolderNodeMap;
Settings fSettings; ::Settings fSettings;
mutex fWorkerLock; mutex fWorkerLock;
BObjectList<IMAPConnectionWorker> fWorkers; BObjectList<IMAPConnectionWorker> fWorkers;
WorkerMap fWorkerMap; WorkerMap fWorkerMap;
@@ -75,4 +76,4 @@ protected:
}; };
#endif // IMAP_PROTOCOL_H #endif // IMAP_PROTOCOL_H
@@ -108,3 +108,9 @@ Settings::BodyFetchLimit() const
{ {
return fMessage.GetInt32("partial_download_limit", -1); return fMessage.GetInt32("partial_download_limit", -1);
} }
bool
Settings::DeleteRemoteWhenLocal() const
{
return fMessage.FindBool("delete_remote_when_local");
}