Browse Source

Clear legacy GUI bridge and list messages from debug

master
evgeny 7 days ago
parent
commit
b771e95997
  1. 6
      tools/chatgui/src/accountlist.cpp
  2. 10
      tools/chatgui/src/channellist.cpp
  3. 23
      tools/chatgui/transport/gui_bridge_impl.cpp

6
tools/chatgui/src/accountlist.cpp

@ -96,10 +96,6 @@ AccountList::AccountList(DbManager* db, QWidget *parent)
m_listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); m_listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
m_listView->setContextMenuPolicy(Qt::CustomContextMenu); m_listView->setContextMenuPolicy(Qt::CustomContextMenu);
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "AccountList: mouse_tracking=%d background=%s hover=%s selected=%s",
m_listView->hasMouseTracking(), qPrintable(m_listView->palette().alternateBase().color().name()),
qPrintable(m_listView->palette().alternateBase().color().lighter(115).name()),
qPrintable(m_listView->palette().highlight().color().name()));
m_detailPanel = new QWidget(this); m_detailPanel = new QWidget(this);
auto* detailLayout = new QVBoxLayout(m_detailPanel); auto* detailLayout = new QVBoxLayout(m_detailPanel);
detailLayout->setContentsMargins(0, 0, 0, 0); detailLayout->setContentsMargins(0, 0, 0, 0);
@ -286,7 +282,7 @@ void AccountList::showMemberDetail(quint64 nodeId) {
void AccountList::requestMemberDetail() { void AccountList::requestMemberDetail() {
if (m_detailNodeId == 0) return; if (m_detailNodeId == 0) return;
struct chat_node_arg* arg = (struct chat_node_arg*)u_malloc(sizeof(struct chat_node_arg)); struct chat_node_arg* arg = (struct chat_node_arg*)u_malloc(sizeof(struct chat_node_arg));
if (!arg) { DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "AccountList: req alloc failed"); return; } if (!arg) { DEBUG_WARN(DEBUG_CATEGORY_CONNECTION, "AccountList: req alloc failed"); return; }
arg->inst = gui_bridge_get_inst(); arg->inst = gui_bridge_get_inst();
arg->node_id = m_detailNodeId; arg->node_id = m_detailNodeId;
gui_bridge_post_uasync_fn(chat_core_collect_member_detail_trampoline, arg); gui_bridge_post_uasync_fn(chat_core_collect_member_detail_trampoline, arg);

10
tools/chatgui/src/channellist.cpp

@ -295,7 +295,7 @@ void ChannelList::loadChannels() {
item->setData(ch.lastMsgAt, ChannelLastMsgAtRole); item->setData(ch.lastMsgAt, ChannelLastMsgAtRole);
item->setData(makeChannelIcon(colors[ci % 6], letter), ChannelIconRole); item->setData(makeChannelIcon(colors[ci % 6], letter), ChannelIconRole);
m_model->appendRow(item); m_model->appendRow(item);
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "ChannelList::loadChannels row=%d cid='%s' name='%s' unread=%d lastMsgAt=%lld", DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "ChannelList::loadChannels row=%d cid='%s' name='%s' unread=%d lastMsgAt=%lld",
m_model->rowCount()-1, qPrintable(ch.channelId), qPrintable(ch.name), ch.unreadCount, m_model->rowCount()-1, qPrintable(ch.channelId), qPrintable(ch.name), ch.unreadCount,
(long long)ch.lastMsgAt); (long long)ch.lastMsgAt);
ci++; ci++;
@ -325,7 +325,7 @@ void ChannelList::loadChannels() {
item->setData(dm.lastTs, ChannelLastMsgAtRole); item->setData(dm.lastTs, ChannelLastMsgAtRole);
item->setData(makeChannelIcon(dmColor, letter), ChannelIconRole); item->setData(makeChannelIcon(dmColor, letter), ChannelIconRole);
m_model->appendRow(item); m_model->appendRow(item);
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "ChannelList::loadChannels dm row=%d conv='%s' peer='%s'", DEBUG_DEBUG(DEBUG_CATEGORY_DM, "ChannelList::loadChannels dm row=%d conv='%s' peer='%s'",
m_model->rowCount()-1, qPrintable(dm.convId), qPrintable(name)); m_model->rowCount()-1, qPrintable(dm.convId), qPrintable(name));
} }
} }
@ -368,7 +368,7 @@ void ChannelList::setChannelPeersOnline(const QString& channelId, int count) {
} }
} }
if (!found) if (!found)
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, " NOT FOUND in model"); DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "ChannelList: channel=%s not found in model", qPrintable(channelId));
} }
void ChannelList::setAutoConnectActive(bool active) { void ChannelList::setAutoConnectActive(bool active) {
@ -384,14 +384,14 @@ void ChannelList::setChannelUnreadCount(const QString& channelId, int count) {
QStandardItem* item = m_model->item(row); QStandardItem* item = m_model->item(row);
if (item && item->data(ChannelChannelIdRole).toString() == channelId) { if (item && item->data(ChannelChannelIdRole).toString() == channelId) {
int old = item->data(ChannelUnreadCountRole).toInt(); int old = item->data(ChannelUnreadCountRole).toInt();
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "ChannelList::setChannelUnreadCount ch=%s %d->%d", DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "ChannelList::setChannelUnreadCount ch=%s %d->%d",
qPrintable(channelId), old, count); qPrintable(channelId), old, count);
item->setData(count, ChannelUnreadCountRole); item->setData(count, ChannelUnreadCountRole);
emit m_model->dataChanged(m_model->index(row, 0), m_model->index(row, 0)); emit m_model->dataChanged(m_model->index(row, 0), m_model->index(row, 0));
return; return;
} }
} }
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "ChannelList::setChannelUnreadCount ch=%s not found", qPrintable(channelId)); DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "ChannelList::setChannelUnreadCount ch=%s not found", qPrintable(channelId));
} }
int ChannelList::getChannelUnreadCount(const QString& channelId) const { int ChannelList::getChannelUnreadCount(const QString& channelId) const {

23
tools/chatgui/transport/gui_bridge_impl.cpp

@ -104,10 +104,10 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
qPrintable(chId), (unsigned long long)author); qPrintable(chId), (unsigned long long)author);
if (g_msg_received_cb) g_msg_received_cb((const char*)d + 1, chLen, author); if (g_msg_received_cb) g_msg_received_cb((const char*)d + 1, chLen, author);
} else { } else {
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge: MSG_RECEIVED invalid data length %d", dlen); DEBUG_WARN(DEBUG_CATEGORY_CHAT, "gui_bridge: MSG_RECEIVED invalid data length %d", dlen);
} }
} else { } else {
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge: MSG_RECEIVED data too short %d", dlen); DEBUG_WARN(DEBUG_CATEGORY_CHAT, "gui_bridge: MSG_RECEIVED data too short %d", dlen);
} }
break; break;
case GUI_EVT_CONNECT_RESULT: case GUI_EVT_CONNECT_RESULT:
@ -118,7 +118,7 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
(unsigned long long)nodeId, (unsigned long long)channelId, result); (unsigned long long)nodeId, (unsigned long long)channelId, result);
if (g_connect_result_cb) g_connect_result_cb(nodeId, channelId, result); if (g_connect_result_cb) g_connect_result_cb(nodeId, channelId, result);
} else { } else {
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge: CONNECT_RESULT data too short %d", dlen); DEBUG_WARN(DEBUG_CATEGORY_CONNECTION, "gui_bridge: CONNECT_RESULT data too short %d", dlen);
} }
break; break;
case GUI_EVT_NEW_PEER: case GUI_EVT_NEW_PEER:
@ -126,7 +126,7 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
uint64_t nodeId; memcpy(&nodeId, d, 8); uint64_t nodeId; memcpy(&nodeId, d, 8);
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "gui_bridge: NEW_PEER node=0x%016llx", (unsigned long long)nodeId); DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "gui_bridge: NEW_PEER node=0x%016llx", (unsigned long long)nodeId);
} else { } else {
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge: NEW_PEER data too short %d", dlen); DEBUG_WARN(DEBUG_CATEGORY_CONNECTION, "gui_bridge: NEW_PEER data too short %d", dlen);
} }
break; break;
case GUI_EVT_CHANNEL_UPDATED: case GUI_EVT_CHANNEL_UPDATED:
@ -138,7 +138,7 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
if (g_channel_updated_cb) g_channel_updated_cb((const char*)d + 1, chLen); if (g_channel_updated_cb) g_channel_updated_cb((const char*)d + 1, chLen);
} }
} else { } else {
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge: CHANNEL_UPDATED data too short %d", dlen); DEBUG_WARN(DEBUG_CATEGORY_CHAT, "gui_bridge: CHANNEL_UPDATED data too short %d", dlen);
} }
break; break;
case GUI_EVT_MY_NODE_ID: case GUI_EVT_MY_NODE_ID:
@ -186,7 +186,7 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
uint64_t nodeId; memcpy(&nodeId, d, 8); uint64_t nodeId; memcpy(&nodeId, d, 8);
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "gui_bridge: NODE_CHANGED node=0x%016llx — pubkey changed, connection closed", (unsigned long long)nodeId); DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "gui_bridge: NODE_CHANGED node=0x%016llx — pubkey changed, connection closed", (unsigned long long)nodeId);
} else { } else {
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge: NODE_CHANGED data too short %d", dlen); DEBUG_WARN(DEBUG_CATEGORY_CONNECTION, "gui_bridge: NODE_CHANGED data too short %d", dlen);
} }
break; break;
case GUI_EVT_ATTACHMENT_DOWNLOADED: case GUI_EVT_ATTACHMENT_DOWNLOADED:
@ -194,7 +194,7 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
uint8_t chLen = d[0]; uint8_t chLen = d[0];
if (dlen >= 1 + chLen + 8) { if (dlen >= 1 + chLen + 8) {
int64_t msgId = 0; memcpy(&msgId, d + 1 + chLen, 8); int64_t msgId = 0; memcpy(&msgId, d + 1 + chLen, 8);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "gui_bridge: ATTACHMENT_DOWNLOADED ch=%.*s msgId=%lld", chLen, (const char*)d + 1, (long long)msgId); DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "gui_bridge: ATTACHMENT_DOWNLOADED ch=%.*s msgId=%lld", chLen, (const char*)d + 1, (long long)msgId);
if (g_attachment_downloaded_cb) g_attachment_downloaded_cb((const char*)d + 1, chLen, msgId); if (g_attachment_downloaded_cb) g_attachment_downloaded_cb((const char*)d + 1, chLen, msgId);
} }
} }
@ -205,7 +205,8 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
if (dlen >= 1 + chLen + 16) { if (dlen >= 1 + chLen + 16) {
int64_t msgId = 0; memcpy(&msgId, d + 1 + chLen, 8); int64_t msgId = 0; memcpy(&msgId, d + 1 + chLen, 8);
int32_t bd = 0, nb = 0; memcpy(&bd, d + 1 + chLen + 8, 4); memcpy(&nb, d + 1 + chLen + 12, 4); int32_t bd = 0, nb = 0; memcpy(&bd, d + 1 + chLen + 8, 4); memcpy(&nb, d + 1 + chLen + 12, 4);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "gui_bridge: DOWNLOAD_PROGRESS ch=%.*s msgId=%lld %d/%d", chLen, (const char*)d + 1, (long long)msgId, bd, nb); DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "gui_bridge: DOWNLOAD_PROGRESS ch=%.*s msgId=%lld %d/%d",
chLen, (const char*)d + 1, (long long)msgId, bd, nb);
if (g_download_progress_cb) g_download_progress_cb((const char*)d + 1, chLen, msgId, bd, nb); if (g_download_progress_cb) g_download_progress_cb((const char*)d + 1, chLen, msgId, bd, nb);
} }
} }
@ -379,7 +380,7 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
} }
break; break;
default: default:
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge: unknown event type %d", eventType); DEBUG_WARN(DEBUG_CATEGORY_GENERAL, "gui_bridge: unknown event type %d", eventType);
break; break;
} }
} }
@ -407,7 +408,7 @@ struct UTUN_INSTANCE* gui_bridge_get_inst(void) {
} }
void gui_bridge_post(int event_type, const uint8_t* data, int data_len) { void gui_bridge_post(int event_type, const uint8_t* data, int data_len) {
if (!g_receiver) { DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge_post: g_receiver=NULL, dropping event %d", event_type); return; } if (!g_receiver) { DEBUG_WARN(DEBUG_CATEGORY_GENERAL, "gui_bridge_post: g_receiver=NULL, dropping event %d", event_type); return; }
QByteArray d; QByteArray d;
if (data_len > 0) d = QByteArray((const char*)data, data_len); if (data_len > 0) d = QByteArray((const char*)data, data_len);
@ -420,7 +421,7 @@ void gui_bridge_post(int event_type, const uint8_t* data, int data_len) {
void gui_bridge_post_uasync_fn(void (*fn)(void*), void* arg) { void gui_bridge_post_uasync_fn(void (*fn)(void*), void* arg) {
if (!g_ua) { if (!g_ua) {
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge_post_uasync_fn: g_ua=NULL, post dropped"); DEBUG_WARN(DEBUG_CATEGORY_GENERAL, "gui_bridge_post_uasync_fn: g_ua=NULL, post dropped");
return; return;
} }
if (!fn) return; if (!fn) return;

Loading…
Cancel
Save