Mail Kit: Changed how filter changes work.

* BMailFilter::HeaderFetched() now only alters the entry_ref, and returns
  B_MOVE_MAIL_ACTION to move a mail.
* Instead of potentially moving the file around several times, the
  BMailProtocol now takes care of carrying out the filter action just once,
  including trying to make the file name unique.
* This also allows the IMAP add-on to know the final location of the mail,
  and thus downloading a message actually works.
* However, with my test inbox, it currently hangs, and a current Debugger does
  not work on my older system -- I guess I need to update.
* Replaced the duplicated space mechanism within the "HaikuMailFormatFilter"
  that is substantially faster, and handles all whitespace, not just spaces.
  It will also replace tabs with spaces.
This commit is contained in:
Axel Dörfler
2015-01-06 15:26:37 +01:00
parent c1f779e350
commit 549949b26f
14 changed files with 215 additions and 198 deletions
+5 -7
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2012, Haiku, Inc. All Rights Reserved.
* Copyright 2011-2013, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _MAIL_FILTER_H
@@ -21,16 +21,14 @@ public:
virtual ~BMailFilter();
// Message hooks if filter is installed to an inbound protocol
virtual void HeaderFetched(const entry_ref& ref,
BFile* file);
virtual void BodyFetched(const entry_ref& ref, BFile* file);
virtual BMailFilterAction HeaderFetched(entry_ref& ref, BFile& file);
virtual void BodyFetched(const entry_ref& ref, BFile& file);
virtual void MailboxSynchronized(status_t status);
// Message hooks if filter is installed to an outbound protocol
virtual void MessageReadyToSend(const entry_ref& ref,
BFile* file);
virtual void MessageSent(const entry_ref& ref,
BFile* file);
BFile& file);
virtual void MessageSent(const entry_ref& ref, BFile& file);
protected:
BMailProtocol& fMailProtocol;
+13 -10
View File
@@ -43,6 +43,13 @@ public:
};
typedef status_t BMailFilterAction;
#define B_NO_MAIL_ACTION 0
#define B_MOVE_MAIL_ACTION 1
#define B_DELETE_MAIL_ACTION 2
class BMailProtocol : public BLooper {
public:
BMailProtocol(
@@ -68,10 +75,6 @@ public:
BDirectory& dir);
virtual status_t DeleteMessage(const entry_ref& ref);
virtual void FileRenamed(const entry_ref& from,
const entry_ref& to);
virtual void FileDeleted(const node_ref& node);
// Convenience methods that call the BMailNotifier
void ShowError(const char* error);
void ShowMessage(const char* message);
@@ -88,17 +91,17 @@ protected:
void ReportProgress(uint32 items, uint64 bytes,
const char* message = NULL);
void ResetProgress(const char* message = NULL);
void NotifyNewMessagesToFetch(int32 nMessages);
// Filter notifications
void NotifyNewMessagesToFetch(int32 nMessages);
void NotifyHeaderFetched(const entry_ref& ref,
BFile* mail);
BMailFilterAction ProcessHeaderFetched(entry_ref& ref,
BFile& mail);
void NotifyBodyFetched(const entry_ref& ref,
BFile* mail);
BFile& mail);
void NotifyMessageReadyToSend(const entry_ref& ref,
BFile* mail);
BFile& mail);
void NotifyMessageSent(const entry_ref& ref,
BFile* mail);
BFile& mail);
void LoadFilters(
const BMailProtocolSettings& settings);