feat: add some base config migration logic, start implementing wrappers for conversation and expiry types

This commit is contained in:
0x330a
2023-01-25 13:16:25 +11:00
parent d01e27c671
commit 7733aec6fc
6 changed files with 1265 additions and 96 deletions

View File

@@ -65,4 +65,20 @@ class UserProfile(pointer: Long) : ConfigBase(pointer) {
external fun getName(): String?
external fun getPic(): UserPic?
external fun setPic(userPic: UserPic)
}
class ConversationConfig(pointer: Long): ConfigBase(pointer) {
companion object {
init {
System.loadLibrary("session_util")
}
external fun newInstance(ed25519SecretKey: ByteArray): ConversationConfig
external fun newInstance(ed25519SecretKey: ByteArray, initialDump: ByteArray): ConversationConfig
}
external fun todo()
}

View File

@@ -0,0 +1,44 @@
package network.loki.messenger.libsession_util.util
sealed class Conversation {
data class OneToOne(
val sessionId: String,
val lastRead: Long,
val expiryMode: ExpiryMode,
): Conversation()
data class OpenGroup(
val baseUrl: String,
val room: String,
val pubKey: ByteArray,
val lastRead: Long,
) : Conversation() {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as OpenGroup
if (baseUrl != other.baseUrl) return false
if (room != other.room) return false
if (!pubKey.contentEquals(other.pubKey)) return false
if (lastRead != other.lastRead) return false
return true
}
override fun hashCode(): Int {
var result = baseUrl.hashCode()
result = 31 * result + room.hashCode()
result = 31 * result + pubKey.contentHashCode()
result = 31 * result + lastRead.hashCode()
return result
}
}
data class LegacyClosedGroup(
val groupId: String,
val lastRead: Long,
val expiryMode: ExpiryMode
): Conversation()
}

View File

@@ -0,0 +1,7 @@
package network.loki.messenger.libsession_util.util
sealed class ExpiryMode(val expiryMinutes: Long) {
object NONE: ExpiryMode(0)
class AfterSend(minutes: Long): ExpiryMode(minutes)
class AfterRead(minutes: Long): ExpiryMode(minutes)
}