xref: /haiku/src/preferences/mail/ConfigWindow.h (revision 97dfeb96704e5dbc5bec32ad7b21379d0125e031)
1 /*
2  * Copyright 2004-2015, Haiku Inc. All rights reserved.
3  * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
4  * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
5  *
6  * Distributed under the terms of the MIT License.
7  */
8 #ifndef CONFIG_WINDOW_H
9 #define CONFIG_WINDOW_H
10 
11 
12 #include <Window.h>
13 #include <ObjectList.h>
14 #include <ListItem.h>
15 
16 #include "MailSettings.h"
17 
18 
19 class BPopup;
20 class BTextControl;
21 class BCheckBox;
22 class BListView;
23 class BButton;
24 class BMenuField;
25 class BMailSettings;
26 class BTextView;
27 class CenterContainer;
28 
29 
30 enum item_types {
31 	ACCOUNT_ITEM = 0,
32 	INBOUND_ITEM,
33 	OUTBOUND_ITEM,
34 	FILTER_ITEM
35 };
36 
37 
38 class AccountItem : public BStringItem {
39 public:
40 								AccountItem(const char* label,
41 									BMailAccountSettings* account,
42 									item_types type);
43 
44 			void				Update(BView* owner, const BFont* font);
45 			void				DrawItem(BView* owner, BRect rect,
46 									bool complete);
47 			BMailAccountSettings* Account() { return fAccount; }
48 			item_types			Type() { return fType; }
49 
50 private:
51 			BMailAccountSettings* fAccount;
52 			item_types			fType;
53 };
54 
55 
56 class ConfigWindow : public BWindow {
57 public:
58 								ConfigWindow();
59 								~ConfigWindow();
60 
61 			bool				QuitRequested();
62 			void				MessageReceived(BMessage* msg);
63 
64 			BMailAccountSettings*	AddAccount();
65 			void				AccountUpdated(BMailAccountSettings* account);
66 
67 private:
68 			BView*				_BuildHowToView();
69 
70 			void				_LoadSettings();
71 			void				_LoadAccounts();
72 			void				_SaveSettings();
73 
74 			status_t			_SetToGeneralSettings(BMailSettings *general);
75 			void				_RevertToLastSettings();
76 
77 			void				_AddAccountToView(
78 									BMailAccountSettings* account);
79 			void				_RemoveAccount(BMailAccountSettings* account);
80 			void				_RemoveAccountFromListView(
81 									BMailAccountSettings* account);
82 			void				_AccountSelected(AccountItem* item);
83 			void				_ReplaceConfigView(BView* view);
84 
85 private:
86 			BListView*			fAccountsListView;
87 			BMailAccountSettings* fLastSelectedAccount;
88 			BView*				fConfigView;
89 			BButton*			fRemoveButton;
90 
91 			BCheckBox*			fCheckMailCheckBox;
92 			BTextControl*		fIntervalControl;
93 			BMenuField*			fStatusModeField;
94 			BTextView*			fHowToTextView;
95 
96 			bool				fSaveSettings;
97 			BObjectList<BMailAccountSettings>	fAccounts;
98 			BObjectList<BMailAccountSettings>	fToDeleteAccounts;
99 };
100 
101 #endif	/* CONFIG_WINDOW_H */
102