diff --git a/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt b/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt index 99c39c96..65924aee 100644 --- a/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt +++ b/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt @@ -282,8 +282,9 @@ object NativeLib { private external fun nativeStreamOpusClose(handle: Long) /* ── Photo message ── */ - fun photoSend(channelId: String, filePath: String, width: Int, height: Int, replyTo: String = "", requestId: Long = 0): Boolean = - nativePhotoSend(channelId, filePath, width, height, messageIdBytes(replyTo), requestId) + fun photoSend(channelId: String, filePath: String, width: Int, height: Int, contentType: String, + replyTo: String = "", requestId: Long = 0, generation: Long = 0): Boolean = + nativePhotoSend(channelId, filePath, width, height, messageIdBytes(replyTo), requestId, contentType, generation) /* ── Voice playback ── */ fun voiceDecodeOpen(filePath: String, outInfo: IntArray): Long = nativeVoiceDecodeOpen(filePath, outInfo) @@ -442,7 +443,7 @@ object NativeLib { /* ── Photo message JNI ── */ private external fun nativePhotoSend(channelId: String, filePath: String, width: Int, height: Int, - replyTo: ByteArray, requestId: Long): Boolean + replyTo: ByteArray, requestId: Long, contentType: String, generation: Long): Boolean /* ── Voice playback JNI ── */ private external fun nativeVoiceDecodeOpen(filePath: String, outInfo: IntArray): Long diff --git a/tools/chatgui-android/jni_bridge/android_jni_bridge.c b/tools/chatgui-android/jni_bridge/android_jni_bridge.c index eb52b25b..d5a2fa3d 100644 --- a/tools/chatgui-android/jni_bridge/android_jni_bridge.c +++ b/tools/chatgui-android/jni_bridge/android_jni_bridge.c @@ -1501,8 +1501,9 @@ int utun_bridge_video_send(const char* channel_id, const char* file_path, const } int utun_bridge_photo_send(const char* channel_id, const char* file_path, const char* db_path, - int width, int height, const uint8_t reply_to[32], uint64_t request_id) { - return photo_send(channel_id, file_path, db_path, width, height, reply_to, request_id); + int width, int height, const uint8_t reply_to[32], uint64_t request_id, + const char* content_type, uint64_t generation) { + return photo_send(channel_id, file_path, db_path, width, height, reply_to, request_id, content_type, generation); } /* ────────────────────────────────────────────────────────────────── @@ -2636,13 +2637,15 @@ JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeVideoSend( JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativePhotoSend( JNIEnv* env, jobject thiz, jstring channelId, jstring filePath, - jint width, jint height, jbyteArray replyTo, jlong requestId) { + jint width, jint height, jbyteArray replyTo, jlong requestId, jstring contentType, jlong generation) { (void)thiz; uint8_t reply[32]; if (jni_message_id(env, replyTo, reply) < 0) return JNI_FALSE; const char* ch = (*env)->GetStringUTFChars(env, channelId, NULL); const char* fp = (*env)->GetStringUTFChars(env, filePath, NULL); - int rc = utun_bridge_photo_send(ch, fp, g_db_path, (int)width, (int)height, reply, (uint64_t)requestId); + const char* type = (*env)->GetStringUTFChars(env, contentType, NULL); + int rc = utun_bridge_photo_send(ch, fp, g_db_path, (int)width, (int)height, reply, (uint64_t)requestId, type, (uint64_t)generation); + if (type) (*env)->ReleaseStringUTFChars(env, contentType, type); if (fp) (*env)->ReleaseStringUTFChars(env, filePath, fp); if (ch) (*env)->ReleaseStringUTFChars(env, channelId, ch); return (rc == 0) ? JNI_TRUE : JNI_FALSE; diff --git a/tools/chatgui-android/jni_bridge/android_jni_bridge.h b/tools/chatgui-android/jni_bridge/android_jni_bridge.h index e9c26d4f..89f500bd 100644 --- a/tools/chatgui-android/jni_bridge/android_jni_bridge.h +++ b/tools/chatgui-android/jni_bridge/android_jni_bridge.h @@ -139,10 +139,11 @@ int utun_bridge_attachment_download(const char* channel_id, int64_t msg_id); int utun_bridge_video_send(const char* channel_id, const char* file_path, const char* db_path, int duration_ms, int width, int height, const uint8_t reply_to[32], uint64_t request_id, uint64_t generation); -/* Готовое фото в канал, без декодирования; JPEG/PNG/GIF/BMP/WebP по расширению, caller задаёт размеры. - * db_path — каталог БД; источник остаётся у caller до завершения копирования. 0/-1, см. photo_sender.h. */ +/* Готовое изображение: MIME/размеры проверяет Android, JPEG/PNG в канал или dm: с generation. + * 0 передаёт JPEG/PNG cache-файл задаче, -1 оставляет caller; дополнительные форматы — см. photo_sender.h. */ int utun_bridge_photo_send(const char* channel_id, const char* file_path, const char* db_path, - int width, int height, const uint8_t reply_to[32], uint64_t request_id); + int width, int height, const uint8_t reply_to[32], uint64_t request_id, + const char* content_type, uint64_t generation); /* Декодирование собственного OPUS-файла (не Ogg): open возвращает owned handle либо NULL. * Все три out обязательны: частота, число каналов, общее число int16 (включая interleaved каналы).