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

Commit 82db38bd authored by cketti's avatar cketti
Browse files

Create ImapStoreConfig

parent a6f75dc5
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -8,11 +8,13 @@ import com.fsck.k9.backend.api.Backend
import com.fsck.k9.backend.imap.ImapBackend
import com.fsck.k9.backend.imap.ImapStoreUriCreator
import com.fsck.k9.backend.imap.ImapStoreUriDecoder
import com.fsck.k9.mail.NetworkType
import com.fsck.k9.mail.ServerSettings
import com.fsck.k9.mail.oauth.OAuth2TokenProvider
import com.fsck.k9.mail.power.PowerManager
import com.fsck.k9.mail.ssl.TrustedSocketFactory
import com.fsck.k9.mail.store.imap.ImapStore
import com.fsck.k9.mail.store.imap.ImapStoreConfig
import com.fsck.k9.mail.transport.smtp.SmtpTransport
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriCreator
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriDecoder
@@ -37,15 +39,27 @@ class ImapBackendFactory(
    private fun createImapStore(account: Account): ImapStore {
        val oAuth2TokenProvider: OAuth2TokenProvider? = null
        val serverSettings = ImapStoreUriDecoder.decode(account.storeUri)
        val config = createImapStoreConfig(account)
        return ImapStore(
                serverSettings,
                account,
                config,
                trustedSocketFactory,
                context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager,
                oAuth2TokenProvider
        )
    }

    private fun createImapStoreConfig(account: Account): ImapStoreConfig {
        return object : ImapStoreConfig {
            override val logLabel
                get() = account.description

            override fun isSubscribedFoldersOnly() = account.isSubscribedFoldersOnly

            override fun useCompression(type: NetworkType) = account.useCompression(type)
        }
    }

    private fun createSmtpTransport(account: Account): SmtpTransport {
        val serverSettings = decodeTransportUri(account.transportUri)
        val oauth2TokenProvider: OAuth2TokenProvider? = null
+15 −1
Original line number Diff line number Diff line
@@ -8,11 +8,13 @@ import com.fsck.k9.backend.api.Backend
import com.fsck.k9.backend.imap.ImapBackend
import com.fsck.k9.backend.imap.ImapStoreUriCreator
import com.fsck.k9.backend.imap.ImapStoreUriDecoder
import com.fsck.k9.mail.NetworkType
import com.fsck.k9.mail.ServerSettings
import com.fsck.k9.mail.oauth.OAuth2TokenProvider
import com.fsck.k9.mail.power.PowerManager
import com.fsck.k9.mail.ssl.TrustedSocketFactory
import com.fsck.k9.mail.store.imap.ImapStore
import com.fsck.k9.mail.store.imap.ImapStoreConfig
import com.fsck.k9.mail.transport.smtp.SmtpTransport
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriCreator
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriDecoder
@@ -37,15 +39,27 @@ class ImapBackendFactory(
    private fun createImapStore(account: Account): ImapStore {
        val oAuth2TokenProvider: OAuth2TokenProvider? = null
        val serverSettings = ImapStoreUriDecoder.decode(account.storeUri)
        val config = createImapStoreConfig(account)
        return ImapStore(
                serverSettings,
                account,
                config,
                trustedSocketFactory,
                context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager,
                oAuth2TokenProvider
        )
    }

    private fun createImapStoreConfig(account: Account): ImapStoreConfig {
        return object : ImapStoreConfig {
            override val logLabel
                get() = account.description

            override fun isSubscribedFoldersOnly() = account.isSubscribedFoldersOnly

            override fun useCompression(type: NetworkType) = account.useCompression(type)
        }
    }

    private fun createSmtpTransport(account: Account): SmtpTransport {
        val serverSettings = decodeTransportUri(account.transportUri)
        val oauth2TokenProvider: OAuth2TokenProvider? = null
+0 −5
Original line number Diff line number Diff line
package com.fsck.k9.mail.store;


import com.fsck.k9.mail.NetworkType;

public interface StoreConfig {
    boolean isSubscribedFoldersOnly();
    boolean useCompression(NetworkType type);

    String getDraftsFolder();
}
+1 −1
Original line number Diff line number Diff line
@@ -1313,7 +1313,7 @@ public class ImapFolder {
    }

    protected String getLogId() {
        String id = store.getStoreConfig().toString() + ":" + getServerId() + "/" + Thread.currentThread().getName();
        String id = store.getLogLabel() + ":" + getServerId() + "/" + Thread.currentThread().getName();
        if (connection != null) {
            id += "/" + connection.getLogId();
        }
+7 −8
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.NetworkType;
import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import com.fsck.k9.mail.store.StoreConfig;
import timber.log.Timber;


@@ -34,7 +33,7 @@ import timber.log.Timber;
 * </pre>
 */
public class ImapStore {
    private final StoreConfig storeConfig;
    private final ImapStoreConfig config;
    private final TrustedSocketFactory trustedSocketFactory;
    private Set<Flag> permanentFlagsIndex = EnumSet.noneOf(Flag.class);
    private ConnectivityManager connectivityManager;
@@ -62,10 +61,10 @@ public class ImapStore {
    private final Map<String, ImapFolder> folderCache = new HashMap<>();


    public ImapStore(ImapStoreSettings serverSettings, StoreConfig storeConfig,
    public ImapStore(ImapStoreSettings serverSettings, ImapStoreConfig config,
            TrustedSocketFactory trustedSocketFactory, ConnectivityManager connectivityManager,
            OAuth2TokenProvider oauthTokenProvider) {
        this.storeConfig = storeConfig;
        this.config = config;
        this.trustedSocketFactory = trustedSocketFactory;

        host = serverSettings.host;
@@ -125,7 +124,7 @@ public class ImapStore {
        try {
            List<FolderListItem> folders = listFolders(connection, false);

            if (!storeConfig.isSubscribedFoldersOnly()) {
            if (!config.isSubscribedFoldersOnly()) {
                return folders;
            }

@@ -329,8 +328,8 @@ public class ImapStore {
        return folderNameCodec;
    }

    StoreConfig getStoreConfig() {
        return storeConfig;
    String getLogLabel() {
        return config.getLogLabel();
    }

    Set<Flag> getPermanentFlagsIndex() {
@@ -376,7 +375,7 @@ public class ImapStore {

        @Override
        public boolean useCompression(final NetworkType type) {
            return storeConfig.useCompression(type);
            return config.useCompression(type);
        }

        @Override
Loading