ProtocolConfigView.h revision 383b34ad
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
18
19class BCheckBox;
20class BGridLayout;
21class BMenuField;
22class BTextControl;
23
24
25namespace BPrivate {
26
27
28class BodyDownloadConfig : public BView {
29public:
30								BodyDownloadConfig();
31
32			void				SetTo(BMailProtocolSettings& settings);
33
34			void				MessageReceived(BMessage* message);
35			void				AttachedToWindow();
36			void				GetPreferredSize(float* width, float* height);
37			status_t			Archive(BMessage* into, bool deep = true) const;
38
39private:
40			BTextControl*		fSizeBox;
41			BCheckBox*			fPartialBox;
42			BStringView*		fBytesLabel;
43};
44
45
46enum 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
57class MailProtocolConfigView : public BView {
58public:
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(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			Archive(BMessage* into, bool deep = true) const;
75
76	virtual	void				AttachedToWindow();
77	virtual void				MessageReceived(BMessage* message);
78
79private:
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
91private:
92			BTextControl*		fHostControl;
93			BTextControl*		fUserControl;
94			BTextControl*		fPasswordControl;
95			BMenuField*			fFlavorField;
96			BMenuField*			fAuthenticationField;
97			BCheckBox*			fLeaveOnServerCheckBox;
98			BCheckBox*			fRemoveFromServerCheckBox;
99			BodyDownloadConfig*	fBodyDownloadConfig;
100};
101
102
103}	// namespace BPrivate
104
105
106#endif	/* _PROTOCOL_CONFIG_VIEW_H */
107