Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1293d48b authored by daquexian's avatar daquexian Committed by Vincent Breitmoser
Browse files

Add more debug messages when guessing

parent f92a68d7
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -168,8 +168,8 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
        } else {
            view.setPasswordInBasicsEnabled(false);
            view.setPasswordHintInBasics(context.getString(
                    R.string.account_setup_basics_password_no_password_needed_hint,
                    EmailHelper.getProviderNameFromEmailAddress(email))
                    R.string.account_setup_basics_password_no_password_needed_hint
                    )
            );
            view.setManualSetupButtonInBasicsVisibility(android.view.View.INVISIBLE);
        }
@@ -297,17 +297,25 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
                    guessedDomainForMailPrefix = "mail." + domain;
                }

                Timber.d("Test %s for imap", guessedDomainForMailPrefix);
                testIncoming(guessedDomainForMailPrefix, false);

                Timber.d("Test %s for smtp and starttls", guessedDomainForMailPrefix);
                testOutgoing(guessedDomainForMailPrefix, ConnectionSecurity.STARTTLS_REQUIRED, false);

                Timber.d("Test %s for smtp and ssl/tls", guessedDomainForMailPrefix);
                testOutgoing(guessedDomainForMailPrefix, ConnectionSecurity.SSL_TLS_REQUIRED, false);

                testIncoming("imap." + domain, false);
                String domainWithImapPrefix = "imap." + domain;
                Timber.d("Test %s for imap", domainWithImapPrefix);
                testIncoming(domainWithImapPrefix, false);

                testOutgoing("smtp." + domain, ConnectionSecurity.STARTTLS_REQUIRED, false);
                String domainWithSmtpPrefix = "smtp." + domain;
                Timber.d("Test %s for smtp and starttls", domainWithSmtpPrefix);
                testOutgoing(domainWithSmtpPrefix, ConnectionSecurity.STARTTLS_REQUIRED, false);

                testOutgoing("smtp." + domain, ConnectionSecurity.SSL_TLS_REQUIRED, false);
                Timber.d("Test %s for smtp and ssl/tls", domainWithSmtpPrefix);
                testOutgoing(domainWithSmtpPrefix, ConnectionSecurity.SSL_TLS_REQUIRED, false);
            }

            private void testIncoming(String domain, boolean useLocalPart) {
@@ -318,11 +326,16 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
                                password, domain).toString());
                        accountConfig.getRemoteStore().checkSettings();
                        incomingReady = true;
                        Timber.d("Server %s is right for imap", domain);
                    } catch (AuthenticationFailedException afe) {
                        if (!useLocalPart) {
                            Timber.d("Server %s is connected, but authentication failed. Use local part as username this time", domain);
                            testIncoming(domain, true);
                        } else {
                            Timber.d("Server %s is connected, but authentication failed for both email address and local-part", domain);
                        }
                    } catch (URISyntaxException | MessagingException ignored) {
                        Timber.d("Unknown error occurred when using OAuth 2.0");
                    }
                }
            }
@@ -342,11 +355,16 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
                            transport.close();
                        }
                        outgoingReady = true;
                        Timber.d("Server %s is right for smtp and %s", domain, connectionSecurity.toString());
                    } catch (AuthenticationFailedException afe) {
                        if (!useLocalPart) {
                            Timber.d("Server %s is connected, but authentication failed. Use local part as username this time", domain);
                            testOutgoing(domain, connectionSecurity, true);
                        } else {
                            Timber.d("Server %s is connected, but authentication failed for both email address and local-part", domain);
                        }
                    } catch (URISyntaxException | MessagingException ignored) {
                        Timber.d("Unknown error occurred when using OAuth 2.0");
                    }
                }
            }
@@ -1517,12 +1535,12 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
            boolean requireLogin) {

        boolean isAuthTypeOAuth = (AuthType.XOAUTH2 == authType);
        boolean isOAuthValid = canOAuth2(username);
        boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
        boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);

        boolean hasValidCertificateAlias = certificateAlias != null;
        boolean hasValidUserName = Utility.requiredFieldValid(username);
        boolean isOAuthValid = hasValidUserName && canOAuth2(username);

        boolean hasValidPasswordSettings = hasValidUserName
                && !isAuthTypeExternal
+1 −1
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ Please submit bug reports, contribute new features and ask questions at
    <string name="account_setup_basics_title">Set up a new account</string>
    <string name="account_setup_basics_email_hint">Email address</string>
    <string name="account_setup_basics_password_hint">Password</string>
    <string name="account_setup_basics_password_no_password_needed_hint">No password needed for %s</string>
    <string name="account_setup_basics_password_no_password_needed_hint">Please click next</string>
    <string name="account_setup_basics_show_password">Show password</string>
    <string name="account_setup_basics_manual_setup_action">Manual setup</string>

+4 −0
Original line number Diff line number Diff line
@@ -9,8 +9,10 @@ import android.content.Context;
import android.test.mock.MockContext;

import com.fsck.k9.Account;
import com.fsck.k9.GlobalsHelper;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.Preferences;
import com.fsck.k9.account.K9OAuth2TokenProvider;
import com.fsck.k9.activity.setup.AccountSetupPresenter.Stage;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.mail.AuthType;
@@ -54,6 +56,8 @@ public class AccountSetupPresenterTest {

        Preferences preferences = mock(Preferences.class);

        GlobalsHelper.setOAuth2TokenProvider(new K9OAuth2TokenProvider(view));

        presenter = new AccountSetupPresenter(context, preferences, view);

        account = mock(Account.class);