stcp: ed25519 pubkey exchange in handshake, fix instance destroy segfault, fix chat_tcp_test
- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
This commit is contained in:
1 parent
a3783b5f55
commit
38c9f229bc
1272 files changed
+968388
-1
No files matched your search
@@ -0,0 +1,112 @@
|
||||
#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"
|
||||
}
|
||||
#include <QVBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
#include <QFrame>
|
||||
|
||||
static void saveUiStateInt(const char* key, int val) {
|
||||
QByteArray v = QByteArray::number(val);
|
||||
size_t klen = strlen(key), vlen = (size_t)v.size(), total = klen + 1 + vlen + 1;
|
||||
if (total > 256) return;
|
||||
void* arg = u_malloc(total);
|
||||
memcpy(arg, key, klen + 1);
|
||||
memcpy((char*)arg + klen + 1, v.constData(), vlen + 1);
|
||||
gui_bridge_post_uasync_fn(chat_core_save_ui_state_trampoline, arg);
|
||||
}
|
||||
|
||||
void postChatSetting(const QString& configPath, const char* name, int val) {
|
||||
config_update_option(configPath, "chatserver", name, QString::number(val), CONFIG_UPDATE_REPLACE);
|
||||
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)
|
||||
{
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 12, 0, 0);
|
||||
layout->setSpacing(14);
|
||||
|
||||
auto* title = new QLabel("Media Storage", this);
|
||||
title->setStyleSheet("font-weight: bold; font-size: 13px;");
|
||||
layout->addWidget(title);
|
||||
|
||||
auto* form = new QFormLayout();
|
||||
form->setSpacing(10);
|
||||
form->setContentsMargins(0, 8, 0, 0);
|
||||
|
||||
m_autoloadCheck = new QCheckBox("Autoload media", this);
|
||||
m_autoloadCheck->setStyleSheet("font-size: 13px;");
|
||||
form->addRow(m_autoloadCheck);
|
||||
|
||||
m_autoloadMaxSize = new QSpinBox(this);
|
||||
m_autoloadMaxSize->setRange(1, 500);
|
||||
m_autoloadMaxSize->setSuffix(" MB");
|
||||
m_autoloadMaxSize->setFixedWidth(110);
|
||||
m_autoloadMaxSize->setStyleSheet(
|
||||
"QSpinBox { border: 1px solid palette(mid); border-radius: 4px;"
|
||||
" padding: 5px 8px; font-size: 13px; background: palette(base); }");
|
||||
form->addRow("Autoload max size:", m_autoloadMaxSize);
|
||||
|
||||
m_maxStorageSize = new QSpinBox(this);
|
||||
m_maxStorageSize->setRange(1, 100);
|
||||
m_maxStorageSize->setSuffix(" GB");
|
||||
m_maxStorageSize->setFixedWidth(110);
|
||||
m_maxStorageSize->setStyleSheet(
|
||||
"QSpinBox { border: 1px solid palette(mid); border-radius: 4px;"
|
||||
" padding: 5px 8px; font-size: 13px; background: palette(base); }");
|
||||
form->addRow("Max storage size:", m_maxStorageSize);
|
||||
|
||||
layout->addLayout(form);
|
||||
|
||||
auto* sep = new QFrame(this);
|
||||
sep->setFrameShape(QFrame::HLine);
|
||||
sep->setStyleSheet("QFrame { color: palette(mid); }");
|
||||
layout->addWidget(sep);
|
||||
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
void StorageSettingsPage::loadFromDb() {
|
||||
if (!m_db) return;
|
||||
|
||||
bool autoload = m_db->getUiStateInt("storage_autoload", 1);
|
||||
m_autoloadCheck->setChecked(autoload);
|
||||
|
||||
int maxSizeMb = m_db->getUiStateInt("storage_autoload_maxsize_mb", 10);
|
||||
m_autoloadMaxSize->setValue(maxSizeMb);
|
||||
|
||||
int maxGb = m_db->getUiStateInt("storage_maxsize_gb", 1);
|
||||
m_maxStorageSize->setValue(maxGb);
|
||||
}
|
||||
|
||||
void StorageSettingsPage::applyAndSave() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user