[haiku-commits] BRANCH jessicah-github.imap.pm [b95a6ab] in src: add-ons/mail_daemon/inbound_protocols/imap/imap_lib kits/mail add-ons/mail_daemon/inbound_protocols/imap servers/mail add-ons/mail_daemon/outbound_protocols/smtp

  • From: jessicah-github.imap.pm <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 1 Jul 2014 13:01:39 +0200 (CEST)

added 4 changesets to branch 'refs/remotes/jessicah-github/imap.pm'
old head: 0000000000000000000000000000000000000000
new head: b95a6ab72a9499e021c2567907b33fdde641e428
overview: https://github.com/jessicah/haiku/compare/b95a6ab

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

76006c1: Axel's IMAP code

1cd5a18: Blah commit.

14ca473: New files

b95a6ab: Disable IPv6 code; broken, and interferes with mailkit atm.
  Also return B_OK when a folder doesn't match on the server, so rest of
  mail keeps on working.

                         [ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ]

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

131 files changed, 9360 insertions(+), 8245 deletions(-)
build/jam/images/definitions/minimum             |   5 +-
headers/os/add-ons/mail_daemon/MailAddon.h       |  74 --
headers/os/add-ons/mail_daemon/MailFilter.h      |  51 +
headers/os/add-ons/mail_daemon/MailProtocol.h    | 260 ++----
.../os/add-ons/mail_daemon/MailSettingsView.h    |  23 +
.../os/add-ons/mail_daemon/ProtocolConfigView.h  |  69 --
headers/os/app/Message.h                         |   5 +-
headers/os/mail/MailDaemon.h                     |  60 +-
headers/os/mail/MailMessage.h                    | 215 +++--
headers/os/mail/MailSettings.h                   | 110 +--
headers/private/mail/FileConfigView.h            |  86 +-
headers/private/mail/MailPrivate.h               |  21 +-
headers/private/mail/ProtocolConfigView.h        | 106 +++
headers/private/mail/ServerConnection.h          |  48 -
src/add-ons/kernel/network/protocols/Jamfile     |   4 +-
.../inbound_filters/match_header/ConfigView.cpp  | 328 ++++---
.../match_header/MatchHeaderSettings.h           |  64 ++
.../inbound_filters/match_header/RuleFilter.cpp  | 161 ++--
.../inbound_filters/match_header/RuleFilter.h    |  48 +-
.../inbound_filters/notifier/ConfigView.h        |  35 -
.../mail_daemon/inbound_filters/notifier/Jamfile |  10 +-
.../{ConfigView.cpp => NotifierConfigView.cpp}   | 143 ++-
.../notifier/NotifierConfigView.h                |  40 +
.../notifier/{filter.cpp => NotifierFilter.cpp}  |  64 +-
...MailNotification.rdef => NotifierFilter.rdef} |   0
.../inbound_filters/spam_filter/SpamFilter.cpp   | 305 ++----
.../inbound_filters/spam_filter/SpamFilter.h     | 106 +--
.../spam_filter/SpamFilterConfig.cpp             | 500 +++-------
.../inbound_protocols/imap/ConfigView.cpp        | 144 +++
...APFolderConfig.cpp => FolderConfigWindow.cpp} | 190 ++--
.../{IMAPFolderConfig.h => FolderConfigWindow.h} |  20 +-
.../mail_daemon/inbound_protocols/imap/IMAP.h    | 143 +++
.../imap/IMAPConnectionWorker.cpp                | 761 +++++++++++++++
.../imap/IMAPConnectionWorker.h                  | 100 ++
.../inbound_protocols/imap/IMAPFolder.cpp        | 460 +++++++++
.../inbound_protocols/imap/IMAPFolder.h          | 111 +++
.../inbound_protocols/imap/IMAPInboundProtocol.h |   2 +-
.../inbound_protocols/imap/IMAPMailbox.cpp       | 105 +++
.../inbound_protocols/imap/IMAPMailbox.h         |  65 ++
.../inbound_protocols/imap/IMAPProtocol.cpp      | 266 ++++++
.../inbound_protocols/imap/IMAPProtocol.h        |  65 ++
.../imap/IMAPRootInboundProtocol.cpp             |   5 +-
.../mail_daemon/inbound_protocols/imap/Jamfile   |  33 +-
.../inbound_protocols/imap/Settings.cpp          | 110 +++
.../inbound_protocols/imap/Settings.h            |  41 +
.../inbound_protocols/imap/Utilities.cpp         |  21 +
.../inbound_protocols/imap/Utilities.h           |  15 +
.../inbound_protocols/imap/imap_config.cpp       | 152 ---
.../inbound_protocols/imap/imap_lib/Commands.cpp | 820 ++++++++++++++++
.../inbound_protocols/imap/imap_lib/Commands.h   | 345 +++++++
.../imap/imap_lib/IMAPFolders.cpp                | 130 ---
.../imap/imap_lib/IMAPFolders.h                  |  51 -
.../imap/imap_lib/IMAPHandler.cpp                | 936 -------------------
.../imap/imap_lib/IMAPHandler.h                  | 303 ------
.../imap/imap_lib/IMAPMailbox.cpp                |  24 +-
.../imap/imap_lib/IMAPMailbox.h                  |  17 +-
.../imap/imap_lib/IMAPParser.cpp                 | 139 ---
.../inbound_protocols/imap/imap_lib/IMAPParser.h |  35 -
.../imap/imap_lib/IMAPProtocol.cpp               | 433 ---------
.../imap/imap_lib/IMAPProtocol.h                 | 129 ---
.../imap/imap_lib/IMAPStorage.cpp                |   9 +-
.../imap/imap_lib/IMAPStorage.h                  |  13 +-
.../inbound_protocols/imap/imap_lib/Protocol.cpp | 420 +++++++++
.../inbound_protocols/imap/imap_lib/Protocol.h   | 118 +++
.../inbound_protocols/imap/imap_lib/Response.cpp | 530 +++++++++--
.../inbound_protocols/imap/imap_lib/Response.h   | 105 ++-
.../inbound_protocols/pop3/ConfigView.cpp        |  65 +-
.../mail_daemon/inbound_protocols/pop3/Jamfile   |   9 +-
.../inbound_protocols/pop3/MessageIO.h           |   5 +-
.../pop3/{pop3.cpp => POP3.cpp}                  | 391 ++++----
.../inbound_protocols/pop3/{pop3.h => POP3.h}    |  38 +-
.../outbound_filters/fortune/ConfigView.cpp      |  95 +-
.../outbound_filters/fortune/ConfigView.h        |  38 +-
.../outbound_filters/fortune/FortuneFilter.cpp   | 122 +++
.../mail_daemon/outbound_filters/fortune/Jamfile |   4 +-
.../outbound_filters/fortune/filter.cpp          | 100 --
.../outbound_protocols/smtp/ConfigView.cpp       |  89 +-
.../mail_daemon/outbound_protocols/smtp/Jamfile  |   4 +-
.../smtp/{smtp.cpp => SMTP.cpp}                  | 120 +--
.../outbound_protocols/smtp/{smtp.h => SMTP.h}   |  28 +-
src/add-ons/tracker/mark_as/Jamfile              |   2 +-
src/add-ons/tracker/mark_as/MarkAs.cpp           |   8 +-
src/add-ons/tracker/mark_as/MarkAsRead.cpp       |  14 +-
src/add-ons/tracker/mark_as/MarkAsRead.rdef      |   1 -
src/apps/mail/Content.cpp                        |  36 +-
src/apps/mail/Content.h                          |   3 -
src/apps/mail/MailWindow.cpp                     |  24 +-
src/apps/people/AttributeTextControl.cpp         |   7 +-
src/kits/app/Message.cpp                         |  15 +-
src/kits/mail/FileConfigView.cpp                 | 123 +--
src/kits/mail/HaikuMailFormatFilter.cpp          | 153 +--
src/kits/mail/HaikuMailFormatFilter.h            |  30 +-
src/kits/mail/Jamfile                            |   9 +-
src/kits/mail/MailDaemon.cpp                     |  99 +-
src/kits/mail/MailFilter.cpp                     |  53 ++
src/kits/mail/MailMessage.cpp                    | 448 ++++-----
src/kits/mail/MailProtocol.cpp                   | 645 ++++---------
src/kits/mail/MailSettings.cpp                   | 479 ++++------
src/kits/mail/MailSettingsView.cpp               |  19 +
[ *** stats truncated: 32 lines dropped *** ]

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

