xref: /haiku/src/preferences/mail/ConfigWindow.h (revision 81ec973846ea4816c53ed8901822e43c8b06878d)
1 /*
2  * Copyright 2004-2012, 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 CenterContainer;
27 
28 
29 enum item_types {
30 	ACCOUNT_ITEM = 0,
31 	INBOUND_ITEM,
32 	OUTBOUND_ITEM,
33 	FILTER_ITEM
34 };
35 
36 
37 class AccountItem : public BStringItem {
38 public:
39 								AccountItem(const char* label,
40 									BMailAccountSettings* account,
41 									item_types type);
42 
43 			void				Update(BView* owner, const BFont* font);
44 			void				DrawItem(BView* owner, BRect rect,
45 									bool complete);
46 			BMailAccountSettings*	GetAccount() { return fAccount; }
47 			item_types			GetType() { return fType; }
48 
49 			void				SetConfigPanel(BView* panel);
50 			BView*				ConfigPanel();
51 private:
52 			BMailAccountSettings*	fAccount;
53 			item_types			fType;
54 			BView*				fConfigPanel;
55 };
56 
57 
58 class ConfigWindow : public BWindow {
59 public:
60 								ConfigWindow();
61 								~ConfigWindow();
62 
63 			bool				QuitRequested();
64 			void				MessageReceived(BMessage* msg);
65 
66 			BMailAccountSettings*	AddAccount();
67 			void				AccountUpdated(BMailAccountSettings* account);
68 
69 private:
70 			BView*				_BuildHowToView();
71 
72 			void				_LoadSettings();
73 			void				_LoadAccounts();
74 			void				_SaveSettings();
75 
76 			status_t			_SetToGeneralSettings(BMailSettings *general);
77 			void				_RevertToLastSettings();
78 
79 			void				_AddAccountToView(
80 									BMailAccountSettings* account);
81 			void				_RemoveAccount(BMailAccountSettings* account);
82 			void				_RemoveAccountFromListView(
83 									BMailAccountSettings* account);
84 			void				_AccountSelected(AccountItem* item);
85 			void				_ReplaceConfigView(BView* view);
86 
87 private:
88 			BListView*			fAccountsListView;
89 			BMailAccountSettings* fLastSelectedAccount;
90 			BView*				fConfigView;
91 			BButton*			fRemoveButton;
92 
93 			BCheckBox*			fCheckMailCheckBox;
94 			BTextControl*		fIntervalControl;
95 			BMenuField*			fStatusModeField;
96 
97 			bool				fSaveSettings;
98 			BObjectList<BMailAccountSettings>	fAccounts;
99 			BObjectList<BMailAccountSettings>	fToDeleteAccounts;
100 };
101 
102 #endif	/* CONFIG_WINDOW_H */
103