1#include <QLoggingCategory>
2#include <QRegularExpression>
3#include "ConnecterConnect.h"
4#include "PluginClientThread.h"
6static Q_LOGGING_CATEGORY(log,
"Client.Connecter.Connect")
11 qDebug(log) << Q_FUNC_INFO;
14CConnecterConnect::~CConnecterConnect()
16 qDebug(log) << Q_FUNC_INFO;
21 QString szId =
Protocol() +
"_" + GetPlugClient()->
Name();
28 +
"_" + QString::number(
GetParameter()->m_Net.GetPort());
30 static QRegularExpression exp(
"[-@:/#%!^&* \\.]");
31 szId = szId.replace(exp,
"_");
55 &&
GetParameter()->GetParameterClient()->GetShowProtocolPrefix())
67 QString szDescription;
69 szDescription = tr(
"Name: ") +
Name() +
"\n";
72 szDescription += tr(
"Protocol: ") +
Protocol()
80 szDescription += tr(
"Server name: ") +
ServerName() +
"\n";
84 szDescription += tr(
"Server address: ") +
GetParameter()->m_Net.GetHost() +
":"
85 + QString::number(
GetParameter()->m_Net.GetPort()) +
"\n";
87 QString szProxy(tr(
"Proxy") +
" ");
89 switch(proxy.GetUsedType()) {
90 case CParameterProxy::TYPE::SSHTunnel:
92 auto &sshNet = proxy.m_SSH.m_Net;
93 szProxy +=
"(" + tr(
"SSH tunnel") +
"): " + sshNet.GetHost() +
":"
94 + QString::number(sshNet.GetPort());
97 case CParameterProxy::TYPE::SockesV5:
99 auto &sockesV5 = proxy.m_SockesV5;
100 szProxy +=
"(" + tr(
"Sockes v5") +
"): " + sockesV5.GetHost() +
":"
101 + QString::number(sockesV5.GetPort());
109 if(!szProxy.isEmpty())
110 szDescription += szProxy +
"\n";
114 szDescription += tr(
"Description: ") + GetPlugClient()->
Description();
116 return szDescription;
121 return qobject_cast<CParameterBase*>(CConnecter::GetParameter());
127 if(nRet)
return nRet;
131 check = connect(
GetParameter(), SIGNAL(sigNameChanged()),
132 this, SLOT(slotUpdateName()));
134 check = connect(
GetParameter(), SIGNAL(sigShowServerNameChanged()),
135 this, SLOT(slotShowServerName()));
144 check = connect(
GetParameter(), SIGNAL(sigZoomFactorChanged(
double)),
145 pViewer, SLOT(slotSetZoomFactor(
double)));
164 bool check = connect(pPara, SIGNAL(sigShowProtocolPrefixChanged()),
165 this, SLOT(slotUpdateName()));
167 check = connect(pPara, SIGNAL(sigSHowIpPortInNameChanged()),
168 this, SLOT(slotUpdateName()));
173 QString szMsg =
"The CConnecter is not parameters! "
174 "please first create parameters, "
175 "then call SetParameter in the ";
176 szMsg += metaObject()->className() + QString(
"::")
177 + metaObject()->className();
178 szMsg += QString(
" or ") + metaObject()->className()
179 + QString(
"::") +
"Initial()";
180 szMsg +=
" to set the parameters pointer. "
181 "Default set CParameterClient for the parameters of connecter "
182 "(CParameterConnecter or its derived classes) "
183 "See: CClient::CreateConnecter. "
184 "If you are sure the parameter of connecter "
185 "does not need CParameterClient. "
186 "Please overload the SetParameterClient in the ";
187 szMsg += QString(metaObject()->className()) +
" . don't set it";
188 qCritical(log) << szMsg.toStdString().c_str();
196 qDebug(log) << Q_FUNC_INFO;
198 = qobject_cast<CPluginClientThread*>(GetPlugClient());
200 emit sigOpenConnect(
this);
204 int nRet = m_pConnect->
Connect();
217 qDebug(log) << Q_FUNC_INFO;
219 = qobject_cast<CPluginClientThread*>(GetPlugClient());
221 emit sigCloseconnect(
this);
225 m_pConnect->deleteLater();
226 m_pConnect =
nullptr;
237 &&
GetParameter()->GetParameterClient()->GetShowIpPortInName())
240 +
":" + QString::number(
GetParameter()->m_Net.GetPort());
245 return m_szServerName;
250 if(m_szServerName == szName)
253 m_szServerName = szName;
virtual int Disconnect()
Disconnect.
virtual int Connect()
Start connect.
The connector interface of the plug-in, which is only used by the plug-in.
virtual const QString Id() override
Identity.
virtual int DisConnect() override
emit sigDisconnected() in here
virtual const QString Description() override
Description.
virtual int Connect() override
virtual void slotSetServerName(const QString &szName)
virtual CParameterBase * GetParameter()
Get parameter.
virtual const QString Name() override
Display order:
virtual int SetParameterClient(CParameterClient *pPara) override
Set CParameterClient.
virtual CConnect * InstanceConnect()=0
New connect.
virtual QString ServerName()
Current connect server name (remote desktop name, if not present, then IP:PORT).
void sigUpdateName(const QString &szName)
void sigConnected()
Successful connection signal.
virtual QWidget * GetViewer()=0
Get Viewer.
void sigDisconnected()
Successful disconnection signal.
virtual int SetParameter(CParameter *p)
Set parameters.
void sigDisconnect()
Notify the user to disconnect.
virtual const QString Protocol() const
Protocol.
void sigUpdateParameters(CConnecter *pConnecter)
Update parameters, notify application to save or show parameters.
A widget which displays output image from a CConnectDesktop and sends input keypresses and mouse acti...
ADAPT_WINDOWS
The ADAPT_WINDOWS enum.
The interface of connecter parameters.
The parameters of client.
void sigChanged()
emit when the parameter changes Usually if required, the corresponding parameter corresponds to a cha...
It starts a background thread by default.
virtual const QString DisplayName() const
The plugin display name.
virtual const QString Description() const =0
Plugin description.
virtual const QString Name() const =0
This name must be the same as the project name (${PROJECT_NAME}). The translation file (${PROJECT_NAM...