xref: /haiku/src/preferences/mail/AutoConfig.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2007-2011, Haiku, Inc. All rights reserved.
3  * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef AUTO_CONFIG_H
7 #define AUTO_CONFIG_H
8 
9 
10 #include <List.h>
11 #include <Node.h>
12 #include <String.h>
13 
14 #define INFO_DIR "Mail/ProviderInfo"
15 
16 #define ATTR_NAME_POPSERVER "POP Server"
17 #define ATTR_NAME_IMAPSERVER "IMAP Server"
18 #define ATTR_NAME_SMTPSERVER "SMTP Server"
19 #define ATTR_NAME_AUTHPOP "POP Authentication"
20 #define ATTR_NAME_AUTHSMTP "SMTP Authentication"
21 #define ATTR_NAME_POPSSL "POP SSL"
22 #define ATTR_NAME_IMAPSSL "IMAP SSL"
23 #define ATTR_NAME_SMTPSSL "SMTP SSL"
24 #define ATTR_NAME_USERNAME "Username Pattern"
25 
26 
27 /*
28 ATTR_NAME_AUTHPOP:
29 	0	plain text
30 	1	APOP
31 
32 ATTR_NAME_AUTHSMTP:
33 	0	none
34 	1	ESMTP
35 	2	POP3 before SMTP
36 
37 ATTR_NAME_USERNAME:
38 	0	username is the email address (default)
39 	1	username is the local-part of the email address local-part@domain.net
40 	2	no username is proposed
41 */
42 
43 
44 
45 struct provider_info
46 {
47 	BString provider;
48 
49 	BString pop_server;
50 	BString imap_server;
51 	BString smtp_server;
52 
53 	int32 authentification_pop;
54 	int32 authentification_smtp;
55 
56 	int32 ssl_pop;
57 	int32 ssl_imap;
58 	int32 ssl_smtp;
59 
60 	int32 username_pattern;
61 };
62 
63 
64 class AutoConfig
65 {
66 	public:
67 		status_t		GetInfoFromMailAddress(const char* email,
68 												provider_info *info);
69 
70 		// for debug
71 		void			PrintProviderInfo(provider_info* pInfo);
72 
73 	private:
74 		status_t		GetMXRecord(const char* provider, provider_info *info);
75 		status_t		GuessServerName(const char* provider,
76 											provider_info *info);
77 
78 		BString			ExtractProvider(const char* email);
79 		status_t		LoadProviderInfo(const BString &provider, provider_info* info);
80 		bool			ReadProviderInfo(BNode *node, provider_info* info);
81 
82 };
83 
84 
85 
86 #endif
87