|
|
|
|
@ -1027,6 +1027,40 @@ void utun_bridge_delete_channel(const char* channel_id) {
|
|
|
|
|
bridge_log(BLEV_INFO, "delete_channel queued ch=%s", channel_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ── Per-channel «play sound on message» ── */ |
|
|
|
|
|
|
|
|
|
struct sound_setting_req { |
|
|
|
|
struct UTUN_INSTANCE* inst; |
|
|
|
|
char ch_id[64]; |
|
|
|
|
int on; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static void sound_setting_trampoline(void* arg) { |
|
|
|
|
struct sound_setting_req* req = (struct sound_setting_req*)arg; |
|
|
|
|
if (!req || !req->inst) { u_free(arg); return; } |
|
|
|
|
chat_core_set_sound_on_message(req->inst, req->ch_id, req->on); |
|
|
|
|
u_free(arg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int utun_bridge_get_sound_on_message(const char* channel_id) { |
|
|
|
|
struct UTUN_INSTANCE* inst = instance_lite_get_instance(); |
|
|
|
|
if (!inst || !chat_core_is_initialized(inst) || !channel_id || !channel_id[0]) return 1; |
|
|
|
|
return chat_core_get_sound_on_message(inst, channel_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void utun_bridge_set_sound_on_message(const char* channel_id, int on) { |
|
|
|
|
if (!channel_id || !channel_id[0]) { bridge_log(BLEV_ERROR, "set_sound: empty ch_id"); return; } |
|
|
|
|
struct UASYNC* ua = instance_lite_get_uasync(); |
|
|
|
|
if (!uasync_is_running(ua)) { bridge_log(BLEV_ERROR, "set_sound: uasync not running"); return; } |
|
|
|
|
struct sound_setting_req* req = u_calloc(1, sizeof(*req)); |
|
|
|
|
if (!req) { bridge_log(BLEV_ERROR, "set_sound: OOM"); return; } |
|
|
|
|
req->inst = instance_lite_get_instance(); |
|
|
|
|
strncpy(req->ch_id, channel_id, sizeof(req->ch_id) - 1); |
|
|
|
|
req->on = on ? 1 : 0; |
|
|
|
|
uasync_post(ua, sound_setting_trampoline, req); |
|
|
|
|
bridge_log(BLEV_INFO, "set_sound queued ch=%s on=%d", channel_id, on ? 1 : 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ──────────────────────────────────────────────────────────────────
|
|
|
|
|
* Local sockets state (for auto-mode UI display) |
|
|
|
|
* ────────────────────────────────────────────────────────────────── */ |
|
|
|
|
@ -1943,15 +1977,32 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetChatSetting(
|
|
|
|
|
if (n) (*env)->ReleaseStringUTFChars(env, name, n); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT jint JNICALL Java_com_utun_chat_data_NativeLib_nativeGetChatSettingInt( |
|
|
|
|
JNIEnv* env, jobject thiz, jstring name, jint def) { |
|
|
|
|
(void)thiz; |
|
|
|
|
const char* n = (*env)->GetStringUTFChars(env, name, NULL); |
|
|
|
|
struct UTUN_INSTANCE* inst = instance_lite_get_instance(); |
|
|
|
|
int val = chat_setting_get_int(inst, n, (int)def); |
|
|
|
|
if (n) (*env)->ReleaseStringUTFChars(env, name, n); |
|
|
|
|
return (jint)val; |
|
|
|
|
} |
|
|
|
|
JNIEXPORT jint JNICALL Java_com_utun_chat_data_NativeLib_nativeGetChatSettingInt( |
|
|
|
|
JNIEnv* env, jobject thiz, jstring name, jint def) { |
|
|
|
|
(void)thiz; |
|
|
|
|
const char* n = (*env)->GetStringUTFChars(env, name, NULL); |
|
|
|
|
struct UTUN_INSTANCE* inst = instance_lite_get_instance(); |
|
|
|
|
int val = chat_setting_get_int(inst, n, (int)def); |
|
|
|
|
if (n) (*env)->ReleaseStringUTFChars(env, name, n); |
|
|
|
|
return (jint)val; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT jint JNICALL Java_com_utun_chat_data_NativeLib_nativeGetSoundOnMessage( |
|
|
|
|
JNIEnv* env, jobject thiz, jstring chId) { |
|
|
|
|
(void)thiz; |
|
|
|
|
const char* c = (*env)->GetStringUTFChars(env, chId, NULL); |
|
|
|
|
int on = utun_bridge_get_sound_on_message(c); |
|
|
|
|
if (c) (*env)->ReleaseStringUTFChars(env, chId, c); |
|
|
|
|
return (jint)on; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetSoundOnMessage( |
|
|
|
|
JNIEnv* env, jobject thiz, jstring chId, jboolean on) { |
|
|
|
|
(void)thiz; |
|
|
|
|
const char* c = (*env)->GetStringUTFChars(env, chId, NULL); |
|
|
|
|
utun_bridge_set_sound_on_message(c, on ? 1 : 0); |
|
|
|
|
if (c) (*env)->ReleaseStringUTFChars(env, chId, c); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSubscribeLogs( |
|
|
|
|
JNIEnv* env, jobject thiz, jboolean enabled) { |
|
|
|
|
|