etcp: переупорядочить close + защита state==2 во всех API-точках; topo: правильная очистка group nodes и registry; chat/member: новый модуль member_sync; chatgui: обновления транспорта и UI
This commit is contained in:
1 parent
b2e4aadbf0
commit
7f901c01e1
38 files changed
+1275
-540
No files matched your search
@@ -60,10 +60,30 @@ static void onChannelUpdatedCallback(const char* ch_id, int ch_id_len) {
|
||||
s_mainWindow->reloadChannels();
|
||||
}
|
||||
|
||||
static void onMembersChangedCallback(const char* ch_id, int ch_id_len) {
|
||||
Q_UNUSED(ch_id_len);
|
||||
static void onMemberListCallback(const uint8_t* data, int len) {
|
||||
if (len < 3) return;
|
||||
uint8_t cl = data[0];
|
||||
if (len < 1 + (int)cl + 2) return;
|
||||
uint16_t count; memcpy(&count, data + 1 + cl, 2);
|
||||
if (s_mainWindow)
|
||||
s_mainWindow->onMembersChanged(ch_id);
|
||||
s_mainWindow->onMemberList(QString::fromUtf8((const char*)data + 1, cl), count, data + 1 + cl + 2, len - 1 - cl - 2);
|
||||
}
|
||||
|
||||
static void onMemberUpdatedCallback(const uint8_t* data, int len) {
|
||||
if (len < 1 + 64 + 1 + 79) return;
|
||||
uint8_t cl = data[0];
|
||||
if (len < 1 + (int)cl + 1 + 79) return;
|
||||
if (s_mainWindow)
|
||||
s_mainWindow->onMemberUpdated(QString::fromUtf8((const char*)data + 1, cl), data + 1 + cl + 1);
|
||||
}
|
||||
|
||||
static void onMemberRemovedCallback(const uint8_t* data, int len) {
|
||||
if (len < 1 + 64 + 8) return;
|
||||
uint8_t cl = data[0];
|
||||
if (len < 1 + (int)cl + 8) return;
|
||||
uint64_t nid; memcpy(&nid, data + 1 + cl, 8);
|
||||
if (s_mainWindow)
|
||||
s_mainWindow->onMemberRemoved(QString::fromUtf8((const char*)data + 1, cl), nid);
|
||||
}
|
||||
|
||||
static void onAutoConnectStatusCallback(uint8_t status, uint16_t total_tried,
|
||||
@@ -109,7 +129,9 @@ MainWindow::~MainWindow() {
|
||||
m_autoPlayTimer->stop();
|
||||
gui_bridge_set_msg_received_cb(nullptr);
|
||||
gui_bridge_set_channel_updated_cb(nullptr);
|
||||
gui_bridge_set_members_changed_cb(nullptr);
|
||||
gui_bridge_set_member_list_cb(nullptr);
|
||||
gui_bridge_set_member_updated_cb(nullptr);
|
||||
gui_bridge_set_member_removed_cb(nullptr);
|
||||
gui_bridge_set_my_node_id_cb(nullptr);
|
||||
gui_bridge_set_auto_connect_status_cb(nullptr);
|
||||
gui_bridge_set_channel_peers_online_cb(nullptr);
|
||||
@@ -157,11 +179,9 @@ void MainWindow::setupNode() {
|
||||
});
|
||||
connect(m_node, &UtunNode::started, this, [this]() {
|
||||
qDebug("UtunNode started");
|
||||
if (m_accountList && m_node) m_accountList->setUtunInstance(m_node->instance());
|
||||
});
|
||||
connect(m_node, &UtunNode::stopped, this, [this]() {
|
||||
qDebug("UtunNode stopped");
|
||||
if (m_node) m_node->finalize();
|
||||
qApp->quit();
|
||||
});
|
||||
|
||||
@@ -260,7 +280,9 @@ void MainWindow::setupBridgeCallbacks() {
|
||||
s_mainWindow = this;
|
||||
gui_bridge_set_msg_received_cb(onMsgReceivedCallback);
|
||||
gui_bridge_set_channel_updated_cb(onChannelUpdatedCallback);
|
||||
gui_bridge_set_members_changed_cb(onMembersChangedCallback);
|
||||
gui_bridge_set_member_list_cb(onMemberListCallback);
|
||||
gui_bridge_set_member_updated_cb(onMemberUpdatedCallback);
|
||||
gui_bridge_set_member_removed_cb(onMemberRemovedCallback);
|
||||
gui_bridge_set_my_node_id_cb([](uint64_t nid) {
|
||||
qDebug("MainWindow: MY_NODE_ID setMyNodeId(%016llx)", (unsigned long long)nid);
|
||||
if (s_mainWindow && s_mainWindow->m_db) s_mainWindow->m_db->setMyNodeId((quint64)nid);
|
||||
@@ -463,10 +485,16 @@ void MainWindow::onMessageReceived(const char* ch_id, int ch_id_len, uint64_t au
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onMembersChanged(const char* ch_id) {
|
||||
QString cur = QSettings().value("last_channel_id").toString();
|
||||
if (cur == QString::fromUtf8(ch_id))
|
||||
m_accountList->refresh();
|
||||
void MainWindow::onMemberList(const QString& chId, int count, const uint8_t* data, int dataLen) {
|
||||
m_accountList->onMemberList(chId, count, data, dataLen);
|
||||
}
|
||||
|
||||
void MainWindow::onMemberUpdated(const QString& chId, const uint8_t* data) {
|
||||
m_accountList->onMemberUpdated(chId, data);
|
||||
}
|
||||
|
||||
void MainWindow::onMemberRemoved(const QString& chId, uint64_t nodeId) {
|
||||
m_accountList->onMemberRemoved(chId, nodeId);
|
||||
}
|
||||
|
||||
void MainWindow::onAutoConnectStatus(uint8_t status, uint16_t /*total_tried*/,
|
||||
|
||||
Reference in new issue
Block a user