xref: /haiku/src/preferences/mail/ConfigWindow.h (revision 6eafb4b041ad79cb936b2041fdb9c56b1209cc10)
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* Account() { return fAccount; }
47 			item_types			Type() { return fType; }
48 
49 private:
50 			BMailAccountSettings* fAccount;
51 			item_types			fType;
52 };
53 
54 
55 class ConfigWindow : public BWindow {
56 public:
57 								ConfigWindow();
58 								~ConfigWindow();
59 
60 			bool				QuitRequested();
61 			void				MessageReceived(BMessage* msg);
62 
63 			BMailAccountSettings*	AddAccount();
64 			void				AccountUpdated(BMailAccountSettings* account);
65 
66 private:
67 			BView*				_BuildHowToView();
68 
69 			void				_LoadSettings();
70 			void				_LoadAccounts();
71 			void				_SaveSettings();
72 
73 			status_t			_SetToGeneralSettings(BMailSettings *general);
74 			void				_RevertToLastSettings();
75 
76 			void				_AddAccountToView(
77 									BMailAccountSettings* account);
78 			void				_RemoveAccount(BMailAccountSettings* account);
79 			void				_RemoveAccountFromListView(
80 									BMailAccountSettings* account);
81 			void				_AccountSelected(AccountItem* item);
82 			void				_ReplaceConfigView(BView* view);
83 
84 private:
85 			BListView*			fAccountsListView;
86 			BMailAccountSettings* fLastSelectedAccount;
87 			BView*				fConfigView;
88 			BButton*			fRemoveButton;
89 
90 			BCheckBox*			fCheckMailCheckBox;
91 			BTextControl*		fIntervalControl;
92 			BMenuField*			fStatusModeField;
93 
94 			bool				fSaveSettings;
95 			BObjectList<BMailAccountSettings>	fAccounts;
96 			BObjectList<BMailAccountSettings>	fToDeleteAccounts;
97 };
98 
99 #endif	/* CONFIG_WINDOW_H */
100