From e784fa79d06a4d21c2ae685f89926a2278b6e053 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Wed, 30 Nov 2022 12:11:12 +1100 Subject: [PATCH] feat: adding additional config base implementations --- .../messenger/libsession_util/ExampleInstrumentedTest.kt | 1 + libsession-util/src/main/cpp/session_util.cpp | 7 +++++++ .../java/network/loki/messenger/libsession_util/Config.kt | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libsession-util/src/androidTest/java/network/loki/messenger/libsession_util/ExampleInstrumentedTest.kt b/libsession-util/src/androidTest/java/network/loki/messenger/libsession_util/ExampleInstrumentedTest.kt index b76380f616..eee938ea1d 100644 --- a/libsession-util/src/androidTest/java/network/loki/messenger/libsession_util/ExampleInstrumentedTest.kt +++ b/libsession-util/src/androidTest/java/network/loki/messenger/libsession_util/ExampleInstrumentedTest.kt @@ -36,6 +36,7 @@ class ExampleInstrumentedTest { val nameFromNative = userProfile.getName() assertEquals(newName, nameFromNative) println("Name received by JNI call: $nameFromNative") + assertTrue(userProfile.dirty()) userProfile.free() } diff --git a/libsession-util/src/main/cpp/session_util.cpp b/libsession-util/src/main/cpp/session_util.cpp index 5b8d6fb251..b5432e4835 100644 --- a/libsession-util/src/main/cpp/session_util.cpp +++ b/libsession-util/src/main/cpp/session_util.cpp @@ -51,4 +51,11 @@ JNIEXPORT void JNICALL Java_network_loki_messenger_libsession_1util_UserProfile_free(JNIEnv *env, jobject obj) { auto profile = ptrToProfile(env, obj); delete profile; +} + +extern "C" +JNIEXPORT jboolean JNICALL +Java_network_loki_messenger_libsession_1util_ConfigBase_dirty(JNIEnv *env, jobject thiz) { + auto* configBase = ptrToConfigBase(env, thiz); + return configBase->is_dirty(); } \ No newline at end of file diff --git a/libsession-util/src/main/java/network/loki/messenger/libsession_util/Config.kt b/libsession-util/src/main/java/network/loki/messenger/libsession_util/Config.kt index a101549e2b..e765668d2f 100644 --- a/libsession-util/src/main/java/network/loki/messenger/libsession_util/Config.kt +++ b/libsession-util/src/main/java/network/loki/messenger/libsession_util/Config.kt @@ -7,9 +7,9 @@ sealed class ConfigBase(protected val /* yucky */ pointer: Long) { System.loadLibrary("session_util") } } + external fun dirty(): Boolean } - class UserProfile(pointer: Long): ConfigBase(pointer) { companion object { init {