xref: /haiku/src/preferences/mail/AutoConfigView.h (revision c90684742e7361651849be4116d0e5de3a817194)
1 #ifndef AUTO_CONFIG_VIEW_H
2 #define AUTO_CONFIG_VIEW_H
3 
4 #include "AutoConfig.h"
5 
6 #include <Box.h>
7 #include <Entry.h>
8 #include <MenuField.h>
9 #include <ProtocolConfigView.h>
10 #include <String.h>
11 #include <TextControl.h>
12 
13 
14 const int32	kNameChangedMsg			=	'?nch';
15 const int32	kEMailChangedMsg		=	'?ech';
16 const int32 kProtokollChangedMsg	=	'?pch';
17 const int32 kServerChangedMsg		=	'?sch';
18 
19 enum inbound_type
20 {
21 	POP,
22 	IMAP
23 };
24 
25 
26 struct account_info
27 {
28 	int32			type;
29 	inbound_type	inboundType;
30 	entry_ref		inboundProtocol;
31 	entry_ref		outboundProtocol;
32 	BString			name;
33 	BString			accountName;
34 	BString			email;
35 	BString			loginName;
36 	BString			password;
37 	provider_info	providerInfo;
38 };
39 
40 
41 class AutoConfigView : public BBox
42 {
43 	public:
44 						AutoConfigView(BRect rect, AutoConfig &config);
45 
46 		virtual void	AttachedToWindow();
47 		virtual void	MessageReceived(BMessage *msg);
48 
49 		bool			GetBasicAccountInfo(account_info &info);
50 		bool			IsValidMailAddress(BString email);
51 
52 	private:
53 		BMenuField*		SetupProtokolView(BRect rect);
54 		status_t		GetSMTPAddonRef(entry_ref *ref);
55 
56 		BString			ExtractLocalPart(const char* email);
57 		void			ProposeUsername();
58 
59 		entry_ref		fSMTPAddonRef;
60 		BMenuField		*fTypeField;
61 		BMenuField		*fInProtocolsField;
62 		BTextControl	*fNameView;
63 		BTextControl	*fAccountNameView;
64 		BTextControl	*fEmailView;
65 		BTextControl	*fLoginNameView;
66 		BTextControl	*fPasswordView;
67 
68 		// ref to the parent autoconfig so you only ones read the database
69 		AutoConfig		&fAutoConfig;
70 };
71 
72 
73 class ServerSettingsView : public BView
74 {
75 	public:
76 						ServerSettingsView(BRect rect, const account_info &info);
77 
78 		void			GetServerInfo(account_info &info);
79 
80 	private:
81 		void			DetectMenuChanges();
82 		void			GetAuthEncrMenu(const entry_ref &ref,
83 										BMenuField **authField,
84 										BMenuField **sslField);
85 		bool			fInboundAccount;
86 		bool			fOutboundAccount;
87 		BTextControl	*fInboundNameView;
88 		BMenuField		*fInboundAuthMenu;
89 		BMenuField		*fInboundEncryptionMenu;
90 		BTextControl	*fOutboundNameView;
91 		BMenuField		*fOutboundAuthMenu;
92 		BMenuField		*fOutboundEncryptionMenu;
93 
94 		BMenuItem		*fInboundAuthItemStart;
95 		BMenuItem		*fInboundEncrItemStart;
96 		BMenuItem		*fOutboundAuthItemStart;
97 		BMenuItem		*fOutboundEncrItemStart;
98 };
99 
100 
101 #endif