Loading backend/api/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -4,5 +4,7 @@ plugins { } dependencies { implementation(projects.core.account) implementation(projects.core.outcome) api(projects.mail.common) } backend/api/src/main/kotlin/net/thunderbird/backend/api/BackendFactory.kt 0 → 100644 +8 −0 Original line number Diff line number Diff line package net.thunderbird.backend.api import com.fsck.k9.backend.api.Backend import net.thunderbird.core.account.BaseAccount interface BackendFactory<TAccount : BaseAccount> { fun createBackend(account: TAccount): Backend } backend/api/src/main/kotlin/net/thunderbird/backend/api/BackendStorageFactory.kt 0 → 100644 +8 −0 Original line number Diff line number Diff line package net.thunderbird.backend.api import com.fsck.k9.backend.api.BackendStorage import net.thunderbird.core.account.BaseAccount interface BackendStorageFactory<in TAccount : BaseAccount> { fun createBackendStorage(account: TAccount): BackendStorage } backend/api/src/main/kotlin/net/thunderbird/backend/api/folder/RemoteFolderCreator.kt 0 → 100644 +65 −0 Original line number Diff line number Diff line package net.thunderbird.backend.api.folder import com.fsck.k9.mail.folders.FolderServerId import net.thunderbird.core.account.BaseAccount import net.thunderbird.core.outcome.Outcome interface RemoteFolderCreator { /** * Creates a folder on the remote server. If the folder already exists and [mustCreate] is `false`, * the operation will succeed returning [RemoteFolderCreationOutcome.Success.AlreadyExists]. * * @param folderServerId The folder server ID. * @param mustCreate If `true`, the folder must be created returning * [RemoteFolderCreationOutcome.Error.FailedToCreateRemoteFolder]. If `false`, the folder will be created * only if it doesn't exist. * @return The result of the operation. * @see RemoteFolderCreationOutcome.Success * @see RemoteFolderCreationOutcome.Error */ suspend fun create( folderServerId: FolderServerId, mustCreate: Boolean, ): Outcome<RemoteFolderCreationOutcome.Success, RemoteFolderCreationOutcome.Error> interface Factory { fun create(account: BaseAccount): RemoteFolderCreator } } sealed interface RemoteFolderCreationOutcome { sealed interface Success : RemoteFolderCreationOutcome { /** * Used to flag that the folder was created successfully. */ data object Created : Success /** * Used to flag that the folder creation was skipped because the folder already exists and * the creation is NOT mandatory. */ data object AlreadyExists : Success } sealed interface Error : RemoteFolderCreationOutcome { /** * Used to flag that the folder creation has failed because the folder already exists and * the creation is mandatory. */ data object AlreadyExists : Error /** * Used to flag that the folder creation failed on the remote server. * @param reason The reason why the folder creation failed. */ data class FailedToCreateRemoteFolder( val reason: String, ) : Error /** * Used to flag that the Create Folder operation is not supported by the server. * E.g. POP3 servers don't support creating archive folders. */ data object NotSupportedOperation : Error } } backend/imap/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ plugins { dependencies { api(projects.backend.api) api(projects.core.outcome) api(projects.core.account) api(projects.mail.protocols.imap) api(projects.mail.protocols.smtp) Loading Loading
backend/api/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -4,5 +4,7 @@ plugins { } dependencies { implementation(projects.core.account) implementation(projects.core.outcome) api(projects.mail.common) }
backend/api/src/main/kotlin/net/thunderbird/backend/api/BackendFactory.kt 0 → 100644 +8 −0 Original line number Diff line number Diff line package net.thunderbird.backend.api import com.fsck.k9.backend.api.Backend import net.thunderbird.core.account.BaseAccount interface BackendFactory<TAccount : BaseAccount> { fun createBackend(account: TAccount): Backend }
backend/api/src/main/kotlin/net/thunderbird/backend/api/BackendStorageFactory.kt 0 → 100644 +8 −0 Original line number Diff line number Diff line package net.thunderbird.backend.api import com.fsck.k9.backend.api.BackendStorage import net.thunderbird.core.account.BaseAccount interface BackendStorageFactory<in TAccount : BaseAccount> { fun createBackendStorage(account: TAccount): BackendStorage }
backend/api/src/main/kotlin/net/thunderbird/backend/api/folder/RemoteFolderCreator.kt 0 → 100644 +65 −0 Original line number Diff line number Diff line package net.thunderbird.backend.api.folder import com.fsck.k9.mail.folders.FolderServerId import net.thunderbird.core.account.BaseAccount import net.thunderbird.core.outcome.Outcome interface RemoteFolderCreator { /** * Creates a folder on the remote server. If the folder already exists and [mustCreate] is `false`, * the operation will succeed returning [RemoteFolderCreationOutcome.Success.AlreadyExists]. * * @param folderServerId The folder server ID. * @param mustCreate If `true`, the folder must be created returning * [RemoteFolderCreationOutcome.Error.FailedToCreateRemoteFolder]. If `false`, the folder will be created * only if it doesn't exist. * @return The result of the operation. * @see RemoteFolderCreationOutcome.Success * @see RemoteFolderCreationOutcome.Error */ suspend fun create( folderServerId: FolderServerId, mustCreate: Boolean, ): Outcome<RemoteFolderCreationOutcome.Success, RemoteFolderCreationOutcome.Error> interface Factory { fun create(account: BaseAccount): RemoteFolderCreator } } sealed interface RemoteFolderCreationOutcome { sealed interface Success : RemoteFolderCreationOutcome { /** * Used to flag that the folder was created successfully. */ data object Created : Success /** * Used to flag that the folder creation was skipped because the folder already exists and * the creation is NOT mandatory. */ data object AlreadyExists : Success } sealed interface Error : RemoteFolderCreationOutcome { /** * Used to flag that the folder creation has failed because the folder already exists and * the creation is mandatory. */ data object AlreadyExists : Error /** * Used to flag that the folder creation failed on the remote server. * @param reason The reason why the folder creation failed. */ data class FailedToCreateRemoteFolder( val reason: String, ) : Error /** * Used to flag that the Create Folder operation is not supported by the server. * E.g. POP3 servers don't support creating archive folders. */ data object NotSupportedOperation : Error } }
backend/imap/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ plugins { dependencies { api(projects.backend.api) api(projects.core.outcome) api(projects.core.account) api(projects.mail.protocols.imap) api(projects.mail.protocols.smtp) Loading