|
|
|
|
@ -659,13 +659,13 @@ void utun_bridge_dm_request_messages(const char* conv_id) {
|
|
|
|
|
uasync_post(ua, dm_messages_trampoline, req); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void utun_bridge_dm_send_file(const char* conv_id, const char* path, const char* name) { |
|
|
|
|
int utun_bridge_dm_send_file(const char* conv_id, const char* path, const char* name) { |
|
|
|
|
struct UASYNC* ua = instance_lite_get_uasync(); |
|
|
|
|
if (!conv_id || !path || !name || !uasync_is_running(ua)) { bridge_log(BLEV_WARN, "DM file: invalid request/core stopped"); return; } |
|
|
|
|
if (!conv_id || !path || !name || !uasync_is_running(ua)) { bridge_log(BLEV_WARN, "DM file: invalid request/core stopped"); return -1; } |
|
|
|
|
struct dm_file_req* req = u_calloc(1, sizeof(*req)); |
|
|
|
|
if (!req) { bridge_log(BLEV_ERROR, "DM file: OOM"); return; } |
|
|
|
|
if (!req) { bridge_log(BLEV_ERROR, "DM file: OOM"); return -1; } |
|
|
|
|
if (strlen(conv_id) >= sizeof(req->conv) || strlen(path) >= sizeof(req->path) || strlen(name) >= sizeof(req->info.name)) { |
|
|
|
|
bridge_log(BLEV_ERROR, "DM file: path, conversation or name too long"); u_free(req); return; |
|
|
|
|
bridge_log(BLEV_ERROR, "DM file: path, conversation or name too long"); u_free(req); return -1; |
|
|
|
|
} |
|
|
|
|
req->inst = instance_lite_get_instance(); |
|
|
|
|
snprintf(req->conv, sizeof(req->conv), "%s", conv_id); |
|
|
|
|
@ -673,7 +673,12 @@ void utun_bridge_dm_send_file(const char* conv_id, const char* path, const char*
|
|
|
|
|
req->info.kind = ATTACHMENT_FILE; |
|
|
|
|
req->remove_source = 1; /* PM picker передаёт собственный уникальный cache-файл. */ |
|
|
|
|
snprintf(req->info.name, sizeof(req->info.name), "%s", name); |
|
|
|
|
uasync_post(ua, dm_send_file_trampoline, req); |
|
|
|
|
if (attachment_validate(&req->info)) { bridge_log(BLEV_ERROR, "DM file: invalid name"); u_free(req); return -1; } |
|
|
|
|
struct posted_task* post = u_calloc(1, sizeof(*post)); |
|
|
|
|
if (!post) { bridge_log(BLEV_ERROR, "DM file: completion allocation failed"); u_free(req); return -1; } |
|
|
|
|
post->callback = dm_send_file_trampoline; post->arg = req; |
|
|
|
|
uasync_post_reserved(ua, post); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void utun_bridge_set_debug_level(const char* category, const char* level) { |
|
|
|
|
@ -1914,16 +1919,17 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeDmRequestMessages
|
|
|
|
|
if (c) (*env)->ReleaseStringUTFChars(env, convId, c); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeDmSendFile( |
|
|
|
|
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeDmSendFile( |
|
|
|
|
JNIEnv* env, jobject thiz, jstring convId, jstring path, jstring name) { |
|
|
|
|
(void)thiz; |
|
|
|
|
const char* c = (*env)->GetStringUTFChars(env, convId, NULL); |
|
|
|
|
const char* p = (*env)->GetStringUTFChars(env, path, NULL); |
|
|
|
|
const char* n = (*env)->GetStringUTFChars(env, name, NULL); |
|
|
|
|
utun_bridge_dm_send_file(c, p, n); |
|
|
|
|
int rc = utun_bridge_dm_send_file(c, p, n); |
|
|
|
|
if (n) (*env)->ReleaseStringUTFChars(env, name, n); |
|
|
|
|
if (p) (*env)->ReleaseStringUTFChars(env, path, p); |
|
|
|
|
if (c) (*env)->ReleaseStringUTFChars(env, convId, c); |
|
|
|
|
return rc == 0 ? JNI_TRUE : JNI_FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_com_utun_chat_data_NativeLib_nativeGetMyNodeId( |
|
|
|
|
|