0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-20 04:02:14 +02:00

Change SettingsFileParser to not depend on AuthType

This commit is contained in:
cketti 2024-06-12 17:31:40 +02:00
parent 3aec5e071e
commit e72929748c
4 changed files with 11 additions and 11 deletions

View File

@ -1,7 +1,5 @@
package com.fsck.k9.preferences
import com.fsck.k9.mail.AuthType
internal typealias SettingsMap = Map<String, String>
internal interface SettingsFile {
@ -26,7 +24,7 @@ internal interface SettingsFile {
val host: String?,
val port: String?,
val connectionSecurity: String?,
val authenticationType: AuthType?,
val authenticationType: String?,
val username: String?,
val password: String?,
val clientCertificateAlias: String?,

View File

@ -1,6 +1,5 @@
package com.fsck.k9.preferences
import com.fsck.k9.mail.AuthType
import com.fsck.k9.preferences.SettingsFile.Account
import com.fsck.k9.preferences.SettingsFile.Contents
import com.fsck.k9.preferences.SettingsFile.Folder
@ -238,7 +237,7 @@ private class XmlSettingsParser(
var host: String? = null
var port: String? = null
var connectionSecurity: String? = null
var authenticationType: AuthType? = null
var authenticationType: String? = null
var username: String? = null
var password: String? = null
var clientCertificateAlias: String? = null
@ -259,8 +258,7 @@ private class XmlSettingsParser(
connectionSecurity = readText()
}
SettingsExporter.AUTHENTICATION_TYPE_ELEMENT -> {
val text = readText()
authenticationType = AuthType.valueOf(text)
authenticationType = readText()
}
SettingsExporter.USERNAME_ELEMENT -> {
username = readText()

View File

@ -515,7 +515,8 @@ class SettingsImporter internal constructor(
val type = toServerSettingsType(importedServer.type!!)
val port = convertPort(importedServer.port)
val connectionSecurity = convertConnectionSecurity(importedServer.connectionSecurity)
val password = if (importedServer.authenticationType == AuthType.XOAUTH2) "" else importedServer.password
val authenticationType = convertAuthenticationType(importedServer.authenticationType)
val password = if (authenticationType == AuthType.XOAUTH2) "" else importedServer.password
val extra = importedServer.extras.orEmpty()
return ServerSettings(
@ -523,7 +524,7 @@ class SettingsImporter internal constructor(
importedServer.host,
port,
connectionSecurity,
importedServer.authenticationType!!,
authenticationType,
importedServer.username!!,
password,
importedServer.clientCertificateAlias,
@ -549,4 +550,8 @@ class SettingsImporter internal constructor(
return ConnectionSecurity.SSL_TLS_REQUIRED
}
}
private fun convertAuthenticationType(authenticationType: String?): AuthType {
return AuthType.valueOf(authenticationType!!)
}
}

View File

@ -10,7 +10,6 @@ import assertk.assertions.index
import assertk.assertions.isEqualTo
import assertk.assertions.isNotNull
import assertk.assertions.prop
import com.fsck.k9.mail.AuthType
import com.fsck.k9.preferences.SettingsFile.Account
import com.fsck.k9.preferences.SettingsFile.Identity
import com.fsck.k9.preferences.SettingsFile.Server
@ -101,6 +100,6 @@ class SettingsFileParserTest : RobolectricTest() {
.prop(Account::incoming)
.isNotNull()
.prop(Server::authenticationType)
.isEqualTo(AuthType.CRAM_MD5)
.isEqualTo("CRAM_MD5")
}
}