Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:56:56 +01:00
parent 75dc487a7a
commit 39c29d175b
6317 changed files with 388324 additions and 2 deletions

View file

@ -0,0 +1,9 @@
plugins {
id(ThunderbirdPlugins.Library.jvm)
alias(libs.plugins.android.lint)
}
dependencies {
api(projects.mail.common)
api(projects.core.common)
}

View file

@ -0,0 +1,13 @@
package app.k9mail.autodiscovery.api
/**
* The authentication types supported when using the [AutoDiscovery] mechanism.
*
* Note: Currently we support the same set of values in [ImapServerSettings] and [SmtpServerSettings]. As soon as this
* changes, this type should be replaced with `ImapAuthenticationType` and `SmtpAuthenticationType`.
*/
enum class AuthenticationType {
PasswordCleartext,
PasswordEncrypted,
OAuth2,
}

View file

@ -0,0 +1,13 @@
package app.k9mail.autodiscovery.api
import net.thunderbird.core.common.mail.EmailAddress
/**
* Provides a mechanism to find mail server settings for a given email address.
*/
interface AutoDiscovery {
/**
* Returns a list of [AutoDiscoveryRunnable]s that perform the actual mail server settings discovery.
*/
fun initDiscovery(email: EmailAddress): List<AutoDiscoveryRunnable>
}

View file

@ -0,0 +1,5 @@
package app.k9mail.autodiscovery.api
interface AutoDiscoveryRegistry {
fun getAutoDiscoveries(): List<AutoDiscovery>
}

View file

@ -0,0 +1,61 @@
package app.k9mail.autodiscovery.api
import java.io.IOException
/**
* Results of a mail server settings lookup.
*/
sealed interface AutoDiscoveryResult {
/**
* Mail server settings found during the lookup.
*/
data class Settings(
val incomingServerSettings: IncomingServerSettings,
val outgoingServerSettings: OutgoingServerSettings,
/**
* Indicates whether the mail server settings lookup was using only trusted channels.
*
* `true` if the settings lookup was only using trusted channels, e.g. lookup via HTTPS where the server
* presented a trusted certificate. `false´ otherwise.
*
* IMPORTANT: When this value is `false`, the settings should be presented to the user and only be used after
* the user has given consent.
*/
val isTrusted: Boolean,
/**
* String describing the source of the server settings. Use a URI if possible.
*/
val source: String,
) : AutoDiscoveryResult
/**
* No usable mail server settings were found.
*/
object NoUsableSettingsFound : AutoDiscoveryResult
/**
* A network error occurred while looking for mail server settings.
*/
data class NetworkError(val exception: IOException) : AutoDiscoveryResult
/**
* Encountered an unexpected exception when looking up mail server settings.
*/
data class UnexpectedException(val exception: Exception) : AutoDiscoveryResult
}
/**
* Incoming mail server settings.
*
* Implementations contain protocol-specific properties.
*/
interface IncomingServerSettings
/**
* Outgoing mail server settings.
*
* Implementations contain protocol-specific properties.
*/
interface OutgoingServerSettings

View file

@ -0,0 +1,10 @@
package app.k9mail.autodiscovery.api
/**
* Performs a mail server settings lookup.
*
* This is an abstraction that allows us to run multiple lookups in parallel.
*/
fun interface AutoDiscoveryRunnable {
suspend fun run(): AutoDiscoveryResult
}

View file

@ -0,0 +1,10 @@
package app.k9mail.autodiscovery.api
import net.thunderbird.core.common.mail.EmailAddress
/**
* Tries to find mail server settings for a given email address.
*/
interface AutoDiscoveryService {
suspend fun discover(email: EmailAddress): AutoDiscoveryResult
}

View file

@ -0,0 +1,9 @@
package app.k9mail.autodiscovery.api
/**
* The connection security methods supported when using the [AutoDiscovery] mechanism.
*/
enum class ConnectionSecurity {
StartTLS,
TLS,
}

View file

@ -0,0 +1,12 @@
package app.k9mail.autodiscovery.api
import net.thunderbird.core.common.net.Hostname
import net.thunderbird.core.common.net.Port
data class ImapServerSettings(
val hostname: Hostname,
val port: Port,
val connectionSecurity: ConnectionSecurity,
val authenticationTypes: List<AuthenticationType>,
val username: String,
) : IncomingServerSettings

View file

@ -0,0 +1,12 @@
package app.k9mail.autodiscovery.api
import net.thunderbird.core.common.net.Hostname
import net.thunderbird.core.common.net.Port
data class SmtpServerSettings(
val hostname: Hostname,
val port: Port,
val connectionSecurity: ConnectionSecurity,
val authenticationTypes: List<AuthenticationType>,
val username: String,
) : OutgoingServerSettings