Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ManageConnect.cpp
1#include "ManageConnect.h"
2#include <QLoggingCategory>
3
4static Q_LOGGING_CATEGORY(log, "Client.MangeConnect")
5
6CManageConnect::CManageConnect(QObject *parent) : QObject(parent)
7{}
8
9CManageConnect::~CManageConnect()
10{
11 qDebug(log) << "CManageConnect::~CManageConnect()";
12 foreach(auto pConnect, m_Connects)
13 {
14 pConnect->Disconnect();
15 pConnect->deleteLater();
16 }
17}
18
19void CManageConnect::slotConnect(CConnecterConnect *pConnecter)
20{
21 int nRet = 0;
22 qDebug(log) << "CManageConnect::slotConnect()";
23 CConnect* pConnect = pConnecter->InstanceConnect();
24 if(!pConnect)
25 {
26 qCritical(log) << "InstanceConnect fail";
27 emit pConnecter->sigDisconnect();
28 return;
29 }
30
31 m_Connects.insert(pConnecter, pConnect);
32
33 nRet = pConnect->Connect();
34 if(nRet)
35 emit pConnecter->sigDisconnect();
36}
37
38void CManageConnect::slotDisconnect(CConnecterConnect *pConnecter)
39{
40 qDebug(log) << "CManageConnect::slotDisconnect()";
41 auto it = m_Connects.find(pConnecter);
42 if(m_Connects.end() == it) return;
43 CConnect* pConnect = it.value();
44 m_Connects.remove(pConnecter);
45 pConnect->Disconnect();
46 pConnect->deleteLater();
47 emit pConnecter->sigDisconnected();
48}
Connect interface.
Definition Connect.h:45
virtual int Disconnect()
Disconnect.
Definition Connect.cpp:89
virtual int Connect()
Start connect.
Definition Connect.cpp:77
The connector interface of the plug-in, which is only used by the plug-in.
virtual CConnect * InstanceConnect()=0
New connect.
void sigDisconnected()
Successful disconnection signal.
void sigDisconnect()
Notify the user to disconnect.
Manage CConnecter.