haiku/headers/os/mail/MailSettings.h
Adrien Destugues 4ec6c3a042 Merge patch by plfiorini :
Some changes to the API for notifications.
	* Don't go through be_roster to send a notification, but use Notification->Send() instead.
	* Rename App to Group to make the purpose clearer

And some changes to the notification code itself:
	* Use the Notification class as the way to convey informations about a notification. Allows easier extension of this class
	* Code cleanup
	* Use of the layout kit for the notify window

Unfortunately, the latter part clashes quite a bit with the changes I already did to the notification window, so it's now quite broken. Working on that next, but I wanted to separate that work from the patch ...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43114 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 14:57:43 +00:00

206 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;
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();
void SetInboundEnabled(bool enabled = true);
bool IsInboundEnabled() const;
void SetOutboundEnabled(bool enabled = true);
bool IsOutboundEnabled() const;
status_t Reload();
status_t Save();
status_t Delete();
bool HasBeenModified();
const BEntry& AccountFile();
private:
status_t _CreateAccountFilePath();
private:
status_t fStatus;
BEntry fAccountFile;
int32 fAccountID;
BString fAccountName;
BString fRealName;
BString fReturnAdress;
MailAddonSettings fInboundSettings;
MailAddonSettings fOutboundSettings;
bool fInboundEnabled;
bool fOutboundEnabled;
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 */