119 lines
3.6 KiB
C++
119 lines
3.6 KiB
C++
/* Панель участников выбранного канала и live-диагностика выбранного узла.
|
|
* Получает события bridge в GUI-потоке; запросы звонка и PM отдаёт через signals. */
|
|
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <QListView>
|
|
#include <QTextEdit>
|
|
#include <QLabel>
|
|
#include <QTimer>
|
|
#include <QMenu>
|
|
#include <QVector>
|
|
#include <QElapsedTimer>
|
|
#include <stdint.h>
|
|
|
|
class MemberListModel;
|
|
class DbManager;
|
|
|
|
struct DetailAddress {
|
|
int family;
|
|
int protocol;
|
|
QByteArray addr;
|
|
int port;
|
|
int socket_id;
|
|
int addr_type;
|
|
QString ifname;
|
|
};
|
|
|
|
struct MemberLinkSnap {
|
|
bool isTcp;
|
|
int linkState;
|
|
int linkStatus;
|
|
bool tcpReady;
|
|
bool isServer;
|
|
int localFamily;
|
|
QByteArray localAddr;
|
|
uint16_t localPort;
|
|
int family;
|
|
QByteArray addr;
|
|
uint16_t port;
|
|
char sockName[20];
|
|
bool isReality;
|
|
};
|
|
|
|
struct MemberSockSnap {
|
|
int sockId;
|
|
uint16_t port;
|
|
int linksUp;
|
|
int linksDown;
|
|
QString ifname;
|
|
};
|
|
|
|
class AccountList : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit AccountList(DbManager* db = nullptr, QWidget *parent = nullptr);
|
|
~AccountList();
|
|
|
|
void setChannel(const QString& channelId);
|
|
void refresh();
|
|
void onMemberDetailData(uint64_t nodeId, const uint8_t* data, int len);
|
|
void onNodeinfoUpdate(const uint8_t* data, int len);
|
|
|
|
/* Bridge callbacks (called from GUI thread) */
|
|
void onMemberList(const QString& chId, int count, const uint8_t* data, int dataLen);
|
|
void onMemberUpdated(const QString& chId, const uint8_t* data);
|
|
void onMemberRemoved(const QString& chId, uint64_t nodeId);
|
|
|
|
MemberListModel* model() const { return m_model; }
|
|
|
|
signals:
|
|
void memberRenamed();
|
|
void callRequested(const QString& channelId, quint64 nodeId, const QString& name);
|
|
void pmRequested(const QString& channelId, quint64 nodeId, const QString& name);
|
|
void inviteRequested(const QString& channelId, quint64 nodeId, const QString& name);
|
|
void filesRequested(const QString& channelId, quint64 nodeId);
|
|
|
|
private slots:
|
|
void onMemberClicked(const QModelIndex& index);
|
|
void onMemberDoubleClicked(const QModelIndex& index);
|
|
void onMemberContextMenu(const QPoint& pos);
|
|
void onDetailTimerTick();
|
|
|
|
private:
|
|
void showMemberDetail(quint64 nodeId);
|
|
void updateDetailDisplay();
|
|
void requestMemberDetail();
|
|
static QString relativeTimeStr(qint64 timestamp);
|
|
static QString addrStr(const void* addr, int family);
|
|
|
|
QListView *m_listView;
|
|
MemberListModel *m_model;
|
|
DbManager *m_db;
|
|
QLabel *m_header;
|
|
QWidget *m_detailPanel;
|
|
QLabel *m_detailHeader;
|
|
QTextEdit *m_detailText;
|
|
QTimer *m_detailTimer;
|
|
QTimer *m_linkTimer;
|
|
QString m_channelId;
|
|
|
|
quint64 m_detailNodeId = 0;
|
|
QString m_detailName;
|
|
bool m_detailOnline = false;
|
|
qint64 m_detailLastSeen = 0;
|
|
qint64 m_detailCreated = 0;
|
|
QVector<DetailAddress> m_detailAddrs;
|
|
|
|
bool m_snapConnPresent = false;
|
|
bool m_snapConnUp = false;
|
|
bool m_snapConnInit = false;
|
|
int m_snapOwnTcpActive = 0;
|
|
uint16_t m_snapChainRtt = 0;
|
|
uint8_t m_snapHopCount = 0;
|
|
uint16_t m_snapBgpNodes = 0;
|
|
QString m_bgpText;
|
|
QVector<MemberLinkSnap> m_snapLinks;
|
|
QVector<MemberSockSnap> m_snapSocks;
|
|
};
|