debug(chatgui): add online status trace across full chain
- cs_is_peer_online: log found/init/links/online - cs_on_peer_status_changed: log channel_count + found_in_channel - cs_handle_welcome/cs_handle_channel_join: log before cs_post_channel_online - MainWindow::onChannelPeersOnline: log cid+online - ChannelList::setChannelPeersOnline: log search/rows, each row cid+match, SET or NOT FOUND - ChannelList::loadChannels: log each added row cid+name
This commit is contained in:
1 parent
9de16be012
commit
ac0d1c18ed
3 files changed
+33
-6
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
/* QListView that prevents deselection, handles invite plus-button clicks */
|
||||
@@ -180,6 +181,8 @@ void ChannelList::loadChannels() {
|
||||
item->setData(QString(), ChannelLastMessageRole);
|
||||
item->setData(makeChannelIcon(colors[ci % 6], letter), ChannelIconRole);
|
||||
m_model->appendRow(item);
|
||||
qDebug() << "ChannelList::loadChannels row=" << (m_model->rowCount()-1)
|
||||
<< "cid='" << ch.channelId << "' name='" << ch.name << "'";
|
||||
ci++;
|
||||
}
|
||||
|
||||
@@ -204,14 +207,26 @@ void ChannelList::selectChannel(const QString& channelId) {
|
||||
}
|
||||
|
||||
void ChannelList::setChannelPeersOnline(const QString& channelId, int count) {
|
||||
int found = 0;
|
||||
qDebug() << "ChannelList::setChannelPeersOnline search='" << channelId
|
||||
<< "' online=" << count << " rows=" << m_model->rowCount();
|
||||
for (int row = 0; row < m_model->rowCount(); row++) {
|
||||
QStandardItem* item = m_model->item(row);
|
||||
if (item && item->data(ChannelChannelIdRole).toString() == channelId) {
|
||||
item->setData(count, ChannelPeersOnlineRole);
|
||||
item->setData(m_autoConnectActive ? 1 : 0, ChannelAutoConnectActiveRole);
|
||||
break;
|
||||
if (item) {
|
||||
QString itemCid = item->data(ChannelChannelIdRole).toString();
|
||||
int match = (itemCid == channelId) ? 1 : 0;
|
||||
qDebug() << " row=" << row << "cid='" << itemCid << "' match=" << match;
|
||||
if (match) {
|
||||
item->setData(count, ChannelPeersOnlineRole);
|
||||
item->setData(m_autoConnectActive ? 1 : 0, ChannelAutoConnectActiveRole);
|
||||
qDebug() << " SET online=" << count;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
qDebug() << " NOT FOUND in model";
|
||||
}
|
||||
|
||||
void ChannelList::setAutoConnectActive(bool active) {
|
||||
|
||||
@@ -297,6 +297,7 @@ void MainWindow::onAutoConnectStatus(uint8_t status, uint16_t /*total_tried*/,
|
||||
void MainWindow::onChannelPeersOnline(const char* ch_id, int ch_id_len, uint16_t online) {
|
||||
if (m_channelList) {
|
||||
QString cid = QString::fromUtf8(ch_id, ch_id_len);
|
||||
qDebug() << "MainWindow::onChannelPeersOnline cid=" << cid << "online=" << online;
|
||||
m_channelList->setChannelPeersOnline(cid, (int)online);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,12 +460,16 @@ static struct ETCP_CONN* cs_find_conn_for_node(struct UTUN_INSTANCE* inst, uint6
|
||||
/* ── helper: check if peer has active ETCP link ── */
|
||||
|
||||
static int cs_is_peer_online(struct UTUN_INSTANCE* inst, uint64_t peer_id) {
|
||||
if (!inst->connections) return 0;
|
||||
if (!inst->connections) { DEBUG_DEBUG(DEBUG_CATEGORY_DB_SYNC, "%s: is_online peer=0x%016llx CONNS=NULL", CS_ID, (unsigned long long)peer_id); return 0; }
|
||||
struct ll_entry* e = queue_find_data_by_index(inst->connections, (const uint8_t*)&peer_id);
|
||||
if (e) {
|
||||
struct conn_queue_entry* ce = (struct conn_queue_entry*)e->data;
|
||||
return ce->conn->initialized && ce->conn->links_up;
|
||||
int onl = ce->conn->initialized && ce->conn->links_up;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DB_SYNC, "%s: is_online peer=0x%016llx found=1 init=%d links=%d online=%d",
|
||||
CS_ID, (unsigned long long)peer_id, ce->conn->initialized, ce->conn->links_up, onl);
|
||||
return onl;
|
||||
}
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DB_SYNC, "%s: is_online peer=0x%016llx found=0", CS_ID, (unsigned long long)peer_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -552,9 +556,11 @@ static void cs_on_peer_status_changed(uint64_t peer, int online) {
|
||||
member_sync_set_online(g_cs->inst, peer, online);
|
||||
|
||||
/* 2. GUI + online-бар */
|
||||
int found_in_channel = 0;
|
||||
for (int i = 0; i < g_cs->channel_count; i++) {
|
||||
for (int j = 0; j < g_cs->channels[i].peer_count; j++) {
|
||||
if (g_cs->channels[i].peer_ids[j] == peer) {
|
||||
found_in_channel = 1;
|
||||
size_t cl = strlen(g_cs->channels[i].channel_id);
|
||||
if (cl > 63) cl = 63;
|
||||
uint8_t evt[65]; evt[0] = (uint8_t)cl;
|
||||
@@ -570,6 +576,9 @@ static void cs_on_peer_status_changed(uint64_t peer, int online) {
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DB_SYNC, "%s: peer_status_changed peer=0x%016llx online=%d channels=%d found=%d",
|
||||
CS_ID, (unsigned long long)peer, online, g_cs->channel_count, found_in_channel);
|
||||
|
||||
/* 4. Запланировать member_sync_start (throttled) */
|
||||
cs_schedule_sync(g_cs);
|
||||
}
|
||||
@@ -1263,6 +1272,7 @@ static void cs_handle_channel_join(struct chat_sync* cs, uint64_t peer,
|
||||
{ uint8_t evt[65]; uint8_t cl=(uint8_t)strlen(ch_id); evt[0]=cl; memcpy(evt+1,ch_id,cl);
|
||||
gui_bridge_post(GUI_EVT_MEMBERS_CHANGED, evt, 1+cl); }
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: JOIN calling cs_post_channel_online ch=%s", CS_ID, ch_id);
|
||||
cs_post_channel_online(cs, ch_id);
|
||||
|
||||
/* initiate member sync with the joiner (server side) */
|
||||
@@ -1392,6 +1402,7 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer,
|
||||
|
||||
gui_bridge_post(GUI_EVT_MEMBERS_CHANGED, evt, 1 + ch_id_len);
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: WELCOME calling cs_post_channel_online ch=%s", CS_ID, ch_id);
|
||||
cs_post_channel_online(cs, ch_id);
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: WELCOME processed ch=%s peers=%d — message sync triggered via db_sync (active conn or peer_check timer every 5s)",
|
||||
|
||||
Reference in new issue
Block a user