[haiku-commits] BRANCH axeld-github.imap - src/kits/mail src/add-ons/mail_daemon/inbound_filters/spam_filter headers/os/add-ons/mail_daemon src/add-ons/mail_daemon/inbound_filters/match_header src/servers/mail

  • From: axeld-github.imap <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 27 Oct 2012 01:49:29 +0200 (CEST)

added 5 changesets to branch 'refs/remotes/axeld-github/imap'
old head: 1cf686d2abff63dc8a8bff3d69b59f13127ce6b9
new head: bdcd91c38ab8312d0fb02403d9424b7f0ca59b12

----------------------------------------------------------------------------

b0f0331: Minor coding style cleanup.

fc52208: Fixed typo.

785fde2: Minor MailNotifier cleanup.
  
  * Renamed to BMailNotifier, as it's part of the public API.
  * Renamed Notifier.{cpp|h} to DefaultNotifier.{cpp|h} as that's the class it
    implements.
  * Made the mail counts uint32, and the byte counts uint64.

4a829ea: Added BMessage::Append(), and new(std::nothrow_t).
  
  * Append() copies all fields from the specified message.
  * The nothrow operator new allows you to add BMessages to a BObjectList.

bdcd91c: Work in progress of mail rework.
  
  * Not everything compiles; all protocols, and inbound filters do, though.
  * Renamed a few classes to give a better idea what they are for; prefixed
    public classes with the 'B' prefix.
  * Moved ProtocolConfigView's classes into the BPrivate namespace.
  * Moved BMailFilter into its own file.
  * Added BMailFilter::DescriptiveName(). This is now used by the RuleFilter
    in order to give a description of what it's doing (ie. no more dozens of
    "Rule filter" entries in the preferences).
  * Removed no longer used MailAddon.h.
  * Renamed Addon to AddOn where found, since that is more consistent with the
    rest of the API.
  * Merged the former MailProtocol with the former MailProtocolThread; the
    differentiation between those two was pretty messy.
  * All configuration views touched so far are now using the layout kit.
  * The RuleFilter is currently broken functionality wise; I have not yet 
decided
    how to solve the stuff it uses (TriggerFileMove() does not exist anymore,
    for example).
  * BMailAddOnSettings (formerly known as AddonSettings) now directly subclass
    BMessage; there are no Settings() and EditSettings() method anymore. The
    class uses a copy of itself to determine whether or not it has been changed.
  * Lots of cleanup.

                                   [ Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

38 files changed, 1785 insertions(+), 2492 deletions(-)
headers/os/add-ons/mail_daemon/MailAddon.h         |   74 --
headers/os/add-ons/mail_daemon/MailFilter.h        |   50 ++
headers/os/add-ons/mail_daemon/MailProtocol.h      |  218 ++----
.../os/add-ons/mail_daemon/ProtocolConfigView.h    |  109 ++-
headers/os/app/Message.h                           |    7 +-
headers/os/mail/MailSettings.h                     |   78 +-
headers/private/mail/FileConfigView.h              |   83 ++-
.../inbound_filters/match_header/ConfigView.cpp    |  310 ++++----
.../inbound_filters/match_header/RuleFilter.cpp    |  116 +--
.../inbound_filters/match_header/RuleFilter.h      |   49 +-
.../inbound_filters/notifier/ConfigView.cpp        |   93 +--
.../inbound_filters/notifier/ConfigView.h          |   50 +-
.../inbound_filters/notifier/filter.cpp            |   68 +-
.../inbound_filters/spam_filter/SpamFilter.cpp     |  290 +++-----
.../inbound_filters/spam_filter/SpamFilter.h       |  101 +--
.../spam_filter/SpamFilterConfig.cpp               |  489 +++----------
.../inbound_protocols/imap/ConfigView.cpp          |   77 +-
.../inbound_protocols/pop3/ConfigView.cpp          |   57 +-
.../mail_daemon/inbound_protocols/pop3/POP3.cpp    |   66 +-
.../mail_daemon/inbound_protocols/pop3/POP3.h      |   14 +-
.../outbound_protocols/smtp/ConfigView.cpp         |   81 +--
.../mail_daemon/outbound_protocols/smtp/smtp.cpp   |   73 +-
.../mail_daemon/outbound_protocols/smtp/smtp.h     |   20 +-
src/kits/app/Message.cpp                           |   41 +-
src/kits/mail/FileConfigView.cpp                   |  120 ++--
src/kits/mail/HaikuMailFormatFilter.cpp            |   31 +-
src/kits/mail/HaikuMailFormatFilter.h              |   17 +-
src/kits/mail/Jamfile                              |    1 +
src/kits/mail/MailFilter.cpp                       |   49 ++
src/kits/mail/MailMessage.cpp                      |    6 +-
src/kits/mail/MailProtocol.cpp                     |  591 +++++-----------
src/kits/mail/MailSettings.cpp                     |  239 ++++---
src/kits/mail/ProtocolConfigView.cpp               |  496 ++++++-------
src/kits/mail/c_mail_api.cpp                       |   32 +-
.../mail/{Notifier.cpp => DefaultNotifier.cpp}     |   31 +-
src/servers/mail/{Notifier.h => DefaultNotifier.h} |   27 +-
src/servers/mail/Jamfile                           |    4 +-
src/servers/mail/MailDaemon.cpp                    |   19 +-

############################################################################

Commit:      b0f0331c3943360c3e4650dde201c8d23017462d

Author:      Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Fri Oct 26 09:43:14 2012 UTC

Minor coding style cleanup.

----------------------------------------------------------------------------

diff --git a/src/servers/mail/MailDaemon.cpp b/src/servers/mail/MailDaemon.cpp
index b12bcbe..3f2a158 100644
--- a/src/servers/mail/MailDaemon.cpp
+++ b/src/servers/mail/MailDaemon.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007-2011, Haiku, Inc. All rights reserved.
+ * Copyright 2007-2012, Haiku, Inc. All rights reserved.
  * Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
  * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  * Distributed under the terms of the MIT License.
@@ -184,8 +184,7 @@ MailDaemonApp::ReadyToRun()
 
                numString << fNewMessages;
                string.ReplaceFirst("%num", numString);
-       }
-       else
+       } else
                string = B_TRANSLATE("No new messages");
 
        fCentralBeep = false;
@@ -213,16 +212,16 @@ MailDaemonApp::RefsReceived(BMessage* message)
        entry_ref ref;
        for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
                BNode node(&ref);
-               if (node.InitCheck() < B_OK)
+               if (node.InitCheck() != B_OK)
                        continue;
 
                int32 account;
                if (node.ReadAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0, 
&account,
-                       sizeof(account)) < 0)
+                               sizeof(account)) < 0)
                        continue;
 
                InboundProtocolThread* protocolThread = 
_FindInboundProtocol(account);
-               if (!protocolThread)
+               if (protocolThread == NULL)
                        continue;
 
                BMessenger target;
@@ -436,7 +435,8 @@ MailDaemonApp::InstallDeskbarIcon()
 
                status = deskbar.AddItem(&ref);
                if (status < B_OK) {
-                       fprintf(stderr, "Can't add deskbar replicant: %s\n", 
strerror(status));
+                       fprintf(stderr, "Can't add deskbar replicant: %s\n",
+                               strerror(status));
                        return;
                }
        }
@@ -702,7 +702,7 @@ MailDaemonApp::_ReloadAccounts(BMessage* message)
                if (it != fAccounts.end())
                        _RemoveAccount(it);
                BMailAccountSettings* settings = accounts.AccountByID(account);
-               if (settings)
+               if (settings != NULL)
                        _InitAccount(*settings);
        }
 }
@@ -802,9 +802,10 @@ MailDaemonApp::_UpdateAutoCheck(bigtime_t interval)
                if (fAutoCheckRunner != NULL) {
                        fAutoCheckRunner->SetInterval(interval);
                        fAutoCheckRunner->SetCount(-1);
-               } else
+               } else {
                        fAutoCheckRunner = new BMessageRunner(be_app_messenger,
                                new BMessage('moto'), interval);
+               }
        } else {
                delete fAutoCheckRunner;
                fAutoCheckRunner = NULL;

############################################################################

Commit:      fc52208fb59ef4b500540e155f1d98798428e9a2

Author:      Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Fri Oct 26 09:47:35 2012 UTC

Fixed typo.

----------------------------------------------------------------------------

diff --git a/headers/os/add-ons/mail_daemon/MailProtocol.h 
b/headers/os/add-ons/mail_daemon/MailProtocol.h
index 4a30c65..0437c23 100644
--- a/headers/os/add-ons/mail_daemon/MailProtocol.h
+++ b/headers/os/add-ons/mail_daemon/MailProtocol.h
@@ -47,13 +47,13 @@ public:
                                                                        
AddonSettings* settings);
        virtual                                         ~MailFilter();
 
-       //! Message hooks if filter is installed to a inbound protocol
+       //! 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 void                            MailboxSynced(status_t status);
 
-       //! Message hooks if filter is installed to a outbound protocol
+       //! 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,

############################################################################

Commit:      785fde20db38d9cbbdecbb702f2ac0b6bd8ca6f1

Author:      Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Fri Oct 26 12:44:44 2012 UTC

Minor MailNotifier cleanup.

* Renamed to BMailNotifier, as it's part of the public API.
* Renamed Notifier.{cpp|h} to DefaultNotifier.{cpp|h} as that's the class it
  implements.
* Made the mail counts uint32, and the byte counts uint64.

----------------------------------------------------------------------------

diff --git a/headers/os/add-ons/mail_daemon/MailProtocol.h 
b/headers/os/add-ons/mail_daemon/MailProtocol.h
index 0437c23..33fa2f2 100644
--- a/headers/os/add-ons/mail_daemon/MailProtocol.h
+++ b/headers/os/add-ons/mail_daemon/MailProtocol.h
@@ -21,18 +21,18 @@
 #include <MailSettings.h>
 
 
