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

+27 -3
View File
@@ -1,6 +1,7 @@
#include "storagesettingspage.h"
#include "../db/db_manager.h"
#include "../transport/gui_bridge.h"
#include "../transport/config_updater.h"
#include "../../lib/mem.h"
extern "C" {
#include "chat/chat_core.h"
@@ -22,6 +23,19 @@ static void saveUiStateInt(const char* key, int val) {
gui_bridge_post_uasync_fn(chat_core_save_ui_state_trampoline, arg);
}
static void postChatSetting(const QString& configPath, const char* name, int val) {
/* persist to config file */
config_update_option(configPath, "chat", name, QString::number(val), CONFIG_UPDATE_REPLACE);
/* apply on-the-fly via bridge */
QByteArray v = QByteArray::number(val);
size_t nlen = strlen(name), vlen = (size_t)v.size(), total = nlen + 1 + vlen + 1;
if (total > 256) return;
void* arg = u_malloc(total);
memcpy(arg, name, nlen + 1);
memcpy((char*)arg + nlen + 1, v.constData(), vlen + 1);
gui_bridge_post_uasync_fn(chat_core_set_setting_trampoline, arg);
}
StorageSettingsPage::StorageSettingsPage(DbManager* db, QWidget* parent)
: QWidget(parent)
, m_db(db)
@@ -84,7 +98,17 @@ void StorageSettingsPage::loadFromDb() {
}
void StorageSettingsPage::applyAndSave() {
saveUiStateInt("storage_autoload", m_autoloadCheck->isChecked() ? 1 : 0);
saveUiStateInt("storage_autoload_maxsize_mb", m_autoloadMaxSize->value());
saveUiStateInt("storage_maxsize_gb", m_maxStorageSize->value());
int autoload = m_autoloadCheck->isChecked() ? 1 : 0;
int autoloadMaxSize = m_autoloadMaxSize->value();
int maxGb = m_maxStorageSize->value();
saveUiStateInt("storage_autoload", autoload);
saveUiStateInt("storage_autoload_maxsize_mb", autoloadMaxSize);
saveUiStateInt("storage_maxsize_gb", maxGb);
if (!m_configPath.isEmpty()) {
postChatSetting(m_configPath, "storage_autoload", autoload);
postChatSetting(m_configPath, "storage_autoload_maxsize_mb", autoloadMaxSize);
postChatSetting(m_configPath, "storage_maxsize_gb", maxGb);
}
}