Repo created
This commit is contained in:
parent
75dc487a7a
commit
39c29d175b
6317 changed files with 388324 additions and 2 deletions
18
feature/mail/folder/api/build.gradle.kts
Normal file
18
feature/mail/folder/api/build.gradle.kts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
plugins {
|
||||
id(ThunderbirdPlugins.Library.kmp)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "net.thunderbird.feature.mail.folder.api"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
implementation(projects.core.outcome)
|
||||
implementation(projects.feature.account.api)
|
||||
implementation(projects.feature.mail.account.api)
|
||||
implementation(libs.androidx.annotation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
data class Folder(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val type: FolderType,
|
||||
val isLocalOnly: Boolean,
|
||||
)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
data class FolderDetails(
|
||||
val folder: Folder,
|
||||
val isInTopGroup: Boolean,
|
||||
val isIntegrate: Boolean,
|
||||
val isSyncEnabled: Boolean,
|
||||
val isVisible: Boolean,
|
||||
val isNotificationsEnabled: Boolean,
|
||||
val isPushEnabled: Boolean,
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
typealias FolderPathDelimiter = String
|
||||
|
||||
const val FOLDER_DEFAULT_PATH_DELIMITER = "/"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
enum class FolderType {
|
||||
REGULAR,
|
||||
INBOX,
|
||||
OUTBOX,
|
||||
SENT,
|
||||
TRASH,
|
||||
DRAFTS,
|
||||
ARCHIVE,
|
||||
SPAM,
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
import androidx.annotation.Discouraged
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.thunderbird.core.outcome.Outcome
|
||||
import net.thunderbird.feature.account.AccountId
|
||||
import net.thunderbird.feature.account.AccountIdFactory
|
||||
|
||||
/**
|
||||
* Manages outbox folders for accounts.
|
||||
*
|
||||
* An outbox folder is a special folder used to store messages that are waiting to be sent.
|
||||
* This interface provides methods for getting and creating outbox folders.
|
||||
*/
|
||||
interface OutboxFolderManager {
|
||||
/**
|
||||
* Gets the folder ID of the outbox folder for the given account.
|
||||
*
|
||||
* @param accountId The ID of the account.
|
||||
* @param createIfMissing If true, the outbox folder will be created if it does not exist.
|
||||
* @return The folder ID of the outbox folder.
|
||||
* @throws IllegalStateException If the outbox folder could not be found.
|
||||
*/
|
||||
suspend fun getOutboxFolderId(accountId: AccountId, createIfMissing: Boolean = true): Long
|
||||
|
||||
/**
|
||||
* Gets the outbox folder ID for the given account.
|
||||
*
|
||||
* This is a blocking call and should not be used on the main thread.
|
||||
*
|
||||
* @param accountId The account ID.
|
||||
* @return The outbox folder ID.
|
||||
*/
|
||||
@Discouraged(message = "Avoid blocking calls from the main thread. Use getOutboxFolderId instead.")
|
||||
fun getOutboxFolderIdSync(accountId: AccountId, createIfMissing: Boolean = true): Long = runBlocking {
|
||||
getOutboxFolderId(accountId, createIfMissing)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an outbox folder for the given account.
|
||||
*
|
||||
* @param accountId The ID of the account for which to create the outbox folder.
|
||||
* @return An [Outcome] that resolves to the ID of the created outbox folder on success,
|
||||
* or an [Exception] on failure.
|
||||
*/
|
||||
suspend fun createOutboxFolder(accountId: AccountId): Outcome<Long, Exception>
|
||||
|
||||
/**
|
||||
* Checks if there are any pending messages in the outbox for the given account.
|
||||
*
|
||||
* @param accountId The ID of the account.
|
||||
* @return `true` if there are pending messages, `false` otherwise.
|
||||
*/
|
||||
suspend fun hasPendingMessages(accountId: AccountId): Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the folder ID of the outbox folder for the given account.
|
||||
*
|
||||
* @param accountId The ID of the account.
|
||||
* @return The folder ID of the outbox folder.
|
||||
* @throws IllegalStateException If the outbox folder could not be found.
|
||||
*/
|
||||
@Discouraged(
|
||||
message = "This is a wrapper for Java compatibility. " +
|
||||
"Always use getOutboxFolderIdSync(uuid: AccountId) instead on Kotlin files.",
|
||||
)
|
||||
@JvmOverloads
|
||||
fun OutboxFolderManager.getOutboxFolderIdSync(accountId: String, createIfMissing: Boolean = true): Long {
|
||||
return getOutboxFolderIdSync(accountId = AccountIdFactory.of(accountId), createIfMissing = createIfMissing)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are pending messages in the outbox folder for the given account.
|
||||
*
|
||||
* This is a blocking call and should not be used on the main thread.
|
||||
* This is a wrapper for Java compatibility. Always use `hasPendingMessages(uuid: AccountId): Boolean`
|
||||
* instead on Kotlin files.
|
||||
*
|
||||
* @param accountId The ID of the account.
|
||||
* @return True if there are pending messages, false otherwise.
|
||||
*/
|
||||
@Discouraged(
|
||||
message = "This is a wrapper for Java compatibility. " +
|
||||
"Always use hasPendingMessages(uuid: AccountId): Boolean instead on Kotlin files.",
|
||||
)
|
||||
fun OutboxFolderManager.hasPendingMessagesSync(accountId: String): Boolean = runBlocking {
|
||||
hasPendingMessages(accountId = AccountIdFactory.of(accountId))
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
data class RemoteFolder(
|
||||
val id: Long,
|
||||
val serverId: String,
|
||||
val name: String,
|
||||
val type: FolderType,
|
||||
)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
enum class SpecialFolderSelection {
|
||||
AUTOMATIC,
|
||||
MANUAL,
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package net.thunderbird.feature.mail.folder.api
|
||||
|
||||
import net.thunderbird.feature.mail.account.api.BaseAccount
|
||||
|
||||
// TODO move to ???
|
||||
interface SpecialFolderUpdater {
|
||||
/**
|
||||
* Updates all account's special folders. If POP3, only Inbox is updated.
|
||||
*/
|
||||
fun updateSpecialFolders()
|
||||
|
||||
fun setSpecialFolder(type: FolderType, folderId: Long?, selection: SpecialFolderSelection)
|
||||
|
||||
interface Factory<TAccount : BaseAccount> {
|
||||
fun create(account: TAccount): SpecialFolderUpdater
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue