1 /* 2 * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. 3 * Copyright 2011 Clemens Zeidler. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef MAIL_SETTINGS_H 7 #define MAIL_SETTINGS_H 8 9 10 #include <vector> 11 12 #include <Archivable.h> 13 #include <Entry.h> 14 #include <List.h> 15 #include <Message.h> 16 #include <ObjectList.h> 17 #include <String.h> 18 19 20 class BPath; 21 22 23 typedef enum 24 { 25 B_MAIL_SHOW_STATUS_WINDOW_NEVER = 0, 26 B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING = 1, 27 B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE = 2, 28 B_MAIL_SHOW_STATUS_WINDOW_ALWAYS = 3 29 } b_mail_status_window_option; 30 31 32 typedef enum 33 { 34 B_MAIL_STATUS_LOOK_TITLED = 0, 35 B_MAIL_STATUS_LOOK_NORMAL_BORDER = 1, 36 B_MAIL_STATUS_LOOK_FLOATING = 2, 37 B_MAIL_STATUS_LOOK_THIN_BORDER = 3, 38 B_MAIL_STATUS_LOOK_NO_BORDER = 4 39 } b_mail_status_window_look; 40 41 42 BString default_sent_directory(); 43 44 45 class BMailSettings { 46 public: 47 BMailSettings(); 48 ~BMailSettings(); 49 50 status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT); 51 status_t Reload(); 52 status_t InitCheck() const; 53 54 // Global settings 55 int32 WindowFollowsCorner(); 56 void SetWindowFollowsCorner(int32 which_corner); 57 58 uint32 ShowStatusWindow(); 59 void SetShowStatusWindow(uint32 mode); 60 61 bool DaemonAutoStarts(); 62 void SetDaemonAutoStarts(bool does_it); 63 64 void SetConfigWindowFrame(BRect frame); 65 BRect ConfigWindowFrame(); 66 67 void SetStatusWindowFrame(BRect frame); 68 BRect StatusWindowFrame(); 69 70 int32 StatusWindowWorkspaces(); 71 void SetStatusWindowWorkspaces(int32 workspaces); 72 73 int32 StatusWindowLook(); 74 void SetStatusWindowLook(int32 look); 75 76 bigtime_t AutoCheckInterval(); 77 void SetAutoCheckInterval(bigtime_t); 78 79 bool CheckOnlyIfPPPUp(); 80 void SetCheckOnlyIfPPPUp(bool yes); 81 82 bool SendOnlyIfPPPUp(); 83 void SetSendOnlyIfPPPUp(bool yes); 84 85 int32 DefaultOutboundAccount(); 86 void SetDefaultOutboundAccount(int32 to); 87 88 private: 89 BMessage fData; 90 uint32 _reserved[4]; 91 }; 92 93 94 class AddonSettings 95 { 96 public: 97 AddonSettings(); 98 99 bool Load(const BMessage& message); 100 bool Save(BMessage& message); 101 102 void SetAddonRef(const entry_ref& ref); 103 const entry_ref& AddonRef() const; 104 105 const BMessage& Settings() const; 106 BMessage& EditSettings(); 107 108 bool HasBeenModified(); 109 private: 110 BMessage fSettings; 111 entry_ref fAddonRef; 112 113 bool fModified; 114 }; 115 116 117 class MailAddonSettings : public AddonSettings 118 { 119 public: 120 bool Load(const BMessage& message); 121 bool Save(BMessage& message); 122 123 int32 CountFilterSettings(); 124 int32 AddFilterSettings(const entry_ref* ref = NULL); 125 bool RemoveFilterSettings(int32 index); 126 bool MoveFilterSettings(int32 from, int32 to); 127 AddonSettings* FilterSettingsAt(int32 index); 128 129 bool HasBeenModified(); 130 private: 131 std::vector<AddonSettings> fFiltersSettings; 132 }; 133 134 135 class BMailAccountSettings 136 { 137 public: 138 BMailAccountSettings(); 139 BMailAccountSettings(BEntry account); 140 ~BMailAccountSettings(); 141 142 status_t InitCheck() { return fStatus; } 143 144 void SetAccountID(int32 id); 145 int32 AccountID(); 146 147 void SetName(const char* name); 148 const char* Name() const; 149 150 void SetRealName(const char* realName); 151 const char* RealName() const; 152 153 void SetReturnAddress(const char* returnAddress); 154 const char* ReturnAddress() const; 155 156 bool SetInboundAddon(const char* name); 157 bool SetOutboundAddon(const char* name); 158 const entry_ref& InboundPath() const; 159 const entry_ref& OutboundPath() const; 160 161 MailAddonSettings& InboundSettings(); 162 MailAddonSettings& OutboundSettings(); 163 164 bool HasInbound(); 165 bool HasOutbound(); 166 167 void SetInboundEnabled(bool enabled = true); 168 bool IsInboundEnabled() const; 169 void SetOutboundEnabled(bool enabled = true); 170 bool IsOutboundEnabled() const; 171 172 status_t Reload(); 173 status_t Save(); 174 status_t Delete(); 175 176 bool HasBeenModified(); 177 178 const BEntry& AccountFile(); 179 private: 180 status_t _CreateAccountFilePath(); 181 182 status_t fStatus; 183 BEntry fAccountFile; 184 185 int32 fAccountID; 186 187 BString fAccountName; 188 BString fRealName; 189 BString fReturnAdress; 190 191 MailAddonSettings fInboundSettings; 192 MailAddonSettings fOutboundSettings; 193 194 bool fInboundEnabled; 195 bool fOutboundEnabled; 196 197 bool fModified; 198 }; 199 200 201 class BMailAccounts { 202 public: 203 BMailAccounts(); 204 ~BMailAccounts(); 205 206 static status_t AccountsPath(BPath& path); 207 208 int32 CountAccounts(); 209 BMailAccountSettings* AccountAt(int32 index); 210 211 BMailAccountSettings* AccountByID(int32 id); 212 BMailAccountSettings* AccountByName(const char* name); 213 private: 214 BObjectList<BMailAccountSettings> fAccounts; 215 }; 216 217 218 #endif /* ZOIDBERG_MAIL_SETTINGS_H */ 219