1#include "ConnecterTelnet.h"
2#include "DlgSettingsTelnet.h"
5#include <QLoggingCategory>
7Q_DECLARE_LOGGING_CATEGORY(Telnet)
20CConnecterTelnet::~CConnecterTelnet()
23QDialog *CConnecterTelnet::GetDialogSettings(QWidget *parent)
28int CConnecterTelnet::SetParameter()
30 return CConnecterTerminal::SetParameter();
38 m_pSocket =
new QTcpSocket(
this);
41 bool check = connect(m_pConsole, SIGNAL(sendData(
const char *,
int)),
42 this, SLOT(slotSendData(
const char *,
int)));
46 check = connect(m_pSocket, SIGNAL(readyRead()),
47 this, SLOT(slotReadyRead()));
50 check = connect(m_pSocket, SIGNAL(error(QAbstractSocket::SocketError)),
51 this, SLOT(slotError(QAbstractSocket::SocketError)));
54 check = connect(m_pSocket, SIGNAL(disconnected()),
55 this, SLOT(DisConnect()));
59 m_pConsole->startTerminalTeletype();
61 m_pSocket->connectToHost(m_pPara->GetHost(), m_pPara->GetPort());
66int CConnecterTelnet::OnDisConnect()
72 if(m_pSocket->state() == QTcpSocket::ConnectedState)
80void CConnecterTelnet::slotSendData(
const char *data,
int size)
83 m_pSocket->write(data, size);
86void CConnecterTelnet::slotReadyRead()
88 if(m_pSocket && m_pConsole)
90 QByteArray data = m_pSocket->readAll();
92 write(m_pConsole->getPtySlaveFd(), data.data(), data.size());
96void CConnecterTelnet::slotError(QAbstractSocket::SocketError err)
99 if(!m_pSocket)
return;
100 szErr = m_pSocket->errorString();
102 qCritical(Telnet) <<
"error:" << err <<
"-" << szErr;
103 if(err == QTcpSocket::ConnectionRefusedError
104 || err == QTcpSocket::HostNotFoundError)
virtual int OnConnect() override
OnConnect.
void sigError(const int nError, const QString &szError)
Triggered when an error is generated.