[haiku-commits] r40397 - in haiku/trunk: build/jam headers/os/add-ons/mail_daemon headers/os/mail headers/private/mail src/kits/mail ...

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 9 Feb 2011 02:49:02 +0100 (CET)

Author: czeidler
Date: 2011-02-09 02:49:01 +0100 (Wed, 09 Feb 2011)
New Revision: 40397
Changeset: http://dev.haiku-os.org/changeset/40397

Added:
   haiku/trunk/src/kits/mail/HaikuMailFormatFilter.cpp
   haiku/trunk/src/kits/mail/HaikuMailFormatFilter.h
   haiku/trunk/src/servers/mail/ErrorLogWindow.cpp
   haiku/trunk/src/servers/mail/ErrorLogWindow.h
   haiku/trunk/src/servers/mail/MailDaemon.cpp
   haiku/trunk/src/servers/mail/MailDaemon.h
   haiku/trunk/src/servers/mail/Notifier.cpp
   haiku/trunk/src/servers/mail/Notifier.h
   haiku/trunk/src/servers/mail/StatusWindow.cpp
   haiku/trunk/src/servers/mail/StatusWindow.h
Removed:
   haiku/trunk/headers/os/add-ons/mail_daemon/ChainRunner.h
   haiku/trunk/headers/os/add-ons/mail_daemon/RemoteStorageProtocol.h
   haiku/trunk/headers/private/mail/status.h
   haiku/trunk/src/kits/mail/ChainRunner.cpp
   haiku/trunk/src/kits/mail/ErrorLogWindow.cpp
   haiku/trunk/src/kits/mail/ErrorLogWindow.h
   haiku/trunk/src/kits/mail/MailAddon.cpp
   haiku/trunk/src/kits/mail/MailChain.cpp
   haiku/trunk/src/kits/mail/RemoteStorageProtocol.cpp
   haiku/trunk/src/kits/mail/StatusWindow.cpp
   haiku/trunk/src/kits/mail/b_mail_message.cpp
   haiku/trunk/src/kits/mail/c_mail_api.cpp
   haiku/trunk/src/kits/mail/cpp_abi_base64.c
Modified:
   haiku/trunk/build/jam/HaikuImage
   haiku/trunk/headers/os/add-ons/mail_daemon/MailAddon.h
   haiku/trunk/headers/os/add-ons/mail_daemon/MailProtocol.h
   haiku/trunk/headers/os/add-ons/mail_daemon/ProtocolConfigView.h
   haiku/trunk/headers/os/mail/E-mail.h
   haiku/trunk/headers/os/mail/MailDaemon.h
   haiku/trunk/headers/os/mail/MailMessage.h
   haiku/trunk/headers/os/mail/MailSettings.h
   haiku/trunk/headers/private/mail/FileConfigView.h
   haiku/trunk/headers/private/mail/crypt.h
   haiku/trunk/headers/private/mail/mail_util.h
   haiku/trunk/src/kits/mail/FileConfigView.cpp
   haiku/trunk/src/kits/mail/Jamfile
   haiku/trunk/src/kits/mail/MailDaemon.cpp
   haiku/trunk/src/kits/mail/MailMessage.cpp
   haiku/trunk/src/kits/mail/MailProtocol.cpp
   haiku/trunk/src/kits/mail/MailSettings.cpp
   haiku/trunk/src/kits/mail/ProtocolConfigView.cpp
   haiku/trunk/src/kits/mail/crypt.cpp
   haiku/trunk/src/kits/mail/mail_util.cpp
   haiku/trunk/src/servers/mail/DeskbarView.cpp
   haiku/trunk/src/servers/mail/Jamfile
   haiku/trunk/src/servers/mail/main.cpp
Log:
Major restructuring of the mail server:

Accounts are now stored in a separate file. Previously they where somehow 
magically assembled from the chain ids. Now its possible to remove a account 
temporary by removing the account file form the account folder.

Each account could have an inbound protocol, an outbound protocol and some 
filters.

Mails are now associated with an account and not with a chain. This required to 
replace the chain id attribute by an account attribute.

Replace BMailFilter and BMailChain by a less general approach. Basically the 
chain had a list of filters and call the ProcessMailMessage for each filter. 
This made it sometime difficult to understand what is going on, e.g. sometimes 
a filter used information gathered by another filters. The new MailProtocol and 
MailFilter classes are calling more dedicated hook functions, e.g. 
HeaderFetched or MessageReadyToSend.

As before all MailProtocol's (plus their filters) are running in their own 
thread.