Commit:      76006c1eab0eb906b32cf137f349291111c9df77
Author:      Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date:        Thu Jun 12 05:11:29 2014 UTC

Axel's IMAP code

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

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/MailProtocol.h 
b/headers/os/add-ons/mail_daemon/MailProtocol.h
index 4a30c65..d4c3b2c 100644
--- a/headers/os/add-ons/mail_daemon/MailProtocol.h
+++ b/headers/os/add-ons/mail_daemon/MailProtocol.h
@@ -1,16 +1,16 @@
-/* Protocol - the base class for protocol filters
- *
+/*
+ * Copyright 2004-2013, Haiku, Inc. All Rights Reserved.
  * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
  * Copyright 2011 Clemens Zeidler. All rights reserved.
-*/
-#ifndef MAIL_PROTOCOL_H
-#define MAIL_PROTOCOL_H
+ *
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _MAIL_PROTOCOL_H
+#define _MAIL_PROTOCOL_H
 
 
 #include <map>
-#include <vector>
 
-#include <Handler.h>
 #include <Looper.h>
 #include <OS.h>
 #include <ObjectList.h>
@@ -21,206 +21,152 @@
 #include <MailSettings.h>
 
 
-class MailNotifier {
+class BMailFilter;
+class BMailSettingsView;
+class BView;
+
+
+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 items, 
uint64 bytes,
                                                                        const 
char* message = NULL) = 0;
        virtual void                            ResetProgress(const char* 
message = NULL) = 0;
 };
 
 
-class MailProtocol;
+typedef status_t BMailFilterAction;
+
+#define B_NO_MAIL_ACTION               0
+#define B_MOVE_MAIL_ACTION             1
+#define B_DELETE_MAIL_ACTION   2
 
 
-class MailFilter {
+class BMailProtocol : public BLooper {
 public:
-                                                               
MailFilter(MailProtocol& protocol,
-                                                                       
AddonSettings* settings);
-       virtual                                         ~MailFilter();
-
-       //! Message hooks if filter is installed to a 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
-       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();
 
+                       const BMailAccountSettings& AccountSettings() const;
 
-class MailProtocolThread;
+                       void                            
SetMailNotifier(BMailNotifier* mailNotifier);
+                       BMailNotifier*          MailNotifier() const;
 
+                       //! 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);
 
-class MailProtocol {
-public:
-                                                               
MailProtocol(BMailAccountSettings* settings);
-       virtual                                         ~MailProtocol();
-
-       virtual void                            SetStopNow() {}
-
-                       BMailAccountSettings&   AccountSettings();
-
-                       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);
-
-                       void                            
SetMailNotifier(MailNotifier* mailNotifier);
-
-       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,
-                                                                       const 
char* message = NULL);
-       virtual void                            ResetProgress(const char* 
message = NULL);
+       virtual void                            MessageReceived(BMessage* 
message);
+
+                       // Mail storage operations
+       virtual status_t                        MoveMessage(const entry_ref& 
ref,
+                                                                       
BDirectory& dir);
+       virtual status_t                        DeleteMessage(const entry_ref& 
ref);
+
+                       // Convenience methods that call the BMailNotifier
+                       void                            ShowError(const char* 
error);
+                       void                            ShowMessage(const char* 
message);
 
-                       //! MailProtocol takes ownership of the filters
-                       bool                            AddFilter(MailFilter* 
filter);
-                       int32                           CountFilter();
-                       MailFilter*                     FilterAt(int32 index);
-                       MailFilter*                     RemoveFilter(int32 
index);
-                       bool                            
RemoveFilter(MailFilter* filter);
+#if __GNUC__ > 2
+                       // Unhide virtual base methods
+                       using BHandler::AddFilter;
+                       using BHandler::RemoveFilter;
+#endif
 
+protected:
+                       void                            SetTotalItems(uint32 
items);
+                       void                            
SetTotalItemsSize(uint64 size);
+                       void                            ReportProgress(uint32 
items, uint64 bytes,
+                                                                       const 
char* message = NULL);
+                       void                            ResetProgress(const 
char* message = NULL);
                        void                            
NotifyNewMessagesToFetch(int32 nMessages);
-                       void                            
NotifyHeaderFetched(const entry_ref& ref,
-                                                                       BFile* 
mail);
+
+                       // Filter notifications
+                       BMailFilterAction       ProcessHeaderFetched(entry_ref& 
ref,
+                                                                       BFile& 
mail, BMessage& attributes);
                        void                            NotifyBodyFetched(const 
entry_ref& ref,
-                                                                       BFile* 
mail);
+                                                                       BFile& 
mail, BMessage& attributes);
+                       BMailFilterAction       
ProcessMessageFetched(entry_ref& ref,
+                                                                       BFile& 
mail, BMessage& attributes);
                        void                            
NotifyMessageReadyToSend(const entry_ref& ref,
-                                                                       BFile* 
mail);
+                                                                       BFile& 
mail);
                        void                            NotifyMessageSent(const 
entry_ref& ref,
-                                                                       BFile* 
mail);
+                                                                       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(const 
BMailAddOnSettings& settings);
+                       BMailFilterAction       
_ProcessHeaderFetched(entry_ref& ref,
+                                                                       BFile& 
mail, BMessage& attributes);
+                       void                            
_NotifyBodyFetched(const entry_ref& ref,
+                                                                       BFile& 
mail, BMessage& attributes);
 
 protected:
-                       void                            
LoadFilters(MailAddonSettings& settings);
-
-                       BMailAccountSettings    fAccountSettings;
-                       MailNotifier*           fMailNotifier;
+                       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;
        virtual status_t                        MarkMessageAsRead(const 
entry_ref& ref,
-                                                                       
read_flags flag = B_READ);
+                                                                       
read_flags flags = 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;
+protected:
+                       void                            
NotiyMailboxSynchronized(status_t status);
 };
 
 
-class MailProtocolThread : public BLooper {
+class BOutboundMailProtocol : public BMailProtocol {
 public:
-                                                               
MailProtocolThread(MailProtocol* protocol);
-       virtual void                            MessageReceived(BMessage* 
message);
-
-                       MailProtocol*           Protocol() { return 
fMailProtocol; }
+                                                               
BOutboundMailProtocol(
+                                                                       const 
BMailAccountSettings& settings);
+       virtual                                         
~BOutboundMailProtocol();
 
-                       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);
+       virtual void                            MessageReceived(BMessage* 
message);
 
-                       void                            
TriggerFileRenamed(const entry_ref& from,
-                                                                       const 
entry_ref& to);
-                       void                            
TriggerFileDeleted(const node_ref& node);
-private:
-                       MailProtocol*           fMailProtocol;
+       virtual status_t                        SendMessages(const BMessage& 
message,
+                                                                       off_t 
totalBytes) = 0;
 };
 
 
