mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
refactor: moving some properties around so we have access in libsession
This commit is contained in:
parent
c0bcc37d2e
commit
336604b9e5
@ -207,7 +207,9 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
|||||||
messagingModuleConfiguration = new MessagingModuleConfiguration(this,
|
messagingModuleConfiguration = new MessagingModuleConfiguration(this,
|
||||||
storage,
|
storage,
|
||||||
messageDataProvider,
|
messageDataProvider,
|
||||||
()-> KeyPairUtilities.INSTANCE.getUserED25519KeyPair(this));
|
()-> KeyPairUtilities.INSTANCE.getUserED25519KeyPair(this),
|
||||||
|
configFactory
|
||||||
|
);
|
||||||
// migrate session open group data
|
// migrate session open group data
|
||||||
OpenGroupMigrator.migrate(getDatabaseComponent());
|
OpenGroupMigrator.migrate(getDatabaseComponent());
|
||||||
// end migration
|
// end migration
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.util
|
package org.thoughtcrime.securesms.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import network.loki.messenger.libsession_util.ConfigBase
|
||||||
import network.loki.messenger.libsession_util.Contacts
|
import network.loki.messenger.libsession_util.Contacts
|
||||||
import network.loki.messenger.libsession_util.UserProfile
|
import network.loki.messenger.libsession_util.UserProfile
|
||||||
import network.loki.messenger.libsession_util.util.Contact
|
import network.loki.messenger.libsession_util.util.Contact
|
||||||
@ -15,12 +16,10 @@ import org.session.libsession.utilities.TextSecurePreferences
|
|||||||
|
|
||||||
object ConfigurationMessageUtilities {
|
object ConfigurationMessageUtilities {
|
||||||
|
|
||||||
const val isNewConfigEnabled = true
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun syncConfigurationIfNeeded(context: Context) {
|
fun syncConfigurationIfNeeded(context: Context) {
|
||||||
// add if check here to schedule new config job process and return early
|
// add if check here to schedule new config job process and return early
|
||||||
if (isNewConfigEnabled) {
|
if (ConfigBase.isNewConfigEnabled) {
|
||||||
// schedule job if none exist
|
// schedule job if none exist
|
||||||
TODO()
|
TODO()
|
||||||
}
|
}
|
||||||
@ -48,7 +47,7 @@ object ConfigurationMessageUtilities {
|
|||||||
|
|
||||||
fun forceSyncConfigurationNowIfNeeded(context: Context): Promise<Unit, Exception> {
|
fun forceSyncConfigurationNowIfNeeded(context: Context): Promise<Unit, Exception> {
|
||||||
// add if check here to schedule new config job process and return early
|
// add if check here to schedule new config job process and return early
|
||||||
if (isNewConfigEnabled) {
|
if (ConfigBase.isNewConfigEnabled) {
|
||||||
// schedule job if none exist
|
// schedule job if none exist
|
||||||
TODO()
|
TODO()
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,9 @@ sealed class ConfigBase(protected val /* yucky */ pointer: Long) {
|
|||||||
System.loadLibrary("session_util")
|
System.loadLibrary("session_util")
|
||||||
}
|
}
|
||||||
external fun kindFor(configNamespace: Int): Class<ConfigBase>
|
external fun kindFor(configNamespace: Int): Class<ConfigBase>
|
||||||
|
|
||||||
|
const val isNewConfigEnabled = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
external fun dirty(): Boolean
|
external fun dirty(): Boolean
|
||||||
|
@ -4,12 +4,14 @@ import android.content.Context
|
|||||||
import com.goterl.lazysodium.utils.KeyPair
|
import com.goterl.lazysodium.utils.KeyPair
|
||||||
import org.session.libsession.database.MessageDataProvider
|
import org.session.libsession.database.MessageDataProvider
|
||||||
import org.session.libsession.database.StorageProtocol
|
import org.session.libsession.database.StorageProtocol
|
||||||
|
import org.session.libsession.utilities.ConfigFactoryProtocol
|
||||||
|
|
||||||
class MessagingModuleConfiguration(
|
class MessagingModuleConfiguration(
|
||||||
val context: Context,
|
val context: Context,
|
||||||
val storage: StorageProtocol,
|
val storage: StorageProtocol,
|
||||||
val messageDataProvider: MessageDataProvider,
|
val messageDataProvider: MessageDataProvider,
|
||||||
val getUserED25519KeyPair: ()-> KeyPair?
|
val getUserED25519KeyPair: () -> KeyPair?,
|
||||||
|
val configFactory: ConfigFactoryProtocol
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package org.session.libsession.messaging.jobs
|
package org.session.libsession.messaging.jobs
|
||||||
|
|
||||||
|
import network.loki.messenger.libsession_util.ConfigBase
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.messages.Destination
|
import org.session.libsession.messaging.messages.Destination
|
||||||
import org.session.libsession.messaging.utilities.Data
|
import org.session.libsession.messaging.utilities.Data
|
||||||
|
import org.session.libsignal.utilities.Log
|
||||||
|
|
||||||
// only contact (self) and closed group destinations will be supported
|
// only contact (self) and closed group destinations will be supported
|
||||||
data class ConfigurationSyncJob(val destination: Destination): Job {
|
data class ConfigurationSyncJob(val destination: Destination): Job {
|
||||||
@ -12,7 +15,21 @@ data class ConfigurationSyncJob(val destination: Destination): Job {
|
|||||||
override val maxFailureCount: Int = 1
|
override val maxFailureCount: Int = 1
|
||||||
|
|
||||||
override suspend fun execute() {
|
override suspend fun execute() {
|
||||||
TODO("Not yet implemented")
|
val userEdKeyPair = MessagingModuleConfiguration.shared.getUserED25519KeyPair()
|
||||||
|
if (destination is Destination.ClosedGroup
|
||||||
|
|| !ConfigBase.isNewConfigEnabled
|
||||||
|
|| userEdKeyPair == null
|
||||||
|
) {
|
||||||
|
// TODO: currently we only deal with single destination until closed groups refactor / implement LCG
|
||||||
|
Log.w(TAG, "Not handling config sync job, TODO")
|
||||||
|
delegate?.handleJobSucceeded(this)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val configFactory = MessagingModuleConfiguration.shared.configFactory
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(): Data {
|
override fun serialize(): Data {
|
||||||
|
Loading…
Reference in New Issue
Block a user