Use AuthenticationType
when creating ServerSettings
This commit is contained in:
parent
e80a02579a
commit
0f6a50df73
2 changed files with 14 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
package app.k9mail.feature.account.setup.domain.entity
|
||||
|
||||
import com.fsck.k9.mail.AuthType
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
enum class AuthenticationType(
|
||||
|
@ -36,3 +37,13 @@ enum class AuthenticationType(
|
|||
fun outgoing() = all()
|
||||
}
|
||||
}
|
||||
|
||||
fun AuthenticationType.toAuthType(): AuthType {
|
||||
return when (this) {
|
||||
AuthenticationType.None -> AuthType.PLAIN
|
||||
AuthenticationType.PasswordCleartext -> AuthType.PLAIN
|
||||
AuthenticationType.PasswordEncrypted -> AuthType.CRAM_MD5
|
||||
AuthenticationType.ClientCertificate -> AuthType.EXTERNAL
|
||||
AuthenticationType.OAuth2 -> AuthType.XOAUTH2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package app.k9mail.feature.account.setup.ui.incoming
|
||||
|
||||
import app.k9mail.feature.account.setup.domain.entity.toAuthType
|
||||
import app.k9mail.feature.account.setup.domain.entity.toMailConnectionSecurity
|
||||
import com.fsck.k9.mail.AuthType
|
||||
import com.fsck.k9.mail.ServerSettings
|
||||
|
||||
// TODO map extras
|
||||
// TODO map authenticationType
|
||||
// TODO map clientCertificateAlias
|
||||
internal fun AccountIncomingConfigContract.State.toServerSettings(): ServerSettings {
|
||||
return ServerSettings(
|
||||
|
@ -13,9 +12,9 @@ internal fun AccountIncomingConfigContract.State.toServerSettings(): ServerSetti
|
|||
host = server.value,
|
||||
port = port.value!!.toInt(),
|
||||
connectionSecurity = security.toMailConnectionSecurity(),
|
||||
authenticationType = AuthType.PLAIN, // TODO replace by actual auth type
|
||||
authenticationType = authenticationType.toAuthType(),
|
||||
username = username.value,
|
||||
password = password.value,
|
||||
password = if (authenticationType.isPasswordRequired) password.value else null,
|
||||
clientCertificateAlias = null, // TODO replace by actual client certificate alias
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue