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

Commit b90fc50d authored by cketti's avatar cketti
Browse files

Convert `ImapSettings` to Kotlin

parent 01539af9
Loading
Loading
Loading
Loading
+17 −31
Original line number Diff line number Diff line
package com.fsck.k9.mail.store.imap;

import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity;
package com.fsck.k9.mail.store.imap

import com.fsck.k9.mail.AuthType
import com.fsck.k9.mail.ConnectionSecurity

/**
 * Settings source for IMAP. Implemented in order to remove coupling between {@link ImapStore} and {@link ImapConnection}.
 * Settings source for IMAP. Implemented in order to remove coupling between [ImapStore] and [ImapConnection].
 */
interface ImapSettings {
    String getHost();

    int getPort();

    ConnectionSecurity getConnectionSecurity();

    AuthType getAuthType();

    String getUsername();

    String getPassword();

    String getClientCertificateAlias();

    boolean useCompression();

    String getPathPrefix();

    void setPathPrefix(String prefix);

    String getPathDelimiter();

    void setPathDelimiter(String delimiter);

    void setCombinedPrefix(String prefix);
internal interface ImapSettings {
    val host: String
    val port: Int
    val connectionSecurity: ConnectionSecurity
    val authType: AuthType
    val username: String
    val password: String?
    val clientCertificateAlias: String?
    fun useCompression(): Boolean

    var pathPrefix: String?
    var pathDelimiter: String?
    fun setCombinedPrefix(prefix: String?)
}
+10 −38
Original line number Diff line number Diff line
@@ -4,47 +4,19 @@ import com.fsck.k9.mail.AuthType
import com.fsck.k9.mail.ConnectionSecurity

internal class SimpleImapSettings(
    private val host: String,
    private val port: Int = 0,
    private val connectionSecurity: ConnectionSecurity = ConnectionSecurity.NONE,
    private val authType: AuthType,
    private val username: String,
    private val password: String? = null,
    override val host: String,
    override val port: Int = 0,
    override val connectionSecurity: ConnectionSecurity = ConnectionSecurity.NONE,
    override val authType: AuthType,
    override val username: String,
    override val password: String? = null,
    private val useCompression: Boolean = false
) : ImapSettings {
    private var pathPrefix: String? = null
    private var pathDelimiter: String? = null
    private var combinedPrefix: String? = null

    override fun getHost(): String = host

    override fun getPort(): Int = port

    override fun getConnectionSecurity(): ConnectionSecurity = connectionSecurity

    override fun getAuthType(): AuthType = authType

    override fun getUsername(): String = username

    override fun getPassword(): String? = password

    override fun getClientCertificateAlias(): String? = null

    override val clientCertificateAlias: String? = null
    override fun useCompression(): Boolean = useCompression

    override fun getPathPrefix(): String? = pathPrefix

    override fun setPathPrefix(prefix: String?) {
        pathPrefix = prefix
    }

    override fun getPathDelimiter(): String? = pathDelimiter
    override var pathPrefix: String? = null
    override var pathDelimiter: String? = null

    override fun setPathDelimiter(delimiter: String?) {
        pathDelimiter = delimiter
    }

    override fun setCombinedPrefix(prefix: String?) {
        combinedPrefix = prefix
    }
    override fun setCombinedPrefix(prefix: String?) = Unit
}