bool ServerForm::initForm() { initCounter(m_ui.labRecv, m_ui.labSend); initLogger(m_ui.chkLog, m_ui.btnClear, m_ui.treeOutput, m_ui.txtOutput); initLister(m_ui.btnConnAll, m_ui.btnConnDel, m_ui.lstConn); bindBuffer(1, m_ui.edtBuf1, m_ui.btnSend1, 0); bindBuffer(2, m_ui.edtBuf2, m_ui.btnSend2, 0); bindBuffer(3, m_ui.edtBuf3, m_ui.btnSend3, 0); connect(m_ui.btnTcp, SIGNAL(clicked(bool)), this, SLOT(trigger(bool))); connect(m_ui.btnUdp, SIGNAL(clicked(bool)), this, SLOT(trigger(bool))); connect(&m_tcp, SIGNAL(connOpen(const QString&)), this, SLOT(listerAdd(const QString&))); connect(&m_tcp, SIGNAL(connClose(const QString&)), this, SLOT(listerRemove(const QString&))); connect(&m_tcp, SIGNAL(message(const QString&)), this, SIGNAL(output(const QString&))); connect(&m_tcp, SIGNAL(dumpbin(const QString&,const char*,quint32)), this, SIGNAL(output(const QString&,const char*,quint32))); connect(&m_tcp, SIGNAL(countRecv(qint32)), this, SLOT(countRecv(qint32))); connect(&m_tcp, SIGNAL(countSend(qint32)), this, SLOT(countSend(qint32))); connect(&m_udp, SIGNAL(connOpen(const QString&)), this, SLOT(listerAdd(const QString&))); connect(&m_udp, SIGNAL(connClose(const QString&)), this, SLOT(listerRemove(const QString&))); connect(&m_udp, SIGNAL(message(const QString&)), this, SIGNAL(output(const QString&))); connect(&m_udp, SIGNAL(dumpbin(const QString&,const char*,quint32)), this, SIGNAL(output(const QString&,const char*,quint32))); connect(&m_udp, SIGNAL(countRecv(qint32)), this, SLOT(countRecv(qint32))); connect(&m_udp, SIGNAL(countSend(qint32)), this, SLOT(countSend(qint32))); return true; }
void TransferForm::trigger(bool start) { if (lock(1000)) { if (m_server) { m_server->stop(); m_server->disconnect(this); delete m_server; m_server = NULL; } IPAddr sa, da; if (start) { start = TK::popIPAddr(m_ui.cmbSrcAddr, m_ui.cmbSrcPort, sa) && TK::popIPAddr(m_ui.cmbDstAddr, m_ui.cmbDstPort, da); } if (start) { QString type = m_ui.cmbType->currentText(); if (type.contains(TK::socketTypeName(true))) m_server = new TransferSktTcp(this); else m_server = new TransferSktUdp(this); if (m_server) { connect(m_server, SIGNAL(connOpen(const QString&)), this, SLOT(listerAdd(const QString&))); connect(m_server, SIGNAL(connClose(const QString&)), this, SLOT(listerRemove(const QString&))); connect(m_server, SIGNAL(message(const QString&)), this, SIGNAL(output(const QString&))); connect(m_server, SIGNAL(dumpbin(const QString&,const char*,quint32)), this, SIGNAL(output(const QString&,const char*,quint32))); connect(m_server, SIGNAL(countRecv(qint32)), this, SLOT(countRecv(qint32))); connect(m_server, SIGNAL(countSend(qint32)), this, SLOT(countSend(qint32))); connect(m_server, SIGNAL(stopped()), this, SLOT(stop())); start = m_server->start(sa.ip, sa.port, da.ip, da.port); if (!start) { m_server->disconnect(this); delete m_server; m_server = NULL; } } else { start = false; } } unlock(); }
void BaseForm::clear() { m_logger.clear(); lock(); countRecv(-1); countSend(-1); unlock(); }
void ClientSkt::recordRecv(qint32 bytes) { emit countRecv(bytes); }
void ServerSkt::recordRecv(qint32 bytes) { emit countRecv(bytes); }