-class InboundProtocolThread : public MailProtocolThread {
-public:
-                                                               
InboundProtocolThread(
-                                                                       
InboundProtocol* protocol);
-                                                               
~InboundProtocolThread();
-
-                       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);
-
-                       InboundProtocol*        fProtocol;
-};
-
-
-class OutboundProtocolThread : public MailProtocolThread {
-public:
-                                                               
OutboundProtocolThread(
-                                                                       
OutboundProtocol* protocol);
-                                                               
~OutboundProtocolThread();
-
-                       void                            
MessageReceived(BMessage* message);
-
-                       void                            SendMessages(const 
std::vector<entry_ref>&
-                                                                       mails, 
size_t totalBytes);
+// Your protocol needs to export these hooks in order to be picked up
+extern "C" BInboundMailProtocol* instantiate_inbound_protocol(
+       const BMailAccountSettings& settings);
+extern "C" BOutboundMailProtocol* instantiate_outbound_protocol(
+       const BMailAccountSettings& settings);
 
-private:
-                       OutboundProtocol*       fProtocol;
-};
+extern "C" BMailSettingsView* instantiate_protocol_settings_view(
+       const BMailAccountSettings& accountSettings,
+       const BMailProtocolSettings& settings);
 
 
-#endif // MAIL_PROTOCOL_H
+#endif // _MAIL_PROTOCOL_H
diff --git a/headers/os/add-ons/mail_daemon/ProtocolConfigView.h 
b/headers/os/add-ons/mail_daemon/ProtocolConfigView.h
deleted file mode 100644
index 045c257..0000000
--- a/headers/os/add-ons/mail_daemon/ProtocolConfigView.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* 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
-
-
-#include <CheckBox.h>
-#include <StringView.h>
-#include <TextControl.h>
-#include <View.h>
-
-#include "MailSettings.h"
-
-
-class BodyDownloadConfig : public BView {
-public:
-                                                               
BodyDownloadConfig();
-
-                       void                            
SetTo(MailAddonSettings& settings);
-
-                       void                            
MessageReceived(BMessage *msg);
-                       void                            AttachedToWindow();
-                       void                            GetPreferredSize(float 
*width, float *height);
-                       status_t                        Archive(BMessage *into, 
bool) const;
-private:
-                       BTextControl*           fSizeBox;
-                       BCheckBox*                      fPartialBox;
-                       BStringView*            fBytesLabel;
-};
-
-
-typedef enum {
-       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;
-
-
-class BMailProtocolConfigView : 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,
-                                                                       bool 
needUserPassword = true);
-
-       virtual status_t                        Archive(BMessage *into, bool 
deep = true) const;
-       virtual void                            GetPreferredSize(float *width, 
float *height);
-       virtual void                            AttachedToWindow();
-       virtual void                            MessageReceived(BMessage *msg);
-       
-private:
-                       BodyDownloadConfig*     fBodyDownloadConfig;
-};
-
-#endif /* ZOIDBERG_PROTOCOL_CONFIG_VIEW_H */
diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h
index df54552..104ebf2 100644
--- a/headers/os/app/Message.h
+++ b/headers/os/app/Message.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2012, Haiku Inc. All Rights Reserved.
+ * Copyright 2005-2013, Haiku Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -27,7 +27,6 @@ class BBlockCache;
 class BMessenger;
 class BHandler;
 class BString;
-class BStringList;
 struct entry_ref;
 
 
@@ -141,8 +140,6 @@ public:
                        status_t                        AddString(const char* 
name, const char* string);
                        status_t                        AddString(const char* 
name,
                                                                        const 
BString& string);
-                       status_t                        AddStrings(const char 
*name,
-                                                                       const 
BStringList& list);
                        status_t                        AddInt8(const char* 
name, int8 value);
                        status_t                        AddUInt8(const char* 
name, uint8 value);
                        status_t                        AddInt16(const char* 
name, int16 value);
@@ -200,8 +197,6 @@ public:
                                                                        
BString* string) const;
                        status_t                        FindString(const char* 
name, int32 index,
                                                                        
BString* string) const;
-                       status_t                        FindStrings(const char* 
name,
-                                                                       
BStringList* list) const;
                        status_t                        FindInt8(const char* 
name, int8* value) const;
                        status_t                        FindInt8(const char* 
name, int32 index,
                                                                        int8* 
value) const;
@@ -491,7 +486,8 @@ public:
                        status_t                        SetRect(const char* 
name, const BRect& value);
                        status_t                        SetSize(const char* 
name, const BSize& value);
                        status_t                        SetData(const char* 
name, type_code type,
-                                                                       const 
void* data, ssize_t numBytes);
+                                                                       const 
void* data, ssize_t numBytes,
+                                                                       bool 
fixedSize = true, int count = 1);
 
        class Private;
        struct message_header;
