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