Expose committed PM file results through Android JNI
This commit is contained in:
1 parent
d6eed3e9c9
commit
ce80fbcd10
3 files changed
+17
-10
No files matched your search
@@ -371,7 +371,8 @@ object NativeLib {
|
||||
fun dmRequestConversations() { nativeDmRequestConversations() }
|
||||
fun dmRequestCallRoute(convId: String) { nativeDmRequestCallRoute(convId) }
|
||||
fun dmRequestMessages(convId: String, generation: Long) { nativeDmRequestMessages(convId, generation) }
|
||||
fun dmSendFile(convId: String, path: String, name: String, generation: Long): Boolean = nativeDmSendFile(convId, path, name, generation)
|
||||
fun dmSendFile(convId: String, path: String, name: String, generation: Long, requestId: Long): Boolean =
|
||||
nativeDmSendFile(convId, path, name, generation, requestId)
|
||||
|
||||
private external fun nativeInit(dbPath: String, controlPort: Int, config: Any, logCb: Any): Boolean
|
||||
private external fun nativeStart(configText: String): Boolean
|
||||
@@ -509,5 +510,5 @@ object NativeLib {
|
||||
private external fun nativeDmRequestConversations()
|
||||
private external fun nativeDmRequestCallRoute(convId: String)
|
||||
private external fun nativeDmRequestMessages(convId: String, generation: Long)
|
||||
private external fun nativeDmSendFile(convId: String, path: String, name: String, generation: Long): Boolean
|
||||
private external fun nativeDmSendFile(convId: String, path: String, name: String, generation: Long, requestId: Long): Boolean
|
||||
}
|
||||
@@ -736,9 +736,11 @@ void utun_bridge_dm_request_messages(const char* conv_id, uint64_t generation) {
|
||||
uasync_post(ua, dm_messages_trampoline, req);
|
||||
}
|
||||
|
||||
int utun_bridge_dm_send_file(const char* conv_id, const char* path, const char* name, uint64_t generation) {
|
||||
int utun_bridge_dm_send_file(const char* conv_id, const char* path, const char* name, uint64_t generation, uint64_t request_id) {
|
||||
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 -1; }
|
||||
if (!conv_id || !path || !name || !generation || !request_id || !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 -1; }
|
||||
if (strlen(conv_id) >= sizeof(req->conv) || strlen(path) >= sizeof(req->path) || strlen(name) >= sizeof(req->info.name)) {
|
||||
@@ -746,6 +748,7 @@ int utun_bridge_dm_send_file(const char* conv_id, const char* path, const char*
|
||||
}
|
||||
req->inst = instance_lite_get_instance();
|
||||
req->generation = generation;
|
||||
req->request_id = request_id;
|
||||
snprintf(req->conv, sizeof(req->conv), "%s", conv_id);
|
||||
snprintf(req->path, sizeof(req->path), "%s", path);
|
||||
req->info.kind = ATTACHMENT_FILE;
|
||||
@@ -2447,12 +2450,14 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeDmRequestMessages
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeDmSendFile(
|
||||
JNIEnv* env, jobject thiz, jstring convId, jstring path, jstring name, jlong generation) {
|
||||
JNIEnv* env, jobject thiz, jstring convId, jstring path, jstring name, jlong generation, jlong requestId) {
|
||||
(void)thiz;
|
||||
if (!convId || !path || !name) { bridge_log(BLEV_ERROR, "DM file JNI: null argument"); return JNI_FALSE; }
|
||||
const char* c = (*env)->GetStringUTFChars(env, convId, NULL);
|
||||
const char* p = (*env)->GetStringUTFChars(env, path, NULL);
|
||||
const char* n = (*env)->GetStringUTFChars(env, name, NULL);
|
||||
int rc = utun_bridge_dm_send_file(c, p, n, (uint64_t)generation);
|
||||
const char* p = c ? (*env)->GetStringUTFChars(env, path, NULL) : NULL;
|
||||
const char* n = p ? (*env)->GetStringUTFChars(env, name, NULL) : NULL;
|
||||
int rc = n ? utun_bridge_dm_send_file(c, p, n, (uint64_t)generation, (uint64_t)requestId) : -1;
|
||||
if (!n) bridge_log(BLEV_ERROR, "DM file JNI: string copy failed");
|
||||
if (n) (*env)->ReleaseStringUTFChars(env, name, n);
|
||||
if (p) (*env)->ReleaseStringUTFChars(env, path, p);
|
||||
if (c) (*env)->ReleaseStringUTFChars(env, convId, c);
|
||||
|
||||
@@ -291,8 +291,9 @@ void utun_bridge_dm_request_conversations(void);
|
||||
/* Снимок видимой истории указанного поколения; запоздалый запрос отбрасывается в uasync. */
|
||||
void utun_bridge_dm_request_messages(const char* conv_id, uint64_t generation);
|
||||
/* 0 — принято и передано владение временным path (удаляется задачей), -1 — отказ, файл остаётся caller.
|
||||
* name — отображаемое имя, строки копируются. Поколение беседы проверяется в uasync. */
|
||||
int utun_bridge_dm_send_file(const char* conv_id, const char* path, const char* name, uint64_t generation);
|
||||
* name — отображаемое имя, строки копируются. Поколение беседы проверяется в uasync.
|
||||
* Ненулевой request_id получает CHAT_EVT_MSG_SUBMITTED после commit либо ошибки; generation также ненулевой. */
|
||||
int utun_bridge_dm_send_file(const char* conv_id, const char* path, const char* name, uint64_t generation, uint64_t request_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user