|
|
|
|
@ -29,6 +29,7 @@
|
|
|
|
|
#include "../../../src/chat/chat_core.h" |
|
|
|
|
#include "../../../src/chat/invite_build.h" |
|
|
|
|
#include "../../../src/chat/chat_setting.h" |
|
|
|
|
#include "../../../src/routing_layer/topo_node_sqlite.h" |
|
|
|
|
#include "../../../src/utun_instance.h" |
|
|
|
|
#include "../../../src/transport_layer/etcp.h" |
|
|
|
|
#include "../../../src/transport_layer/etcp_connections.h" |
|
|
|
|
@ -1906,6 +1907,44 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeDmSend(
|
|
|
|
|
if (c) (*env)->ReleaseStringUTFChars(env, convId, c); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* UI получает подтверждение commit через CHAT_EVT_DM_INVITE_RESULT, а не через return JNI. */ |
|
|
|
|
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeDmInvite( |
|
|
|
|
JNIEnv* env, jobject thiz, jlong request_id, jlong peer, jstring source, jlong channel, jstring name, jboolean cancel) { |
|
|
|
|
(void)thiz; |
|
|
|
|
struct UASYNC* ua = instance_lite_get_uasync(); |
|
|
|
|
struct UTUN_INSTANCE* inst = instance_lite_get_instance(); |
|
|
|
|
if (!uasync_is_running(ua) || !inst) { bridge_log(BLEV_ERROR, "invite PM: core unavailable"); return JNI_FALSE; } |
|
|
|
|
struct dm_invite_req* req = u_calloc(1, sizeof(*req)); |
|
|
|
|
if (!req) { bridge_log(BLEV_ERROR, "invite PM: request allocation failed"); return JNI_FALSE; } |
|
|
|
|
const char* src = (*env)->GetStringUTFChars(env, source, NULL); |
|
|
|
|
const char* nm = src ? (*env)->GetStringUTFChars(env, name, NULL) : NULL; |
|
|
|
|
if (!src || !nm) { |
|
|
|
|
if (src) (*env)->ReleaseStringUTFChars(env, source, src); |
|
|
|
|
bridge_log(BLEV_ERROR, "invite PM: string conversion failed"); u_free(req); return JNI_FALSE; |
|
|
|
|
} |
|
|
|
|
req->inst = inst; req->request_id = (uint64_t)request_id; req->peer_node_id = (uint64_t)peer; |
|
|
|
|
req->channel_id = (uint64_t)channel; req->cancel = cancel ? 1 : 0; |
|
|
|
|
snprintf(req->source_ch_id, sizeof(req->source_ch_id), "%s", src); |
|
|
|
|
snprintf(req->peer_name, sizeof(req->peer_name), "%s", nm); |
|
|
|
|
(*env)->ReleaseStringUTFChars(env, source, src); (*env)->ReleaseStringUTFChars(env, name, nm); |
|
|
|
|
if (uasync_post(ua, dm_invite_trampoline, req) != 0) { |
|
|
|
|
bridge_log(BLEV_ERROR, "invite PM: post failed"); u_free(req); return JNI_FALSE; |
|
|
|
|
} |
|
|
|
|
return JNI_TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Чтение членства для выбора групп и открытия уже присоединённого канала. */ |
|
|
|
|
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeIsChannelMember( |
|
|
|
|
JNIEnv* env, jobject thiz, jstring channel, jlong node) { |
|
|
|
|
(void)thiz; |
|
|
|
|
struct UTUN_INSTANCE* inst = instance_lite_get_instance(); |
|
|
|
|
const char* id = (*env)->GetStringUTFChars(env, channel, NULL); |
|
|
|
|
if (!id) { bridge_log(BLEV_ERROR, "channel membership: string conversion failed"); return JNI_FALSE; } |
|
|
|
|
int member = inst && topo_node_sqlite_member_in_channel(inst->topo_sqlite_db, id, (uint64_t)node); |
|
|
|
|
(*env)->ReleaseStringUTFChars(env, channel, id); |
|
|
|
|
return member ? JNI_TRUE : JNI_FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeDmRequestConversations( |
|
|
|
|
JNIEnv* env, jobject thiz) { |
|
|
|
|
(void)env; (void)thiz; |
|
|
|
|
|