diff --git a/headers/os/mail/MailDaemon.h b/headers/os/mail/MailDaemon.h
index 4cef96a..e2434d8 100644
--- a/headers/os/mail/MailDaemon.h
+++ b/headers/os/mail/MailDaemon.h
@@ -1,45 +1,45 @@
-#ifndef MAIL_DAEMON_H
-#define MAIL_DAEMON_H
-/* Daemon - talking to the mail daemon
- *
- * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
- * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
-*/
+/*
+ * Copyright 2012, Haiku Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _MAIL_DAEMON_H
+#define _MAIL_DAEMON_H
 
 
 #include <E-mail.h>
+#include <Messenger.h>
 
 
-#define B_MAIL_DAEMON_SIGNATURE "application/x-vnd.Be-POST"
+enum {
+       B_MAIL_BODY_FETCHED = '_Mbf'
+};
 
-const uint32 kMsgCheckAndSend = 'mbth';
-const uint32 kMsgCheckMessage = 'mnow';
-const uint32 kMsgSendMessages = 'msnd';
-const uint32 kMsgSettingsUpdated = 'mrrs';
-const uint32 kMsgAccountsChanged = 'macc';
-const uint32 kMsgSetStatusWindowMode = 'shst';
-const uint32 kMsgCountNewMessages = 'mnum';
-const uint32 kMsgMarkMessageAsRead = 'mmar';
-const uint32 kMsgFetchBody = 'mfeb';
-const uint32 kMsgBodyFetched = 'mbfe';
 
+class BMailDaemon {
+public:
+                                                               BMailDaemon();
+       virtual                                         ~BMailDaemon();
 
-class BMessenger;
+                       bool                            IsRunning();
 
+                       status_t                        CheckMail(int32 
accountID = -1);
+                       status_t                        
CheckAndSendQueuedMail(int32 accountID = -1);
 
-class BMailDaemon {
-public:
-       //! accountID = -1 means check all accounts
-       static status_t                         CheckMail(int32 accountID = -1);
-       static status_t                         CheckAndSendQueuedMail(int32 
accountID = -1);
-       static status_t                         SendQueuedMail();
-       static int32                            CountNewMessages(
+                       status_t                        SendQueuedMail();
+
+                       int32                           CountNewMessages(
                                                                        bool 
waitForFetchCompletion = false);
-       static status_t                         MarkAsRead(int32 account, const 
entry_ref& ref,
+                       status_t                        MarkAsRead(int32 
account, const entry_ref& ref,
                                                                        
read_flags flag = B_READ);
-       static status_t                         FetchBody(const entry_ref& ref,
+                       status_t                        FetchBody(const 
entry_ref& ref,
                                                                        
BMessenger* listener = NULL);
-       static status_t                         Quit();
+
+                       status_t                        Quit();
+                       status_t                        Launch();
+
+private:
+                       BMessenger                      fDaemon;
 };
 
-#endif // MAIL_DAEMON_H
+
+#endif // _MAIL_DAEMON_H
diff --git a/headers/os/mail/MailMessage.h b/headers/os/mail/MailMessage.h
index dcca852..0c87e8b 100644
--- a/headers/os/mail/MailMessage.h
+++ b/headers/os/mail/MailMessage.h
@@ -1,20 +1,27 @@
-#ifndef ZOIDBERG_MAIL_MESSAGE_H
-#define ZOIDBERG_MAIL_MESSAGE_H
-/* Message - the main general purpose mail message class
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
+/*
+ * Copyright 2007-2012, Haiku Inc. All Rights Reserved.
+ * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _MAIL_MESSAGE_H_
+#define _MAIL_MESSAGE_H_
+
+
+//! The main general purpose mail message class
 
 
 #include <MailContainer.h>
 
 
-// add our additional attributes 
+// add our additional attributes
 #define B_MAIL_ATTR_ACCOUNT "MAIL:account"
 #define B_MAIL_ATTR_THREAD "MAIL:thread"
 
 
 class BDirectory;
+class BEntry;
+
 
 enum mail_reply_to_mode {
        B_MAIL_REPLY_TO = 0,
@@ -22,91 +29,115 @@ enum mail_reply_to_mode {
        B_MAIL_REPLY_TO_SENDER
 };
 
+
 class BEmailMessage : public BMailContainer {
-       public:
-               BEmailMessage(BPositionIO *mail_file = NULL, bool own = false, 
uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
-               BEmailMessage(const entry_ref *ref,
-                       uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
-               virtual ~BEmailMessage();
-
-               status_t InitCheck() const;
-               BPositionIO *Data() const { return fData; }
-                       // is only set if the message owns the data
-
-               BEmailMessage *ReplyMessage(mail_reply_to_mode replyTo, bool 
accountFromMail, const char *quote_style = "> ");
-               BEmailMessage *ForwardMessage(bool accountFromMail, bool 
includeAttachments = false);
-                       // These return messages with the body quoted and
-                       // ready to send via the appropriate channel. 
ReplyMessage()
-                       // addresses the message appropriately, but 
ForwardMessage()
-                       // leaves it unaddressed.
-
-               const char *To();
-               const char *From();
-               const char *ReplyTo();
-               const char *CC();
-               const char *Subject();
-               const char *Date();
-               int Priority();
-
-               void SetSubject(const char *to, uint32 charset = 
B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
-               void SetReplyTo(const char *to, uint32 charset = 
B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
-               void SetFrom(const char *to, uint32 charset = 
B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
-               void SetTo(const char *to, uint32 charset = 
B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
-               void SetCC(const char *to, uint32 charset = 
B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
-               void SetBCC(const char *to);
-               void SetPriority(int to);
-
-               status_t GetName(char *name,int32 maxLength) const;
-               status_t GetName(BString *name) const;
-
-               void SendViaAccountFrom(BEmailMessage *message);
-               void SendViaAccount(const char *account_name);
-               void SendViaAccount(int32 account);
-               int32 Account() const;
-               status_t GetAccountName(BString& accountName) const;
-
-               virtual status_t AddComponent(BMailComponent *component);
-               virtual status_t RemoveComponent(BMailComponent *component);
-               virtual status_t RemoveComponent(int32 index);
-
-               virtual BMailComponent *GetComponent(int32 index, bool 
parse_now = false);
-               virtual int32 CountComponents() const;
-
-               void Attach(entry_ref *ref, bool include_attributes = true);
-               bool IsComponentAttachment(int32 index);
-
-               void SetBodyTextTo(const char *text);
-               const char *BodyText();
-
-               status_t SetBody(BTextMailComponent *body);
-               BTextMailComponent *Body();
-
-               virtual status_t SetToRFC822(BPositionIO *data, size_t length, 
bool parse_now = false);
-               virtual status_t RenderToRFC822(BPositionIO *render_to);
-
-               status_t RenderTo(BDirectory *dir, BEntry *message = NULL);
-                       //---message will be set to the message file if not 
equal to NULL
-
-               status_t Send(bool send_now);
-
-       private:
-               BTextMailComponent *RetrieveTextBody(BMailComponent *);
-
-               virtual void _ReservedMessage1();
-               virtual void _ReservedMessage2();
-               virtual void _ReservedMessage3();
-
-               BPositionIO *fData;
-
-               status_t _status;
-               int32 _account_id;
-               char *_bcc;
-
-               int32 _num_components;
-               BMailComponent *_body;
-               BTextMailComponent *_text_body;
-
-               uint32 _reserved[5];
+public:
+                                                               
BEmailMessage(BPositionIO* stream = NULL,
+                                                                       bool 
ownStream = false,
+                                                                       uint32 
defaultCharSet
+                                                                               
= B_MAIL_NULL_CONVERSION);
+                                                               
BEmailMessage(const entry_ref* ref,
+                                                                       uint32 
defaultCharSet
+                                                                               
= B_MAIL_NULL_CONVERSION);
+       virtual                                         ~BEmailMessage();
+
+                       status_t                        InitCheck() const;
+                       BPositionIO*            Data() const { return fData; }
+                               // is only set if the message owns the data
+
+                       BEmailMessage*          ReplyMessage(mail_reply_to_mode 
replyTo,
+                                                                       bool 
accountFromMail,
+                                                                       const 
char* quoteStyle = "> ");
+                       BEmailMessage*          ForwardMessage(bool 
accountFromMail,
+                                                                       bool 
includeAttachments = false);
+                               // These return messages with the body quoted 
and
+                               // ready to send via the appropriate channel. 
ReplyMessage()
+                               // addresses the message appropriately, but 
ForwardMessage()
+                               // leaves it unaddressed.
+
+                       const char*                     To();
+                       const char*                     From();
+                       const char*                     ReplyTo();
+                       const char*                     CC();
+                       const char*                     Subject();
+                       const char*                     Date();
+                       int                                     Priority();
+
+                       void                            SetSubject(const char* 
to,
+                                                                       uint32 
charset = B_MAIL_NULL_CONVERSION,
+                                                                       
mail_encoding encoding = null_encoding);
+                       void                            SetReplyTo(const char* 
to,
+                                                                       uint32 
charset = B_MAIL_NULL_CONVERSION,
+                                                                       
mail_encoding encoding = null_encoding);
+                       void                            SetFrom(const char* to,
+                                                                       uint32 
charset = B_MAIL_NULL_CONVERSION,
+                                                                       
mail_encoding encoding = null_encoding);
+                       void                            SetTo(const char* to,
+                                                                       uint32 
charset = B_MAIL_NULL_CONVERSION,
+                                                                       
mail_encoding encoding = null_encoding);
+                       void                            SetCC(const char* to,
+                                                                       uint32 
charset = B_MAIL_NULL_CONVERSION,
+                                                                       
mail_encoding encoding = null_encoding);
+                       void                            SetBCC(const char* to);
+                       void                            SetPriority(int to);
+
+                       status_t                        GetName(char* name, 
int32 maxLength) const;
+                       status_t                        GetName(BString* name) 
const;
+
+                       void                            
SendViaAccountFrom(BEmailMessage* message);
+                       void                            SendViaAccount(const 
char* accountName);
+                       void                            SendViaAccount(int32 
account);
+                       int32                           Account() const;
+                       status_t                        GetAccountName(BString& 
accountName) const;
+
+       virtual status_t                        AddComponent(BMailComponent 
*component);
+       virtual status_t                        RemoveComponent(BMailComponent 
*component);
+       virtual status_t                        RemoveComponent(int32 index);
+
+       virtual BMailComponent*         GetComponent(int32 index,
+                                                                       bool 
parseNow = false);
+       virtual int32                           CountComponents() const;
+
+                       void                            Attach(entry_ref* ref,
+                                                                       bool 
includeAttributes = true);
+                       bool                            
IsComponentAttachment(int32 index);
+
+                       void                            SetBodyTextTo(const 
char* text);
+                       const char*                     BodyText();
+
+                       status_t                        
SetBody(BTextMailComponent* body);
+                       BTextMailComponent*     Body();
+
+       virtual status_t                        SetToRFC822(BPositionIO* data, 
size_t length,
+                                                                       bool 
parseNow = false);
+       virtual status_t                        RenderToRFC822(BPositionIO* 
renderTo);
+
+                       status_t                        RenderTo(BDirectory* 
dir,
+                                                                       BEntry* 
message = NULL);
+                               // Message will be set to the message file if 
not equal to NULL
+
+                       status_t                        Send(bool sendNow);
+
+private:
+                       BTextMailComponent*     
_RetrieveTextBody(BMailComponent* component);
+
+       virtual void                            _ReservedMessage1();
+       virtual void                            _ReservedMessage2();
+       virtual void                            _ReservedMessage3();
+
+private:
+                       BPositionIO*            fData;
+
+                       status_t                        fStatus;
+                       int32                           fAccountID;
+                       char*                           fBCC;
+
+                       int32                           fComponentCount;
+                       BMailComponent*         fBody;
+                       BTextMailComponent*     fTextBody;
+
+                       uint32                          _reserved[5];
 };
 
-#endif /* ZOIDBERG_MAIL_MESSAGE_H */
+
+#endif // _MAIL_MESSAGE_H_
diff --git a/headers/os/mail/MailSettings.h b/headers/os/mail/MailSettings.h
index 42ab039f..b52ee0a 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
@@ -33,43 +35,22 @@ public:
                                                                BMailSettings();
                                                                
