From 1e4538de6f45dfcf4561535d6e8473461461877b Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Fri, 10 Dec 2010 14:43:44 +0000 Subject: [PATCH] Don't send a mail entry located in trash folder. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39804 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/mail/main.cpp | 59 +++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/src/servers/mail/main.cpp b/src/servers/mail/main.cpp index 77c3ddbdac..9d59c7bd71 100644 --- a/src/servers/mail/main.cpp +++ b/src/servers/mail/main.cpp @@ -10,23 +10,24 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include #include #include @@ -78,7 +79,8 @@ public: private: void _UpdateAutoCheck(bigtime_t interval); - bool _IsPending(BNode& entry) const; + static bool _IsPending(BNode& node); + static bool _IsEntryInTrash(BEntry& entry); private: BMessageRunner* fAutoCheckRunner; @@ -515,6 +517,9 @@ MailDaemonApp::SendPendingMessages(BMessage* msg) off_t size; while (query.GetNextEntry(&entry) == B_OK) { + if (_IsEntryInTrash(entry)) + continue; + while (node.SetTo(&entry) == B_BUSY) snooze(1000); if (!_IsPending(node)) @@ -560,6 +565,9 @@ MailDaemonApp::SendPendingMessages(BMessage* msg) off_t size; while (query.GetNextEntry(&entry) == B_OK) { + if (_IsEntryInTrash(entry)) + continue; + node.SetTo(&entry); if (!_IsPending(node)) continue; @@ -606,8 +614,10 @@ MailDaemonApp::Pulse() /*! Work-around for a broken index that contains out-of-date information. */ + +/* static */ bool -MailDaemonApp::_IsPending(BNode& node) const +MailDaemonApp::_IsPending(BNode& node) { int32 flags; if (node.ReadAttr(B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0, &flags, sizeof(int32)) @@ -618,6 +628,27 @@ MailDaemonApp::_IsPending(BNode& node) const } +/* static */ +bool +MailDaemonApp::_IsEntryInTrash(BEntry& entry) +{ + entry_ref ref; + + entry.GetRef(&ref); + BPath trashPath; + BPath entryPath(&entry); + BVolume volume(ref.device); + if (volume.InitCheck() == B_OK) { + find_directory(B_TRASH_DIRECTORY, &trashPath, false, &volume); + if (strncmp(entryPath.Path(), trashPath.Path(), + strlen(trashPath.Path())) == 0) + return true; + } + + return false; +} + + // #pragma mark -