Cleaned up the error and status window a bit. Abstracted the interface to these 
windows. Should be easy to write a BNotification api back-end now.

Parsing of mail headers is much faster now. Fetching the headers of a large 
mailbox takes ~min and not ~hour now! Initial checkout time is in the same 
order like Opera. The problem was the massive use of fgets in parse_header 
(mail_util.cpp) now the complete header is read in one go. Furthermore, only 
interesting fields are extracted.

Remove some unused files, BeOS relicts... Feel free to translate the mail 
server and remove the own language system (headers/private/mail/MDRLanguage.h).

Sorry for the remaining old (and new) coding style issues, sometime just ignore 
them, to many :(



Modified: haiku/trunk/build/jam/HaikuImage
===================================================================
--- haiku/trunk/build/jam/HaikuImage    2011-02-08 22:20:13 UTC (rev 40396)
+++ haiku/trunk/build/jam/HaikuImage    2011-02-09 01:49:01 UTC (rev 40397)
@@ -524,10 +524,8 @@
 AddFilesToHaikuImage system add-ons mail_daemon inbound_protocols : POP3 IMAP ;
 AddFilesToHaikuImage system add-ons mail_daemon outbound_protocols : SMTP ;
 AddFilesToHaikuImage system add-ons mail_daemon inbound_filters
-       : Match\ Header Spam\ Filter R5\ Daemon\ Filter ;
+       : MatchHeader SpamFilter NewMailNotification ;
 AddFilesToHaikuImage system add-ons mail_daemon outbound_filters : Fortune ;
-AddFilesToHaikuImage system add-ons mail_daemon system_filters
-       : Inbox New\ mail\ notification Outbox Message\ Parser ;
 AddFilesToHaikuImage system add-ons media : $(SYSTEM_ADD_ONS_MEDIA) ;
 AddFilesToHaikuImage system add-ons media plugins
        : $(SYSTEM_ADD_ONS_MEDIA_PLUGINS) ;

Modified: haiku/trunk/headers/os/add-ons/mail_daemon/MailAddon.h
===================================================================
--- haiku/trunk/headers/os/add-ons/mail_daemon/MailAddon.h      2011-02-08 
22:20:13 UTC (rev 40396)
+++ haiku/trunk/headers/os/add-ons/mail_daemon/MailAddon.h      2011-02-09 
01:49:01 UTC (rev 40397)
@@ -1,116 +1,39 @@
-#ifndef ZOIDBERG_MAIL_ADDON_H
-#define ZOIDBERG_MAIL_ADDON_H
 /* 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
 
 
-class BMessage;
-class BView;
-class BPositionIO;
-class BEntry;
-class BPath;
-class BView;
-class BString;
-class BPositionIO;
-class BEntry;
+#include "MailProtocol.h"
+#include "MailSettings.h"
 
-enum {
-       B_MAIL_DISCARD = B_MAIL_ERROR_BASE + 8,
-       //--- This terminates the chain and removes the message being processed
-       // both from disk and from the server.
-       B_MAIL_END_FETCH,
-       //--- Terminates the current operation
-       B_MAIL_END_CHAIN
-       //--- This is for yikes errors, like an unreachable server.
-};
 
-class BMailStatusView;
-class BMailChainRunner;
+class BView;
 
-class BMailFilter
-{
-  public:
-       BMailFilter(BMessage* settings);
-       // How to support queueing messages until a time of the
-       // day/week/month/year?  The settings will contain a
-       // persistent ChainID field, the same for all Filters
-       // on the same "chain".
-       
-       virtual ~BMailFilter();
-       // This will be called when the settings for this Filter
-       // are changed, or there are no new messages to consume
-       // after settings->FindInt32("timeout") seconds.
-       
-       virtual status_t InitCheck(BString* out_message = NULL) = 0;
-       // Returns B_OK if the Filter was constructed success-
-       // fully.  Otherwise it returns an error code.  If it is
-       // passed a valid BString*, it may add an error message
-       // to the end of that BString iff it returns an error.
-       // If it returns an error code then the MailFilter will
-       // probably be deleted and the error shown to the user.
-       
-       virtual status_t ProcessMailMessage
-       (
-               BPositionIO** io_message, BEntry* io_entry,
-               BMessage* io_headers, BPath* io_folder, const char *io_uid
-       ) = 0;
-       // Filters a message.  On input and output, the arguments
-       // are expected to be as below; however it is allowed for
-       // the MailFilter to alter any of these values as nece-
-       // ssary, so long as the constraints are as described when
-       // the function returns:
-       //
-       //   * io_message - a PositionIO that contains the message
-       //       data, pointing to the first byte of the message's
-       //       header.  This can be swapped if, eg, the message
-       //       is copied across volume boundries. When the chain
-       //       begins this is a file in /tmp.
-       //   * io_entry - The entry for the PositionIO above.
-       //   * io_headers - a list of attributes that will be added
-       //       to the message file.
-       //   * io_folder - The message's "folder"---may be com-
-       //       pletely unrelated to its on-disk Entry.
-       //   * io_uid - The unique ID provided by the message's
-       //       Protocol
-       //
-       // At most one Filter::ProcessMailMessage() for a given
-       // chain (and thus ChainID) will be called at a time.
-
-  private:
-       virtual void _ReservedFilter1();
-       virtual void _ReservedFilter2();
-       virtual void _ReservedFilter3();
-       virtual void _ReservedFilter4();
-};
-
 //
 // The addon interface: export instantiate_mailfilter()
 // and instantiate_mailconfig() to create a Filter addon
 //
 
-extern "C" _EXPORT BView* instantiate_config_panel(BMessage *settings,BMessage 
*metadata);
-// return a view that configures the MailProtocol or MailFilter
+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.
-// A note on the metadata argument: The metadata pointer is
-// guaranteed to remain valid as long as this view exists. As it is
-// a pointer to the chain's metadata, your view can save any
-// chain-global settings to it in its Archive() function. Note that
-// you must cache this pointer yourself! You will never get it again.
-// Also note that it is possible for it to be NULL. 
 
-extern "C" _EXPORT BMailFilter* instantiate_mailfilter(BMessage *settings,
-       BMailChainRunner *runner);
-// Return a MailProtocol or MailFilter ready to do its thing,
-// based on settings produced by archiving your config panel.
-// Note that a Mail::Protocol is a Mail::Filter, so use
-// instantiate_mailfilter to start things up.
+extern "C" _EXPORT BView* instantiate_filter_config_panel(AddonSettings&);
+extern "C" _EXPORT MailFilter* instantiate_mailfilter(MailProtocol& protocol,
+       AddonSettings* settings);
 
-extern "C" _EXPORT status_t descriptive_name(BMessage *msg, char *buffer);
+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.

Modified: haiku/trunk/headers/os/add-ons/mail_daemon/MailProtocol.h
===================================================================
--- haiku/trunk/headers/os/add-ons/mail_daemon/MailProtocol.h   2011-02-08 
22:20:13 UTC (rev 40396)
+++ haiku/trunk/headers/os/add-ons/mail_daemon/MailProtocol.h   2011-02-09 
01:49:01 UTC (rev 40397)
@@ -1,107 +1,225 @@
-#ifndef ZOIDBERG_MAIL_PROTOCOL_H
-#define ZOIDBERG_MAIL_PROTOCOL_H
 /* Protocol - the base class for protocol filters
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. 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
 
 
+#include <map>
+#include <vector>
+
+#include <Handler.h>
+#include <Looper.h>
 #include <OS.h>
+#include <ObjectList.h>
+#include <Entry.h>
+#include <File.h>
 
-#include <MailAddon.h>
+#include <MailSettings.h>
 
 
-class BHandler;
-class BStringList;
-class BMailChainRunner;
+class MailNotifier {
+public:
+       virtual                                         ~MailNotifier() {}
 
-class BMailProtocol : public BMailFilter
-{
-  public:
-       BMailProtocol(BMessage* settings, BMailChainRunner *runner);
-       // Open a connection based on 'settings'.  'settings' will
-       // contain a persistent uint32 ChainID field.  At most one
-       // Protocol per ChainID will exist at a given time.
-       // The constructor of Mail::Protocol initializes manifest.
-       // It is your responsibility to fill in unique_ids, *and
-       // to keep it updated* in the course of whatever nefarious
-       // things your protocol does.
-       
-       virtual ~BMailProtocol();
-       // Close the connection and clean up.   This will be cal-
-       // led after FetchMessage() or FetchNewMessage() returns
-       // B_TIMED_OUT or B_ERROR, or when the settings for this
-       // Protocol are changed.
-       
-       virtual status_t GetMessage(
-               const char* uid,
-               BPositionIO** out_file, BMessage* out_headers,
-               BPath* out_folder_location
-       )=0;
-       // Downloads the message with id uid, writing the message's
-       // RFC2822 contents to *out_file and storing any headers it
-       // wants to add other than those from the message itself into
-       // out_headers.  It may store a path (if this type of account
-       // supports folders) in *out_folder_location.
-       //
-       // Returns B_OK if the message is now available in out_file,
-       // B_NAME_NOT_FOUND if there is no message with id 'uid' on
-       // the server, or another error if the connection failed.
-       //
-       // B_OK will cause the message to be stored and processed.
-       // B_NAME_NOT_FOUND will cause appropriate recovery to be
-       // taken (if such exists) but not cause the connection to
-       // be terminated.  Any other error will cause anything writen
-       // to be discarded and and the connection closed.
-       
-       // OBS:
-       // The Protocol may replace *out_file with a custom (read-
-       // only) BPositionIO-derived object that preserves the il-
-       // lusion that the message is writen to *out_file, but in
-       // fact only reads from the server and writes to *out_file
-       // on demand.  This BPositionIO must guarantee that any
-       // data returned by Read() has also been writen to *out_-
-       // file.  It must return a read error if reading from the
-       // network or writing to *out_file fails.
-       //
-       // The mail_daemon will delete *out_file before invoking
-       // FetchMessage() or FetchNewMessage() again.
-       
-       virtual status_t DeleteMessage(const char* uid)=0;
-       // Removes the message from the server.  After this, it's
-       // assumed (but not required) that GetMessage(uid,...)
-       // et al will fail with B_NAME_NOT_FOUND.
-       
-                       void CheckForDeletedMessages();
-       // You can call this to trigger a sweep for deleted messages.
-       // Automatically called at the beginning of the chain.
-       
-       //------MailFilter calls
-       virtual status_t ProcessMailMessage
-       (
-               BPositionIO** io_message, BEntry* io_entry,
-               BMessage* io_headers, BPath* io_folder, const char* io_uid
-       );
-       
-  protected:
-       BStringList *manifest, *unique_ids;
-       BMessage *settings;
-       
-       BMailChainRunner *runner;       
-  private:
-       inline void error_alert(const char *process, status_t error);
-       virtual void _ReservedProtocol1();
-       virtual void _ReservedProtocol2();
-       virtual void _ReservedProtocol3();
-       virtual void _ReservedProtocol4();
-       virtual void _ReservedProtocol5();
+       virtual MailNotifier*           Clone() = 0;
 
-       friend class DeletePass;
-       
-       BHandler *trash_monitor;
-       BStringList *uids_on_disk;
-       
-       uint32 _reserved[3];
+       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,
+                                                                       const 
char* message = NULL) = 0;
+       virtual void                            ResetProgress(const char* 
message = NULL) = 0;
 };
 
-#endif // ZOIDBERG_MAIL_PROTOCOL_H
+
+class MailProtocol;
+
+
+class MailFilter {
+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;
+};
+
+
+class MailProtocolThread;
+
+
+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);
+
+                       //! MailProtocol takes ownership of the filters
+                       bool                            AddFilter(MailFilter* 
filter);
+                       int32                           CountFilter();
+                       MailFilter*                     FilterAt(int32 index);
+                       MailFilter*                     RemoveFilter(int32 
index);
+                       bool                            
RemoveFilter(MailFilter* filter);
+
+                       void                            
NotifyNewMessagesToFetch(int32 nMessages);
+                       void                            
NotifyHeaderFetched(const entry_ref& ref,
+                                                                       BFile* 
mail);
+                       void                            NotifyBodyFetched(const 
entry_ref& ref,
+                                                                       BFile* 
mail);
+                       void                            
NotifyMessageReadyToSend(const entry_ref& ref,
+                                                                       BFile* 
mail);
+                       void                            NotifyMessageSent(const 
entry_ref& ref,
+                                                                       BFile* 
mail);
+
+                       //! mail storage operations
+       virtual status_t                        MoveMessage(const entry_ref& 
ref,
+                                                                       
BDirectory& dir);
+       virtual status_t                        DeleteMessage(const entry_ref& 
ref);
+
+       virtual void                            FileRenamed(const entry_ref& 
from,
+                                                                       const 
entry_ref& to);
+       virtual void                            FileDeleted(const node_ref& 
node);
+
+protected:
+                       void                            
LoadFilters(MailAddonSettings& settings);
+
+                       BMailAccountSettings    fAccountSettings;
+                       MailNotifier*           fMailNotifier;
+
+private:
+                       MailFilter*                     
_LoadFilter(AddonSettings* filterSettings);
+
+                       MailProtocolThread*     fProtocolThread;
+                       BObjectList<BHandler>   fHandlerList;
+                       BObjectList<MailFilter> fFilterList;
+                       std::map<entry_ref, image_id>   fFilterImages;
+};
+
+
+class InboundProtocol : public MailProtocol {
+public:
+                                                               
InboundProtocol(BMailAccountSettings* settings);
+       virtual                                         ~InboundProtocol();
+
+       virtual status_t                        SyncMessages() = 0;
+       virtual status_t                        FetchBody(const entry_ref& ref) 
= 0;
+       virtual status_t                        MarkMessageAsRead(const 
entry_ref& ref,
+                                                                       bool 
read = true);
+       virtual status_t                        DeleteMessage(const entry_ref& 
ref) = 0;
+       virtual status_t                        AppendMessage(const entry_ref& 
ref);
+};
+
+
+class OutboundProtocol : public MailProtocol {
+public:
+                                                               
OutboundProtocol(
+                                                                       
BMailAccountSettings* settings);
+       virtual                                         ~OutboundProtocol();
+
+       virtual status_t                        SendMessages(const 
std::vector<entry_ref>&
+                                                                       mails, 
size_t totalBytes) = 0;
+};
+
+
+class MailProtocolThread : public BLooper {
+public:
+                                                               
MailProtocolThread(MailProtocol* protocol);
+       virtual void                            MessageReceived(BMessage* 
message);
+
+                       MailProtocol*           Protocol() { return 
fMailProtocol; }
+
+                       void                            SetStopNow();
+                       /*! These function post a message to the loop to 
trigger the action.
+                       */
+                       void                            TriggerFileMove(const 
entry_ref& ref,
+                                                                       
BDirectory& dir);
+                       void                            
TriggerFileDeletion(const entry_ref& ref);
+
+                       void                            
TriggerFileRenamed(const entry_ref& from,
+                                                                       const 
entry_ref& to);
+                       void                            
TriggerFileDeleted(const node_ref& node);
+private:
+                       MailProtocol*           fMailProtocol;
+};
+
+
+class InboundProtocolThread : public MailProtocolThread {
+public:
+                                                               
InboundProtocolThread(
+                                                                       
InboundProtocol* protocol);
+                                                               
~InboundProtocolThread();
+
+                       void                            
MessageReceived(BMessage* message);
+
+                       void                            SyncMessages();
+                       void                            FetchBody(const 
entry_ref& ref,
+                                                                       bool 
launch = false);
+                       void                            MarkMessageAsRead(const 
entry_ref& ref,
+                                                                       bool 
read = true);
+                       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);
+
+private:
+                       OutboundProtocol*       fProtocol;
+};
+
+
+#endif // MAIL_PROTOCOL_H

