xref: /haiku/headers/private/mail/ProtocolConfigView.h (revision 5ac9b506412b11afb993bb52d161efe7666958a5)
1 /*
2  * Copyright 2004-2012, Haiku Inc. All rights reserved.
3  * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
4  *
5  * Distributed under the terms of the MIT License.
6  */
7 #ifndef _PROTOCOL_CONFIG_VIEW_H
8 #define _PROTOCOL_CONFIG_VIEW_H
9 
10 
11 #include <CheckBox.h>
12 #include <StringView.h>
13 #include <TextControl.h>
14 #include <View.h>
15 
16 #include <MailSettings.h>
17 #include <MailSettingsView.h>
18 
19 
20 class BCheckBox;
21 class BGridLayout;
22 class BMenuField;
23 class BTextControl;
24 
25 
26 namespace BPrivate {
27 
28 
29 class BodyDownloadConfigView : public BView {
30 public:
31 								BodyDownloadConfigView();
32 
33 			void				SetTo(const BMailProtocolSettings& settings);
34 
35 			status_t			SaveInto(BMailAddOnSettings& settings) const;
36 
37 	virtual	void				MessageReceived(BMessage* message);
38 	virtual	void				AttachedToWindow();
39 
40 private:
41 			BTextControl*		fSizeControl;
42 			BCheckBox*			fPartialBox;
43 };
44 
45 
46 enum mail_protocol_config_options {
47 	B_MAIL_PROTOCOL_HAS_AUTH_METHODS 			= 1,
48 	B_MAIL_PROTOCOL_HAS_FLAVORS 				= 2,
49 	B_MAIL_PROTOCOL_HAS_USERNAME 				= 4,
50 	B_MAIL_PROTOCOL_HAS_PASSWORD 				= 8,
51 	B_MAIL_PROTOCOL_HAS_HOSTNAME 				= 16,
52 	B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER	= 32,
53 	B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD			= 64
54 };
55 
56 
57 class MailProtocolConfigView : public BMailSettingsView {
58 public:
59 								MailProtocolConfigView(uint32 optionsMask
60 										= B_MAIL_PROTOCOL_HAS_FLAVORS
61 											| B_MAIL_PROTOCOL_HAS_USERNAME
62 											| B_MAIL_PROTOCOL_HAS_PASSWORD
63 											| B_MAIL_PROTOCOL_HAS_HOSTNAME);
64 	virtual						~MailProtocolConfigView();
65 
66 			void				SetTo(const BMailProtocolSettings& settings);
67 
68 			void				AddFlavor(const char* label);
69 			void				AddAuthMethod(const char* label,
70 									bool needUserPassword = true);
71 
72 			BGridLayout*		Layout() const;
73 
74 	virtual status_t			SaveInto(BMailAddOnSettings& settings) const;
75 
76 	virtual	void				AttachedToWindow();
77 	virtual void				MessageReceived(BMessage* message);
78 
79 private:
80 			BTextControl*		_AddTextControl(BGridLayout* layout,
81 									const char* name, const char* label);
82 			BMenuField*			_AddMenuField(BGridLayout* layout,
83 									const char* name, const char* label);
84 			void				_StoreIndexOfMarked(BMessage& message,
85 									const char* name, BMenuField* field) const;
86 			void				_StoreCheckBox(BMessage& message,
87 									const char* name,
88 									BCheckBox* checkBox) const;
89 			void				_SetCredentialsEnabled(bool enabled);
90 
91 private:
92 			BTextControl*		fHostControl;
93 			BTextControl*		fUserControl;
94 			BTextControl*		fPasswordControl;
95 			BMenuField*			fFlavorField;
96 			BMenuField*			fAuthenticationField;
97 			BCheckBox*			fLeaveOnServerCheckBox;
98 			BCheckBox*			fRemoveFromServerCheckBox;
99 			BodyDownloadConfigView* fBodyDownloadConfig;
100 };
101 
102 
103 }	// namespace BPrivate
104 
105 
106 #endif	/* _PROTOCOL_CONFIG_VIEW_H */
107