haiku/headers/os/mail/MailSettings.h
Clemens Zeidler 1af4fa4ba6 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
2011-02-09 01:49:01 +00:00

208 lines
4.5 KiB
C++

/*
* 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,
B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING = 1,
B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE = 2,
B_MAIL_SHOW_STATUS_WINDOW_ALWAYS = 3
} b_mail_status_window_option;
typedef enum
{
B_MAIL_STATUS_LOOK_TITLED = 0,
B_MAIL_STATUS_LOOK_NORMAL_BORDER = 1,
B_MAIL_STATUS_LOOK_FLOATING = 2,
B_MAIL_STATUS_LOOK_THIN_BORDER = 3,
B_MAIL_STATUS_LOOK_NO_BORDER = 4
} b_mail_status_window_look;
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);
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:
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 */