Modified: haiku/trunk/headers/os/add-ons/mail_daemon/ProtocolConfigView.h
===================================================================
--- haiku/trunk/headers/os/add-ons/mail_daemon/ProtocolConfigView.h     
2011-02-08 22:20:13 UTC (rev 40396)
+++ haiku/trunk/headers/os/add-ons/mail_daemon/ProtocolConfigView.h     
2011-02-09 01:49:01 UTC (rev 40397)
@@ -1,38 +1,69 @@
-#ifndef ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
-#define ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
 /* 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_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();
+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(BMessage *archive);
+                       void                            
SetTo(MailAddonSettings& archive);
                
-               void AddFlavor(const char *label);
-               void AddAuthMethod(const char *label,bool needUserPassword = 
true);
+                       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);
+       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:
-               uint32 _reserved[5];
+private:
+                       BodyDownloadConfig*     fBodyDownloadConfig;
 };
 
 #endif /* ZOIDBERG_PROTOCOL_CONFIG_VIEW_H */

Modified: haiku/trunk/headers/os/mail/E-mail.h
===================================================================
--- haiku/trunk/headers/os/mail/E-mail.h        2011-02-08 22:20:13 UTC (rev 
40396)
+++ haiku/trunk/headers/os/mail/E-mail.h        2011-02-09 01:49:01 UTC (rev 
40397)
@@ -92,27 +92,6 @@
 } mail_notification;
 
 
