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

Commit 2a2c0b00 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Merge branch 'GSOC_account_setup' into material-1.0-backup

# Conflicts:
#	README.md
#	k9mail-library/src/main/java/com/fsck/k9/mail/transport/smtp/SmtpTransport.java
#	k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapConnectionTest.java
#	k9mail-library/src/test/java/com/fsck/k9/mail/transport/smtp/SmtpTransportTest.java
#	k9mail/build.gradle
#	k9mail/src/main/AndroidManifest.xml
#	k9mail/src/main/java/com/fsck/k9/Account.java
#	k9mail/src/main/java/com/fsck/k9/Globals.java
#	k9mail/src/main/java/com/fsck/k9/K9.java
#	k9mail/src/main/java/com/fsck/k9/activity/Accounts.java
#	k9mail/src/main/java/com/fsck/k9/activity/K9ActivityCommon.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupAccountType.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupCheckSettings.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupComposition.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupIncoming.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupNames.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupOptions.java
#	k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupOutgoing.java
#	k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java
#	k9mail/src/main/java/com/fsck/k9/fragment/ConfirmationDialogFragment.java
#	k9mail/src/main/java/com/fsck/k9/notification/AuthenticationErrorNotifications.java
#	k9mail/src/main/res/values-ca/strings.xml
#	k9mail/src/main/res/values-de/strings.xml
#	k9mail/src/main/res/values-eu/strings.xml
#	k9mail/src/main/res/values-fr/strings.xml
#	k9mail/src/main/res/values-pl/strings.xml
#	k9mail/src/main/res/values-pt-rBR/strings.xml
#	k9mail/src/main/res/values-sl/strings.xml
#	k9mail/src/main/res/values-tr/strings.xml
#	k9mail/src/main/res/values/colors.xml
#	k9mail/src/main/res/values/dimensions.xml
#	k9mail/src/main/res/values/strings.xml
parents 177b52df 1abae13a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ dependencies {
    compile "com.android.support:support-annotations:${androidSupportLibraryVersion}"
    compile "com.jakewharton.timber:timber:${timberVersion}"

    compile 'dnsjava:dnsjava:2.1.7'
    compile 'org.jsoup:jsoup:1.10.2'

    androidTestCompile 'com.android.support.test:runner:0.4.1'
    androidTestCompile 'com.madgag.spongycastle:pg:1.51.0.0'

+2 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@ package com.fsck.k9.mail;

public class AuthenticationFailedException extends MessagingException {
    public static final long serialVersionUID = -1;
    public static final String OAUTH2_ERROR_INVALID_REFRESH_TOKEN = "oauth2-invalid refresh token";
    public static final String OAUTH2_ERROR_UNKNOWN = "oauth2-unknown";

    public AuthenticationFailedException(String message) {
        super(message);
+8 −0
Original line number Diff line number Diff line
package com.fsck.k9.mail;

public class OAuth2NeedUserPromptException extends MessagingException {

    public OAuth2NeedUserPromptException() {
        super("Need user's prompt for xoauth2");
    }
}
+9 −3
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package com.fsck.k9.mail;

import android.content.Context;

import com.fsck.k9.mail.oauth.OAuth2AuthorizationCodeFlowTokenProvider;
import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
import com.fsck.k9.mail.ssl.DefaultTrustedSocketFactory;
import com.fsck.k9.mail.store.StoreConfig;
@@ -18,10 +19,15 @@ public class TransportProvider {

    public synchronized Transport getTransport(Context context, StoreConfig storeConfig)
        throws MessagingException {
        return getTransport(context, storeConfig, null);
    }

    public synchronized Transport getTransport(Context context, StoreConfig storeConfig,
            OAuth2TokenProvider oAuth2TokenProvider) throws MessagingException {
        String uri = storeConfig.getTransportUri();
        if (uri.startsWith("smtp")) {
            OAuth2TokenProvider oauth2TokenProvider = null;
            return new SmtpTransport(storeConfig, new DefaultTrustedSocketFactory(context), oauth2TokenProvider);
            return new SmtpTransport(storeConfig, new DefaultTrustedSocketFactory(context),
                    oAuth2TokenProvider);
        } else if (uri.startsWith("webdav")) {
            return new WebDavTransport(storeConfig);
        } else {
+147 −0
Original line number Diff line number Diff line
package com.fsck.k9.mail.autoconfiguration;


/**
 * An interface for autoconfiguration
 */

public interface AutoConfigure {
    ProviderInfo findProviderInfo(String email);

    public static class ProviderInfo {
        public String incomingUsernameTemplate = "";

        public String outgoingUsernameTemplate = "";

        public String incomingType = "";
        public String incomingSocketType = "";
        public String incomingAddr = "";
        public int incomingPort = -1;
        public String outgoingType = "";
        public String outgoingSocketType = "";
        public String outgoingAddr = "";
        public int outgoingPort = -1;

        public static String USERNAME_TEMPLATE_EMAIL = "$email";
        public static String USERNAME_TEMPLATE_USER = "$user";
        public static String USERNAME_TEMPLATE_DOMAIN = "$domain";
        public static String USERNAME_TEMPLATE_SRV = "$srv";

        public static String INCOMING_TYPE_IMAP = "imap";
        public static String INCOMING_TYPE_POP3 = "pop3";
        public static String OUTGOING_TYPE_SMTP = "smtp";

        public static String SOCKET_TYPE_SSL_OR_TLS = "ssl";
        public static String SOCKET_TYPE_STARTTLS = "tls";

        public static int IMAP_SSL_OR_TLS_DEFAULT_PORT = 993;
        public static int IMAP_STARTTLS_DEFAULT_PORT = 143;
        public static int POP3_SSL_OR_TLS_DEFAULT_PORT = 995;
        public static int POP3_STARTTLS_DEFAULT_PORT = 110;
        public static int SMTP_SSL_OR_TLS_DEFAULT_PORT = 465;
        public static int SMTP_STARTTLS_DEFAULT_PORT = 587;

        public ProviderInfo fillDefaultPorts() {
            if (incomingPort == -1) {
                if (incomingType.equals(INCOMING_TYPE_IMAP)) {
                    if (incomingSocketType.equals(SOCKET_TYPE_SSL_OR_TLS)) {
                        incomingPort = IMAP_SSL_OR_TLS_DEFAULT_PORT;
                    } else if (incomingSocketType.equals(SOCKET_TYPE_STARTTLS)) {
                        incomingPort = IMAP_STARTTLS_DEFAULT_PORT;
                    }
                } else if (incomingType.equals(INCOMING_TYPE_POP3)) {
                    if (incomingSocketType.equals(SOCKET_TYPE_SSL_OR_TLS)) {
                        incomingPort = POP3_SSL_OR_TLS_DEFAULT_PORT;
                    } else if (incomingSocketType.equals(SOCKET_TYPE_STARTTLS)) {
                        incomingPort = POP3_STARTTLS_DEFAULT_PORT;
                    }
                }
            }

            if (outgoingPort == -1) {
                if (outgoingType.equals(OUTGOING_TYPE_SMTP)) {
                    if (outgoingSocketType.equals(SOCKET_TYPE_SSL_OR_TLS)) {
                        outgoingPort = SMTP_SSL_OR_TLS_DEFAULT_PORT;
                    } else if (outgoingSocketType.equals(SOCKET_TYPE_STARTTLS)) {
                        outgoingPort = SMTP_STARTTLS_DEFAULT_PORT;
                    }
                }
            }

            return this;
        }

        @Override
        public String toString() {
            return "ProviderInfo{" +
                    "incomingUsernameTemplate='" + incomingUsernameTemplate + '\'' +
                    ", outgoingUsernameTemplate='" + outgoingUsernameTemplate + '\'' +
                    ", incomingType='" + incomingType + '\'' +
                    ", incomingSocketType='" + incomingSocketType + '\'' +
                    ", incomingAddr='" + incomingAddr + '\'' +
                    ", incomingPort=" + incomingPort +
                    ", outgoingType='" + outgoingType + '\'' +
                    ", outgoingSocketType='" + outgoingSocketType + '\'' +
                    ", outgoingAddr='" + outgoingAddr + '\'' +
                    ", outgoingPort=" + outgoingPort +
                    '}';
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }

            ProviderInfo that = (ProviderInfo) o;

            if (incomingPort != that.incomingPort) {
                return false;
            }
            if (outgoingPort != that.outgoingPort) {
                return false;
            }
            if (!incomingUsernameTemplate.equals(that.incomingUsernameTemplate)) {
                return false;
            }
            if (!outgoingUsernameTemplate.equals(that.outgoingUsernameTemplate)) {
                return false;
            }
            if (!incomingType.equals(that.incomingType)) {
                return false;
            }
            if (!incomingSocketType.equals(that.incomingSocketType)) {
                return false;
            }
            if (!incomingAddr.equals(that.incomingAddr)) {
                return false;
            }
            if (!outgoingType.equals(that.outgoingType)) {
                return false;
            }
            if (!outgoingSocketType.equals(that.outgoingSocketType)) {
                return false;
            }
            return outgoingAddr.equals(that.outgoingAddr);

        }

        @Override
        public int hashCode() {
            int result = incomingUsernameTemplate.hashCode();
            result = 31 * result + outgoingUsernameTemplate.hashCode();
            result = 31 * result + incomingType.hashCode();
            result = 31 * result + incomingSocketType.hashCode();
            result = 31 * result + incomingAddr.hashCode();
            result = 31 * result + incomingPort;
            result = 31 * result + outgoingType.hashCode();
            result = 31 * result + outgoingSocketType.hashCode();
            result = 31 * result + outgoingAddr.hashCode();
            result = 31 * result + outgoingPort;
            return result;
        }
    }
}
Loading