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