mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
add configuration and storage
This commit is contained in:
parent
c1f84732ad
commit
da71fdfe44
@ -0,0 +1,22 @@
|
|||||||
|
package org.session.libsession.messaging
|
||||||
|
|
||||||
|
import org.session.libsignal.libsignal.loki.SessionResetProtocol
|
||||||
|
import org.session.libsignal.libsignal.state.*
|
||||||
|
import org.session.libsignal.metadata.certificate.CertificateValidator
|
||||||
|
import org.session.libsignal.service.loki.protocol.closedgroups.SharedSenderKeysDatabaseProtocol
|
||||||
|
|
||||||
|
class Configuration(val storage: StorageProtocol, val signalStorage: SignalProtocolStore, val sskDatabase: SharedSenderKeysDatabaseProtocol, val sessionResetImp: SessionResetProtocol, val certificateValidator: CertificateValidator) {
|
||||||
|
companion object {
|
||||||
|
lateinit var shared: Configuration
|
||||||
|
|
||||||
|
fun configure(storage: StorageProtocol,
|
||||||
|
signalStorage: SignalProtocolStore,
|
||||||
|
sskDatabase: SharedSenderKeysDatabaseProtocol,
|
||||||
|
sessionResetImp: SessionResetProtocol,
|
||||||
|
certificateValidator: CertificateValidator
|
||||||
|
) {
|
||||||
|
if (Companion::shared.isInitialized) { return }
|
||||||
|
shared = Configuration(storage, signalStorage, sskDatabase, sessionResetImp, certificateValidator)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package org.session.libsession.messaging
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.AttachmentUploadJob
|
||||||
|
import org.session.libsession.messaging.jobs.Job
|
||||||
|
import org.session.libsession.messaging.jobs.MessageSendJob
|
||||||
|
import org.session.libsession.messaging.opengroups.OpenGroup
|
||||||
|
|
||||||
|
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
||||||
|
import org.session.libsignal.libsignal.ecc.ECPrivateKey
|
||||||
|
|
||||||
|
interface StorageProtocol {
|
||||||
|
|
||||||
|
// General
|
||||||
|
fun getUserPublicKey(): String?
|
||||||
|
fun getUserKeyPair(): ECKeyPair?
|
||||||
|
fun getUserDisplayName(): String?
|
||||||
|
fun getUserProfileKey(): ByteArray?
|
||||||
|
fun getUserProfilePictureURL(): String?
|
||||||
|
|
||||||
|
// Shared Sender Keys
|
||||||
|
fun getClosedGroupPrivateKey(publicKey: String): ECPrivateKey?
|
||||||
|
fun isClosedGroup(publicKey: String): Boolean
|
||||||
|
|
||||||
|
// Jobs
|
||||||
|
fun persist(job: Job)
|
||||||
|
fun markJobAsSucceeded(job: Job)
|
||||||
|
fun markJobAsFailed(job: Job)
|
||||||
|
fun getAllPendingJobs(type: String): List<Job>
|
||||||
|
fun getAttachmentUploadJob(attachmentID: String): AttachmentUploadJob?
|
||||||
|
fun getMessageSendJob(messageSendJobID: String): MessageSendJob?
|
||||||
|
fun resumeMessageSendJobIfNeeded(messageSendJobID: String)
|
||||||
|
fun isJobCanceled(job: Job): Boolean
|
||||||
|
|
||||||
|
// Authorization
|
||||||
|
fun getAuthToken(server: String): String?
|
||||||
|
fun setAuthToken(server: String, newValue: String?)
|
||||||
|
fun removeAuthToken(server: String)
|
||||||
|
|
||||||
|
// Open Groups
|
||||||
|
fun getOpenGroup(threadID: String): OpenGroup?
|
||||||
|
fun getThreadID(openGroupID: String): String?
|
||||||
|
|
||||||
|
// Open Group Public Keys
|
||||||
|
fun getOpenGroupPublicKey(server: String): String?
|
||||||
|
fun setOpenGroupPublicKey(server: String, newValue: String)
|
||||||
|
|
||||||
|
// Last Message Server ID
|
||||||
|
fun getLastMessageServerID(group: Long, server: String): Long?
|
||||||
|
fun setLastMessageServerID(group: Long, server: String, newValue: Long)
|
||||||
|
fun removeLastMessageServerID(group: Long, server: String)
|
||||||
|
|
||||||
|
// Last Deletion Server ID
|
||||||
|
fun getLastDeletionServerID(group: Long, server: String): Long?
|
||||||
|
fun setLastDeletionServerID(group: Long, server: String, newValue: Long)
|
||||||
|
fun removeLastDeletionServerID(group: Long, server: String)
|
||||||
|
|
||||||
|
// Open Group Metadata
|
||||||
|
fun setUserCount(group: Long, server: String, newValue: Int)
|
||||||
|
fun setOpenGroupProfilePictureURL(group: Long, server: String, newValue: String)
|
||||||
|
fun getOpenGroupProfilePictureURL(group: Long, server: String): String?
|
||||||
|
fun updateTitle(groupID: String, newValue: String)
|
||||||
|
fun updateProfilePicture(groupID: String, newValue: ByteArray)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun getSessionRequestSentTimestamp(publicKey: String): Long?
|
||||||
|
fun setSessionRequestSentTimestamp(publicKey: String, newValue: Long)
|
||||||
|
fun getSessionRequestProcessedTimestamp(publicKey: String): Long?
|
||||||
|
fun setSessionRequestProcessedTimestamp(publicKey: String, newValue: Long)
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.session.libsession.snode
|
||||||
|
|
||||||
|
import org.session.libsignal.service.loki.utilities.Broadcaster
|
||||||
|
|
||||||
|
class Configuration(val storage: SnodeStorageProtocol, val broadcaster: Broadcaster) {
|
||||||
|
companion object {
|
||||||
|
lateinit var shared: Configuration
|
||||||
|
|
||||||
|
fun configure(storage: SnodeStorageProtocol, broadcaster: Broadcaster) {
|
||||||
|
if (Companion::shared.isInitialized) { return }
|
||||||
|
shared = Configuration(storage, broadcaster)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.session.libsession.snode
|
||||||
|
|
||||||
|
interface SnodeStorageProtocol {
|
||||||
|
fun getSnodePool(): Set<Snode>
|
||||||
|
fun setSnodePool(newValue: Set<Snode>)
|
||||||
|
fun getOnionRequestPaths(): List<List<Snode>>
|
||||||
|
fun clearOnionRequestPaths()
|
||||||
|
fun setOnionRequestPaths(newValue: List<List<Snode>>)
|
||||||
|
fun getSwarm(publicKey: String): Set<Snode>?
|
||||||
|
fun setSwarm(publicKey: String, newValue: Set<Snode>)
|
||||||
|
fun getLastMessageHashValue(snode: Snode, publicKey: String): String?
|
||||||
|
fun setLastMessageHashValue(snode: Snode, publicKey: String, newValue: String)
|
||||||
|
fun getReceivedMessageHashValues(publicKey: String): Set<String>?
|
||||||
|
fun setReceivedMessageHashValues(publicKey: String, newValue: Set<String>)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user