Simplification

This commit is contained in:
M66B 2020-05-19 07:16:31 +02:00
parent 37ddbaf77c
commit 0aa7addb7a
1 changed files with 11 additions and 10 deletions

View File

@ -288,23 +288,26 @@ public class FragmentQuickSetup extends FragmentBase {
String user = (provider.user == EmailProvider.UserType.EMAIL ? email : username); String user = (provider.user == EmailProvider.UserType.EMAIL ? email : username);
Log.i("User type=" + provider.user + " name=" + user); Log.i("User type=" + provider.user + " name=" + user);
List<EntityFolder> folders = null; List<EntityFolder> folders;
String aprotocol = provider.imap.starttls ? "imap" : "imaps"; String aprotocol = provider.imap.starttls ? "imap" : "imaps";
try (EmailService iservice = new EmailService( try (EmailService iservice = new EmailService(
context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) { context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
boolean check_folders = false;
try { try {
iservice.connect( iservice.connect(
provider.imap.host, provider.imap.port, provider.imap.host, provider.imap.port,
EmailService.AUTH_TYPE_PASSWORD, null, EmailService.AUTH_TYPE_PASSWORD, null,
user, password, user, password,
null, imap_fingerprint); null, imap_fingerprint);
check_folders = true;
} catch (EmailService.UntrustedException ex) { } catch (EmailService.UntrustedException ex) {
if (check) if (check) {
imap_fingerprint = ex.getFingerprint(); imap_fingerprint = ex.getFingerprint();
else iservice.connect(
provider.imap.host, provider.imap.port,
EmailService.AUTH_TYPE_PASSWORD, null,
user, password,
null, imap_fingerprint);
} else
throw ex; throw ex;
} catch (AuthenticationFailedException ex) { } catch (AuthenticationFailedException ex) {
if (!user.equals(username)) { if (!user.equals(username)) {
@ -320,12 +323,10 @@ public class FragmentQuickSetup extends FragmentBase {
throw ex; throw ex;
} }
if (check_folders) { folders = iservice.getFolders();
folders = iservice.getFolders();
if (folders == null) if (folders == null)
throw new IllegalArgumentException(context.getString(R.string.title_setup_no_system_folders)); throw new IllegalArgumentException(context.getString(R.string.title_setup_no_system_folders));
}
} }
String iprotocol = provider.smtp.starttls ? "smtp" : "smtps"; String iprotocol = provider.smtp.starttls ? "smtp" : "smtps";