vfs: check userland buffers before reading them.
[haiku.git] / headers / os / mail / MailSettings.h
blob26b63366d723ed840fbd50d76279c1c8470ee982
1 /*
2 * Copyright 2004-2012, Haiku Inc. All rights reserved.
3 * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
4 * Copyright 2011 Clemens Zeidler.
6 * Distributed under the terms of the MIT License.
7 */
8 #ifndef MAIL_SETTINGS_H
9 #define MAIL_SETTINGS_H
12 #include <vector>
14 #include <Archivable.h>
15 #include <Entry.h>
16 #include <List.h>
17 #include <Message.h>
18 #include <ObjectList.h>
19 #include <String.h>
22 class BPath;
25 typedef enum {
26 B_MAIL_SHOW_STATUS_WINDOW_NEVER = 0,
27 B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING = 1,
28 B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE = 2,
29 B_MAIL_SHOW_STATUS_WINDOW_ALWAYS = 3
30 } b_mail_status_window_option;
33 class BMailSettings {
34 public:
35 BMailSettings();
36 ~BMailSettings();
38 status_t Save();
39 status_t Reload();
40 status_t InitCheck() const;
42 // Global settings
43 int32 WindowFollowsCorner();
44 void SetWindowFollowsCorner(int32 which_corner);
46 uint32 ShowStatusWindow();
47 void SetShowStatusWindow(uint32 mode);
49 bool DaemonAutoStarts();
50 void SetDaemonAutoStarts(bool does_it);
52 void SetConfigWindowFrame(BRect frame);
53 BRect ConfigWindowFrame();
55 void SetStatusWindowFrame(BRect frame);
56 BRect StatusWindowFrame();
58 int32 StatusWindowWorkspaces();
59 void SetStatusWindowWorkspaces(int32 workspaces);
61 int32 StatusWindowLook();
62 void SetStatusWindowLook(int32 look);
64 bigtime_t AutoCheckInterval();
65 void SetAutoCheckInterval(bigtime_t);
67 bool CheckOnlyIfPPPUp();
68 void SetCheckOnlyIfPPPUp(bool yes);
70 bool SendOnlyIfPPPUp();
71 void SetSendOnlyIfPPPUp(bool yes);
73 int32 DefaultOutboundAccount();
74 void SetDefaultOutboundAccount(int32 to);
76 private:
77 BMessage fData;
78 uint32 _reserved[4];
82 class BMailAddOnSettings : public BMessage {
83 public:
84 BMailAddOnSettings();
85 virtual ~BMailAddOnSettings();
87 virtual status_t Load(const BMessage& message);
88 virtual status_t Save(BMessage& message);
90 void SetAddOnRef(const entry_ref& ref);
91 const entry_ref& AddOnRef() const;
93 virtual bool HasBeenModified() const;
95 private:
96 const char* _RelativizePath(const BPath& path) const;
98 private:
99 BMessage fOriginalSettings;
100 entry_ref fRef;
101 entry_ref fOriginalRef;
105 class BMailProtocolSettings : public BMailAddOnSettings {
106 public:
107 BMailProtocolSettings();
108 virtual ~BMailProtocolSettings();
110 virtual status_t Load(const BMessage& message);
111 virtual status_t Save(BMessage& message);
113 int32 CountFilterSettings() const;
114 int32 AddFilterSettings(const entry_ref* ref = NULL);
115 void RemoveFilterSettings(int32 index);
116 bool MoveFilterSettings(int32 from, int32 to);
117 BMailAddOnSettings* FilterSettingsAt(int32 index) const;
119 virtual bool HasBeenModified() const;
121 private:
122 BObjectList<BMailAddOnSettings> fFiltersSettings;
126 class BMailAccountSettings {
127 public:
128 BMailAccountSettings();
129 BMailAccountSettings(BEntry account);
130 ~BMailAccountSettings();
132 status_t InitCheck() { return fStatus; }
134 void SetAccountID(int32 id);
135 int32 AccountID() const;
137 void SetName(const char* name);
138 const char* Name() const;
140 void SetRealName(const char* realName);
141 const char* RealName() const;
143 void SetReturnAddress(const char* returnAddress);
144 const char* ReturnAddress() const;
146 bool SetInboundAddOn(const char* name);
147 bool SetOutboundAddOn(const char* name);
148 const entry_ref& InboundAddOnRef() const;
149 const entry_ref& OutboundAddOnRef() const;
151 BMailProtocolSettings& InboundSettings();
152 const BMailProtocolSettings& InboundSettings() const;
153 BMailProtocolSettings& OutboundSettings();
154 const BMailProtocolSettings& OutboundSettings() const;
156 bool HasInbound();
157 bool HasOutbound();
159 void SetInboundEnabled(bool enabled = true);
160 bool IsInboundEnabled() const;
161 void SetOutboundEnabled(bool enabled = true);
162 bool IsOutboundEnabled() const;
164 status_t Reload();
165 status_t Save();
166 status_t Delete();
168 bool HasBeenModified() const;
170 const BEntry& AccountFile() const;
172 private:
173 status_t _CreateAccountFilePath();
174 status_t _GetAddOnRef(const char* subPath,
175 const char* name, entry_ref& ref);
177 private:
178 status_t fStatus;
179 BEntry fAccountFile;
181 int32 fAccountID;
183 BString fAccountName;
184 BString fRealName;
185 BString fReturnAdress;
187 BMailProtocolSettings fInboundSettings;
188 BMailProtocolSettings fOutboundSettings;
190 bool fInboundEnabled;
191 bool fOutboundEnabled;
193 bool fModified;
197 class BMailAccounts {
198 public:
199 BMailAccounts();
200 ~BMailAccounts();
202 static status_t AccountsPath(BPath& path);
204 int32 CountAccounts();
205 BMailAccountSettings* AccountAt(int32 index);
207 BMailAccountSettings* AccountByID(int32 id);
208 BMailAccountSettings* AccountByName(const char* name);
209 private:
210 BObjectList<BMailAccountSettings> fAccounts;
214 #endif /* ZOIDBERG_MAIL_SETTINGS_H */