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/* 28ATTR_NAME_AUTHPOP: 29 0 plain text 30 1 APOP 31 32ATTR_NAME_AUTHSMTP: 33 0 none 34 1 ESMTP 35 2 POP3 before SMTP 36 37ATTR_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 45struct 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 64class 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