-// #pragma mark - global functions
-
-
-int32 count_pop_accounts(void);
-status_t get_pop_account(mail_pop_account*, int32 index = 0);
-status_t set_pop_account(mail_pop_account*, int32 index = 0,
-       bool save = true);
-status_t get_smtp_host(char*);
-status_t set_smtp_host(char*, bool save = true);
-status_t get_mail_notification(mail_notification*);
-status_t set_mail_notification(mail_notification*, bool save = true);
-
-status_t check_for_mail(int32* incoming_count = NULL);
-status_t send_queued_mail(void);
-status_t forward_mail(entry_ref*, const char* recipients, bool now = true);
-
-ssize_t        decode_base64(char* out, char* in, off_t length,
-       bool replace_cr = false);
-ssize_t        encode_base64(char* out, char* in, off_t length);
-
-
 // #pragma mark - BMailMessage
 
 class BMailMessage {

Modified: haiku/trunk/headers/os/mail/MailDaemon.h
===================================================================
--- haiku/trunk/headers/os/mail/MailDaemon.h    2011-02-08 22:20:13 UTC (rev 
40396)
+++ haiku/trunk/headers/os/mail/MailDaemon.h    2011-02-09 01:49:01 UTC (rev 
40397)
@@ -1,18 +1,34 @@
-#ifndef ZOIDBERG_MAIL_DAEMON_H
-#define ZOIDBERG_MAIL_DAEMON_H
+#ifndef MAIL_DAEMON_H
+#define MAIL_DAEMON_H
 /* Daemon - talking to the mail daemon
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
+ *
+ * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
+ * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
 */
 
+
+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';
+
+
 class BMailDaemon {
-       public:
-               static status_t CheckMail(bool send_queued_mail = true,const 
char *account = NULL);
-               static status_t SendQueuedMail();
-               static int32    CountNewMessages(bool wait_for_fetch_completion 
= false);
+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(
+                                                                       bool 
waitForFetchCompletion = false);
+       static status_t                         MarkAsRead(int32 account, const 
entry_ref& ref,
+                                                                       bool 
read = true);
 
-               static status_t Quit();
+       static status_t                         Quit();
 };
 
-#endif /* ZOIDBERG_MAIL_DAEMON_H */
-
+#endif // MAIL_DAEMON_H

Modified: haiku/trunk/headers/os/mail/MailMessage.h
===================================================================
--- haiku/trunk/headers/os/mail/MailMessage.h   2011-02-08 22:20:13 UTC (rev 
40396)
+++ haiku/trunk/headers/os/mail/MailMessage.h   2011-02-09 01:49:01 UTC (rev 
40397)
@@ -25,7 +25,8 @@
 class BEmailMessage : public BMailContainer {
        public:
                BEmailMessage(BPositionIO *mail_file = NULL, bool own = false, 
uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
-               BEmailMessage(entry_ref *ref, uint32 defaultCharSet = 
B_MAIL_NULL_CONVERSION);
+               BEmailMessage(const entry_ref *ref,
+                       uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
                virtual ~BEmailMessage();
 
                status_t InitCheck() const;
@@ -60,7 +61,7 @@
 
                void SendViaAccountFrom(BEmailMessage *message);
                void SendViaAccount(const char *account_name);
-               void SendViaAccount(int32 chain_id);
+               void SendViaAccount(int32 account);
                int32 Account() const;
                status_t GetAccountName(char *account,int32 maxLength) const;
                status_t GetAccountName(BString *account) const;
@@ -99,7 +100,7 @@
                BPositionIO *fData;
 
                status_t _status;
-               int32 _chain_id;
+               int32 _account_id;
                char *_bcc;
 
                int32 _num_components;

Modified: haiku/trunk/headers/os/mail/MailSettings.h
===================================================================
--- haiku/trunk/headers/os/mail/MailSettings.h  2011-02-08 22:20:13 UTC (rev 
40396)
+++ haiku/trunk/headers/os/mail/MailSettings.h  2011-02-09 01:49:01 UTC (rev 
40397)
@@ -1,17 +1,25 @@
-#ifndef ZOIDBERG_MAIL_SETTINGS_H
-#define ZOIDBERG_MAIL_SETTINGS_H
-/* Settings - the mail daemon's settings
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. 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
+#define MAIL_SETTINGS_H
 
 
+#include <vector>
+
 #include <Archivable.h>
+#include <Entry.h>
 #include <List.h>
 #include <Message.h>
+#include <ObjectList.h>
+#include <String.h>
 
+
 class BPath;
 
+
 typedef enum
 {
        B_MAIL_SHOW_STATUS_WINDOW_NEVER         = 0,
@@ -20,6 +28,7 @@
        B_MAIL_SHOW_STATUS_WINDOW_ALWAYS        = 3
 } b_mail_status_window_option;
 
+
 typedef enum
 {
        B_MAIL_STATUS_LOOK_TITLED                = 0,
@@ -29,126 +38,170 @@
        B_MAIL_STATUS_LOOK_NO_BORDER             = 4
 } b_mail_status_window_look;
 
-typedef enum {
-       inbound,
-       outbound
-} b_mail_chain_direction;
 
-class BMailStatusWindow;
-class BMailChain;
+class BMailSettings {
+public:
+                                                               BMailSettings();
+                                                               
~BMailSettings();
 
-BMailChain* NewMailChain();
-BMailChain* GetMailChain(uint32 id);
+                       status_t                        Save(bigtime_t timeout 
= B_INFINITE_TIMEOUT);
+                       status_t                        Reload();
+                       status_t                        InitCheck() const;
 
-status_t GetOutboundMailChains(BList* list);
-status_t GetInboundMailChains(BList* list);
+                       // Global settings
+                       int32                           WindowFollowsCorner();
+                       void                            
SetWindowFollowsCorner(int32 which_corner);
 
+                       uint32                          ShowStatusWindow();
+                       void                            
SetShowStatusWindow(uint32 mode);
+                       
+                       bool                            DaemonAutoStarts();
+                       void                            
SetDaemonAutoStarts(bool does_it);
 
-class BMailChain : public BArchivable {
+                       void                            
SetConfigWindowFrame(BRect frame);
+                       BRect                           ConfigWindowFrame();
+
+                       void                            
SetStatusWindowFrame(BRect frame);
+                       BRect                           StatusWindowFrame();
+
+                       int32                           
StatusWindowWorkspaces();
+                       void                            
SetStatusWindowWorkspaces(int32 workspaces);
+
+                       int32                           StatusWindowLook();
+                       void                            
SetStatusWindowLook(int32 look);
+
+                       bigtime_t                       AutoCheckInterval();
+                       void                            
SetAutoCheckInterval(bigtime_t);
+
+                       bool                            CheckOnlyIfPPPUp();
+                       void                            
SetCheckOnlyIfPPPUp(bool yes);
+
+                       bool                            SendOnlyIfPPPUp();
+                       void                            SetSendOnlyIfPPPUp(bool 
yes);
+
+                       int32                           
DefaultOutboundAccount();
+                       void                            
SetDefaultOutboundAccount(int32 to);
+
+private:
+                       BMessage                        fData;
+                       uint32                          _reserved[4];
+};
+
+
+class AddonSettings
+{
 public:
-       BMailChain(uint32 id);
-       BMailChain(BMessage*);
-       virtual ~BMailChain();
-       
-       virtual status_t Archive(BMessage*, bool) const;
-       static BArchivable* Instantiate(BMessage*);
-       
-       status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT);
-       status_t Delete() const;
-       status_t Reload();
-       status_t InitCheck() const;
-       
-       uint32 ID() const;
-       
-       b_mail_chain_direction ChainDirection() const;
-       void SetChainDirection(b_mail_chain_direction);
-       
-       const char* Name() const;
-       status_t SetName(const char*);
-       
-       BMessage* MetaData() const;
-       
-       // "Filter" below refers to the settings message for a MailFilter
-       int32 CountFilters() const;
-       status_t GetFilter(int32 index, BMessage* out_settings, entry_ref* 
addon = NULL) const;
-       status_t SetFilter(int32 index, const BMessage&, const entry_ref&);
-       
-       status_t AddFilter(const BMessage&, const entry_ref&); // at end
-       status_t AddFilter(int32 index, const BMessage&, const entry_ref&);
-       status_t RemoveFilter(int32 index);
-       
-       void RunChain(BMailStatusWindow* window,
-               bool async = true,
-               bool save_when_done = true,
-               bool delete_when_done = false);
-       
-  private:
-       status_t GetPath(BPath& path) const;
-       status_t Load(BMessage*);
-       
-       int32 fId;
-       char fName[B_FILE_NAME_LENGTH];
-       BMessage* fMetaData;
-       
-       status_t fStatus;
+                                                               AddonSettings();
 
-       b_mail_chain_direction fDirection;
+                       bool                            Load(const BMessage& 
message);
+                       bool                            Save(BMessage& message);
 
-       int32 fSettingsCount;
-       int32 fAddonsCount;
-       BList fFilterSettings;
-       BList fFilterAddons;
-       
-       uint32 _reserved[5];
+                       void                            SetAddonRef(const 
entry_ref& ref);
+       const   entry_ref&                      AddonRef() const;
+
+       const   BMessage&                       Settings() const;
+                       BMessage&                       EditSettings();
+
+                       bool                            HasBeenModified();
+private:
+                       BMessage                        fSettings;
+                       entry_ref                       fAddonRef;
+
+                       bool                            fModified;
 };
 
 
-class BMailSettings {
-  public:
-       BMailSettings();
-       ~BMailSettings();
-       
-       status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT);
-       status_t Reload();
-       status_t InitCheck() const;
-       
-       // Global settings
-       int32 WindowFollowsCorner();
-       void SetWindowFollowsCorner(int32 which_corner);
-       
-       uint32 ShowStatusWindow();
-       void SetShowStatusWindow(uint32 mode);
-       
-       bool DaemonAutoStarts();
-       void SetDaemonAutoStarts(bool does_it);
+class MailAddonSettings : public AddonSettings
+{
+public:
+                       bool                            Load(const BMessage& 
message);
+                       bool                            Save(BMessage& message);
 
-       void SetConfigWindowFrame(BRect frame);
-       BRect ConfigWindowFrame();
+                       int32                           CountFilterSettings();
+                       int32                           AddFilterSettings(const 
entry_ref* ref = NULL);
+                       bool                            
RemoveFilterSettings(int32 index);
+                       bool                            
MoveFilterSettings(int32 from, int32 to);
+                       AddonSettings*          FilterSettingsAt(int32 index);
 
-       void SetStatusWindowFrame(BRect frame);
-       BRect StatusWindowFrame();
+                       bool                            HasBeenModified();
+private:
+                       std::vector<AddonSettings>      fFiltersSettings;
+};
 
-       int32 StatusWindowWorkspaces();
-       void SetStatusWindowWorkspaces(int32 workspaces);
 
-       int32 StatusWindowLook();
-       void SetStatusWindowLook(int32 look);
-       
-       bigtime_t AutoCheckInterval();
-       void SetAutoCheckInterval(bigtime_t);
-       
-       bool CheckOnlyIfPPPUp();
-       void SetCheckOnlyIfPPPUp(bool yes);
-       
-       bool SendOnlyIfPPPUp();
-       void SetSendOnlyIfPPPUp(bool yes);
-       
-       uint32 DefaultOutboundChainID();
-       void SetDefaultOutboundChainID(uint32 to);
+class BMailAccountSettings
+{
+       public:
+                                                               
BMailAccountSettings();
+                                                               
BMailAccountSettings(BEntry account);
+                                                               
~BMailAccountSettings();
 
-  private:
-       BMessage fData;
-       uint32 _reserved[4];
+                       status_t                        InitCheck() { return 
fStatus; }
+
+                       void                            SetAccountID(int32 id);
+                       int32                           AccountID();
+
+                       void                            SetName(const char* 
name);
+       const   char*                           Name() const;
+
+                       void                            SetRealName(const char* 
realName);
+       const   char*                           RealName() const;
+
+                       void                            SetReturnAddress(const 
char* returnAddress);
+       const   char*                           ReturnAddress() const;
+
+                       bool                            SetInboundAddon(const 
char* name);
+                       bool                            SetOutboundAddon(const 
char* name);
+       const   entry_ref&                      InboundPath() const;
+       const   entry_ref&                      OutboundPath() const;
+
+                       MailAddonSettings&      InboundSettings();
+                       MailAddonSettings&      OutboundSettings();
+
+                       bool                            HasInbound();
+                       bool                            HasOutbound();
+
+                       status_t                        Reload();
+                       status_t                        Save();
+                       status_t                        Delete();
+
+                       bool                            HasBeenModified();
+
+       const   BEntry&                         AccountFile();
+private:
+                       status_t                        _CreateAccountFile();
+
+                       status_t                        fStatus;
+                       BEntry                          fAccountFile;
+
+                       int32                           fAccountID;
+
+                       BString                         fAccountName;
+                       BString                         fRealName;
+                       BString                         fReturnAdress;
+
+                       MailAddonSettings       fInboundSettings;
+                       MailAddonSettings       fOutboundSettings;
+
+                       bool                            fModified;
 };
 
+
+class BMailAccounts {
+public:
+                                                               BMailAccounts();
+                                                               
~BMailAccounts();
+
+       static  status_t                        AccountsPath(BPath& path);
+
+                       int32                           CountAccounts();
+                       BMailAccountSettings*   AccountAt(int32 index);
+
+                       BMailAccountSettings*   AccountByID(int32 id);

[... truncated: 5742 lines follow ...]

Other related posts:

  • » [haiku-commits] r40397 - in haiku/trunk: build/jam headers/os/add-ons/mail_daemon headers/os/mail headers/private/mail src/kits/mail ... - clemens . zeidler