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 :( git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40397 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -92,27 +92,6 @@ typedef struct {
|
||||
} 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 {
|
||||
|
||||
@@ -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 <[email protected]>
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
static status_t Quit();
|
||||
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:
|
||||
//! 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();
|
||||
};
|
||||
|
||||
#endif /* ZOIDBERG_MAIL_DAEMON_H */
|
||||
|
||||
#endif // MAIL_DAEMON_H
|
||||
|
||||
@@ -25,7 +25,8 @@ enum mail_reply_to_mode {
|
||||
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 @@ class BEmailMessage : public BMailContainer {
|
||||
|
||||
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 @@ class BEmailMessage : public BMailContainer {
|
||||
BPositionIO *fData;
|
||||
|
||||
status_t _status;
|
||||
int32 _chain_id;
|
||||
int32 _account_id;
|
||||
char *_bcc;
|
||||
|
||||
int32 _num_components;
|
||||
|
||||
+172
-119
@@ -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 @@ typedef enum
|
||||
B_MAIL_SHOW_STATUS_WINDOW_ALWAYS = 3
|
||||
} b_mail_status_window_option;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
B_MAIL_STATUS_LOOK_TITLED = 0,
|
||||
@@ -29,126 +38,170 @@ typedef enum
|
||||
B_MAIL_STATUS_LOOK_NO_BORDER = 4
|
||||
} b_mail_status_window_look;
|
||||
|
||||
typedef enum {
|
||||
inbound,
|
||||
outbound
|
||||
} b_mail_chain_direction;
|
||||
|
||||
class BMailStatusWindow;
|
||||
class BMailChain;
|
||||
|
||||
BMailChain* NewMailChain();
|
||||
BMailChain* GetMailChain(uint32 id);
|
||||
|
||||
status_t GetOutboundMailChains(BList* list);
|
||||
status_t GetInboundMailChains(BList* list);
|
||||
|
||||
|
||||
class BMailChain : public BArchivable {
|
||||
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;
|
||||
|
||||
b_mail_chain_direction fDirection;
|
||||
|
||||
int32 fSettingsCount;
|
||||
int32 fAddonsCount;
|
||||
BList fFilterSettings;
|
||||
BList fFilterAddons;
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
public:
|
||||
BMailSettings();
|
||||
~BMailSettings();
|
||||
|
||||
void SetConfigWindowFrame(BRect frame);
|
||||
BRect ConfigWindowFrame();
|
||||
status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
status_t Reload();
|
||||
status_t InitCheck() const;
|
||||
|
||||
void SetStatusWindowFrame(BRect frame);
|
||||
BRect StatusWindowFrame();
|
||||
// Global settings
|
||||
int32 WindowFollowsCorner();
|
||||
void SetWindowFollowsCorner(int32 which_corner);
|
||||
|
||||
int32 StatusWindowWorkspaces();
|
||||
void SetStatusWindowWorkspaces(int32 workspaces);
|
||||
uint32 ShowStatusWindow();
|
||||
void SetShowStatusWindow(uint32 mode);
|
||||
|
||||
bool DaemonAutoStarts();
|
||||
void SetDaemonAutoStarts(bool does_it);
|
||||
|
||||
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);
|
||||
void SetConfigWindowFrame(BRect frame);
|
||||
BRect ConfigWindowFrame();
|
||||
|
||||
private:
|
||||
BMessage fData;
|
||||
uint32 _reserved[4];
|
||||
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:
|
||||
AddonSettings();
|
||||
|
||||
bool Load(const BMessage& message);
|
||||
bool Save(BMessage& message);
|
||||
|
||||
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 MailAddonSettings : public AddonSettings
|
||||
{
|
||||
public:
|
||||
bool Load(const BMessage& message);
|
||||
bool Save(BMessage& message);
|
||||
|
||||
int32 CountFilterSettings();
|
||||
int32 AddFilterSettings(const entry_ref* ref = NULL);
|
||||
bool RemoveFilterSettings(int32 index);
|
||||
bool MoveFilterSettings(int32 from, int32 to);
|
||||
AddonSettings* FilterSettingsAt(int32 index);
|
||||
|
||||
bool HasBeenModified();
|
||||
private:
|
||||
std::vector<AddonSettings> fFiltersSettings;
|
||||
};
|
||||
|
||||
|
||||
class BMailAccountSettings
|
||||
{
|
||||
public:
|
||||
BMailAccountSettings();
|
||||
BMailAccountSettings(BEntry account);
|
||||
~BMailAccountSettings();
|
||||
|
||||
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);
|
||||
BMailAccountSettings* AccountByName(const char* name);
|
||||
private:
|
||||
BObjectList<BMailAccountSettings> fAccounts;
|
||||
};
|
||||
|
||||
|
||||
#endif /* ZOIDBERG_MAIL_SETTINGS_H */
|
||||
|
||||
Reference in New Issue
Block a user