~BMailSettings();
 
-                       status_t                        Save(bigtime_t timeout 
= B_INFINITE_TIMEOUT);
+                       status_t                        Save();
                        status_t                        Reload();
                        status_t                        InitCheck() const;
 
                        // Global settings
-                       int32                           WindowFollowsCorner();
-                       void                            
SetWindowFollowsCorner(int32 which_corner);
-
                        uint32                          ShowStatusWindow();
-                       void                            
SetShowStatusWindow(uint32 mode);
+                       status_t                        
SetShowStatusWindow(uint32 mode);
 
                        bool                            DaemonAutoStarts();
-                       void                            
SetDaemonAutoStarts(bool does_it);
-
-                       void                            
SetConfigWindowFrame(BRect frame);
-                       BRect                           ConfigWindowFrame();
-
-                       void                            
SetStatusWindowFrame(BRect frame);
-                       BRect                           StatusWindowFrame();
-
-                       int32                           
StatusWindowWorkspaces();
-                       void                            
SetStatusWindowWorkspaces(int32 workspaces);
-
-                       int32                           StatusWindowLook();
-                       void                            
SetStatusWindowLook(int32 look);
+                       status_t                        
SetDaemonAutoStarts(bool autoStart);
 
                        bigtime_t                       AutoCheckInterval();
-                       void                            
SetAutoCheckInterval(bigtime_t);
-
-                       bool                            CheckOnlyIfPPPUp();
-                       void                            
SetCheckOnlyIfPPPUp(bool yes);
-
-                       bool                            SendOnlyIfPPPUp();
-                       void                            SetSendOnlyIfPPPUp(bool 
yes);
+                       status_t                        
SetAutoCheckInterval(bigtime_t interval);
 
                        int32                           
DefaultOutboundAccount();
-                       void                            
SetDefaultOutboundAccount(int32 to);
+                       status_t                        
SetDefaultOutboundAccount(int32 to);
 
 private:
                        BMessage                        fData;
@@ -77,49 +58,52 @@ private:
 };
 
 
