chat_settings: [chat] config section + live sync + fix test segfault

- New chat_setting.c/h: unified chat settings API (int/str getters)
- Config parser supports [chat] section, calls chat_setting_set per key
- chat_core exposes chat_core_set_setting / trampoline for GUI bridge
- chatgui: AudioDevice + Storage pages persist to [chat] config + live apply
- chatgui-android: ConfigProvider, NativeLib, headless handle chat settings
- MessageList: 200 msg limit, fixed saveChannelState via trampoline
- test_media_delivery_full: fix segfault at shutdown (mon() timer vs freed conns)
This commit is contained in:
evgeny committed 2026-07-29 21:18:49 +03:00
1 parent efbb495016
commit b8920cf483
22 files changed
+420 -43

No files matched your search

@@ -4,6 +4,7 @@
#include "headless_control.h"
#include "../libutun_lite/utun_config_api.h"
#include "../libutun_lite/invite_link_c.h"
#include "../../../src/chat/chat_setting.h"
#include <stdint.h>
#include <stdio.h>
@@ -303,6 +304,20 @@ static int handle_join(int fd, int id, const char* json) {
return 0;
}
static int handle_chat_setting(int fd, int id, const char* json) {
char name[128], value[128];
if (json_get_str(json, "name", name, sizeof(name)) < 0 || json_get_str(json, "value", value, sizeof(value)) < 0) {
send_response(fd, id, NULL, "missing name or value");
return 0;
}
int rc = chat_setting_set(name, value);
if (rc == -1) { send_response(fd, id, NULL, "unknown setting"); return 0; }
if (rc == -2) { send_response(fd, id, NULL, "invalid value"); return 0; }
printf("control: chat_setting %s=%s\n", name, value);
send_response(fd, id, "{\"set\":true}", NULL);
return 0;
}
/* ── Command dispatch ── */
typedef int (*cmd_handler_fn)(int fd, int id, const char* json);
@@ -310,13 +325,13 @@ typedef int (*cmd_handler_fn)(int fd, int id, const char* json);
static const char* const g_cmd_names[] = {
"ping", "status", "connect", "disconnect", "connections",
"create_channel", "channels", "send", "messages",
"debug_level", "subscribe", "join", "quit", NULL
"debug_level", "subscribe", "join", "chat_setting", "quit", NULL
};
static cmd_handler_fn g_cmd_handlers[] = {
handle_ping, handle_status, NULL, NULL, handle_connections,
NULL, NULL, NULL, NULL,
handle_debug_level, handle_subscribe, handle_join, handle_quit
handle_debug_level, handle_subscribe, handle_join, handle_chat_setting, handle_quit
};
static void handle_command(struct control_client* cli, const char* json) {