Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-24 18:55:42 +01:00
parent a629de6271
commit 3cef7c5092
2161 changed files with 246605 additions and 2 deletions

View file

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

View file

@ -0,0 +1,101 @@
package com.fsck.k9.backend.api
import com.fsck.k9.mail.BodyFactory
import com.fsck.k9.mail.Flag
import com.fsck.k9.mail.Message
import com.fsck.k9.mail.MessagingException
import com.fsck.k9.mail.Part
interface Backend {
val supportsFlags: Boolean
val supportsExpunge: Boolean
val supportsMove: Boolean
val supportsCopy: Boolean
val supportsUpload: Boolean
val supportsTrashFolder: Boolean
val supportsSearchByDate: Boolean
val isPushCapable: Boolean
@Throws(MessagingException::class)
fun refreshFolderList()
// TODO: Add a way to cancel the sync process
fun sync(folderServerId: String, syncConfig: SyncConfig, listener: SyncListener)
@Throws(MessagingException::class)
fun downloadMessage(syncConfig: SyncConfig, folderServerId: String, messageServerId: String)
@Throws(MessagingException::class)
fun downloadMessageStructure(folderServerId: String, messageServerId: String)
@Throws(MessagingException::class)
fun downloadCompleteMessage(folderServerId: String, messageServerId: String)
@Throws(MessagingException::class)
fun setFlag(folderServerId: String, messageServerIds: List<String>, flag: Flag, newState: Boolean)
@Throws(MessagingException::class)
fun markAllAsRead(folderServerId: String)
@Throws(MessagingException::class)
fun expunge(folderServerId: String)
@Throws(MessagingException::class)
fun expungeMessages(folderServerId: String, messageServerIds: List<String>)
@Throws(MessagingException::class)
fun deleteMessages(folderServerId: String, messageServerIds: List<String>)
@Throws(MessagingException::class)
fun deleteAllMessages(folderServerId: String)
@Throws(MessagingException::class)
fun moveMessages(
sourceFolderServerId: String,
targetFolderServerId: String,
messageServerIds: List<String>
): Map<String, String>?
@Throws(MessagingException::class)
fun moveMessagesAndMarkAsRead(
sourceFolderServerId: String,
targetFolderServerId: String,
messageServerIds: List<String>
): Map<String, String>?
@Throws(MessagingException::class)
fun copyMessages(
sourceFolderServerId: String,
targetFolderServerId: String,
messageServerIds: List<String>
): Map<String, String>?
@Throws(MessagingException::class)
fun search(
folderServerId: String,
query: String?,
requiredFlags: Set<Flag>?,
forbiddenFlags: Set<Flag>?,
performFullTextSearch: Boolean
): List<String>
@Throws(MessagingException::class)
fun fetchPart(folderServerId: String, messageServerId: String, part: Part, bodyFactory: BodyFactory)
@Throws(MessagingException::class)
fun findByMessageId(folderServerId: String, messageId: String): String?
@Throws(MessagingException::class)
fun uploadMessage(folderServerId: String, message: Message): String?
@Throws(MessagingException::class)
fun checkIncomingServerSettings()
@Throws(MessagingException::class)
fun sendMessage(message: Message)
@Throws(MessagingException::class)
fun checkOutgoingServerSettings()
fun createPusher(callback: BackendPusherCallback): BackendPusher
}

View file

@ -0,0 +1,36 @@
package com.fsck.k9.backend.api
import com.fsck.k9.mail.Flag
import com.fsck.k9.mail.Message
import com.fsck.k9.mail.MessageDownloadState
import java.util.Date
// FIXME: add documentation
interface BackendFolder {
val name: String
val visibleLimit: Int
fun getMessageServerIds(): Set<String>
fun getAllMessagesAndEffectiveDates(): Map<String, Long?>
fun destroyMessages(messageServerIds: List<String>)
fun clearAllMessages()
fun getMoreMessages(): MoreMessages
fun setMoreMessages(moreMessages: MoreMessages)
fun setLastChecked(timestamp: Long)
fun setStatus(status: String?)
fun isMessagePresent(messageServerId: String): Boolean
fun getMessageFlags(messageServerId: String): Set<Flag>
fun setMessageFlag(messageServerId: String, flag: Flag, value: Boolean)
fun saveMessage(message: Message, downloadState: MessageDownloadState)
fun getOldestMessageDate(): Date?
fun getFolderExtraString(name: String): String?
fun setFolderExtraString(name: String, value: String?)
fun getFolderExtraNumber(name: String): Long?
fun setFolderExtraNumber(name: String, value: Long)
enum class MoreMessages {
UNKNOWN,
FALSE,
TRUE
}
}

View file

@ -0,0 +1,8 @@
package com.fsck.k9.backend.api
interface BackendPusher {
fun start()
fun updateFolders(folderServerIds: Collection<String>)
fun stop()
fun reconnect()
}

View file

@ -0,0 +1,7 @@
package com.fsck.k9.backend.api
interface BackendPusherCallback {
fun onPushEvent(folderServerId: String)
fun onPushError(exception: Exception)
fun onPushNotSupported()
}

View file

@ -0,0 +1,27 @@
package com.fsck.k9.backend.api
import com.fsck.k9.mail.FolderType
import java.io.Closeable
interface BackendStorage {
fun getFolder(folderServerId: String): BackendFolder
fun getFolderServerIds(): List<String>
fun createFolderUpdater(): BackendFolderUpdater
fun getExtraString(name: String): String?
fun setExtraString(name: String, value: String)
fun getExtraNumber(name: String): Long?
fun setExtraNumber(name: String, value: Long)
}
interface BackendFolderUpdater : Closeable {
fun createFolders(folders: List<FolderInfo>)
fun deleteFolders(folderServerIds: List<String>)
fun changeFolder(folderServerId: String, name: String, type: FolderType)
}
inline fun BackendStorage.updateFolders(block: BackendFolderUpdater.() -> Unit) {
createFolderUpdater().use { it.block() }
}

View file

@ -0,0 +1,5 @@
package com.fsck.k9.backend.api
import com.fsck.k9.mail.FolderType
data class FolderInfo(val serverId: String, val name: String, val type: FolderType)

View file

@ -0,0 +1,19 @@
package com.fsck.k9.backend.api
import com.fsck.k9.mail.Flag
import java.util.Date
data class SyncConfig(
val expungePolicy: ExpungePolicy,
val earliestPollDate: Date?,
val syncRemoteDeletions: Boolean,
val maximumAutoDownloadMessageSize: Int,
val defaultVisibleLimit: Int,
val syncFlags: Set<Flag>
) {
enum class ExpungePolicy {
IMMEDIATELY,
MANUALLY,
ON_POLL
}
}

View file

@ -0,0 +1,21 @@
package com.fsck.k9.backend.api
interface SyncListener {
fun syncStarted(folderServerId: String)
fun syncAuthenticationSuccess()
fun syncHeadersStarted(folderServerId: String)
fun syncHeadersProgress(folderServerId: String, completed: Int, total: Int)
fun syncHeadersFinished(folderServerId: String, totalMessagesInMailbox: Int, numNewMessages: Int)
fun syncProgress(folderServerId: String, completed: Int, total: Int)
fun syncNewMessage(folderServerId: String, messageServerId: String, isOldMessage: Boolean)
fun syncRemovedMessage(folderServerId: String, messageServerId: String)
fun syncFlagChanged(folderServerId: String, messageServerId: String)
fun syncFinished(folderServerId: String)
fun syncFailed(folderServerId: String, message: String, exception: Exception?)
fun folderStatusChanged(folderServerId: String)
}