mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-30 23:36:32 +00:00
feat: hacky workaround for new protobuf encryption branches !
This commit is contained in:
@@ -82,7 +82,7 @@ Java_network_loki_messenger_libsession_1util_ConfigBase_confirmPushed(JNIEnv *en
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "bugprone-reserved-identifier"
|
||||
JNIEXPORT jint JNICALL
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_ConfigBase_merge___3Lkotlin_Pair_2(JNIEnv *env, jobject thiz,
|
||||
jobjectArray to_merge) {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
@@ -94,21 +94,31 @@ Java_network_loki_messenger_libsession_1util_ConfigBase_merge___3Lkotlin_Pair_2(
|
||||
auto pair = extractHashAndData(env, jElement);
|
||||
configs.push_back(pair);
|
||||
}
|
||||
return conf->merge(configs);
|
||||
auto returned = conf->merge(configs);
|
||||
auto string_stack = util::build_string_stack(env, returned);
|
||||
return string_stack;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_ConfigBase_merge__Lkotlin_Pair_2(JNIEnv *env, jobject thiz,
|
||||
jobject to_merge) {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto conf = ptrToConfigBase(env, thiz);
|
||||
std::vector<std::pair<std::string, session::ustring>> configs = {extractHashAndData(env, to_merge)};
|
||||
return conf->merge(configs);
|
||||
auto returned = conf->merge(configs);
|
||||
auto string_stack = util::build_string_stack(env, returned);
|
||||
return string_stack;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_ConfigBase_configNamespace(JNIEnv *env, jobject thiz) {
|
||||
auto conf = ptrToConfigBase(env, thiz);
|
||||
return (std::int16_t) conf->storage_namespace();
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jclass JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_ConfigBase_00024Companion_kindFor(JNIEnv *env,
|
||||
jobject thiz,
|
||||
|
||||
@@ -186,6 +186,17 @@ namespace util {
|
||||
return group_member;
|
||||
}
|
||||
|
||||
jobject build_string_stack(JNIEnv* env, std::vector<std::string> to_add) {
|
||||
jclass stack_class = env->FindClass("java/util/Stack");
|
||||
jmethodID constructor = env->GetMethodID(stack_class,"<init>", "()V");
|
||||
jmethodID add = env->GetMethodID(stack_class, "push", "(Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
jobject our_stack = env->NewObject(stack_class, constructor);
|
||||
for (std::basic_string_view<char> string: to_add) {
|
||||
env->CallObjectMethod(our_stack, add, env->NewStringUTF(string.data()));
|
||||
}
|
||||
return our_stack;
|
||||
}
|
||||
|
||||
jobject jlongFromOptional(JNIEnv* env, std::optional<long long> optional) {
|
||||
if (!optional) {
|
||||
return nullptr;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define SESSION_ANDROID_UTIL_H
|
||||
|
||||
#include <jni.h>
|
||||
#include <mutex>
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include "session/types.hpp"
|
||||
@@ -12,13 +11,6 @@
|
||||
#include "session/config/profile_pic.hpp"
|
||||
#include "session/config/user_groups.hpp"
|
||||
#include "session/config/expiring.hpp"
|
||||
//#include <android/log.h>
|
||||
|
||||
//#define LOG_TAG "libsession-jni"
|
||||
//#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
|
||||
//#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
|
||||
//#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||
//#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
|
||||
|
||||
namespace util {
|
||||
extern std::mutex util_mutex_;
|
||||
@@ -37,6 +29,7 @@ namespace util {
|
||||
jstring jstringFromOptional(JNIEnv* env, std::optional<std::string_view> optional);
|
||||
jobject serialize_session_id(JNIEnv* env, std::string_view session_id);
|
||||
std::string deserialize_session_id(JNIEnv* env, jobject session_id);
|
||||
jobject build_string_stack(JNIEnv* env, std::vector<std::string> to_add);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -57,11 +57,11 @@ sealed class ConfigBase(pointer: Long): Config(pointer) {
|
||||
external fun dump(): ByteArray
|
||||
external fun encryptionDomain(): String
|
||||
external fun confirmPushed(seqNo: Long, newHash: String)
|
||||
external fun merge(toMerge: Array<Pair<String,ByteArray>>): Int
|
||||
external fun merge(toMerge: Array<Pair<String,ByteArray>>): Stack<String>
|
||||
external fun currentHashes(): List<String>
|
||||
|
||||
// Singular merge
|
||||
external fun merge(toMerge: Pair<String,ByteArray>): Int
|
||||
external fun merge(toMerge: Pair<String,ByteArray>): Stack<String>
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user