QTfrontend/net/tcpBase.cpp
changeset 7289 835bb2852579
parent 7180 53ffc8853008
child 7615 b39beffcf05e
equal deleted inserted replaced
7286:068adc6948e3 7289:835bb2852579
    24 
    24 
    25 #include <QImage>
    25 #include <QImage>
    26 
    26 
    27 #include "hwconsts.h"
    27 #include "hwconsts.h"
    28 
    28 
    29 //QList<TCPBase*> srvsList;
    29 QList<TCPBase*> srvsList;
    30 //QPointer<QTcpServer> TCPBase::IPCServer(0);
    30 QPointer<QTcpServer> TCPBase::IPCServer(0);
    31 
    31 
    32 TCPBase::~TCPBase()
    32 TCPBase::~TCPBase()
    33 {
    33 {
       
    34     if (IPCSocket)
       
    35         IPCSocket->deleteLater();
    34 }
    36 }
    35 
    37 
    36 TCPBase::TCPBase(bool demoMode) :
    38 TCPBase::TCPBase(bool demoMode) :
    37     m_isDemoMode(demoMode),
    39     m_isDemoMode(demoMode),
    38     IPCSocket(0), IPCServer(0)
    40     IPCSocket(0)
    39 {
    41 {
    40     if(!IPCServer)
    42     if(!IPCServer)
    41     {
    43     {
    42         IPCServer = new QTcpServer(0);
    44         IPCServer = new QTcpServer(0);
    43         IPCServer->setMaxPendingConnections(1);
    45         IPCServer->setMaxPendingConnections(1);
    63     IPCSocket = IPCServer->nextPendingConnection();
    65     IPCSocket = IPCServer->nextPendingConnection();
    64     if(!IPCSocket) return;
    66     if(!IPCSocket) return;
    65     connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect()));
    67     connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect()));
    66     connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
    68     connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
    67     SendToClientFirst();
    69     SendToClientFirst();
       
    70 
       
    71     if(srvsList.size()==1) srvsList.pop_front();
       
    72     emit isReadyNow();
    68 }
    73 }
    69 
    74 
    70 void TCPBase::/*Real*/Start()
    75 void TCPBase::RealStart()
    71 {
    76 {
    72     connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    77     connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    73     IPCSocket = 0;
    78     IPCSocket = 0;
    74 
    79 
    75     QProcess * process;
    80     QProcess * process;
   107     QMessageBox::critical(0, tr("Error"),
   112     QMessageBox::critical(0, tr("Error"),
   108                           tr("Unable to run engine: %1 (")
   113                           tr("Unable to run engine: %1 (")
   109                           .arg(error) + bindir->absolutePath() + "/hwengine)");
   114                           .arg(error) + bindir->absolutePath() + "/hwengine)");
   110 }
   115 }
   111 
   116 
   112 /*
       
   113 void TCPBase::tcpServerReady()
   117 void TCPBase::tcpServerReady()
   114 {
   118 {
   115     disconnect(srvsList.takeFirst(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
   119     disconnect(srvsList.takeFirst(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
   116 
   120 
   117     RealStart();
   121     RealStart();
   118 }
   122 }
       
   123 
   119 void TCPBase::Start()
   124 void TCPBase::Start()
   120 {
   125 {
   121     if(srvsList.isEmpty())
   126     if(srvsList.isEmpty())
   122     {
   127     {
   123         srvsList.push_back(this);
   128         srvsList.push_back(this);
   128         srvsList.push_back(this);
   133         srvsList.push_back(this);
   129         return;
   134         return;
   130     }
   135     }
   131 
   136 
   132     RealStart();
   137     RealStart();
   133 }*/
   138 }
   134 
   139 
   135 void TCPBase::onClientRead()
   140 void TCPBase::onClientRead()
   136 {
   141 {
   137 }
   142 }
   138 
   143