feat: just implement deserialize community info

This commit is contained in:
0x330a 2023-03-01 17:37:12 +11:00
parent 49819765c8
commit e9afb8fa44
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C

View File

@ -59,10 +59,9 @@ Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getCommunityInfo(J
if (community) { if (community) {
community_info = serialize_community_info(env, *community); community_info = serialize_community_info(env, *community);
} }
// TODO: implement getCommunityInfo()
env->ReleaseStringUTFChars(base_url, base_url_bytes); env->ReleaseStringUTFChars(base_url, base_url_bytes);
env->ReleaseStringUTFChars(room, room_bytes); env->ReleaseStringUTFChars(room, room_bytes);
return community_info;
} }
extern "C" extern "C"
@ -70,33 +69,59 @@ JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getLegacyGroupInfo(JNIEnv *env, Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getLegacyGroupInfo(JNIEnv *env,
jobject thiz, jobject thiz,
jstring session_id) { jstring session_id) {
// TODO: implement getLegacyGroupInfo() auto conf = ptrToUserGroups(env, thiz);
auto id_bytes = env->GetStringUTFChars(session_id, nullptr);
auto legacy_group = conf->get_legacy_group(id_bytes);
jobject return_group = nullptr;
if (legacy_group) {
return_group = serialize_legacy_group_info(env, *legacy_group);
}
env->ReleaseStringUTFChars(session_id, id_bytes);
return return_group;
} }
extern "C" extern "C"
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructCommunityInfo( Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructCommunityInfo(
JNIEnv *env, jobject thiz, jstring base_url, jstring room, jstring pub_key_hex) { JNIEnv *env, jobject thiz, jstring base_url, jstring room, jstring pub_key_hex) {
// TODO: implement getOrConstructCommunityInfo() auto conf = ptrToUserGroups(env, thiz);
auto base_url_bytes = env->GetStringUTFChars(base_url, nullptr);
auto room_bytes = env->GetStringUTFChars(room, nullptr);
auto pub_hex_bytes = env->GetStringUTFChars(pub_key_hex, nullptr);
auto group = conf->get_or_construct_community(base_url_bytes, room_bytes, pub_hex_bytes);
env->ReleaseStringUTFChars(base_url, base_url_bytes);
env->ReleaseStringUTFChars(room, room_bytes);
env->ReleaseStringUTFChars(pub_key_hex, pub_hex_bytes);
return serialize_community_info(env, group);
} }
extern "C" extern "C"
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructLegacyGroupInfo( Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructLegacyGroupInfo(
JNIEnv *env, jobject thiz, jstring session_id) { JNIEnv *env, jobject thiz, jstring session_id) {
// TODO: implement getOrConstructLegacyGroupInfo() auto conf = ptrToUserGroups(env, thiz);
auto id_bytes = env->GetStringUTFChars(session_id, nullptr);
auto group = conf->get_or_construct_legacy_group(id_bytes);
env->ReleaseStringUTFChars(session_id, id_bytes);
return serialize_legacy_group_info(env, group);
} }
extern "C" extern "C"
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_set__Lnetwork_loki_messenger_libsession_1util_util_GroupInfo_CommunityGroupInfo_2( Java_network_loki_messenger_libsession_1util_UserGroupsConfig_set__Lnetwork_loki_messenger_libsession_1util_util_GroupInfo_CommunityGroupInfo_2(
JNIEnv *env, jobject thiz, jobject community_info) { JNIEnv *env, jobject thiz, jobject community_info) {
// TODO: implement set() auto conf = ptrToUserGroups(env, thiz);
auto deserialized = (env, community_info);
conf->set(deserialized);
} }
extern "C" extern "C"
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_set__Lnetwork_loki_messenger_libsession_1util_util_GroupInfo_LegacyGroupInfo_2( Java_network_loki_messenger_libsession_1util_UserGroupsConfig_set__Lnetwork_loki_messenger_libsession_1util_util_GroupInfo_LegacyGroupInfo_2(
JNIEnv *env, jobject thiz, jobject legacy_group_info) { JNIEnv *env, jobject thiz, jobject legacy_group_info) {
// TODO: implement set() auto conf = ptrToUserGroups(env, thiz);
auto deserialized = deserialize_legacy_group_info(env, legacy_group_info);
conf->set(*deserialized);
} }