Convert ImapSettings to Kotlin

This commit is contained in:
cketti 2022-08-10 15:17:41 +02:00
parent 01539af985
commit b90fc50d1a
2 changed files with 26 additions and 68 deletions

View file

@ -1,36 +1,22 @@
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();
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
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);
var pathPrefix: String?
var pathDelimiter: String?
fun setCombinedPrefix(prefix: String?)
}

View file

@ -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 var pathPrefix: String? = null
override var pathDelimiter: String? = null
override fun setPathPrefix(prefix: String?) {
pathPrefix = prefix
}
override fun getPathDelimiter(): String? = pathDelimiter
override fun setPathDelimiter(delimiter: String?) {
pathDelimiter = delimiter
}
override fun setCombinedPrefix(prefix: String?) {
combinedPrefix = prefix
}
override fun setCombinedPrefix(prefix: String?) = Unit
}