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

+9
View File
@@ -16,6 +16,7 @@
#include <netinet/in.h>
#endif
#include "../lib/mem.h"
#include "chat/chat_setting.h"
#define MAX_LINE_LEN 1024
#define INITIAL_ARRAY_CAPACITY 8
@@ -49,6 +50,7 @@ typedef enum {
SECTION_TCP_PROXY_SERVER,
SECTION_NETWORK,
SECTION_GUI,
SECTION_CHAT,
SECTION_NTP,
SECTION_LOG_UDP
} section_type_t;
@@ -755,6 +757,7 @@ static section_type_t parse_section_header(const char *line, char *name, size_t
if (strcasecmp(section, "tcp_proxy_server") == 0) return SECTION_TCP_PROXY_SERVER;
if (strcasecmp(section, "ntp") == 0) return SECTION_NTP;
if (strcasecmp(section, "gui") == 0) return SECTION_GUI;
if (strcasecmp(section, "chat") == 0) return SECTION_CHAT;
if (strcasecmp(section, "log_udp") == 0) return SECTION_LOG_UDP;
char *colon = strchr(section, ':');
@@ -985,6 +988,11 @@ static struct utun_config* parse_config_internal(FILE *fp, const char *filename)
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown ntp option '%s'. Valid: enabled, server, interval", filename, line_num, key);
}
break;
case SECTION_CHAT:
if (chat_setting_set(key, value) < 0) {
/* chat_setting_set уже напечатал ошибку */
}
break;
case SECTION_GUI:
break;
default:
@@ -1108,6 +1116,7 @@ struct utun_config* parse_config_from_buf(const char *buf, size_t len, const cha
case SECTION_TCP_PROXY_SERVER: cfg->global.tcp_proxy_server_enabled = 1; if (strcmp(key, "tcp_recv_buf") == 0) cfg->global.tcp_recv_buf = atoi(value); break;
case SECTION_NETWORK: if (cur_network) parse_network(key, value, cur_network, filename, line_num); break;
case SECTION_NTP: if (strcmp(key, "enabled") == 0) cfg->global.ntp_enabled = strcasecmp(value, "yes") == 0 || strcasecmp(value, "1") == 0 || strcasecmp(value, "true") == 0; else if (strcmp(key, "server") == 0) { struct CFG_NTP_SERVER *ns = u_calloc(1, sizeof(struct CFG_NTP_SERVER)); if (ns) { strncpy(ns->name, value, sizeof(ns->name) - 1); ns->name[sizeof(ns->name) - 1] = '\0'; ns->next = cfg->global.ntp_servers; cfg->global.ntp_servers = ns; cfg->global.ntp_server_count++; } } else if (strcmp(key, "interval") == 0) { cfg->global.ntp_resync_interval = atoi(value); if (cfg->global.ntp_resync_interval < 60) cfg->global.ntp_resync_interval = 60; } else DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown ntp option '%s'", filename, line_num, key); break;
case SECTION_CHAT: chat_setting_set(key, value); break;
case SECTION_GUI: break;
case SECTION_LOG_UDP:
if (strcmp(key, "ip") == 0) strncpy(cfg->global.log_udp_ip, value, sizeof(cfg->global.log_udp_ip) - 1);