xref: /haiku/headers/os/mail/MailSettings.h (revision dfc8a217db488098641462dfc334dcc0f7d62456)
1 #ifndef ZOIDBERG_MAIL_SETTINGS_H
2 #define ZOIDBERG_MAIL_SETTINGS_H
3 /* Settings - the mail daemon's settings
4 **
5 ** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
6 */
7 
8 
9 #include <Archivable.h>
10 #include <List.h>
11 #include <Message.h>
12 
13 class BPath;
14 
15 typedef enum
16 {
17 	B_MAIL_SHOW_STATUS_WINDOW_NEVER         = 0,
18 	B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING	= 1,
19 	B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE	= 2,
20 	B_MAIL_SHOW_STATUS_WINDOW_ALWAYS        = 3
21 } b_mail_status_window_option;
22 
23 typedef enum
24 {
25 	B_MAIL_STATUS_LOOK_TITLED                = 0,
26 	B_MAIL_STATUS_LOOK_NORMAL_BORDER         = 1,
27 	B_MAIL_STATUS_LOOK_FLOATING              = 2,
28 	B_MAIL_STATUS_LOOK_THIN_BORDER           = 3,
29 	B_MAIL_STATUS_LOOK_NO_BORDER             = 4
30 } b_mail_status_window_look;
31 
32 typedef enum {
33 	inbound,
34 	outbound
35 } b_mail_chain_direction;
36 
37 class BMailStatusWindow;
38 class BMailChain;
39 
40 BMailChain* NewMailChain();
41 BMailChain* GetMailChain(uint32 id);
42 
43 status_t GetOutboundMailChains(BList* list);
44 status_t GetInboundMailChains(BList* list);
45 
46 
47 class BMailChain : public BArchivable {
48 public:
49 	BMailChain(uint32 id);
50 	BMailChain(BMessage*);
51 	virtual ~BMailChain();
52 
53 	virtual status_t Archive(BMessage*, bool) const;
54 	static BArchivable* Instantiate(BMessage*);
55 
56 	status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT);
57 	status_t Delete() const;
58 	status_t Reload();
59 	status_t InitCheck() const;
60 
61 	uint32 ID() const;
62 
63 	b_mail_chain_direction ChainDirection() const;
64 	void SetChainDirection(b_mail_chain_direction);
65 
66 	const char* Name() const;
67 	status_t SetName(const char*);
68 
69 	BMessage* MetaData() const;
70 
71 	// "Filter" below refers to the settings message for a MailFilter
72 	int32 CountFilters() const;
73 	status_t GetFilter(int32 index, BMessage* out_settings, entry_ref* addon = NULL) const;
74 	status_t SetFilter(int32 index, const BMessage&, const entry_ref&);
75 
76 	status_t AddFilter(const BMessage&, const entry_ref&); // at end
77 	status_t AddFilter(int32 index, const BMessage&, const entry_ref&);
78 	status_t RemoveFilter(int32 index);
79 
80 	void RunChain(BMailStatusWindow* window,
81 		bool async = true,
82 		bool save_when_done = true,
83 		bool delete_when_done = false);
84 
85   private:
86 	status_t GetPath(BPath& path) const;
87 	status_t Load(BMessage*);
88 
89 	int32 fId;
90 	char fName[B_FILE_NAME_LENGTH];
91 	BMessage* fMetaData;
92 
93 	status_t fStatus;
94 
95   	b_mail_chain_direction fDirection;
96 
97 	int32 fSettingsCount;
98 	int32 fAddonsCount;
99 	BList fFilterSettings;
100 	BList fFilterAddons;
101 
102 	uint32 _reserved[5];
103 };
104 
105 
106 class BMailSettings {
107   public:
108 	BMailSettings();
109 	~BMailSettings();
110 
111 	status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT);
112 	status_t Reload();
113 	status_t InitCheck() const;
114 
115 	// Global settings
116 	int32 WindowFollowsCorner();
117 	void SetWindowFollowsCorner(int32 which_corner);
118 
119 	uint32 ShowStatusWindow();
120 	void SetShowStatusWindow(uint32 mode);
121 
122 	bool DaemonAutoStarts();
123 	void SetDaemonAutoStarts(bool does_it);
124 
125 	void SetConfigWindowFrame(BRect frame);
126 	BRect ConfigWindowFrame();
127 
128 	void SetStatusWindowFrame(BRect frame);
129 	BRect StatusWindowFrame();
130 
131 	int32 StatusWindowWorkspaces();
132 	void SetStatusWindowWorkspaces(int32 workspaces);
133 
134 	int32 StatusWindowLook();
135 	void SetStatusWindowLook(int32 look);
136 
137 	bigtime_t AutoCheckInterval();
138 	void SetAutoCheckInterval(bigtime_t);
139 
140 	bool CheckOnlyIfPPPUp();
141 	void SetCheckOnlyIfPPPUp(bool yes);
142 
143 	bool SendOnlyIfPPPUp();
144 	void SetSendOnlyIfPPPUp(bool yes);
145 
146 	uint32 DefaultOutboundChainID();
147 	void SetDefaultOutboundChainID(uint32 to);
148 
149   private:
150 	BMessage fData;
151 	uint32 _reserved[4];
152 };
153 
154 #endif	/* ZOIDBERG_MAIL_SETTINGS_H */
155