-class MailNotifier {
+class BMailNotifier {
 public:
-       virtual                                         ~MailNotifier() {}
+       virtual                                         ~BMailNotifier() {}
 
-       virtual MailNotifier*           Clone() = 0;
+       virtual BMailNotifier*          Clone() = 0;
 
        virtual void                            ShowError(const char* error) = 
0;
        virtual void                            ShowMessage(const char* 
message) = 0;
 
-       virtual void                            SetTotalItems(int32 items) = 0;
-       virtual void                            SetTotalItemsSize(int32 size) = 
0;
-       virtual void                            ReportProgress(int bytes, int 
messages,
+       virtual void                            SetTotalItems(uint32 items) = 0;
+       virtual void                            SetTotalItemsSize(uint64 size) 
= 0;
+       virtual void                            ReportProgress(uint32 messages, 
uint64 bytes,
                                                                        const 
char* message = NULL) = 0;
        virtual void                            ResetProgress(const char* 
message = NULL) = 0;
 };
@@ -86,7 +86,7 @@ public:
                        //! Does not delete handler
                        bool                            RemoveHandler(BHandler* 
handler);
 
-                       void                            
SetMailNotifier(MailNotifier* mailNotifier);
+                       void                            
SetMailNotifier(BMailNotifier* mailNotifier);
 
        virtual void                            ShowError(const char* error);
        virtual void                            ShowMessage(const char* 
message);
@@ -126,7 +126,7 @@ protected:
                        void                            
LoadFilters(MailAddonSettings& settings);
 
                        BMailAccountSettings    fAccountSettings;
-                       MailNotifier*           fMailNotifier;
+                       BMailNotifier*          fMailNotifier;
 
 private:
                        MailFilter*                     
_LoadFilter(AddonSettings* filterSettings);
diff --git a/src/kits/mail/MailProtocol.cpp b/src/kits/mail/MailProtocol.cpp
index 54623d5..13f28d9 100644
--- a/src/kits/mail/MailProtocol.cpp
+++ b/src/kits/mail/MailProtocol.cpp
@@ -185,7 +185,7 @@ MailProtocol::RemoveHandler(BHandler* handler)
 
 
 void
-MailProtocol::SetMailNotifier(MailNotifier* mailNotifier)
+MailProtocol::SetMailNotifier(BMailNotifier* mailNotifier)
 {
        delete fMailNotifier;
        fMailNotifier = mailNotifier;
diff --git a/src/servers/mail/Notifier.cpp 
b/src/servers/mail/DefaultNotifier.cpp
similarity index 84%
rename from src/servers/mail/Notifier.cpp
rename to src/servers/mail/DefaultNotifier.cpp
index 6a69096..4418de2 100644
--- a/src/servers/mail/Notifier.cpp
+++ b/src/servers/mail/DefaultNotifier.cpp
@@ -1,17 +1,17 @@
 /*
- * Copyright 2011, Haiku, Inc. All rights reserved.
+ * Copyright 2011-2012, Haiku, Inc. All rights reserved.
  * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  * Distributed under the terms of the MIT License.
  */
 
 
+#include "DefaultNotifier.h"
+
 #include <Catalog.h>
 #include <IconUtils.h>
 #include <MailDaemon.h>
 #include <Roster.h>
 
-#include "Notifier.h"
-
 
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "Notifier"
@@ -30,12 +30,9 @@ DefaultNotifier::DefaultNotifier(const char* accountName, 
bool inbound,
        fTotalSize(0),
        fSizeDone(0)
 {
-       BString desc;
-       if (fIsInbound == true)
-               desc << B_TRANSLATE("Fetching mail for %name");
-       else
-               desc << B_TRANSLATE("Sending mail for %name");
-    desc.ReplaceFirst("%name", fAccountName);
+       BString desc(fIsInbound ? B_TRANSLATE("Fetching mail for %name")
+               : B_TRANSLATE("Sending mail for %name"));
+       desc.ReplaceFirst("%name", fAccountName);
 
        BString identifier;
        identifier << accountName << inbound;
@@ -59,10 +56,11 @@ DefaultNotifier::~DefaultNotifier()
 }
 
 
-MailNotifier*
+BMailNotifier*
 DefaultNotifier::Clone()
 {
-       return new DefaultNotifier(fAccountName, fIsInbound, fErrorWindow, 
fShowMode);
+       return new DefaultNotifier(fAccountName, fIsInbound, fErrorWindow,
+               fShowMode);
 }
 
 
@@ -81,7 +79,7 @@ DefaultNotifier::ShowMessage(const char* message)
 
 
 void
-DefaultNotifier::SetTotalItems(int32 items)
+DefaultNotifier::SetTotalItems(uint32 items)
 {
        fTotalItems = items;
        BString progress;
@@ -91,7 +89,7 @@ DefaultNotifier::SetTotalItems(int32 items)
 
 
 void
-DefaultNotifier::SetTotalItemsSize(int32 size)
+DefaultNotifier::SetTotalItemsSize(uint64 size)
 {
        fTotalSize = size;
        fNotification.SetProgress(fSizeDone / (float)fTotalSize);
@@ -99,7 +97,8 @@ DefaultNotifier::SetTotalItemsSize(int32 size)
 
 
 void
-DefaultNotifier::ReportProgress(int bytes, int messages, const char* message)
+DefaultNotifier::ReportProgress(uint32 messages, uint64 bytes,
+       const char* message)
 {
        fSizeDone += bytes;
        if (fTotalSize > 0)
@@ -107,11 +106,10 @@ DefaultNotifier::ReportProgress(int bytes, int messages, 
const char* message)
        else if (fTotalItems > 0) {
                // No size information available
                // Report progress in terms of message count instead
-               
                fNotification.SetProgress(fItemsDone / (float)fTotalItems);
        } else {
                // No message count information either
-               // TODO we should use a B_INFORMATION_NOTIFICATION here, but it 
is not
+               // TODO: we should use a B_INFORMATION_NOTIFICATION here, but 
it is not
                // possible to change the BNotification type after creating 
it...
                fNotification.SetProgress(0);
        }
@@ -119,7 +117,6 @@ DefaultNotifier::ReportProgress(int bytes, int messages, 
const char* message)
        fItemsDone += messages;
 
        BString progress;
-
        progress << message << "\t";
 
        if (fTotalItems > 0)
diff --git a/src/servers/mail/Notifier.h b/src/servers/mail/DefaultNotifier.h
similarity index 62%
rename from src/servers/mail/Notifier.h
rename to src/servers/mail/DefaultNotifier.h
index d00e9d6..fa292dd 100644
--- a/src/servers/mail/Notifier.h
+++ b/src/servers/mail/DefaultNotifier.h
@@ -1,10 +1,10 @@
 /*
- * Copyright 2011, Haiku, Inc. All rights reserved.
+ * Copyright 2011-2012, Haiku, Inc. All rights reserved.
  * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  * Distributed under the terms of the MIT License.
  */
-#ifndef NOTIFIER_H
-#define NOTIFIER_H
+#ifndef DEFAULT_NOTIFIER_H
+#define DEFAULT_NOTIFIER_H
 
 
 #include <Notification.h>
@@ -16,21 +16,21 @@
 #include "StatusWindow.h"
 
 
-class DefaultNotifier : public MailNotifier {
+class DefaultNotifier : public BMailNotifier {
 public:
                                                                
DefaultNotifier(const char* accountName,
                                                                        bool 
inbound, ErrorLogWindow* errorWindow,
                                                                        uint32& 
showMode);
                                                                
~DefaultNotifier();
 
-                       MailNotifier*           Clone();
+                       BMailNotifier*          Clone();
 
                        void                            ShowError(const char* 
error);
                        void                            ShowMessage(const char* 
message);
 
-                       void                            SetTotalItems(int32 
items);
-                       void                            SetTotalItemsSize(int32 
size);
-                       void                            ReportProgress(int 
bytes, int messages,
+                       void                            SetTotalItems(uint32 
items);
+                       void                            
SetTotalItemsSize(uint64 size);
+                       void                            ReportProgress(uint32 
messages, uint64 bytes,
                                                                        const 
char* message = NULL);
                        void                            ResetProgress(const 
char* message = NULL);
 
@@ -41,10 +41,11 @@ private:
                        BNotification           fNotification;
                        uint32&                         fShowMode;
 
-                       int                                     fTotalItems;
-                       int                                     fItemsDone;
-                       int                                     fTotalSize;
-                       int                                     fSizeDone;
+                       uint32                          fTotalItems;
+                       uint32                          fItemsDone;
+                       uint64                          fTotalSize;
+                       uint64                          fSizeDone;
 };
 
-#endif //NOTIFIER_H
+
+#endif // DEFAULT_NOTIFIER_H
diff --git a/src/servers/mail/Jamfile b/src/servers/mail/Jamfile
index 26cabb4..dd9ece7 100644
--- a/src/servers/mail/Jamfile
+++ b/src/servers/mail/Jamfile
@@ -18,7 +18,7 @@ Server mail_daemon :
        LEDAnimation.cpp
        MailDaemon.cpp
        main.cpp
-       Notifier.cpp
+       DefaultNotifier.cpp
        : be libmail.so tracker $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSTDC++)
                $(TARGET_NETWORK_LIBS)
 ;
@@ -35,5 +35,5 @@ DoCatalogs mail_daemon :
        :
        DeskbarView.cpp
        MailDaemon.cpp
-       Notifier.cpp
+       DefaultNotifier.cpp
 ;

############################################################################

Commit:      4a829ea53495f488c7621d3431b166acc619ecd1

Author:      Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Fri Oct 26 20:13:26 2012 UTC

Added BMessage::Append(), and new(std::nothrow_t).

* Append() copies all fields from the specified message.
* The nothrow operator new allows you to add BMessages to a BObjectList.

----------------------------------------------------------------------------

diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h
index 2920a1a..c64fdd7 100644
--- a/headers/os/app/Message.h
+++ b/headers/os/app/Message.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2010, Haiku Inc. All Rights Reserved.
+ * Copyright 2005-2012, Haiku Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -9,6 +9,8 @@
 #define _MESSAGE_H
 
 
+#include <new>
+
 #include <BeBuild.h>
 #include <DataIO.h>
 #include <Flattenable.h>
@@ -146,6 +148,8 @@ class BMessage {
                                                        const void *data, 
ssize_t numBytes,
                                                        bool isFixedSize = 
true, int32 count = 1);
 
+               status_t                Append(const BMessage &message);
+
                // Removing data
                status_t                RemoveData(const char *name, int32 
index = 0);
                status_t                RemoveName(const char *name);
@@ -268,6 +272,7 @@ class BMessage {
 
                void                    *operator new(size_t size);
                void                    *operator new(size_t, void *pointer);
+               void                    *operator new(size_t, const 
std::nothrow_t &noThrow);
                void                    operator delete(void *pointer, size_t 
size);
 
                // Private, reserved, or obsolete
diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp
index a4af465..4b9e5db 100644
--- a/src/kits/app/Message.cpp
+++ b/src/kits/app/Message.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2011, Haiku Inc. All rights reserved.
+ * Copyright 2005-2012, Haiku Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -245,8 +245,15 @@ void *
 BMessage::operator new(size_t size)
 {
        DEBUG_FUNCTION_ENTER2;
-       void *pointer = sMsgCache->Get(size);
-       return pointer;
+       return sMsgCache->Get(size);
+}
+
+
+void *
+BMessage::operator new(size_t size, const std::nothrow_t &noThrow)
+{
+       DEBUG_FUNCTION_ENTER2;
+       return sMsgCache->Get(size);
 }
 
 
@@ -2623,6 +2630,34 @@ BMessage::AddFlat(const char *name, BFlattenable 
*object, int32 count)
 
 
 status_t
+BMessage::Append(const BMessage &other)
+{
+       field_header *field = other.fFields;
+       for (uint32 i = 0; i < other.fHeader->field_count; i++, field++) {
+               const char *name = (const char *)(other.fData + field->offset);
+               const void *data = (const void *)(other.fData + field->offset
+                       + field->name_length);
+               bool isFixed = (field->flags & FIELD_FLAG_FIXED_SIZE) != 0;
+               size_t size = field->data_size / field->count;
+
+               for (uint32 j = 0; j < field->count; j++) {
+                       if (!isFixed)
+                               size = *(uint32 *)data;
+
+                       status_t status = AddData(name, field->type, data, size,
+                               isFixed != 0, 1);
+                       if (status != B_OK)
+                               return status;
+
+                       data = (const void *)((const char *)data + size
+                               + (isFixed ? 0 : sizeof(uint32)));
+               }
+       }
+       return B_OK;
+}
+
+
+status_t
 BMessage::FindAlignment(const char *name, BAlignment *alignment) const
 {
        return FindAlignment(name, 0, alignment);

############################################################################

Commit:      bdcd91c38ab8312d0fb02403d9424b7f0ca59b12

Author:      Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Fri Oct 26 23:25:39 2012 UTC

Work in progress of mail rework.

* Not everything compiles; all protocols, and inbound filters do, though.
* Renamed a few classes to give a better idea what they are for; prefixed
  public classes with the 'B' prefix.
* Moved ProtocolConfigView's classes into the BPrivate namespace.
* Moved BMailFilter into its own file.
* Added BMailFilter::DescriptiveName(). This is now used by the RuleFilter
  in order to give a description of what it's doing (ie. no more dozens of
  "Rule filter" entries in the preferences).
* Removed no longer used MailAddon.h.
* Renamed Addon to AddOn where found, since that is more consistent with the
  rest of the API.
* Merged the former MailProtocol with the former MailProtocolThread; the
  differentiation between those two was pretty messy.
* All configuration views touched so far are now using the layout kit.
* The RuleFilter is currently broken functionality wise; I have not yet decided
  how to solve the stuff it uses (TriggerFileMove() does not exist anymore,
  for example).
* BMailAddOnSettings (formerly known as AddonSettings) now directly subclass
  BMessage; there are no Settings() and EditSettings() method anymore. The
  class uses a copy of itself to determine whether or not it has been changed.
* Lots of cleanup.

----------------------------------------------------------------------------

diff --git a/headers/os/add-ons/mail_daemon/MailAddon.h 
b/headers/os/add-ons/mail_daemon/MailAddon.h
deleted file mode 100644
index eaf816d..0000000
--- a/headers/os/add-ons/mail_daemon/MailAddon.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Filter - the base class for all mail filters
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
-#ifndef ZOIDBERG_MAIL_ADDON_H
-#define ZOIDBERG_MAIL_ADDON_H
-
-
-#include "MailProtocol.h"
-#include "MailSettings.h"
-
-
-class BView;
-
-//
-// The addon interface: export instantiate_mailfilter()
-// and instantiate_mailconfig() to create a Filter addon
-//
-
-extern "C" _EXPORT InboundProtocol* instantiate_inbound_protocol(
-       BMailAccountSettings* settings);
-extern "C" _EXPORT OutboundProtocol* instantiate_outbound_protocol(
-       BMailAccountSettings* settings);
-extern "C" _EXPORT BView* instantiate_config_panel(MailAddonSettings&,
-       BMailAccountSettings&);
-// return a view that configures the MailProtocol
-// returned by the functions below.  BView::Archive(foo,true)
-// produces this addon's settings, which are passed to the in-
-// stantiate_* functions and stored persistently.  This function
-// should gracefully handle empty and NULL settings.
-
-extern "C" _EXPORT BView* instantiate_filter_config_panel(AddonSettings&);
-extern "C" _EXPORT MailFilter* instantiate_mailfilter(MailProtocol& protocol,
-       AddonSettings* settings);
-
-extern "C" _EXPORT BString descriptive_name();
-// the config panel will show this name in the chains filter
-// list if this function returns B_OK.
-// The buffer is as big as B_FILE_NAME_LENGTH.
-
-// standard Filters:
-//
-// * Parser - does ParseRFC2822(io_message,io_headers)
-// * Folder - stores the message in the specified folder,
-//     optionally under io_folder, returns MD_HANDLED
-// * HeaderFilter(regex,Yes_fiters,No_filters) -
-//     Applies Nes_filters to messages that have a header
-//     matching regex; applies No_filters otherwise.
-// * CompatabilityFilter - Invokes the standard mail_dae-
-//     mon filter ~/config/settings/add-ons/MailDaemon/Filter
-//     on the message's Entry.
-// * Producer - Reads outbound messages from disk and inserts
-//     them into the queue.
-// * SMTPSender - Sends the message, via the specified
-//     SMTP server, to the people in header field
-//    "MAIL:recipients", changes the the Entry's
-//    "MAIL:flags" field to no longer pending, changes the
-//    "MAIL:status" header field to "Sent", and adds a header
-//     field "MAIL:when" with the time it was sent.
-// * Dumper - returns MD_DISCARD
-//
-//
-// Standard chain types:
-//
-//   Incoming Mail: Protocol - Parser - Notifier - Folder
-//   Outgoing Mail: Producer - SMTPSender
-//
-// "chains" are lists of addons that appear in, or can be
-// added to, the "Accounts" list in the config panel, a tree-
-// view ordered by the chain type and the chain's AccountName().
-// Their config views should be shown, one after the other,
-// in the config panel.
-
-#endif /* ZOIDBERG_MAIL_ADDON_H */
diff --git a/headers/os/add-ons/mail_daemon/MailFilter.h 
b/headers/os/add-ons/mail_daemon/MailFilter.h
new file mode 100644
index 0000000..69b9f73
--- /dev/null
+++ b/headers/os/add-ons/mail_daemon/MailFilter.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011-2012, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef MAIL_FILTER_H
+#define MAIL_FILTER_H
+
+
+#include "MailProtocol.h"
+#include "MailSettings.h"
+
+
+class BMailProtocol;
+class BView;
+
+
+class BMailFilter {
+public:
+                                                               
BMailFilter(BMailProtocol& protocol,
+                                                                       
BMailAddOnSettings* settings);
+       virtual                                         ~BMailFilter();
+
+       virtual BString                         DescriptiveName() const = 0;
+
+       // 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 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);
+
+protected:
+                       BMailProtocol&          fMailProtocol;
+                       BMailAddOnSettings*     fSettings;
+};
+
+
+// Your filter needs to export these hooks in order to be picked up
+extern "C" BView* instantiate_filter_config_panel(BMailAddOnSettings& 
settings);
+extern "C" BMailFilter* instantiate_filter(BMailProtocol& protocol,
+       BMailAddOnSettings* settings);
+extern "C" BString filter_name();
+
+
+#endif // MAIL_FILTER_H
diff --git a/headers/os/add-ons/mail_daemon/MailProtocol.h 
b/headers/os/add-ons/mail_daemon/MailProtocol.h
index 33fa2f2..85f9965 100644
--- a/headers/os/add-ons/mail_daemon/MailProtocol.h
+++ b/headers/os/add-ons/mail_daemon/MailProtocol.h
@@ -21,6 +21,9 @@
 #include <MailSettings.h>
 
 
+class BMailFilter;
+
+
 class BMailNotifier {
 public:
        virtual                                         ~BMailNotifier() {}
@@ -38,71 +41,47 @@ public:
 };
 
 
-class MailProtocol;
-
-
-class MailFilter {
+class BMailProtocol : BLooper {
 public:
-                                                               
MailFilter(MailProtocol& protocol,
-                                                                       
AddonSettings* settings);
-       virtual                                         ~MailFilter();
-
-       //! 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 void                            MailboxSynced(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);
-protected:
-                       MailProtocol&           fMailProtocol;
-                       AddonSettings*          fAddonSettings;
-};
-
+                                                               BMailProtocol(
+                                                                       const 
BMailAccountSettings& settings);
+       virtual                                         ~BMailProtocol();
 
-class MailProtocolThread;
+                       const BMailAccountSettings& AccountSettings() const;
 
+                       void                            
SetMailNotifier(BMailNotifier* mailNotifier);
+                       BMailNotifier*          MailNotifier() const;
 
-class MailProtocol {
-public:
-                                                               
MailProtocol(BMailAccountSettings* settings);
-       virtual                                         ~MailProtocol();
+                       //! We take ownership of the filters
+                       bool                            AddFilter(BMailFilter* 
filter);
+                       int32                           CountFilter() const;
+                       BMailFilter*            FilterAt(int32 index) const;
+                       BMailFilter*            RemoveFilter(int32 index);
+                       bool                            
RemoveFilter(BMailFilter* filter);
 
-       virtual void                            SetStopNow() {}
+       virtual void                            MessageReceived(BMessage* 
message);
 
-                       BMailAccountSettings&   AccountSettings();
+                       // Mail storage operations
+       virtual status_t                        MoveMessage(const entry_ref& 
ref,
+                                                                       
BDirectory& dir);
+       virtual status_t                        DeleteMessage(const entry_ref& 
ref);
 
-                       void                            SetProtocolThread(
-                                                                       
MailProtocolThread* protocolThread);
-       virtual void                            AddedToLooper() {}
-                       MailProtocolThread*     Looper();
-                       /*! Add handler to the handler list. The handler is 
installed /
-                       removed to the according BLooper automatically. */
-                       bool                            AddHandler(BHandler* 
handler);
-                       //! Does not delete handler
-                       bool                            RemoveHandler(BHandler* 
handler);
+       virtual void                            FileRenamed(const entry_ref& 
from,
+                                                                       const 
entry_ref& to);
+       virtual void                            FileDeleted(const node_ref& 
node);
 
-                       void                            
SetMailNotifier(BMailNotifier* mailNotifier);
+                       // Convenience methods that call the BMailNotifier
+                       void                            ShowError(const char* 
error);
+                       void                            ShowMessage(const char* 
message);
 
-       virtual void                            ShowError(const char* error);
-       virtual void                            ShowMessage(const char* 
message);
-       virtual void                            SetTotalItems(int32 items);
-       virtual void                            SetTotalItemsSize(int32 size);
-       virtual void                            ReportProgress(int bytes, int 
messages,
+protected:
+                       void                            SetTotalItems(uint32 
items);
+                       void                            
SetTotalItemsSize(uint64 size);
+                       void                            ReportProgress(uint32 
messages, uint64 bytes,
                                                                        const 
char* message = NULL);
-       virtual void                            ResetProgress(const char* 
message = NULL);
-
-                       //! MailProtocol takes ownership of the filters
-                       bool                            AddFilter(MailFilter* 
filter);
-                       int32                           CountFilter();
-                       MailFilter*                     FilterAt(int32 index);
-                       MailFilter*                     RemoveFilter(int32 
index);
-                       bool                            
RemoveFilter(MailFilter* filter);
+                       void                            ResetProgress(const 
char* message = NULL);
 
+                       // Filter notifications
                        void                            
NotifyNewMessagesToFetch(int32 nMessages);
                        void                            
NotifyHeaderFetched(const entry_ref& ref,
                                                                        BFile* 
mail);
@@ -113,35 +92,29 @@ public:
                        void                            NotifyMessageSent(const 
entry_ref& ref,
                                                                        BFile* 
mail);
 
-                       //! mail storage operations
-       virtual status_t                        MoveMessage(const entry_ref& 
ref,
-                                                                       
BDirectory& dir);
-       virtual status_t                        DeleteMessage(const entry_ref& 
ref);
+                       void                            LoadFilters(
+                                                                       const 
BMailProtocolSettings& settings);
 
-       virtual void                            FileRenamed(const entry_ref& 
from,
-                                                                       const 
entry_ref& to);
-       virtual void                            FileDeleted(const node_ref& 
node);
+private:
+                       BMailFilter*            _LoadFilter(BMailAddOnSettings* 
filterSettings);
 
 protected:
-                       void                            
LoadFilters(MailAddonSettings& settings);
-
-                       BMailAccountSettings    fAccountSettings;
+                       const BMailAccountSettings fAccountSettings;
                        BMailNotifier*          fMailNotifier;
 
 private:
-                       MailFilter*                     
_LoadFilter(AddonSettings* filterSettings);
-
-                       MailProtocolThread*     fProtocolThread;
-                       BObjectList<BHandler>   fHandlerList;
-                       BObjectList<MailFilter> fFilterList;
-                       std::map<entry_ref, image_id>   fFilterImages;
+                       BObjectList<BMailFilter> fFilterList;
+                       std::map<entry_ref, image_id> fFilterImages;
 };
 
 
-class InboundProtocol : public MailProtocol {
+class BInboundMailProtocol : public BMailProtocol {
 public:
-                                                               
InboundProtocol(BMailAccountSettings* settings);
-       virtual                                         ~InboundProtocol();
+                                                               
BInboundMailProtocol(
+                                                                       const 
BMailAccountSettings& settings);
+       virtual                                         ~BInboundMailProtocol();
+
+       virtual void                            MessageReceived(BMessage* 
message);
 
        virtual status_t                        SyncMessages() = 0;
        virtual status_t                        FetchBody(const entry_ref& ref) 
= 0;
@@ -149,78 +122,33 @@ public:
                                                                        
read_flags flag = B_READ);
        virtual status_t                        DeleteMessage(const entry_ref& 
ref) = 0;
        virtual status_t                        AppendMessage(const entry_ref& 
ref);
-};
-
-
-class OutboundProtocol : public MailProtocol {
-public:
-                                                               
OutboundProtocol(
-                                                                       
BMailAccountSettings* settings);
-       virtual                                         ~OutboundProtocol();
-
-       virtual status_t                        SendMessages(const 
std::vector<entry_ref>&
-                                                                       mails, 
size_t totalBytes) = 0;
-};
-
-
-class MailProtocolThread : public BLooper {
-public:
-                                                               
MailProtocolThread(MailProtocol* protocol);
-       virtual void                            MessageReceived(BMessage* 
message);
-
-                       MailProtocol*           Protocol() { return 
fMailProtocol; }
-
-                       void                            SetStopNow();
-                       /*! These function post a message to the loop to 
trigger the action.
-                       */
-                       void                            TriggerFileMove(const 
entry_ref& ref,
-                                                                       
BDirectory& dir);
-                       void                            
TriggerFileDeletion(const entry_ref& ref);
 
-                       void                            
TriggerFileRenamed(const entry_ref& from,
-                                                                       const 
entry_ref& to);
-                       void                            
TriggerFileDeleted(const node_ref& node);
-private:
-                       MailProtocol*           fMailProtocol;
+protected:
+                       void                            
NotiyMailboxSynchronized(status_t status);
 };
 
 
-class InboundProtocolThread : public MailProtocolThread {
+class BOutboundMailProtocol : public BMailProtocol {
 public:
-                                                               
InboundProtocolThread(
-                                                                       
InboundProtocol* protocol);
-                                                               
~InboundProtocolThread();
+                                                               
BOutboundMailProtocol(
+                                                                       const 
BMailAccountSettings& settings);
+       virtual                                         
~BOutboundMailProtocol();
 
-                       void                            
MessageReceived(BMessage* message);
-
-                       void                            SyncMessages();
-                       void                            FetchBody(const 
entry_ref& ref,
-                                                                       
BMessenger* listener = NULL);
-                       void                            MarkMessageAsRead(const 
entry_ref& ref,
-                                                                       
read_flags flag = B_READ);
-                       void                            DeleteMessage(const 
entry_ref& ref);
-                       void                            AppendMessage(const 
entry_ref& ref);
-private:
-                       void                            
_NotiyMailboxSynced(status_t status);
+       virtual void                            MessageReceived(BMessage* 
message);
 
-                       InboundProtocol*        fProtocol;
+       virtual status_t                        SendMessages(
+                                                                       const 
std::vector<entry_ref>& mails,
+                                                                       size_t 
totalBytes) = 0;
 };
 
 
-class OutboundProtocolThread : public MailProtocolThread {
-public:
-                                                               
OutboundProtocolThread(
-                                                                       
OutboundProtocol* protocol);
-                                                               
~OutboundProtocolThread();
-
-                       void                            
MessageReceived(BMessage* message);
-
-                       void                            SendMessages(const 
std::vector<entry_ref>&
-                                                                       mails, 
size_t totalBytes);
-
-private:
-                       OutboundProtocol*       fProtocol;
-};
+// Your protocol needs to export these hooks in order to be picked up
+extern "C" _EXPORT BInboundMailProtocol* instantiate_inbound_protocol(
+       const BMailAccountSettings& settings);
+extern "C" _EXPORT BOutboundMailProtocol* instantiate_outbound_protocol(
+       const BMailAccountSettings& settings);
+extern "C" _EXPORT BView* instantiate_protocol_config_panel(
+       BMailAccountSettings& settings);
 
 
 #endif // MAIL_PROTOCOL_H
diff --git a/headers/os/add-ons/mail_daemon/ProtocolConfigView.h 
b/headers/os/add-ons/mail_daemon/ProtocolConfigView.h
index 045c257..7d79b81 100644
--- a/headers/os/add-ons/mail_daemon/ProtocolConfigView.h
+++ b/headers/os/add-ons/mail_daemon/ProtocolConfigView.h
@@ -1,9 +1,11 @@
-/* ProtocolConfigView - the standard config view for all protocols
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
-#ifndef ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
-#define ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
+/*
+ * Copyright 2004-2012, Haiku Inc. All rights reserved.
+ * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _PROTOCOL_CONFIG_VIEW_H
+#define _PROTOCOL_CONFIG_VIEW_H
 
 
 #include <CheckBox.h>
@@ -11,19 +13,29 @@
 #include <TextControl.h>
 #include <View.h>
 
-#include "MailSettings.h"
+#include <MailSettings.h>
+
+
+class BCheckBox;
+class BGridLayout;
+class BMenuField;
+class BTextControl;
+
+
+namespace BPrivate {
 
 
 class BodyDownloadConfig : public BView {
 public:
                                                                
BodyDownloadConfig();
 
-                       void                            
SetTo(MailAddonSettings& settings);
+                       void                            
SetTo(BMailProtocolSettings& settings);
 
-                       void                            
MessageReceived(BMessage *msg);
+                       void                            
MessageReceived(BMessage* message);
                        void                            AttachedToWindow();
-                       void                            GetPreferredSize(float 
*width, float *height);
-                       status_t                        Archive(BMessage *into, 
bool) const;
+                       void                            GetPreferredSize(float* 
width, float* height);
+                       status_t                        Archive(BMessage* into, 
bool deep = true) const;
+
 private:
                        BTextControl*           fSizeBox;
                        BCheckBox*                      fPartialBox;
@@ -31,39 +43,64 @@ private:
 };
 
 
-typedef enum {
-       B_MAIL_PROTOCOL_HAS_AUTH_METHODS                = 1,
+enum mail_protocol_config_options {
+       B_MAIL_PROTOCOL_HAS_AUTH_METHODS                        = 1,
        B_MAIL_PROTOCOL_HAS_FLAVORS                             = 2,
-       B_MAIL_PROTOCOL_HAS_USERNAME                    = 4,
-       B_MAIL_PROTOCOL_HAS_PASSWORD                    = 8,
-       B_MAIL_PROTOCOL_HAS_HOSTNAME                    = 16,
-       B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER = 32,
-       B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD = 64
-} b_mail_protocol_config_options;
+       B_MAIL_PROTOCOL_HAS_USERNAME                            = 4,
+       B_MAIL_PROTOCOL_HAS_PASSWORD                            = 8,
+       B_MAIL_PROTOCOL_HAS_HOSTNAME                            = 16,
+       B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER        = 32,
+       B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD                        = 64
+};
 
 
-class BMailProtocolConfigView : public BView {
+class MailProtocolConfigView : public BView {
 public:
-                                                               
BMailProtocolConfigView(uint32 options_mask
-                                                                       = 
B_MAIL_PROTOCOL_HAS_FLAVORS
-                                                                       | 
B_MAIL_PROTOCOL_HAS_USERNAME
-                                                                       | 
B_MAIL_PROTOCOL_HAS_PASSWORD
-                                                                       | 
B_MAIL_PROTOCOL_HAS_HOSTNAME);
-       virtual                                         
~BMailProtocolConfigView();
-               
-                       void                            
SetTo(MailAddonSettings& archive);
-               
-                       void                            AddFlavor(const char 
*label);
-                       void                            AddAuthMethod(const 
char *label,
+                                                               
MailProtocolConfigView(uint32 optionsMask
+                                                                               
= B_MAIL_PROTOCOL_HAS_FLAVORS
+                                                                               
        | B_MAIL_PROTOCOL_HAS_USERNAME
+                                                                               
        | B_MAIL_PROTOCOL_HAS_PASSWORD
+                                                                               
        | B_MAIL_PROTOCOL_HAS_HOSTNAME);
+       virtual                                         
~MailProtocolConfigView();
+
+                       void                            
SetTo(BMailProtocolSettings& settings);
+
+                       void                            AddFlavor(const char* 
label);
+                       void                            AddAuthMethod(const 
char* label,
                                                                        bool 
needUserPassword = true);
 
-       virtual status_t                        Archive(BMessage *into, bool 
deep = true) const;
-       virtual void                            GetPreferredSize(float *width, 
float *height);
+                       BGridLayout*            Layout() const;
+
+       virtual status_t                        Archive(BMessage* into, bool 
deep = true) const;
+
        virtual void                            AttachedToWindow();
-       virtual void                            MessageReceived(BMessage *msg);
-       
+       virtual void                            MessageReceived(BMessage* 
message);
+
+private:
+                       BTextControl*           _AddTextControl(BGridLayout* 
layout,
+                                                                       const 
char* name, const char* label);
+                       BMenuField*                     
_AddMenuField(BGridLayout* layout,
+                                                                       const 
char* name, const char* label);
+                       void                            
_StoreIndexOfMarked(BMessage& message,
+                                                                       const 
char* name, BMenuField* field) const;
+                       void                            
_StoreCheckBox(BMessage& message,
+                                                                       const 
char* name,
+                                                                       
BCheckBox* checkBox) const;
+                       void                            
_SetCredentialsEnabled(bool enabled);
+
 private:
+                       BTextControl*           fHostControl;
+                       BTextControl*           fUserControl;
+                       BTextControl*           fPasswordControl;
+                       BMenuField*                     fFlavorField;
+                       BMenuField*                     fAuthenticationField;
+                       BCheckBox*                      fLeaveOnServerCheckBox;
+                       BCheckBox*                      
fRemoveFromServerCheckBox;
                        BodyDownloadConfig*     fBodyDownloadConfig;
 };
 
-#endif /* ZOIDBERG_PROTOCOL_CONFIG_VIEW_H */
+
+}      // namespace BPrivate
+
+
+#endif /* _PROTOCOL_CONFIG_VIEW_H */
diff --git a/headers/os/mail/MailSettings.h b/headers/os/mail/MailSettings.h
index 42ab039f..c119f73 100644
--- a/headers/os/mail/MailSettings.h
+++ b/headers/os/mail/MailSettings.h
@@ -1,6 +1,8 @@
 /*
+ * Copyright 2004-2012, Haiku Inc. All rights reserved.
  * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
  * Copyright 2011 Clemens Zeidler.
+ *
  * Distributed under the terms of the MIT License.
  */
 #ifndef MAIL_SETTINGS_H
@@ -77,49 +79,49 @@ private:
 };
 
 
-class AddonSettings {
+class BMailAddOnSettings : public BMessage {
 public:
-                                                               AddonSettings();
+                                                               
BMailAddOnSettings();
+       virtual                                         ~BMailAddOnSettings();
 
-                       bool                            Load(const BMessage& 
message);
-                       bool                            Save(BMessage& message);
+       virtual status_t                        Load(const BMessage& message);
+       virtual status_t                        Save(BMessage& message);
 
-                       void                            SetAddonRef(const 
entry_ref& ref);
-       const   entry_ref&                      AddonRef() const;
+                       void                            SetAddOnRef(const 
entry_ref& ref);
+                       const entry_ref&        AddOnRef() const;
 
-       const   BMessage&                       Settings() const;
-                       BMessage&                       EditSettings();
-
-                       bool                            HasBeenModified();
+       virtual bool                            HasBeenModified() const;
 
 private:
-                       BMessage                        fSettings;
-                       entry_ref                       fAddonRef;
-
-                       bool                            fModified;
+                       BMessage                        fOriginalSettings;
+                       entry_ref                       fRef;
+                       entry_ref                       fOriginalRef;
 };
 
 
-class MailAddonSettings : public AddonSettings {
+class BMailProtocolSettings : public BMailAddOnSettings {
 public:
-                       bool                            Load(const BMessage& 
message);
-                       bool                            Save(BMessage& message);
+                                                               
BMailProtocolSettings();
+       virtual                                         
~BMailProtocolSettings();
 
-                       int32                           CountFilterSettings();
+       virtual status_t                        Load(const BMessage& message);
+       virtual status_t                        Save(BMessage& message);
+
+                       int32                           CountFilterSettings() 
const;
                        int32                           AddFilterSettings(const 
entry_ref* ref = NULL);
-                       bool                            
RemoveFilterSettings(int32 index);
+                       void                            
RemoveFilterSettings(int32 index);
                        bool                            
MoveFilterSettings(int32 from, int32 to);
-                       AddonSettings*          FilterSettingsAt(int32 index);
+                       BMailAddOnSettings*     FilterSettingsAt(int32 index) 
const;
 
-                       bool                            HasBeenModified();
+       virtual bool                            HasBeenModified() const;
 
 private:
-                       std::vector<AddonSettings>      fFiltersSettings;
+                       BObjectList<BMailAddOnSettings> fFiltersSettings;
 };
 
 
 class BMailAccountSettings {
-       public:
+public:
                                                                
BMailAccountSettings();
                                                                
BMailAccountSettings(BEntry account);
                                                                
~BMailAccountSettings();
@@ -127,24 +129,26 @@ class BMailAccountSettings {
                        status_t                        InitCheck() { return 
fStatus; }
 
                        void                            SetAccountID(int32 id);
-                       int32                           AccountID();
+                       int32                           AccountID() const;
 
                        void                            SetName(const char* 
name);
-       const   char*                           Name() const;
+                       const char*                     Name() const;
 
                        void                            SetRealName(const char* 
realName);
-       const   char*                           RealName() const;
+                       const char*                     RealName() const;
 
                        void                            SetReturnAddress(const 
char* returnAddress);
-       const   char*                           ReturnAddress() const;
+                       const char*                     ReturnAddress() const;
 
-                       bool                            SetInboundAddon(const 
char* name);
-                       bool                            SetOutboundAddon(const 
char* name);
-       const   entry_ref&                      InboundPath() const;
-       const   entry_ref&                      OutboundPath() const;
+                       bool                            SetInboundAddOn(const 
char* name);
+                       bool                            SetOutboundAddOn(const 
char* name);
+                       const entry_ref&        InboundAddOnRef() const;
+                       const entry_ref&        OutboundAddOnRef() const;
 
-                       MailAddonSettings&      InboundSettings();
-                       MailAddonSettings&      OutboundSettings();
+                       BMailProtocolSettings& InboundSettings();
+                       const BMailProtocolSettings& InboundSettings() const;
+                       BMailProtocolSettings& OutboundSettings();
+                       const BMailProtocolSettings& OutboundSettings() const;
 
                        bool                            HasInbound();
                        bool                            HasOutbound();
@@ -158,9 +162,9 @@ class BMailAccountSettings {
                        status_t                        Save();
                        status_t                        Delete();
 
-                       bool                            HasBeenModified();
+                       bool                            HasBeenModified() const;
 
-       const   BEntry&                         AccountFile();
+                       const BEntry&           AccountFile() const;
 
 private:
                        status_t                        
_CreateAccountFilePath();
@@ -175,8 +179,8 @@ private:
                        BString                         fRealName;
                        BString                         fReturnAdress;
 
-                       MailAddonSettings       fInboundSettings;
-                       MailAddonSettings       fOutboundSettings;
+                       BMailProtocolSettings fInboundSettings;
+                       BMailProtocolSettings fOutboundSettings;
 
                        bool                            fInboundEnabled;
                        bool                            fOutboundEnabled;
diff --git a/headers/private/mail/FileConfigView.h 
b/headers/private/mail/FileConfigView.h
index 42b30e3..40cc402 100644
--- a/headers/private/mail/FileConfigView.h
+++ b/headers/private/mail/FileConfigView.h
@@ -1,9 +1,11 @@
-#ifndef FILE_CONFIG_VIEW
-#define FILE_CONFIG_VIEW
-/* FileConfigView - a file configuration view for filters
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
+/*
+ * Copyright 2004-2012, Haiku, Inc. All rights reserved.
+ * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FILE_CONFIG_VIEW_H
+#define _FILE_CONFIG_VIEW_H
 
 
 #include <View.h>
@@ -13,45 +15,56 @@
 class BTextControl;
 class BButton;
 
-class BFileControl : public BView
-{
-       public:
-               BFileControl(BRect rect,const char *name,const char 
*label,const char *pathOfFile = NULL,uint32 flavors = B_DIRECTORY_NODE);
-               ~BFileControl();
 
-               virtual void AttachedToWindow();
-               virtual void MessageReceived(BMessage *msg);
+namespace BPrivate {
 
-               void SetText(const char *pathOfFile);
-               const char *Text() const;
 
-               void SetEnabled(bool enabled);
+class FileControl : public BView {
+public:
+                                                               
FileControl(const char* name, const char* label,
+                                                                       const 
char* pathOfFile = NULL,
+                                                                       uint32 
flavors = B_DIRECTORY_NODE);
+       virtual                                         ~FileControl();
 
-               virtual void GetPreferredSize(float *width, float *height);
+       virtual void                            AttachedToWindow();
+       virtual void                            MessageReceived(BMessage* 
message);
 
-       private:
-               BTextControl    *fText;
-               BButton                 *fButton;
+                       void                            SetText(const char* 
pathOfFile);
+                       const char*                     Text() const;
 
-               BFilePanel              *fPanel;
-               
-               uint32                  _reserved[5];
+                       void                            SetEnabled(bool 
enabled);
+
+private:
+                       BTextControl*           fText;
+                       BButton*                        fButton;
+
+                       BFilePanel*                     fPanel;
+
+                       uint32                          _reserved[5];
 };
 
-class BMailFileConfigView : public BFileControl
-{
-       public:
-               BMailFileConfigView(const char *label,const char *name,bool 
useMeta = false,const char *defaultPath = NULL,uint32 flavors = 
B_DIRECTORY_NODE);
 
-               void SetTo(const BMessage *archive, BMessage *metadata);
-               virtual status_t Archive(BMessage *into, bool deep = true) 
const;
+class MailFileConfigView : public FileControl {
+public:
+                                                               
MailFileConfigView(const char* label,
+                                                                       const 
char* name, bool useMeta = false,
+                                                                       const 
char* defaultPath = NULL,
+                                                                       uint32 
flavors = B_DIRECTORY_NODE);
+
+                       void                            SetTo(const BMessage* 
archive,
+                                                                       
BMessage* metadata);
+       virtual status_t                        Archive(BMessage* into, bool 
deep = true) const;
 
-       private:
-               BMessage        *fMeta;
-               bool            fUseMeta;
-               const char      *fName;
+private:
+                       BMessage*                       fMeta;
+                       bool                            fUseMeta;
+                       const char*                     fName;
 
-               uint32                  _reserved[5];
+                       uint32                          _reserved[5];
 };
 
-#endif /* FILE_CONFIG_VIEW */
+
+}      // namespace BPrivate
+
+
+#endif // _FILE_CONFIG_VIEW_H
diff --git 
a/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp 
b/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp
index 03e8487..b4f707d 100644
--- a/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp
+++ b/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp
@@ -1,199 +1,231 @@
-/* RuleFilter's config view - performs action depending on matching a header 
value
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
+/*
+ * Copyright 2004-2012, Haiku, Inc. All rights reserved.
+ * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
 
 
 #include <stdio.h>
 
 #include <Catalog.h>
+#include <LayoutBuilder.h>
+#include <MailFilter.h>
+#include <MailSettings.h>
 #include <MenuField.h>
-#include <PopUpMenu.h>
+#include <MenuItem.h>
 #include <Message.h>
+#include <PopUpMenu.h>
 #include <TextControl.h>
-#include <MenuItem.h>
 
-#include <MailAddon.h>
 #include <FileConfigView.h>
-#include <MailSettings.h>
+
+#include "RuleFilter.h"
 
 
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "ConfigView"
 
 
-const uint32 kMsgActionMoveTo = 'argm';
-const uint32 kMsgActionDelete = 'argd';
-const uint32 kMsgActionSetTo = 'args';
-const uint32 kMsgActionReplyWith = 'argr';
-const uint32 kMsgActionSetRead = 'arge';
+using namespace BPrivate;
+
+
+static const uint32 kMsgActionChanged = 'actC';
 
 
 class RuleFilterConfig : public BView {
-       public:
-               RuleFilterConfig(const BMessage *settings);
-
-               virtual void MessageReceived(BMessage *msg);
-               virtual void AttachedToWindow();
-               virtual status_t Archive(BMessage *into, bool deep = true) 
const;
-               virtual void GetPreferredSize(float *width, float *height);
-       private:
-               BTextControl *attr, *regex;
-               BFileControl *arg;
-               BPopUpMenu *menu, *outbound;
-               BMenuField *outbound_field;
-               int staging;
-               int32 chain;
+public:
+                                                               
RuleFilterConfig(const BMessage& settings);
+
+       virtual void                            MessageReceived(BMessage* 
message);
+       virtual void                            AttachedToWindow();
+       virtual status_t                        Archive(BMessage* into, bool 
deep = true) const;
+
+private:
+                       void                            _SetVisible(BView* 
view, bool visible);
+
+private:
+                       BTextControl*           fAttributeControl;
+                       BTextControl*           fRegexControl;
+                       FileControl*            fFileControl;
+                       BTextControl*           fFlagsControl;
+                       BPopUpMenu*                     fActionMenu;
+                       BPopUpMenu*                     fAccountMenu;
+                       BMenuField*                     fAccountField;
+                       int                                     fAction;
+                       int32                           fAccountID;
 };
 
 
-RuleFilterConfig::RuleFilterConfig(const BMessage *settings)
+RuleFilterConfig::RuleFilterConfig(const BMessage& settings)
        :
-       BView(BRect(0,0,260,85),"rulefilter_config", B_FOLLOW_LEFT | 
B_FOLLOW_TOP,
-               0), menu(NULL)
+       BView("rulefilter_config", 0),
+       fActionMenu(NULL)
 {
        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-       attr = new BTextControl(BRect(5,5,100,20),"attr", B_TRANSLATE("If"),
-               B_TRANSLATE("header (e.g. Subject)"),NULL);
-       attr->SetDivider(be_plain_font->StringWidth(B_TRANSLATE("If"))+ 4);
-       if (settings->HasString("attribute"))
-               attr->SetText(settings->FindString("attribute"));
-       AddChild(attr);
-
-       regex = new BTextControl(BRect(104,5,255,20),"attr", B_TRANSLATE("has"),
+
+       if (settings.HasInt32("do_what"))
+               fAction = settings.FindInt32("do_what");
+       else
+               fAction = -1;
+
+       fAttributeControl = new BTextControl("attr", B_TRANSLATE("If"),
+               B_TRANSLATE("header (e.g. Subject)"), NULL);
+       if (settings.HasString("attribute"))
+               fAttributeControl->SetText(settings.FindString("attribute"));
+
+       fRegexControl = new BTextControl("regex", B_TRANSLATE("has"),
                B_TRANSLATE("value (use REGEX: in from of regular expressions 
like "
-               "*spam*)"), NULL);
-       regex->SetDivider(be_plain_font->StringWidth(B_TRANSLATE("has")) + 4);
-       if (settings->HasString("regex"))
-               regex->SetText(settings->FindString("regex"));
-       AddChild(regex);
+                       "*spam*)"), NULL);
+       if (settings.HasString("regex"))
+               fRegexControl->SetText(settings.FindString("regex"));
 
-       arg = new BFileControl(BRect(5,55,255,80),"arg", NULL,
+       fFileControl = new FileControl("arg", NULL,
                B_TRANSLATE("this field is based on the action"));
-       if (BControl *control = (BControl *)arg->FindView("select_file"))
+       if (BControl* control = 
(BControl*)fFileControl->FindView("select_file"))
                control->SetEnabled(false);
-       if (settings->HasString("argument"))
-               arg->SetText(settings->FindString("argument"));
+       if (fAction == ACTION_MOVE_TO && settings.HasString("argument"))
+               fFileControl->SetText(settings.FindString("argument"));
 
-       outbound = new BPopUpMenu(B_TRANSLATE("<Choose account>"));
+       fFlagsControl = new BTextControl("flags", NULL, NULL);
+       if (fAction == ACTION_SET_FLAGS_TO && settings.HasString("argument"))
+               fFlagsControl->SetText(settings.FindString("argument"));
 
-       if (settings->HasInt32("do_what"))
-               staging = settings->FindInt32("do_what");
-       else
-               staging = -1;
-       if (staging == 3)
-               chain = settings->FindInt32("argument");
+       // Populate account menu
+
+       fAccountMenu = new BPopUpMenu(B_TRANSLATE("<Choose account>"));
+
+       if (fAction == ACTION_REPLY_WITH)
+               fAccountID = settings.FindInt32("argument");
        else
-               chain = -1;
-       printf("Chain: %ld\n",chain);
+               fAccountID = -1;
 
        BMailAccounts accounts;
        for (int32 i = 0; i < accounts.CountAccounts(); i++) {
                BMailAccountSettings* account = accounts.AccountAt(i);
                if (!account->HasOutbound())
                        continue;
-               BMenuItem *item = new BMenuItem(account->Name(),
-                       new BMessage(account->AccountID()));
-               outbound->AddItem(item);
-               if (account->AccountID() == chain)
+
+               BMessage* message = new BMessage();
+               message->AddInt32("account id", account->AccountID());
+
+               BMenuItem* item = new BMenuItem(account->Name(), message);
+               fAccountMenu->AddItem(item);
+               if (account->AccountID() == fAccountID)
                        item->SetMarked(true);
        }
-}
 
+       fAccountField = new BMenuField("reply", "Foo", fAccountMenu);
+       if (fAction >= 0) {
+               BMenuItem* item = fActionMenu->ItemAt(fAction);
+               if (item != NULL) {
+                       item->SetMarked(true);
+                       MessageReceived(item->Message());
+               }
+       }
 
-void RuleFilterConfig::AttachedToWindow() {
-       if (menu != NULL)
-               return; // We switched back from another tab
-
-       menu = new BPopUpMenu(B_TRANSLATE("<Choose action>"));
-       menu->AddItem(new BMenuItem(B_TRANSLATE("Move to"),
-               new BMessage(kMsgActionMoveTo)));
-       menu->AddItem(new BMenuItem(B_TRANSLATE("Set flags to"),
-               new BMessage(kMsgActionSetTo)));
-       menu->AddItem(new BMenuItem(B_TRANSLATE("Delete message"),
-               new BMessage(kMsgActionDelete)));
-       menu->AddItem(new BMenuItem(B_TRANSLATE("Reply with"),
-               new BMessage(kMsgActionReplyWith)));
-       menu->AddItem(new BMenuItem(B_TRANSLATE("Set as read"),
-               new BMessage(kMsgActionSetRead)));
-       menu->SetTargetForItems(this);
-
-       BMenuField *field = new BMenuField(BRect(5,30,210,50),"do_what",
-               B_TRANSLATE("Then"), menu);
-       field->ResizeToPreferred();
-       field->SetDivider(be_plain_font->StringWidth(B_TRANSLATE("Then")) + 8);
-       AddChild(field);
-
-       outbound_field = new 
BMenuField(BRect(5,55,255,80),"reply","Foo",outbound);
-       outbound_field->ResizeToPreferred();
-       outbound_field->SetDivider(0);
-       if (staging >= 0) {
-               menu->ItemAt(staging)->SetMarked(true);
-               MessageReceived(menu->ItemAt(staging)->Message());
-       } else {
-               AddChild(arg);
+       // Popuplate action menu
+
+       fActionMenu = new BPopUpMenu(B_TRANSLATE("<Choose action>"));
+
+       const struct {
+               rule_action     action;
+               const char*     label;
+       } kActions[] = {
+               {ACTION_MOVE_TO, B_TRANSLATE("Move to")},
+               {ACTION_SET_FLAGS_TO, B_TRANSLATE("Set flags to")},
+               {ACTION_DELETE_MESSAGE, B_TRANSLATE("Delete message")},
+               {ACTION_REPLY_WITH, B_TRANSLATE("Reply with")},
+               {ACTION_SET_AS_READ, B_TRANSLATE("Set as read")},
+       };
+       for (size_t i = 0; i < sizeof(kActions) / sizeof(kActions[0]); i++) {
+               BMessage* message = new BMessage(kMsgActionChanged);
+               message->AddInt32("action", (int32)kActions[i].action);
+
+               fActionMenu->AddItem(new BMenuItem(kActions[i].label, message));
        }
+
+       BMenuField* actionField = new BMenuField("do_what", B_TRANSLATE("Then"),
+               fActionMenu);
+
+       // Build layout
+
+       BLayoutBuilder::Group<>(this, B_VERTICAL)
+               .AddGroup(B_HORIZONTAL)
+                       .Add(fAttributeControl->CreateLabelLayoutItem())
+                       .Add(fAttributeControl->CreateTextViewLayoutItem())
+                       .Add(fRegexControl->CreateLabelLayoutItem())
+                       .Add(fRegexControl->CreateTextViewLayoutItem())
+               .End()
+               .AddGroup(B_HORIZONTAL)
+                       .Add(actionField->CreateLabelLayoutItem())
+                       .Add(actionField->CreateMenuBarLayoutItem())
+               .End()
+               .Add(fFileControl)
+               .Add(fAccountField);
+}
+
+
+void
+RuleFilterConfig::AttachedToWindow()
+{
+       fActionMenu->SetTargetForItems(this);
 }
 
-status_t RuleFilterConfig::Archive(BMessage *into, bool deep) const {
+
+status_t
+RuleFilterConfig::Archive(BMessage *into, bool deep) const
+{
        into->MakeEmpty();
-       into->AddInt32("do_what",menu->IndexOf(menu->FindMarked()));
-       into->AddString("attribute",attr->Text());
-       into->AddString("regex",regex->Text());
-       if (into->FindInt32("do_what") == 3)
-               into->AddInt32("argument", 
outbound->FindMarked()->Message()->what);
-       else
-               into->AddString("argument",arg->Text());
+       into->AddInt32("do_what", 
fActionMenu->IndexOf(fActionMenu->FindMarked()));
+       into->AddString("attribute", fAttributeControl->Text());
+       into->AddString("regex", fRegexControl->Text());
+       if (into->FindInt32("do_what") == ACTION_REPLY_WITH) {
+               BMenuItem* item = fAccountMenu->FindMarked();
+               if (item != NULL) {
+                       into->AddInt32("argument",
+                               item->Message()->FindInt32("account id"));
+               }
+       } else
+               into->AddString("argument", fFileControl->Text());
 
        return B_OK;
 }
 
-void RuleFilterConfig::MessageReceived(BMessage *msg) {
-       switch (msg->what)
-       {
-               case kMsgActionMoveTo:
-               case kMsgActionSetTo:
-                       if (arg->FindView("file_path"))
-                               arg->SetEnabled(true);
-                       if (BControl *control = (BControl 
*)arg->FindView("select_file"))
-                               control->SetEnabled(msg->what == 
kMsgActionMoveTo);
-                       if (arg->Parent() == NULL) {
-                               outbound_field->RemoveSelf();
-                               AddChild(arg);
-                       }
-                       break;
-               case kMsgActionDelete:
-                       arg->SetEnabled(false);
-                       if (arg->Parent() == NULL) {
-                               outbound_field->RemoveSelf();
-                               AddChild(arg);
-                       }
-                       break;
-               case kMsgActionReplyWith:
-                       if (outbound->Parent() == NULL) {
-                               arg->RemoveSelf();
-                               AddChild(outbound_field);
-                       }
-                       break;
-               case kMsgActionSetRead:
-                       arg->SetEnabled(false);
-                       if (arg->Parent() == NULL) {
-                               outbound_field->RemoveSelf();
-                               AddChild(arg);
-                       }
+
+void
+RuleFilterConfig::MessageReceived(BMessage* message)
+{
+       switch (message->what) {
+               case kMsgActionChanged:
+                       fAction = message->FindInt32("action");
+
+                       _SetVisible(fFileControl, fAction == ACTION_MOVE_TO);
+                       _SetVisible(fFlagsControl, fAction == 
ACTION_SET_FLAGS_TO);
+                       _SetVisible(fAccountField, fAction == 
ACTION_REPLY_WITH);
                        break;
+
                default:
-                       BView::MessageReceived(msg);
+                       BView::MessageReceived(message);
        }
 }
 
-void RuleFilterConfig::GetPreferredSize(float *width, float *height) {
-       *width = 260;
-       *height = 55;
+
+void
+RuleFilterConfig::_SetVisible(BView* view, bool visible)
+{
+       while (visible && view->IsHidden(view))
+               view->Show();
+       while (!visible && !view->IsHidden(view))
+               view->Hide();
 }
 
 
-BView* instantiate_filter_config_panel(AddonSettings& settings)
+// #pragma mark -
+
+
+BView*
+instantiate_filter_config_panel(BMailAddOnSettings& settings)
 {
-       return new RuleFilterConfig(&settings.Settings());
+       return new RuleFilterConfig(settings);
 }
diff --git 
a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp 
b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp
index 512a002..c90911d 100644
--- a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp
+++ b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp
@@ -1,7 +1,12 @@
-/* Match Header - performs action depending on matching a header value
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
+/*
+ * Copyright 2004-2012, Haiku, Inc. All rights reserved.
+ * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
+
+
+//!    Performs action depending on matching a header value.
 
 
 #include "RuleFilter.h"
@@ -22,38 +27,46 @@
 #define B_TRANSLATION_CONTEXT "RuleFilter"
 
 
-RuleFilter::RuleFilter(MailProtocol& protocol, AddonSettings* addonSettings)
+RuleFilter::RuleFilter(BMailProtocol& protocol, BMailAddOnSettings* settings)
        :
-       MailFilter(protocol, addonSettings)
+       BMailFilter(protocol, settings)
 {
-       const BMessage* settings = &addonSettings->Settings();
        // attribute is adapted to our "capitalize-each-word-in-the-header" 
policy
        settings->FindString("attribute", &fAttribute);
        fAttribute.CapitalizeEachWord();
 
-       BString regex;
-       settings->FindString("regex", &regex);
-       
-       int32 index = regex.FindFirst("REGEX:");
+       settings->FindString("regex", &fExpression);
+       int32 index = fExpression.FindFirst("REGEX:");
        if (index == B_ERROR || index > 0)
-               EscapeRegexTokens(regex);
+               EscapeRegexTokens(fExpression);
        else
-               regex.RemoveFirst("REGEX:");
-               
-       fMatcher.SetPattern(regex, false);
-       
-       settings->FindString("argument",&fArg);
-       settings->FindInt32("do_what",(long *)&fDoWhat);
-       if (fDoWhat == Z_SET_REPLY)
+               fExpression.RemoveFirst("REGEX:");
+
+       fMatcher.SetPattern(fExpression, false);
+
+       settings->FindString("argument", &fArg);
+       settings->FindInt32("do_what", (int32*)&fAction);
+       if (fAction == ACTION_REPLY_WITH)
                settings->FindInt32("argument", &fReplyAccount);
 }
 
 
+BString
+RuleFilter::DescriptiveName() const
+{
+       BString name(B_TRANSLATE("Match \"%attribute\" against \"%regex\""));
+       name.ReplaceAll("%attribute", fAttribute);
+       name.ReplaceAll("%regex", fExpression);
+       return name;
+}
+
+
 void
 RuleFilter::HeaderFetched(const entry_ref& ref, BFile* file)
 {
+       // That field doesn't exist? NO match
        if (fAttribute == "")
-               return; //----That field doesn't exist? NO match
+               return;
 
        attr_info info;
        if (file->GetAttrInfo("Subject", &info) != B_OK
@@ -68,72 +81,59 @@ RuleFilter::HeaderFetched(const entry_ref& ref, BFile* file)
        BString data = buffer;
        delete[] buffer;
 
-       if (!fMatcher.Match(data))
-               return; //-----There wasn't an error. We're just not supposed 
to do anything
-       
-       switch (fDoWhat) {
-               case Z_MOVE_TO:
+       if (!fMatcher.Match(data)) {
+               // We're not supposed to do anything
+               return;
+       }
+
+       switch (fAction) {
+               case ACTION_MOVE_TO:
                {
                        BDirectory dir(fArg);
-                       fMailProtocol.Looper()->TriggerFileMove(ref, dir);
+                       // TODO: move is currently broken!
+//                     fMailProtocol.Looper()->TriggerFileMove(ref, dir);
                        break;
                }
-               case Z_TRASH:
+               case ACTION_DELETE_MESSAGE:
                        // TODO trash!?
-                       fMailProtocol.Looper()->TriggerFileDeletion(ref);
+//                     fMailProtocol.Looper()->TriggerFileDeletion(ref);
                        break;
 
-               case Z_FLAG:
+               case ACTION_SET_FLAGS_TO:
                        file->WriteAttrString("MAIL:filter_flags", &fArg);
                        break;
 
-               case Z_SET_REPLY:
+               case ACTION_REPLY_WITH:
                        file->WriteAttr("MAIL:reply_with", B_INT32_TYPE, 0, 
&fReplyAccount,
-                               4);
+                               sizeof(int32));
                        break;
-               case Z_SET_READ:
+               case ACTION_SET_AS_READ:
                {
-                       InboundProtocol& protocol = 
(InboundProtocol&)fMailProtocol;
+                       BInboundMailProtocol& protocol
+                               = (BInboundMailProtocol&)fMailProtocol;
                        protocol.MarkMessageAsRead(ref, B_READ);
                        break;
                }
                default:
-                       fprintf(stderr,"Unknown do_what: 0x%04x!\n", fDoWhat);
+                       fprintf(stderr,"Unknown do_what: 0x%04x!\n", fAction);
        }
-       
+
        return;
 }
 
 
-BString
-descriptive_name()
-{
-       /*const char *attribute = NULL;
-       settings->FindString("attribute",&attribute);
-       const char *regex = NULL;
-       settings->FindString("regex",&regex);
-
-       if (!attribute || strlen(attribute) > 15)
-               return B_ERROR;
-       sprintf(buffer, "Match \"%s\"", attribute);
-
-       if (!regex)
-               return B_OK;
-
-       char reg[20];
-       strncpy(reg, regex, 16);
-       if (strlen(regex) > 15)
-               strcpy(reg + 15, "...");
+// #pragma mark -
 
-       sprintf(buffer + strlen(buffer), " against \"%s\"", reg);
 
-       return B_OK;*/
+BString
+filter_name()
+{
        return B_TRANSLATE("Rule filter");
 }
 
 
-MailFilter*
-instantiate_mailfilter(MailProtocol& protocol, AddonSettings* settings)
+BMailFilter*
+instantiate_filter(BMailProtocol& protocol, BMailAddOnSettings* settings)
 {
        return new RuleFilter(protocol, settings);
 }
diff --git a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.h 
b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.h
index 63a729b..2780a7c 100644
--- a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.h
+++ b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.h
@@ -1,40 +1,47 @@
-#ifndef ZOIDBERG_RULE_FILTER_H
-#define ZOIDBERG_RULE_FILTER_H
-/* RuleFilter - performs action depending on matching a header value
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
+/*
+ * Copyright 2004-2012, Haiku, Inc. All rights reserved.
+ * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef RULE_FILTER_H
+#define RULE_FILTER_H
 
 
 #include <Message.h>
 #include <List.h>
-#include <MailAddon.h>
+#include <MailFilter.h>
 
 #include "StringMatcher.h"
 
 
-typedef enum {
-       Z_MOVE_TO,
-       Z_FLAG,
-       Z_TRASH,
-       Z_SET_REPLY,
-       Z_SET_READ
-} z_mail_action_flags;
+enum rule_action {
+       ACTION_MOVE_TO,
+       ACTION_SET_FLAGS_TO,
+       ACTION_DELETE_MESSAGE,
+       ACTION_REPLY_WITH,
+       ACTION_SET_AS_READ
+};
 
 
-class RuleFilter : public MailFilter {
+class RuleFilter : public BMailFilter {
 public:
-                                                               
RuleFilter(MailProtocol& protocol,
-                                                                       
AddonSettings* settings);
-                       void                            HeaderFetched(const 
entry_ref& ref,
+                                                               
RuleFilter(BMailProtocol& protocol,
+                                                                       
BMailAddOnSettings* settings);
+
+       virtual BString                         DescriptiveName() const;
+
+       virtual void                            HeaderFetched(const entry_ref& 
ref,
                                                                        BFile* 
file);
 
 private:
-                       StringMatcher           fMatcher;
                        BString                         fAttribute;
+                       BString                         fExpression;
+                       StringMatcher           fMatcher;
                        BString                         fArg;
                        int32                           fReplyAccount;
-                       z_mail_action_flags     fDoWhat;
+                       rule_action                     fAction;
 };
 
-#endif /* ZOIDBERG_RULE_FILTER_H */
+
+#endif // RULE_FILTER_H
diff --git a/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.cpp 
b/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.cpp
index fa9e8fc..0f48672 100644
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.cpp
+++ b/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.cpp
@@ -1,20 +1,23 @@
-/* ConfigView - the configuration view for the Notifier filter
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
+/*
+ * Copyright 2004-2012, Haiku, Inc. All rights reserved.
+ * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
 
 
 #include "ConfigView.h"
 
 #include <Catalog.h>
 #include <CheckBox.h>
+#include <LayoutBuilder.h>
 #include <PopUpMenu.h>
 #include <MenuItem.h>
 #include <MenuField.h>
 #include <String.h>
 #include <Message.h>
 
-#include <MailAddon.h>
+#include <MailFilter.h>
 #include <MailSettings.h>
 
 
@@ -26,18 +29,12 @@ const uint32 kMsgNotifyMethod = 'nomt';
 
 
 ConfigView::ConfigView()
-       :       BView(BRect(0,0,10,10),"notifier_config",B_FOLLOW_LEFT | 
B_FOLLOW_TOP,0)
+       :
+       BView("notifier_config", 0)
 {
        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 
-       // determine font height
-       font_height fontHeight;
-       GetFontHeight(&fontHeight);
-       float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent
-               + fontHeight.leading) + 6;
-       
-       BRect frame(5,2,250,itemHeight + 2);
-       BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false);
+       BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
 
        const char *notifyMethods[] = {
                B_TRANSLATE("Beep"),
@@ -47,29 +44,26 @@ ConfigView::ConfigView()
                B_TRANSLATE("Central beep"),
                B_TRANSLATE("Log window")
        };
-       for (int32 i = 0,j = 1;i < 6;i++,j *= 2) {
+       for (int32 i = 0, j = 1;i < 6; i++, j *= 2) {
                menu->AddItem(new BMenuItem(notifyMethods[i],
                        new BMessage(kMsgNotifyMethod)));
        }
 
-       BMenuField *field = new BMenuField(frame,"notify", 
B_TRANSLATE("Method:"),
-               menu);
-       field->ResizeToPreferred();
-       field->SetDivider(field->StringWidth(B_TRANSLATE("Method:")) + 6);
-       AddChild(field);
-
-       ResizeToPreferred();
-}              
+       BLayoutBuilder::Group<>(this).Add(
+               new BMenuField("notify", B_TRANSLATE("Method:"), menu));
+}
 
 
-void ConfigView::AttachedToWindow()
+void
+ConfigView::AttachedToWindow()
 {
        if (BMenuField *field = dynamic_cast<BMenuField *>(FindView("notify")))
                field->Menu()->SetTargetForItems(this);
 }
 
 
-void ConfigView::SetTo(const BMessage *archive)
+void
+ConfigView::SetTo(const BMessage *archive)
 {
        int32 method = archive->FindInt32("notification_method");
        if (method < 0)
@@ -79,8 +73,7 @@ void ConfigView::SetTo(const BMessage *archive)
        if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) == NULL)
                return;
 
-       for (int32 i = field->Menu()->CountItems();i-- > 0;)
-       {
+       for (int32 i = field->Menu()->CountItems(); i-- > 0;) {
                BMenuItem *item = field->Menu()->ItemAt(i);
                item->SetMarked((method & (1L << i)) != 0);
        }
@@ -88,15 +81,15 @@ void ConfigView::SetTo(const BMessage *archive)
 }
 
 
-void ConfigView::UpdateNotifyText()
+void
+ConfigView::UpdateNotifyText()
 {
        BMenuField *field;
        if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) == NULL)
                return;
 
        BString label;
-       for (int32 i = field->Menu()->CountItems();i-- > 0;)
-       {
+       for (int32 i = field->Menu()->CountItems(); i-- > 0;) {
                BMenuItem *item = field->Menu()->ItemAt(i);
                if (!item->IsMarked())
                        continue;
@@ -111,16 +104,16 @@ void ConfigView::UpdateNotifyText()
 }
 
 
-void ConfigView::MessageReceived(BMessage *msg)
+void
+ConfigView::MessageReceived(BMessage *msg)
 {
-       switch (msg->what)
-       {
+       switch (msg->what) {
                case kMsgNotifyMethod:
                {
                        BMenuItem *item;
                        if (msg->FindPointer("source",(void **)&item) < B_OK)
                                break;
-                       
+
                        item->SetMarked(!item->IsMarked());
                        UpdateNotifyText();
                        break;
@@ -131,46 +124,34 @@ void ConfigView::MessageReceived(BMessage *msg)
 }
 
 
-status_t ConfigView::Archive(BMessage *into, bool) const
+status_t
+ConfigView::Archive(BMessage *into, bool /*deep*/) const
 {
        int32 method = 0;
 
        BMenuField *field;
-       if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) != NULL)
-       {
-               for (int32 i = field->Menu()->CountItems();i-- > 0;)
-               {
+       if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) != NULL) {
+               for (int32 i = field->Menu()->CountItems(); i-- > 0;) {
                        BMenuItem *item = field->Menu()->ItemAt(i);
                        if (item->IsMarked())
                                method |= 1L << i;
                }
        }
 
-       if (into->ReplaceInt32("notification_method",method) != B_OK)
-               into->AddInt32("notification_method",method);
+       if (into->ReplaceInt32("notification_method", method) != B_OK)
+               into->AddInt32("notification_method", method);
 
        return B_OK;
 }
 
-       
-void ConfigView::GetPreferredSize(float *width, float *height)
-{
-       *width = 258;
-       *height = ChildAt(0)->Bounds().Height() + 8;
-}
+
+// #pragma mark -
 
 
 BView*
-instantiate_filter_config_panel(AddonSettings& settings)
+instantiate_filter_config_panel(BMailAddOnSettings& settings)
 {
        ConfigView *view = new ConfigView();
-       view->SetTo(&settings.Settings());
+       view->SetTo(&settings);
        return view;
 }
-
-
-BString
-descriptive_name()
-{
-       return B_TRANSLATE("New mails notification");
-}
diff --git a/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.h 
b/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.h
index 33f433f..db95ef0 100644
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.h
+++ b/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.h
@@ -1,35 +1,39 @@
-#ifndef CONFIG_VIEW
-#define CONFIG_VIEW
-/* ConfigView - the configuration view for the Notifier filter
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
+/*
+ * Copyright 2004-2012, Haiku, Inc. All rights reserved.
+ * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef CONFIG_VIEW_H
+#define CONFIG_VIEW_H
 
 
 #include <View.h>
 
 
 enum {
-       do_beep = 1,
-       alert = 2,
-       blink_leds = 4,
-       big_doozy_alert = 8,
-       one_central_beep = 16,
-       log_window = 32
+       NOTIFY_BEEP                             = 1,
+       NOTIFY_ALERT                    = 2,
+       NOTIFY_BLINK_LEDS               = 4,
+       NOTIFY_CENTRAL_ALERT    = 8,
+       NOTIFY_CENTRAL_BEEP             = 16,
+       NOTIFY_NOTIFICATION             = 32
 };
 
-class ConfigView : public BView
-{
-       public:
-               ConfigView();
-               void SetTo(const BMessage *archive);
-               virtual status_t Archive(BMessage *into, bool deep = true) 
const;
 
-               virtual void AttachedToWindow();
-               virtual void MessageReceived(BMessage *msg);
-               virtual void GetPreferredSize(float *width, float *height);
+class ConfigView : public BView {
+public:
+                                                               ConfigView();
 
-               void UpdateNotifyText();
+                       void                            SetTo(const BMessage 
*archive);
+
+       virtual status_t                        Archive(BMessage *into, bool 
deep = true) const;
+
+       virtual void                            AttachedToWindow();
+       virtual void                            MessageReceived(BMessage *msg);
+
+                       void                            UpdateNotifyText();
 };
 
-#endif /* CONFIG_VIEW */
+
+#endif // CONFIG_VIEW_H
diff --git a/src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp 
b/src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp
index 4e33116..82cc6ff 100644
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp
+++ b/src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp
@@ -1,8 +1,13 @@
-/* New Mail Notification - notifies incoming e-mail
- *
+/*
+ * Copyright 2004-2012, Haiku, Inc. All rights reserved.
  * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
  * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
-*/
+ *
+ * Distributed under the terms of the MIT License.
+ */
+
+
+//!    Notifies incoming e-mail
 
 
 #include <Alert.h>
@@ -13,7 +18,7 @@
 #include <Path.h>
 #include <String.h>
 
-#include <MailAddon.h>
+#include <MailFilter.h>
 
 #include "ConfigView.h"
 
@@ -22,33 +27,44 @@
 #define B_TRANSLATION_CONTEXT "filter"
 
 
-class NotifyFilter : public MailFilter
-{
+class NotifyFilter : public BMailFilter {
 public:
-                                                               
NotifyFilter(MailProtocol& protocol,
-                                                                       
AddonSettings* settings);
+                                                               
NotifyFilter(BMailProtocol& protocol,
+                                                                       
BMailAddOnSettings* settings);
+
+       virtual BString                         DescriptiveName() const;
 
                        void                            HeaderFetched(const 
entry_ref& ref,
                                                                        BFile* 
file);
-                       void                            MailboxSynced(status_t 
status);
+                       void                            
MailboxSynchronized(status_t status);
+
 private:
                        int32                           fStrategy;
                        int32                           fNNewMessages;
 };
 
 
-NotifyFilter::NotifyFilter(MailProtocol& protocol, AddonSettings* settings)
+NotifyFilter::NotifyFilter(BMailProtocol& protocol,
+       BMailAddOnSettings* settings)
        :
-       MailFilter(protocol, settings),
+       BMailFilter(protocol, settings),
        fNNewMessages(0)
 {
-       fStrategy = settings->Settings().FindInt32("notification_method");
+       fStrategy = settings->FindInt32("notification_method");
+}
+
+
+BString
+NotifyFilter::DescriptiveName() const
+{
+       return filter_name();
 }
 
 
 void
 NotifyFilter::HeaderFetched(const entry_ref& ref, BFile* file)
 {
+       // TODO: do not use MAIL:status here!
        char statusString[256];
        if (file->ReadAttr("MAIL:status", B_STRING_TYPE, 0, statusString, 256) 
< 0)
                return;
@@ -58,15 +74,15 @@ NotifyFilter::HeaderFetched(const entry_ref& ref, BFile* 
file)
 
 
 void
-NotifyFilter::MailboxSynced(status_t status)
+NotifyFilter::MailboxSynchronized(status_t status)
 {
        if (fNNewMessages == 0)
                return;
 
-       if (fStrategy & do_beep)
+       if ((fStrategy & NOTIFY_BEEP) != 0)
                system_beep("New E-mail");
 
-       if (fStrategy & alert) {
+       if ((fStrategy & NOTIFY_ALERT) != 0) {
                BString text, numString;
                if (fNNewMessages != 1)
                        text << B_TRANSLATE("You have %num new messages for 
%name.");
@@ -83,13 +99,13 @@ NotifyFilter::MailboxSynced(status_t status)
                alert->Go(NULL);
        }
 
-       if (fStrategy & blink_leds)
+       if ((fStrategy & NOTIFY_BLINK_LEDS) != 0)
                be_app->PostMessage('mblk');
 
-       if (fStrategy & one_central_beep)
+       if ((fStrategy & NOTIFY_CENTRAL_BEEP) != 0)
                be_app->PostMessage('mcbp');
 
-       if (fStrategy & big_doozy_alert) {
+       if ((fStrategy & NOTIFY_CENTRAL_ALERT) != 0) {
                BMessage msg('numg');
                msg.AddInt32("num_messages", fNNewMessages);
                msg.AddString("name", fMailProtocol.AccountSettings().Name());
@@ -97,7 +113,7 @@ NotifyFilter::MailboxSynced(status_t status)
                be_app->PostMessage(&msg);
        }
 
-       if (fStrategy & log_window) {
+       if ((fStrategy & NOTIFY_NOTIFICATION) != 0) {
                BString message, numString;
                if (fNNewMessages != 1)
                        message << B_TRANSLATE("%num new messages");
@@ -114,8 +130,18 @@ NotifyFilter::MailboxSynced(status_t status)
 }
 
 
-MailFilter*
-instantiate_mailfilter(MailProtocol& protocol, AddonSettings* settings)
+// #pragma mark -
+
+
+BString
+filter_name()
+{
+       return B_TRANSLATE("New mails notification");
+}
+
+
+BMailFilter*
+instantiate_filter(BMailProtocol& protocol, BMailAddOnSettings* settings)
 {
        return new NotifyFilter(protocol, settings);
 }
diff --git a/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp 
b/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp
index 0a55b77..de364d4 100644
--- a/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp
+++ b/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp
@@ -4,113 +4,22 @@
  * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  * Distributed under the terms of the MIT License.
  */
-/******************************************************************************
- * $Id: SpamFilter.cpp 29284 2009-02-22 13:45:40Z bga $
- *
- * SpamFilter - Uses Bayesian statistics to evaluate the spaminess of a
- * message.  The evaluation is done by a separate server, this add-on just gets
- * the text and uses scripting commands to get an evaluation from the server.
- * If the server isn't running, it will be found and started up.  Once the
- * evaluation has been received, it is added to the message as an attribute and
- * optionally as an addition to the subject.  Some other add-on later in the
- * pipeline will use the attribute to delete the message or move it to some
- * other folder.
- *
- * Public Domain 2002, by Alexander G. M. Smith, no warranty.
- *
- * $Log: SpamFilter.cpp,v $ (SVN doesn't support log messages so manually done)
- * r11769 | bonefish | 2005-03-17 03:30:54 -0500 (Thu, 17 Mar 2005) | 1 line
- * Move trunk into respective module.
- *
- * r9934 | nwhitehorn | 2004-11-11 21:55:05 -0500 (Thu, 11 Nov 2004) | 2 lines
- * Added AGMS's excellent spam detection software.  Still some weirdness with
- * the configuration interface from E-mail prefs.
- *
- * r9669 | brunoga | 2004-10-30 18:23:26 -0400 (Sat, 30 Oct 2004) | 2 lines
- * AGMS Spam Filter.
- *
- * Revision 1.19  2004/09/20 15:57:30  nwhitehorn
- * Mostly updated the tree to Be/Haiku style identifier naming conventions. I 
have a few more things to work out, mostly in mail_util.h, and then I'm 
proceeding to jamify the build system. Then we go into Haiku CVS.
- *
- * Revision 1.18  2003/09/20 12:39:27  agmsmith
- * Memory leak delete needs [] bug.
- *
- * Revision 1.17  2003/07/08 21:12:47  agmsmith
- * Changed other spam filter defaults to values I find useful.
- *
- * Revision 1.16  2003/07/08 20:56:40  agmsmith
- * Turn on auto-training for the spam filter by default.
- *
- * Revision 1.15  2003/07/06 13:30:33  agmsmith
- * Make sure that the spam filter doesn't auto-train the message twice
- * when it gets a partially downloaded e-mail (will just train on the
- * partial one, ignore the complete message when it gets downloaded).
- *
- * Revision 1.14  2003/05/27 17:12:59  nwhitehorn
- * Massive refactoring of the Protocol/ChainRunner/Filter system. You can 
probably
- * examine its scope by examining the number of files changed. Regardless, 
this is
- * preparation for lots of new features, and REAL WORKING IMAP. Yes, you heard 
me.
- * Enjoy, and prepare for bugs (although I've fixed all the ones I've found, I 
susp
- * ect there are some memory leaks in ChainRunner).
- *
- * Revision 1.13  2003/02/08 21:54:17  agmsmith
- * Updated the AGMSBayesianSpamServer documentation to match the current
- * version.  Also removed the Beep options from the spam filter, now they
- * are turned on or off in the system sound preferences.
- *
- * Revision 1.12  2002/12/18 02:27:45  agmsmith
- * Added uncertain classification as suggested by BiPolar.
- *
- * Revision 1.11  2002/12/16 16:03:20  agmsmith
- * Changed spam cutoff to 0.95 to work with default Chi-Squared scoring.
- *
- * Revision 1.10  2002/12/13 22:04:42  agmsmith
- * Changed default to turn on the Spam marker in the subject.
- *
- * Revision 1.9  2002/12/13 20:27:44  agmsmith
- * Added auto-training mode to the filter.  It evaluates a message for
- * spaminess then recursively adds it to the database.  This can lead
- * to weird results unless the user corrects the bad classifications.
- *
- * Revision 1.8  2002/11/28 20:20:57  agmsmith
- * Now checks if the spam database is running in headers only mode, and
- * then only downloads headers if that is the case.
- *
- * Revision 1.7  2002/11/10 19:36:26  agmsmith
- * Retry launching server a few times, but not too many.
- *
- * Revision 1.6  2002/11/03 02:21:02  agmsmith
- * Never mind, just use the SourceForge version numbers.  Ugh.
- *
- * Revision 1.8  2002/10/21 16:12:09  agmsmith
- * Added option for spam if no words found, use new method of saving
- * the attribute which avoids hacking the rest of the mail system.
- *
- * Revision 1.7  2002/10/11 20:01:28  agmsmith
- * Added sound effects (system beep) for genuine and spam, plus config option
- * for it.
- *
- * Revision 1.6  2002/10/01 00:45:34  agmsmith
- * Changed default spam ratio to 0.56 from 0.9, for use with
- * the Gary Robinson method in AGMSBayesianSpamServer 1.49.
- *
- * Revision 1.5  2002/09/25 13:23:21  agmsmith
- * Don't leave the data stream at the initial position, try leaving it
- * at the end.  Was having mail progress bar problems.
- *
- * Revision 1.4  2002/09/23 19:14:13  agmsmith
- * Added an option to have the server quit when done.
- *
- * Revision 1.3  2002/09/23 03:33:34  agmsmith
- * First working version, with cutoff ratio and subject modification,
- * and an attribute added if a patch is made to the Folder filter.
- *
- * Revision 1.2  2002/09/21 20:57:22  agmsmith
- * Fixed bugs so now it compiles.
- *
- * Revision 1.1  2002/09/21 20:47:15  agmsmith
- * Initial revision
- */
+
+/*!    Uses Bayesian statistics to evaluate the spaminess of a message.
+       The evaluation is done by a separate server, this add-on just gets
+       the text and uses scripting commands to get an evaluation from the 
server.
+       If the server isn't running, it will be found and started up.  Once the
+       evaluation has been received, it is added to the message as an 
attribute and
+       optionally as an addition to the subject.  Some other add-on later in 
the
+       pipeline will use the attribute to delete the message or move it to some
+       other folder.
+*/
+
+
+#include "SpamFilter.h"
+
+#include <stdlib.h>
+#include <stdio.h>
 
 #include <Beep.h>
 #include <Catalog.h>
@@ -123,76 +32,62 @@
 #include <FindDirectory.h>
 #include <Entry.h>
 
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "SpamFilter.h"
-
 
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "SpamFilter"
 
 
 // The names match the ones set up by spamdbm for sound effects.
-static const char *kAGMSBayesBeepGenuineName = "SpamFilter-Genuine";
-static const char *kAGMSBayesBeepSpamName = "SpamFilter-Spam";
-static const char *kAGMSBayesBeepUncertainName = "SpamFilter-Uncertain";
+static const char* kAGMSBayesBeepGenuineName = "SpamFilter-Genuine";
+static const char* kAGMSBayesBeepSpamName = "SpamFilter-Spam";
+static const char* kAGMSBayesBeepUncertainName = "SpamFilter-Uncertain";
 
-static const char *kServerSignature = "application/x-vnd.agmsmith.spamdbm";
+static const char* kServerSignature = "application/x-vnd.agmsmith.spamdbm";
 
 
-AGMSBayesianSpamFilter::AGMSBayesianSpamFilter(MailProtocol& protocol,
-       AddonSettings* addonSettings)
+SpamFilter::SpamFilter(BMailProtocol& protocol, BMailAddOnSettings* settings)
        :
-       MailFilter(protocol, addonSettings),
-
-       fAddSpamToSubject(false),
-       fAutoTraining(true),
-       fGenuineCutoffRatio(0.01f),
-       fHeaderOnly(false),
-       fLaunchAttemptCount(0),
-       fNoWordsMeansSpam(true),
-       fQuitServerWhenFinished(false),
-       fSpamCutoffRatio(0.99f)
+       BMailFilter(protocol, settings)
 {
-       bool            tempBool;
-       float           tempFloat;
-       BMessenger      tempMessenger;
-
-       const BMessage* settings = &addonSettings->Settings();
-       if (settings != NULL) {
-               if (settings->FindBool ("AddMarkerToSubject", &tempBool) == 
B_OK)
-                       fAddSpamToSubject = tempBool;
-               if (settings->FindBool ("AutoTraining", &tempBool) == B_OK)
-                       fAutoTraining = tempBool;
-               if (settings->FindFloat ("GenuineCutoffRatio", &tempFloat) == 
B_OK)
-                       fGenuineCutoffRatio = tempFloat;
-               if (settings->FindBool ("NoWordsMeansSpam", &tempBool) == B_OK)
-                       fNoWordsMeansSpam = tempBool;
-               if (settings->FindBool ("QuitServerWhenFinished", &tempBool) == 
B_OK)
-                       fQuitServerWhenFinished = tempBool;
-               if (settings->FindFloat ("SpamCutoffRatio", &tempFloat) == B_OK)
-                       fSpamCutoffRatio = tempFloat;
-       }
+       if (settings->FindBool("AddMarkerToSubject", &fAddSpamToSubject) != 
B_OK)
+               fAddSpamToSubject = false;
+       if (settings->FindBool("AutoTraining", &fAutoTraining) != B_OK)
+               fAutoTraining = true;
+       if (settings->FindFloat("GenuineCutoffRatio", &fGenuineCutoffRatio) != 
B_OK)
+               fGenuineCutoffRatio = 0.01f;
+       if (settings->FindBool("NoWordsMeansSpam", &fNoWordsMeansSpam) != B_OK)
+               fNoWordsMeansSpam = true;
+       if (settings->FindBool("QuitServerWhenFinished",
+                       &fQuitServerWhenFinished) != B_OK)
+               fQuitServerWhenFinished = false;
+       if (settings->FindFloat("SpamCutoffRatio", &fSpamCutoffRatio) != B_OK)
+               fSpamCutoffRatio = 0.99f;
 }
 
 

[ *** diff truncated: 4192 lines dropped *** ]



Other related posts:

  • » [haiku-commits] BRANCH axeld-github.imap - src/kits/mail src/add-ons/mail_daemon/inbound_filters/spam_filter headers/os/add-ons/mail_daemon src/add-ons/mail_daemon/inbound_filters/match_header src/servers/mail - axeld-github . imap