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