pull/147/head
M66B 6 years ago
parent 33235e74f7
commit dd26997b6b

@ -129,11 +129,11 @@ public class Provider {
static Provider fromDomain(Context context, String domain) throws IOException { static Provider fromDomain(Context context, String domain) throws IOException {
try { try {
return Provider.fromISPDB(domain); return Provider.fromISPDB(context, domain);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
try { try {
return Provider.fromDNS(domain); return Provider.fromDNS(context, domain);
} catch (UnknownHostException ex1) { } catch (UnknownHostException ex1) {
Log.w(ex1); Log.w(ex1);
throw new UnknownHostException(context.getString(R.string.title_setup_no_settings, domain)); throw new UnknownHostException(context.getString(R.string.title_setup_no_settings, domain));
@ -141,11 +141,14 @@ public class Provider {
} }
} }
private static Provider fromISPDB(String domain) throws IOException, XmlPullParserException { private static Provider fromISPDB(Context context, String domain) throws IOException, XmlPullParserException {
Provider provider = new Provider(domain); Provider provider = new Provider(domain);
if ("gmail.com".equals(domain)) { if ("gmail.com".equals(domain)) {
provider.documentation = new StringBuilder(); provider.documentation = new StringBuilder();
provider.documentation.append("<a href=\"https://www.google.com/settings/security/lesssecureapps\">Enable access for \"less secure\" apps</a>"); provider.documentation
.append("<a href=\"https://www.google.com/settings/security/lesssecureapps\">")
.append(context.getString(R.string.title_setup_setting_gmail))
.append("</a>");
} }
// https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat // https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat
@ -320,7 +323,7 @@ public class Provider {
return provider; return provider;
} }
private static Provider fromDNS(String domain) throws TextParseException, UnknownHostException { private static Provider fromDNS(Context context, String domain) throws TextParseException, UnknownHostException {
// https://tools.ietf.org/html/rfc6186 // https://tools.ietf.org/html/rfc6186
SRVRecord imap = lookup("_imaps._tcp." + domain); SRVRecord imap = lookup("_imaps._tcp." + domain);
SRVRecord smtp = lookup("_submission._tcp." + domain); SRVRecord smtp = lookup("_submission._tcp." + domain);

@ -87,6 +87,7 @@
<string name="title_setup_imported">Settings imported</string> <string name="title_setup_imported">Settings imported</string>
<string name="title_setup_quick">Quick config</string> <string name="title_setup_quick">Quick config</string>
<string name="title_setup_quick_remark">Quick config can be used for most major providers</string> <string name="title_setup_quick_remark">Quick config can be used for most major providers</string>
<string name="title_setup_setting_gmail">Enable access for "less secure" apps</string>
<string name="title_setup_no_settings">No settings found for \'%1$s\'</string> <string name="title_setup_no_settings">No settings found for \'%1$s\'</string>
<string name="title_setup_quick_success">An account and an identity have been added. You can review the details below using the \'manage\' buttons.</string> <string name="title_setup_quick_success">An account and an identity have been added. You can review the details below using the \'manage\' buttons.</string>
<string name="title_setup_quick_failed">You can try to configure an account and an identity below too</string> <string name="title_setup_quick_failed">You can try to configure an account and an identity below too</string>

Loading…
Cancel
Save