-class AddonSettings {
+class BMailAddOnSettings : public BMessage {
 public:
-                                                               AddonSettings();
-
-                       bool                            Load(const BMessage& 
message);
-                       bool                            Save(BMessage& message);
+                                                               
BMailAddOnSettings();
+       virtual                                         ~BMailAddOnSettings();
 
-                       void                            SetAddonRef(const 
entry_ref& ref);
-       const   entry_ref&                      AddonRef() const;
+       virtual status_t                        Load(const BMessage& message);
+       virtual status_t                        Save(BMessage& message);
 
-       const   BMessage&                       Settings() const;
-                       BMessage&                       EditSettings();
+                       void                            SetAddOnRef(const 
entry_ref& ref);
+                       const entry_ref&        AddOnRef() const;
 
-                       bool                            HasBeenModified();
+       virtual bool                            HasBeenModified() const;
 
 private:
-                       BMessage                        fSettings;
-                       entry_ref                       fAddonRef;
+                       const char*                     _RelativizePath(const 
BPath& path) const;
 
-                       bool                            fModified;
+private:
+                       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();
+
+       virtual status_t                        Load(const BMessage& message);
+       virtual status_t                        Save(BMessage& message);
 
-                       int32                           CountFilterSettings();
+                       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 +111,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 +144,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 +161,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..2f43667 100644
--- a/headers/private/mail/FileConfigView.h
+++ b/headers/private/mail/FileConfigView.h
@@ -1,57 +1,71 @@
-#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>
 #include <FilePanel.h>
 
 
-class BTextControl;
 class BButton;
+class BMailAddOnSettings;
+class BTextControl;
+
+
+namespace BPrivate {
+
 
-class BFileControl : public BView
-{
-       public:
-               BFileControl(BRect rect,const char *name,const char 
*label,const char *pathOfFile = NULL,uint32 flavors = B_DIRECTORY_NODE);
-               ~BFileControl();
+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 AttachedToWindow();
-               virtual void MessageReceived(BMessage *msg);
+       virtual void                            AttachedToWindow();
+       virtual void                            MessageReceived(BMessage* 
message);
 
-               void SetText(const char *pathOfFile);
-               const char *Text() const;
+                       void                            SetText(const char* 
pathOfFile);
+                       const char*                     Text() const;
 
-               void SetEnabled(bool enabled);
+                       void                            SetEnabled(bool 
enabled);
 
-               virtual void GetPreferredSize(float *width, float *height);
+private:
+                       BTextControl*           fText;
+                       BButton*                        fButton;
 
-       private:
-               BTextControl    *fText;
-               BButton                 *fButton;
+                       BFilePanel*                     fPanel;
 
-               BFilePanel              *fPanel;
-               
-               uint32                  _reserved[5];
+                       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);
 
-       private:
-               BMessage        *fMeta;
-               bool            fUseMeta;
-               const char      *fName;
+                       void                            SetTo(const BMessage* 
archive,
+                                                                       
BMessage* metadata);
+                       status_t                        
SaveInto(BMailAddOnSettings& settings) const;
 
-               uint32                  _reserved[5];
+private:
+                       BMessage*                       fMeta;
+                       bool                            fUseMeta;
+                       const char*                     fName;
+
+                       uint32                          _reserved[5];
 };
 
-#endif /* FILE_CONFIG_VIEW */
+
+}      // namespace BPrivate
+
+
+#endif // _FILE_CONFIG_VIEW_H
diff --git a/headers/private/mail/MailPrivate.h 
b/headers/private/mail/MailPrivate.h
index 74b8afa..e30ff64 100644
--- a/headers/private/mail/MailPrivate.h
+++ b/headers/private/mail/MailPrivate.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011, Haiku Inc. All Rights Reserved.
+ * Copyright 2011-2012, Haiku Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  */
 #ifndef MAIL_PRIVATE_H
@@ -12,13 +12,32 @@
 
 namespace BPrivate {
 
+
+#define B_MAIL_DAEMON_SIGNATURE "application/x-vnd.Be-POST"
+
+
+// mail daemon & protocol message constants
+const uint32 kMsgCheckAndSend = 'mbth';
+const uint32 kMsgCheckMessage = 'mnow';
+const uint32 kMsgSendMessages = 'msnd';
+const uint32 kMsgSettingsUpdated = 'mrrs';
+const uint32 kMsgAccountsChanged = 'macc';
+const uint32 kMsgSetStatusWindowMode = 'shst';
+const uint32 kMsgCountNewMessages = 'mnum';
+const uint32 kMsgMarkMessageAsRead = 'mmar';
+const uint32 kMsgFetchBody = 'mfeb';
+const uint32 kMsgSyncMessages = '&SyM';
+
+
 BPath default_mail_directory();
 BPath default_mail_in_directory();
 BPath default_mail_out_directory();
 
+
 status_t WriteMessageFile(const BMessage& archive, const BPath& path,
        const char* name);
 
+
 }      // namespace BPrivate
 
 
diff --git a/headers/private/mail/ServerConnection.h 
b/headers/private/mail/ServerConnection.h
deleted file mode 100644
index 041f1b6..0000000
--- a/headers/private/mail/ServerConnection.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2010-2011, Haiku Inc. All Rights Reserved.
- * Copyright 2010 Clemens Zeidler. All rights reserved.
- *
- * Distributed under the terms of the MIT License.
- */
-#ifndef SERVER_CONNECTION_H
-#define SERVER_CONNECTION_H
-
-
-#include "SupportDefs.h"
-
-
-namespace BPrivate {
-
-
-class AbstractConnection;
-
-
-class ServerConnection {
-public:
-                                                               
ServerConnection();
-                                                               
~ServerConnection();
-
-                       status_t                        ConnectSSL(const char* 
server,
-                                                                       uint32 
port = 993);
-
-                       status_t                        ConnectSocket(const 
char* server,
-                                                                       uint32 
port = 143);
-                       status_t                        Disconnect();
-
-                       status_t                        WaitForData(bigtime_t 
timeout);
-
-                       ssize_t                         Read(char* buffer, 
uint32 length);
-                       ssize_t                         Write(const char* 
buffer, uint32 length);
-
-private:
-                       AbstractConnection*     fConnection;
-};
-
-
-}      // namespace BPrivate
-
-
-using BPrivate::ServerConnection;
-
-
-#endif // SERVER_CONNECTION_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 38936ec..7e4698b 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,237 @@
-/* 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 <MailSettingsView.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 "MatchHeaderSettings.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';
-
-
-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;
+using namespace BPrivate;
+
+
+static const uint32 kMsgActionChanged = 'actC';
+
+
+class RuleFilterConfig : public BMailSettingsView {
+public:
+                                                               
RuleFilterConfig(
+                                                                       const 
BMailAddOnSettings& settings);
+
+       virtual status_t                        SaveInto(BMailAddOnSettings& 
settings) const;
+
+       virtual void                            MessageReceived(BMessage* 
message);
+       virtual void                            AttachedToWindow();
+
+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 BMailAddOnSettings& addOnSettings)
        :
-       BView(BRect(0,0,260,85),"rulefilter_config", B_FOLLOW_LEFT | 
B_FOLLOW_TOP,
-               0), menu(NULL)
+       BMailSettingsView("rulefilter_config"),
+       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"),
-               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);
-
-       arg = new BFileControl(BRect(5,55,255,80),"arg", NULL,
+
+       MatchHeaderSettings settings(addOnSettings);
+       fAction = settings.Action();
+
+       fAttributeControl = new BTextControl("attr", B_TRANSLATE("If"),
+               B_TRANSLATE("header (e.g. Subject)"), NULL);
+       fAttributeControl->SetText(settings.Attribute());
+
+       fRegexControl = new BTextControl("regex", B_TRANSLATE("has"),
+               B_TRANSLATE("value (use REGEX: in front of regular expressions 
like "
+                       "*spam*)"), NULL);
+       fRegexControl->SetText(settings.Expression());
+
+       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"));
+       fFileControl->SetText(settings.MoveTarget());
+
+       fFlagsControl = new BTextControl("flags", NULL, NULL);
+       fFlagsControl->SetText(settings.SetFlagsTo());
 
-       outbound = new BPopUpMenu(B_TRANSLATE("<Choose account>"));
+       // Populate account menu
 
-       if (settings->HasInt32("do_what"))
-               staging = settings->FindInt32("do_what");
-       else
-               staging = -1;
-       if (staging == 3)
-               chain = settings->FindInt32("argument");
-       else
-               chain = -1;
-       printf("Chain: %" B_PRId32 "\n",chain);
+       fAccountMenu = new BPopUpMenu(B_TRANSLATE("<Choose account>"));
+       fAccountID = settings.ReplyAccount();
 
        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);
        }
-}
 
-
-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);
+       fAccountField = new BMenuField("reply", "Foo", fAccountMenu);
+       if (fAction >= 0) {
+               BMenuItem* item = fActionMenu->ItemAt(fAction);
+               if (item != NULL) {
+                       item->SetMarked(true);
+                       MessageReceived(item->Message());
+               }
        }
-}
 
-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());
+       // 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));
+       }
 
-       return B_OK;
+       BMenuField* actionField = new BMenuField("action", 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::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);
-                       }
+
+status_t
+RuleFilterConfig::SaveInto(BMailAddOnSettings& settings) const
+{
+       int32 action = fActionMenu->IndexOf(fActionMenu->FindMarked());
+       settings.SetInt32("action", action);
+       settings.SetString("attribute", fAttributeControl->Text());
+       settings.SetString("regex", fRegexControl->Text());
+
+       switch (action) {
+               case ACTION_MOVE_TO:
+                       settings.SetString("move target", fFileControl->Text());
                        break;
-               case kMsgActionDelete:
-                       arg->SetEnabled(false);
-                       if (arg->Parent() == NULL) {
-                               outbound_field->RemoveSelf();
-                               AddChild(arg);
-                       }
+
+               case ACTION_SET_FLAGS_TO:
+                       settings.SetString("set flags", fFlagsControl->Text());
                        break;
-               case kMsgActionReplyWith:
-                       if (outbound->Parent() == NULL) {
-                               arg->RemoveSelf();
-                               AddChild(outbound_field);
+
+               case ACTION_REPLY_WITH:
+               {
+                       BMenuItem* item = fAccountMenu->FindMarked();
+                       if (item != NULL) {
+                               settings.SetInt32("account",
+                                       item->Message()->FindInt32("account 
id"));
                        }
                        break;
-               case kMsgActionSetRead:
-                       arg->SetEnabled(false);
-                       if (arg->Parent() == NULL) {
-                               outbound_field->RemoveSelf();
-                               AddChild(arg);
-                       }
+               }
+       }
+
+       return B_OK;
+}
+
+
+void
+RuleFilterConfig::AttachedToWindow()
+{
+       fActionMenu->SetTargetForItems(this);
+}
+
+
+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 -
+
+
+BMailSettingsView*
+instantiate_filter_settings_view(const BMailAccountSettings& accountSettings,
+       const BMailAddOnSettings& settings)
 {
-       return new RuleFilterConfig(&settings.Settings());
+       return new RuleFilterConfig(settings);
 }
diff --git a/src/add-ons/mail_daemon/inbound_filters/match_header/Jamfile 
b/src/add-ons/mail_daemon/inbound_filters/match_header/Jamfile
index 347ee33..98e4c72 100644
--- a/src/add-ons/mail_daemon/inbound_filters/match_header/Jamfile
+++ b/src/add-ons/mail_daemon/inbound_filters/match_header/Jamfile
@@ -13,7 +13,7 @@ Addon MatchHeader
        RuleFilter.cpp
        StringMatcher.cpp
        :
-       be libmail.so $(TARGET_LIBSUPC++) localestub
+       be libmail.so $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
        ;
 
 DoCatalogs MatchHeader
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 ed3bf8a..c01f46e 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-2013, 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"
@@ -17,123 +22,121 @@
 
 #include <MailProtocol.h>
 
+#include "MatchHeaderSettings.h"
+
 
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "RuleFilter"
 
 
-RuleFilter::RuleFilter(MailProtocol& protocol, AddonSettings* addonSettings)
+RuleFilter::RuleFilter(BMailProtocol& protocol,
+       const BMailAddOnSettings& addOnSettings)
        :
-       MailFilter(protocol, addonSettings)
+       BMailFilter(protocol, &addOnSettings)
 {
-       const BMessage* settings = &addonSettings->Settings();
+       MatchHeaderSettings settings(addOnSettings);
+
        // attribute is adapted to our "capitalize-each-word-in-the-header" 
policy
-       settings->FindString("attribute", &fAttribute);
+       fAttribute = settings.Attribute();
        fAttribute.CapitalizeEachWord();
 
-       BString regex;
-       settings->FindString("regex", &regex);
-       
-       int32 index = regex.FindFirst("REGEX:");
+       fExpression = settings.Expression();
+       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", (int32*)&fDoWhat);
-       if (fDoWhat == Z_SET_REPLY)
-               settings->FindInt32("argument", &fReplyAccount);
+               fExpression.RemoveFirst("REGEX:");
+
+       fMatcher.SetPattern(fExpression, false);
+
+       fAction = settings.Action();
+       fMoveTarget = settings.MoveTarget();
+       fSetFlags = settings.SetFlagsTo();
+       fReplyAccount = settings.ReplyAccount();
 }
 
 
-void
-RuleFilter::HeaderFetched(const entry_ref& ref, BFile* file)
+BMailFilterAction
+RuleFilter::HeaderFetched(entry_ref& ref, BFile& file, BMessage& attributes)
 {
+       // That field doesn't exist? NO match
        if (fAttribute == "")
-               return; //----That field doesn't exist? NO match
+               return B_NO_MAIL_ACTION;
 
        attr_info info;
-       if (file->GetAttrInfo("Subject", &info) != B_OK
+       if (file.GetAttrInfo("Subject", &info) != B_OK
                || info.type != B_STRING_TYPE)
-               return;
+               return B_NO_MAIL_ACTION;
 
-       char* buffer = new char[info.size];
-       if (file->ReadAttr(fAttribute, B_STRING_TYPE, 0, buffer, info.size) < 
0) {
-               delete[] buffer;
-               return;
+       BString data = attributes.GetString(fAttribute.String(), NULL);
+       if (data.IsEmpty() || !fMatcher.Match(data)) {
+               // We're not supposed to do anything
+               return B_NO_MAIL_ACTION;
        }
-       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:
+
+       switch (fAction) {
+               case ACTION_MOVE_TO:
                {
-                       BDirectory dir(fArg);
-                       fMailProtocol.Looper()->TriggerFileMove(ref, dir);
-                       break;
+                       BDirectory dir(fMoveTarget);
+                       node_ref nodeRef;
+                       status_t status = dir.GetNodeRef(&nodeRef);
+                       if (status != B_OK)
+                               return status;
+
+                       ref.device = nodeRef.device;
+                       ref.directory = nodeRef.node;
+                       return B_MOVE_MAIL_ACTION;
                }
-               case Z_TRASH:
-                       // TODO trash!?
-                       fMailProtocol.Looper()->TriggerFileDeletion(ref);
-                       break;
 
-               case Z_FLAG:
-                       file->WriteAttrString("MAIL:filter_flags", &fArg);
+               case ACTION_DELETE_MESSAGE:
+                       return B_DELETE_MAIL_ACTION;
+
+               case ACTION_SET_FLAGS_TO:
+                       file.WriteAttrString("MAIL:filter_flags", &fSetFlags);
                        break;
 
-               case Z_SET_REPLY:
-                       file->WriteAttr("MAIL:reply_with", B_INT32_TYPE, 0, 
&fReplyAccount,
-                               4);
+               case ACTION_REPLY_WITH:
+                       file.WriteAttr("MAIL:reply_with", B_INT32_TYPE, 0, 
&fReplyAccount,
+                               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);
+       return B_NO_MAIL_ACTION;
+}
 
-       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;*/
-       return B_TRANSLATE("Rule filter");
+BString
+filter_name(const BMailAccountSettings& accountSettings,
+       const BMailAddOnSettings* addOnSettings)
+{
+       if (addOnSettings != NULL) {
+               MatchHeaderSettings settings(*addOnSettings);
+               if (settings.Attribute() != NULL && settings.Expression() != 
NULL) {
+                       BString name(
+                               B_TRANSLATE("Match \"%attribute\" against 
\"%regex\""));
+                       name.ReplaceAll("%attribute", settings.Attribute());
+                       name.ReplaceAll("%regex", settings.Expression());
+                       return name;
+               }
+       }
+       return B_TRANSLATE("Match header");
 }
 
 
-MailFilter*
-instantiate_mailfilter(MailProtocol& protocol, AddonSettings* settings)
+BMailFilter*
+instantiate_filter(BMailProtocol& protocol, const 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..e7a48f3 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,38 @@
-#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-2013, 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 "MatchHeaderSettings.h"
 #include "StringMatcher.h"
 
 
-typedef enum {
-       Z_MOVE_TO,
-       Z_FLAG,
-       Z_TRASH,
-       Z_SET_REPLY,
-       Z_SET_READ
-} z_mail_action_flags;
-
-
-class RuleFilter : public MailFilter {
+class RuleFilter : public BMailFilter {
 public:
-                                                               
RuleFilter(MailProtocol& protocol,
-                                                                       
AddonSettings* settings);
-                       void                            HeaderFetched(const 
entry_ref& ref,
-                                                                       BFile* 
file);
+                                                               
RuleFilter(BMailProtocol& protocol,
+                                                                       const 
BMailAddOnSettings& settings);
+
+       virtual BMailFilterAction       HeaderFetched(entry_ref& ref, BFile& 
file,
+                                                                       
BMessage& attributes);
 
 private:
-                       StringMatcher           fMatcher;
                        BString                         fAttribute;
-                       BString                         fArg;
+                       BString                         fExpression;
+                       StringMatcher           fMatcher;
+                       BString                         fMoveTarget;
+                       BString                         fSetFlags;
                        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
deleted file mode 100644
index fa9e8fc..0000000
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/* ConfigView - the configuration view for the Notifier filter
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
-
-
-#include "ConfigView.h"
-
-#include <Catalog.h>
-#include <CheckBox.h>
-#include <PopUpMenu.h>
-#include <MenuItem.h>
-#include <MenuField.h>
-#include <String.h>
-#include <Message.h>
-
-#include <MailAddon.h>
-#include <MailSettings.h>
-
-
-#undef B_TRANSLATION_CONTEXT
-#define B_TRANSLATION_CONTEXT "ConfigView"
-
-
-const uint32 kMsgNotifyMethod = 'nomt';
-
-
-ConfigView::ConfigView()
-       :       BView(BRect(0,0,10,10),"notifier_config",B_FOLLOW_LEFT | 
B_FOLLOW_TOP,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);
-
-       const char *notifyMethods[] = {
-               B_TRANSLATE("Beep"),
-               B_TRANSLATE("Alert"),
-               B_TRANSLATE("Keyboard LEDs"),
-               B_TRANSLATE("Central alert"),
-               B_TRANSLATE("Central beep"),
-               B_TRANSLATE("Log window")
-       };
-       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();
-}              
-
-
-void ConfigView::AttachedToWindow()
-{
-       if (BMenuField *field = dynamic_cast<BMenuField *>(FindView("notify")))
-               field->Menu()->SetTargetForItems(this);
-}
-
-
-void ConfigView::SetTo(const BMessage *archive)
-{
-       int32 method = archive->FindInt32("notification_method");
-       if (method < 0)
-               method = 1;
-
-       BMenuField *field;
-       if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) == NULL)
-               return;
-
-       for (int32 i = field->Menu()->CountItems();i-- > 0;)
-       {
-               BMenuItem *item = field->Menu()->ItemAt(i);
-               item->SetMarked((method & (1L << i)) != 0);
-       }
-       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;)
-       {
-               BMenuItem *item = field->Menu()->ItemAt(i);
-               if (!item->IsMarked())
-                       continue;
-
-               if (label != "")
-                       label.Prepend(" + ");
-               label.Prepend(item->Label());
-       }
-       if (label == "")
-               label = B_TRANSLATE("none");
-       field->MenuItem()->SetLabel(label.String());
-}
-
-
-void ConfigView::MessageReceived(BMessage *msg)
-{
-       switch (msg->what)
-       {
-               case kMsgNotifyMethod:
-               {
-                       BMenuItem *item;
-                       if (msg->FindPointer("source",(void **)&item) < B_OK)
-                               break;
-                       
-                       item->SetMarked(!item->IsMarked());
-                       UpdateNotifyText();
-                       break;
-               }
-               default:
-                       BView::MessageReceived(msg);
-       }
-}
-
-
-status_t ConfigView::Archive(BMessage *into, bool) const
-{
-       int32 method = 0;
-
-       BMenuField *field;
-       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);
-
-       return B_OK;
-}
-
-       
-void ConfigView::GetPreferredSize(float *width, float *height)
-{
-       *width = 258;
-       *height = ChildAt(0)->Bounds().Height() + 8;
-}
-
-
-BView*
-instantiate_filter_config_panel(AddonSettings& settings)
-{
-       ConfigView *view = new ConfigView();
-       view->SetTo(&settings.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
deleted file mode 100644
index 33f433f..0000000
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/ConfigView.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef CONFIG_VIEW
-#define CONFIG_VIEW
-/* ConfigView - the configuration view for the Notifier filter
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
-
-
-#include <View.h>
-
-
-enum {
-       do_beep = 1,
-       alert = 2,
-       blink_leds = 4,
-       big_doozy_alert = 8,
-       one_central_beep = 16,
-       log_window = 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);
-
-               void UpdateNotifyText();
-};
-
-#endif /* CONFIG_VIEW */
diff --git a/src/add-ons/mail_daemon/inbound_filters/notifier/Jamfile 
b/src/add-ons/mail_daemon/inbound_filters/notifier/Jamfile
index 68f2349..74fd2c5 100644
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/Jamfile
+++ b/src/add-ons/mail_daemon/inbound_filters/notifier/Jamfile
@@ -5,18 +5,18 @@ UsePublicHeaders [ FDirName add-ons mail_daemon ] ;
 
 SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
 
-AddResources NewMailNotification : NewMailNotification.rdef ;
+AddResources NewMailNotification : NotifierFilter.rdef ;
 
 Addon NewMailNotification :
-       filter.cpp
-       ConfigView.cpp
+       NotifierFilter.cpp
+       NotifierConfigView.cpp
        :
-       be libmail.so localestub $(TARGET_LIBSUPC++)
+       be libmail.so $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++)
        ;
 
 DoCatalogs NewMailNotification :
        x-vnd.Haiku-NewMailNotification
        :
-       ConfigView.cpp
-       filter.cpp
+       NotifierFilter.cpp
+       NotifierConfigView.cpp
 ;
diff --git 
a/src/add-ons/mail_daemon/inbound_filters/notifier/NewMailNotification.rdef 
b/src/add-ons/mail_daemon/inbound_filters/notifier/NewMailNotification.rdef
deleted file mode 100644
index a27a2df..0000000
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/NewMailNotification.rdef
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * NewMailNotification.rdef
- */
-
-resource app_signature "application/x-vnd.Haiku-NewMailNotification";
-
-resource app_version {
-       major  = 1,
-       middle = 0,
-       minor  = 0,
-       variety = 0,
-       internal = 0,
-       short_info = "1.0.0",
-       long_info = "Haiku NewMailNotification mail_daemon add-on."
-};
diff --git a/src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp 
b/src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp
deleted file mode 100644
index d417ed7..0000000
--- a/src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/* New Mail Notification - notifies incoming e-mail
- *
- * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
- * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
-*/
-
-
-#include <Alert.h>
-#include <Application.h>
-#include <Beep.h>
-#include <Catalog.h>
-#include <Message.h>
-#include <Path.h>
-#include <String.h>
-
-#include <MailAddon.h>
-
-#include "ConfigView.h"
-
-
-#undef B_TRANSLATION_CONTEXT
-#define B_TRANSLATION_CONTEXT "filter"
-
-
-class NotifyFilter : public MailFilter
-{
-public:
-                                                               
NotifyFilter(MailProtocol& protocol,
-                                                                       
AddonSettings* settings);
-
-                       void                            HeaderFetched(const 
entry_ref& ref,
-                                                                       BFile* 
file);
-                       void                            MailboxSynced(status_t 
status);
-private:
-                       int32                           fStrategy;
-                       int32                           fNNewMessages;
-};
-
-
-NotifyFilter::NotifyFilter(MailProtocol& protocol, AddonSettings* settings)
-       :
-       MailFilter(protocol, settings),
-       fNNewMessages(0)
-{
-       fStrategy = settings->Settings().FindInt32("notification_method");
-}
-
-
-void
-NotifyFilter::HeaderFetched(const entry_ref& ref, BFile* file)
-{
-       char statusString[256];
-       if (file->ReadAttr("MAIL:status", B_STRING_TYPE, 0, statusString, 256) 
< 0)
-               return;
-       if (BString(statusString).Compare("Read") != 0)
-               fNNewMessages++;
-}
-
-
-void
-NotifyFilter::MailboxSynced(status_t status)
-{
-       if (fNNewMessages == 0)
-               return;
-
-       if (fStrategy & do_beep)
-               system_beep("New E-mail");
-
-       if (fStrategy & alert) {
-               BString text, numString;
-               if (fNNewMessages != 1)
-                       text << B_TRANSLATE("You have %num new messages for 
%name.");
-               else
-                       text << B_TRANSLATE("You have %num new message for 
%name.");
-
-               numString << fNNewMessages;
-               text.ReplaceFirst("%num", numString);
-               text.ReplaceFirst("%name", 
fMailProtocol.AccountSettings().Name());
-
-               BAlert *alert = new BAlert(B_TRANSLATE("New messages"), 
text.String(),
-                       B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL);
-               alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
-               alert->SetFeel(B_NORMAL_WINDOW_FEEL);
-               alert->Go(NULL);
-       }
-
-       if (fStrategy & blink_leds)
-               be_app->PostMessage('mblk');
-
-       if (fStrategy & one_central_beep)
-               be_app->PostMessage('mcbp');
-
-       if (fStrategy & big_doozy_alert) {
-               BMessage msg('numg');
-               msg.AddInt32("num_messages", fNNewMessages);
-               msg.AddString("name", fMailProtocol.AccountSettings().Name());
-
-               be_app->PostMessage(&msg);
-       }
-
-       if (fStrategy & log_window) {
-               BString message, numString;
-               if (fNNewMessages != 1)
-                       message << B_TRANSLATE("%num new messages");
-               else
-                       message << B_TRANSLATE("%num new message");
-
-               numString << fNNewMessages;
-               message.ReplaceFirst("%num", numString);
-
-               fMailProtocol.ShowMessage(message.String());
-       }
-
-       fNNewMessages = 0;
-}
-
-
-MailFilter*
-instantiate_mailfilter(MailProtocol& protocol, AddonSettings* settings)
-{
-       return new NotifyFilter(protocol, settings);
-}
-
diff --git a/src/add-ons/mail_daemon/inbound_filters/spam_filter/Jamfile 
b/src/add-ons/mail_daemon/inbound_filters/spam_filter/Jamfile
index e471ac7..e3a5250 100644
--- a/src/add-ons/mail_daemon/inbound_filters/spam_filter/Jamfile
+++ b/src/add-ons/mail_daemon/inbound_filters/spam_filter/Jamfile
@@ -12,7 +12,7 @@ Addon SpamFilter :
        SpamFilterConfig.cpp
        SpamFilter.cpp
        :
-       be libmail.so localestub $(TARGET_LIBSUPC++)
+       be libmail.so $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++)
        ;
 
 DoCatalogs SpamFilter
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 ea79b60..9ca3a6c 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
@@ -1,116 +1,25 @@
 /*
- * Copyright 2002-2011, Haiku, Inc. All rights reserved.
+ * Copyright 2002-2013, Haiku, Inc. All rights reserved.
  * Copyright 2002 Alexander G. M. Smith.
  * 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,50 @@

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


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

Commit:      1cd5a1879101871124b95386711000bedd1dc514
Author:      Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date:        Thu Jun 12 07:26:43 2014 UTC

Blah commit.

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

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

Commit:      14ca473e197e0b7e091f6164b862e91a8d87d53d
Author:      Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date:        Thu Jun 12 07:30:36 2014 UTC

New files

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

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

Commit:      b95a6ab72a9499e021c2567907b33fdde641e428
Author:      Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date:        Thu Jun 12 11:35:15 2014 UTC

Disable IPv6 code; broken, and interferes with mailkit atm.
Also return B_OK when a folder doesn't match on the server, so rest of
mail keeps on working.

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


Other related posts:

  • » [haiku-commits] BRANCH jessicah-github.imap.pm [b95a6ab] in src: add-ons/mail_daemon/inbound_protocols/imap/imap_lib kits/mail add-ons/mail_daemon/inbound_protocols/imap servers/mail add-ons/mail_daemon/outbound_protocols/smtp - jessicah-github . imap . pm