Wrap config_base.cpp also

This commit is contained in:
fanchao 2024-05-28 14:37:06 +10:00
parent f16735d4ee
commit a78c11f258

View File

@ -1,5 +1,6 @@
#include "config_base.h" #include "config_base.h"
#include "util.h" #include "util.h"
#include "jni_utils.h"
extern "C" { extern "C" {
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
@ -85,18 +86,20 @@ Java_network_loki_messenger_libsession_1util_ConfigBase_confirmPushed(JNIEnv *en
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_ConfigBase_merge___3Lkotlin_Pair_2(JNIEnv *env, jobject thiz, Java_network_loki_messenger_libsession_1util_ConfigBase_merge___3Lkotlin_Pair_2(JNIEnv *env, jobject thiz,
jobjectArray to_merge) { jobjectArray to_merge) {
std::lock_guard lock{util::util_mutex_}; return jni_utils::run_catching_cxx_exception_or_throws<jobject>(env, [=] {
auto conf = ptrToConfigBase(env, thiz); std::lock_guard lock{util::util_mutex_};
size_t number = env->GetArrayLength(to_merge); auto conf = ptrToConfigBase(env, thiz);
std::vector<std::pair<std::string,session::ustring>> configs = {}; size_t number = env->GetArrayLength(to_merge);
for (int i = 0; i < number; i++) { std::vector<std::pair<std::string, session::ustring>> configs = {};
auto jElement = (jobject) env->GetObjectArrayElement(to_merge, i); for (int i = 0; i < number; i++) {
auto pair = extractHashAndData(env, jElement); auto jElement = (jobject) env->GetObjectArrayElement(to_merge, i);
configs.push_back(pair); auto pair = extractHashAndData(env, jElement);
} configs.push_back(pair);
auto returned = conf->merge(configs); }
auto string_stack = util::build_string_stack(env, returned); auto returned = conf->merge(configs);
return string_stack; auto string_stack = util::build_string_stack(env, returned);
return string_stack;
});
} }
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL