diff --git a/client/client.pro b/client/client.pro index fd4a89a0..39ce2fb8 100644 --- a/client/client.pro +++ b/client/client.pro @@ -11,7 +11,6 @@ include("3rd/QtSsh/src/botan/botan.pri") HEADERS += \ ../ipc/ipc.h \ - communicator.h \ core/defs.h \ core/errorstrings.h \ core/ipcclient.h \ @@ -19,7 +18,6 @@ HEADERS += \ core/servercontroller.h \ debug.h \ defines.h \ - localclient.h \ managementserver.h \ message.h \ protocols/shadowsocksvpnprotocol.h \ @@ -33,12 +31,10 @@ HEADERS += \ protocols/openvpnprotocol.h \ SOURCES += \ - communicator.cpp \ core/ipcclient.cpp \ core/openvpnconfigurator.cpp \ core/servercontroller.cpp \ debug.cpp \ - localclient.cpp \ main.cpp \ managementserver.cpp \ message.cpp \ diff --git a/client/communicator.cpp b/client/communicator.cpp deleted file mode 100644 index af349a0b..00000000 --- a/client/communicator.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "communicator.h" -#include "defines.h" -#include "localclient.h" -#include "utils.h" - -Communicator::Communicator(QObject* parent) : QObject(parent), - m_localClient(nullptr) -{ - connectToServer(); -} - -Communicator::~Communicator() -{ - -} - -void Communicator::connectToServer() -{ - if (m_localClient) { - delete m_localClient; - } - - m_localClient = new LocalClient(this); - connect(m_localClient, &LocalClient::connected, this, &Communicator::onConnected); - connect(m_localClient, &LocalClient::lineAvailable, this, &Communicator::onLineAvailable); - - m_localClient->connectToServer(Utils::serverName()); -} - -void Communicator::onConnected() -{ - qDebug().noquote() << QString("Connected to local server '%1'").arg(m_localClient->serverName()); - Message message(Message::State::Initialize, QStringList({"Client"})); - sendMessage(message); -} - -void Communicator::onLineAvailable(const QString& line) -{ - Message message(line); - if (!message.isValid()) { - qDebug() << "Message is not valid"; - return; - } - - emit messageReceived(message); -} - -bool Communicator::isConnected() const -{ - if (!m_localClient) { - return false; - } - - return m_localClient->connectedState(); -} - -QString Communicator::readData() -{ - return QString(); -} - -bool Communicator::writeData(const QString& data) -{ - return m_localClient->write(data.toUtf8()); -} - -void Communicator::sendMessage(const Message& message) -{ - if (!isConnected()) { - return; - } - const QString data = message.toString(); - bool status = writeData(data + "\n"); - - qDebug().noquote() << QString("Send message '%1',%2 status '%2'"). - arg(static_cast(message.state())). - arg(data). - arg(Utils::toString(status)); -} diff --git a/client/communicator.h b/client/communicator.h deleted file mode 100644 index 3c4f1628..00000000 --- a/client/communicator.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef COMMUNICATOR_H -#define COMMUNICATOR_H - -#include -#include - -#include "message.h" - -class LocalClient; - -class Communicator : public QObject -{ - Q_OBJECT - -public: - explicit Communicator(QObject* parent = nullptr); - ~Communicator(); - - bool isConnected() const; - void sendMessage(const Message& message); - -signals: - void messageReceived(const Message& message); - - void comminicatorConnected(); - void comminicatorDisconnected(); - -protected slots: - void onConnected(); - void onLineAvailable(const QString& line); - -protected: - QString readData(); - bool writeData(const QString& data); - void connectToServer(); - - LocalClient* m_localClient; -}; - - -#endif // COMMUNICATOR_H diff --git a/client/localclient.cpp b/client/localclient.cpp deleted file mode 100644 index 280f7702..00000000 --- a/client/localclient.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include - -#include "localclient.h" - -LocalClient::LocalClient(QObject *parent) : QObject(parent), - m_socket(new QLocalSocket(this)) -{ - m_in.setDevice(m_socket); - m_in.setVersion(QDataStream::Qt_5_10); - - connect(m_socket, &QLocalSocket::readyRead, this, &LocalClient::onReadyRead); - connect(m_socket, &QLocalSocket::connected, this, &LocalClient::onConnected); - connect(m_socket, QOverload::of(&QLocalSocket::error), this, &LocalClient::displayError); -} - -void LocalClient::connectToServer(const QString& name) -{ - m_blockSize = 0; - m_socket->abort(); - m_socket->connectToServer(name); -} - -QString LocalClient::serverName() const -{ - return m_socket->serverName(); -} - -void LocalClient::onConnected() -{ - emit connected(); -} - -bool LocalClient::connectedState() const -{ - return (m_socket->state() == QLocalSocket::ConnectedState); -} - -quint64 LocalClient::write(const QByteArray& data) -{ - return m_socket->write(data); -} - -void LocalClient::onReadyRead() -{ - if (m_socket->canReadLine()) { - char buf[1024]; - qint64 lineLength = m_socket->readLine(buf, sizeof(buf)); - if (lineLength != -1) { - QString line = buf; - line = line.simplified(); - qDebug().noquote() << QString("Read line: '%1'").arg(line); - emit lineAvailable(line); - } - } -} - -void LocalClient::displayError(QLocalSocket::LocalSocketError socketError) -{ - Q_UNUSED(socketError) - qDebug().noquote() << QString("The following error occurred: %1.").arg(m_socket->errorString()); -} diff --git a/client/localclient.h b/client/localclient.h deleted file mode 100644 index cd66af7a..00000000 --- a/client/localclient.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LOCALCLIENT_H -#define LOCALCLIENT_H - -#include -#include - -class LocalClient : public QObject -{ - Q_OBJECT - -public: - explicit LocalClient(QObject *parent = nullptr); - - QString serverName() const; - bool connectedState() const; - quint64 write(const QByteArray& data); - void connectToServer(const QString& name); - -signals: - void connected(); - void lineAvailable(const QString& line); - -private slots: - void displayError(QLocalSocket::LocalSocketError socketError); - void onConnected(); - void onReadyRead(); - -private: - QLocalSocket* m_socket; - QDataStream m_in; - quint32 m_blockSize; -}; - -#endif // LOCALCLIENT_H diff --git a/client/protocols/openvpnprotocol.cpp b/client/protocols/openvpnprotocol.cpp index d2c912cd..af55d6d2 100644 --- a/client/protocols/openvpnprotocol.cpp +++ b/client/protocols/openvpnprotocol.cpp @@ -15,7 +15,7 @@ OpenVpnProtocol::OpenVpnProtocol(const QString& args, QObject* parent) : //m_requestFromUserToStop(false) { setConfigFile(args); - connect(m_communicator, &Communicator::messageReceived, this, &OpenVpnProtocol::onMessageReceived); + //connect(m_communicator, &Communicator::messageReceived, this, &OpenVpnProtocol::onMessageReceived); connect(&m_managementServer, &ManagementServer::readyRead, this, &OpenVpnProtocol::onReadyReadDataFromManagementServer); } @@ -172,14 +172,26 @@ ErrorCode OpenVpnProtocol::start() return ErrorCode::AmneziaServiceConnectionFailed; } process->setProgram(openVpnExecPath()); - process->setArguments(QStringList() << "--config" << configPath()<< - "--management"<< m_managementHost<< QString::number(m_managementPort)<< - "--management-client"<< - "--log-append"<< vpnLogFileNamePath); + QStringList arguments({"--config" , configPath(), + "--management", m_managementHost, QString::number(m_managementPort), + "--management-client", + "--log-append", vpnLogFileNamePath + }); + process->setArguments(arguments); + + qDebug() << arguments.join(" "); + connect(process.data(), &IpcProcessInterfaceReplica::errorOccurred, [&](QProcess::ProcessError error) { + qDebug() << "IpcProcessInterfaceReplica errorOccurred" << error; + }); + + connect(process.data(), &IpcProcessInterfaceReplica::stateChanged, [&](QProcess::ProcessState newState) { + qDebug() << "IpcProcessInterfaceReplica stateChanged" << newState; + }); + process->start(); //m_communicator->sendMessage(Message(Message::State::StartRequest, args)); - startTimeoutTimer(); + //startTimeoutTimer(); return ErrorCode::NoError; } diff --git a/client/protocols/vpnprotocol.cpp b/client/protocols/vpnprotocol.cpp index 8119e67e..545e4291 100644 --- a/client/protocols/vpnprotocol.cpp +++ b/client/protocols/vpnprotocol.cpp @@ -5,7 +5,7 @@ #include "vpnprotocol.h" #include "core/errorstrings.h" -Communicator* VpnProtocol::m_communicator = nullptr; +//Communicator* VpnProtocol::m_communicator = nullptr; VpnProtocol::VpnProtocol(const QString& args, QObject* parent) : QObject(parent), @@ -20,17 +20,17 @@ VpnProtocol::VpnProtocol(const QString& args, QObject* parent) Q_UNUSED(args) } -void VpnProtocol::initializeCommunicator(QObject* parent) -{ - if (!m_communicator) { - m_communicator = new Communicator(parent); - } -} +//void VpnProtocol::initializeCommunicator(QObject* parent) +//{ +// if (!m_communicator) { +// m_communicator = new Communicator(parent); +// } +//} -Communicator* VpnProtocol::communicator() -{ - return m_communicator; -} +//Communicator* VpnProtocol::communicator() +//{ +// return m_communicator; +//} void VpnProtocol::setLastError(ErrorCode lastError) { diff --git a/client/protocols/vpnprotocol.h b/client/protocols/vpnprotocol.h index a9cc1331..f3d9d4ea 100644 --- a/client/protocols/vpnprotocol.h +++ b/client/protocols/vpnprotocol.h @@ -22,7 +22,7 @@ public: static Communicator* communicator(); static QString textConnectionState(ConnectionState connectionState); - static void initializeCommunicator(QObject* parent = nullptr); + //static void initializeCommunicator(QObject* parent = nullptr); virtual bool onConnected() const; @@ -54,7 +54,7 @@ protected: virtual void setBytesChanged(quint64 receivedBytes, quint64 sentBytes); virtual void setConnectionState(VpnProtocol::ConnectionState state); - static Communicator* m_communicator; + //static Communicator* m_communicator; ConnectionState m_connectionState; QString m_routeGateway; diff --git a/client/vpnconnection.cpp b/client/vpnconnection.cpp index b9f8419d..937720f3 100644 --- a/client/vpnconnection.cpp +++ b/client/vpnconnection.cpp @@ -14,7 +14,7 @@ VpnConnection::VpnConnection(QObject* parent) : QObject(parent) { - VpnProtocol::initializeCommunicator(parent); + //VpnProtocol::initializeCommunicator(parent); } void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes) diff --git a/ipc/ipcserverprocess.cpp b/ipc/ipcserverprocess.cpp index 452faca7..3690c1c7 100644 --- a/ipc/ipcserverprocess.cpp +++ b/ipc/ipcserverprocess.cpp @@ -3,25 +3,51 @@ IpcServerProcess::IpcServerProcess(QObject *parent) : IpcProcessInterfaceSource(parent), - m_process(QSharedPointer(new QProcess(this))) + m_process(QSharedPointer(new QProcess())) { - connect(m_process.data(), &QProcess::errorOccurred, this, &IpcServerProcess::errorOccurred); - connect(m_process.data(), QOverload::of(&QProcess::finished), this, &IpcServerProcess::finished); - connect(m_process.data(), &QProcess::readyReadStandardError, this, &IpcServerProcess::readyReadStandardError); - connect(m_process.data(), &QProcess::readyReadStandardOutput, this, &IpcServerProcess::readyReadStandardOutput); - connect(m_process.data(), &QProcess::started, this, &IpcServerProcess::started); - connect(m_process.data(), &QProcess::stateChanged, this, &IpcServerProcess::stateChanged); +// connect(m_process.data(), &QProcess::errorOccurred, this, &IpcServerProcess::errorOccurred); +// connect(m_process.data(), QOverload::of(&QProcess::finished), this, &IpcServerProcess::finished); +// connect(m_process.data(), &QProcess::readyReadStandardError, this, &IpcServerProcess::readyReadStandardError); +// connect(m_process.data(), &QProcess::readyReadStandardOutput, this, &IpcServerProcess::readyReadStandardOutput); +// connect(m_process.data(), &QProcess::started, this, &IpcServerProcess::started); +// connect(m_process.data(), &QProcess::stateChanged, this, &IpcServerProcess::stateChanged); + + connect(m_process.data(), &QProcess::errorOccurred, [&](QProcess::ProcessError error){ + qDebug() << "IpcServerProcess errorOccurred " << error; + }); + + connect(m_process.data(), &QProcess::readyReadStandardError, [&](){ + qDebug() << "IpcServerProcess StandardError " << m_process->readAllStandardError(); + + }); + connect(m_process.data(), &QProcess::readyReadStandardOutput, [&](){ + qDebug() << "IpcServerProcess StandardOutput " << m_process->readAllStandardOutput(); + + }); + + connect(m_process.data(), &QProcess::readyRead, [&](){ + qDebug() << "IpcServerProcess StandardOutput " << m_process->readAll(); + + }); + } -void IpcServerProcess::start(const QString &program, const QStringList &args) +void IpcServerProcess::start(const QString &program, const QStringList &arguments) { - m_process->start(program, args); + m_process->start(program, arguments); + qDebug() << "IpcServerProcess started, " << arguments; + + m_process->waitForStarted(); + qDebug() << "waitForStarted started, " << m_process->errorString(); } void IpcServerProcess::start() { m_process->start(); - qDebug() << "IpcServerProcess started, " << m_process->arguments(); + qDebug() << "IpcServerProcess started, " << m_process->program() << m_process->arguments(); + + m_process->waitForStarted(); + qDebug() << "waitForStarted , " << m_process->errorString() << m_process->error(); } void IpcServerProcess::close() @@ -32,7 +58,6 @@ void IpcServerProcess::close() void IpcServerProcess::setArguments(const QStringList &arguments) { m_process->setArguments(arguments); - qDebug() << "IpcServerProcess started, " << arguments; } void IpcServerProcess::setInputChannelMode(QProcess::InputChannelMode mode) diff --git a/ipc/ipcserverprocess.h b/ipc/ipcserverprocess.h index e5222f8d..b95a5c8e 100644 --- a/ipc/ipcserverprocess.h +++ b/ipc/ipcserverprocess.h @@ -11,7 +11,7 @@ class IpcServerProcess : public IpcProcessInterfaceSource public: explicit IpcServerProcess(QObject *parent = nullptr); - void start(const QString &program, const QStringList &args) override; + void start(const QString &program, const QStringList &arguments) override; void start() override; void close() override; diff --git a/service/server/localserver.cpp b/service/server/localserver.cpp index f2703b02..644afeec 100644 --- a/service/server/localserver.cpp +++ b/service/server/localserver.cpp @@ -14,12 +14,12 @@ #endif LocalServer::LocalServer(QObject *parent) : QObject(parent), - m_clientConnection(nullptr), - m_clientConnected(false), +// m_clientConnection(nullptr), +// m_clientConnected(false), m_ipcServer(this) { - m_server = QSharedPointer(new QLocalServer(this)); - m_server->setSocketOptions(QLocalServer::WorldAccessOption); +// m_server = QSharedPointer(new QLocalServer(this)); +// m_server->setSocketOptions(QLocalServer::WorldAccessOption); // if (!m_server->listen(Utils::serverName())) { // qDebug() << QString("Unable to start the server: %1.").arg(m_server->errorString()); @@ -36,186 +36,186 @@ LocalServer::LocalServer(QObject *parent) : QObject(parent), LocalServer::~LocalServer() { - m_clientConnected = false; - m_server->disconnect(); +// m_clientConnected = false; +// m_server->disconnect(); - QFile::remove(Utils::serverName()); +// QFile::remove(Utils::serverName()); qDebug() << "Local server stopped"; } -bool LocalServer::isRunning() const -{ - return true; - //return m_server->isListening(); -} +//bool LocalServer::isRunning() const +//{ +// return true; +// //return m_server->isListening(); +//} -void LocalServer::onNewConnection() -{ - if (m_clientConnection) { - m_clientConnection->deleteLater(); - } +//void LocalServer::onNewConnection() +//{ +// if (m_clientConnection) { +// m_clientConnection->deleteLater(); +// } - m_clientConnection = m_server->nextPendingConnection(); - connect(m_clientConnection, &QLocalSocket::disconnected, this, &LocalServer::onDisconnected); - m_clientConnected = true; +// m_clientConnection = m_server->nextPendingConnection(); +// connect(m_clientConnection, &QLocalSocket::disconnected, this, &LocalServer::onDisconnected); +// m_clientConnected = true; - qDebug() << "New connection"; +// qDebug() << "New connection"; - for(;;) { - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - if (!m_clientConnected || !m_clientConnection) { - break; - } +// for(;;) { +// qApp->processEvents(QEventLoop::ExcludeUserInputEvents); +// if (!m_clientConnected || !m_clientConnection) { +// break; +// } - if (m_clientConnection->waitForReadyRead(1000) && m_clientConnection->canReadLine()) { - char buf[1024]; - qint64 lineLength = m_clientConnection->readLine(buf, sizeof(buf)); - if (lineLength != -1) { - QString line = buf; - line = line.simplified(); - qDebug().noquote() << QString("Read line: '%1'").arg(line); - Message incomingMessage(line); - if (!incomingMessage.isValid()) { - qWarning().noquote() << "Message is not valid!"; - continue; - } - else { - qDebug().noquote() << QString("Got message id: '%1'").arg(static_cast(incomingMessage.state())); - //qDebug().noquote() << incomingMessage.rawData(); - } +// if (m_clientConnection->waitForReadyRead(1000) && m_clientConnection->canReadLine()) { +// char buf[1024]; +// qint64 lineLength = m_clientConnection->readLine(buf, sizeof(buf)); +// if (lineLength != -1) { +// QString line = buf; +// line = line.simplified(); +// qDebug().noquote() << QString("Read line: '%1'").arg(line); +// Message incomingMessage(line); +// if (!incomingMessage.isValid()) { +// qWarning().noquote() << "Message is not valid!"; +// continue; +// } +// else { +// qDebug().noquote() << QString("Got message id: '%1'").arg(static_cast(incomingMessage.state())); +// //qDebug().noquote() << incomingMessage.rawData(); +// } - switch (incomingMessage.state()) { - case Message::State::Initialize: - #ifdef Q_OS_WIN - TapController::Instance().checkAndSetup(); - #endif - sendMessage(Message(Message::State::Initialize, QStringList({"Server"}))); - break; - case Message::State::StartRequest: - startProcess(incomingMessage.args()); - break; - case Message::State::FinishRequest: - finishProcess(incomingMessage.args()); - break; +// switch (incomingMessage.state()) { +// case Message::State::Initialize: +// #ifdef Q_OS_WIN +// TapController::Instance().checkAndSetup(); +// #endif +// sendMessage(Message(Message::State::Initialize, QStringList({"Server"}))); +// break; +// case Message::State::StartRequest: +// startProcess(incomingMessage.args()); +// break; +// case Message::State::FinishRequest: +// finishProcess(incomingMessage.args()); +// break; - case Message::State::RoutesAddRequest: - routesAddRequest(incomingMessage.args()); - break; - case Message::State::RouteDeleteRequest: - routeDeleteRequest(incomingMessage.args()); - break; - case Message::State::ClearSavedRoutesRequest: - Router::Instance().clearSavedRoutes(); - break; - case Message::State::FlushDnsRequest: - Router::Instance().flushDns(); - break; - case Message::State::InstallDriverRequest: - checkAndInstallDriver(incomingMessage.args()); - break; +// case Message::State::RoutesAddRequest: +// routesAddRequest(incomingMessage.args()); +// break; +// case Message::State::RouteDeleteRequest: +// routeDeleteRequest(incomingMessage.args()); +// break; +// case Message::State::ClearSavedRoutesRequest: +// Router::Instance().clearSavedRoutes(); +// break; +// case Message::State::FlushDnsRequest: +// Router::Instance().flushDns(); +// break; +// case Message::State::InstallDriverRequest: +// checkAndInstallDriver(incomingMessage.args()); +// break; - default: - ; - } - } - } - } +// default: +// ; +// } +// } +// } +// } - qDebug() << "Released"; -} +// qDebug() << "Released"; +//} -void LocalServer::finishProcess(const QStringList& args) -{ - Q_UNUSED(args) -} +//void LocalServer::finishProcess(const QStringList& args) +//{ +// Q_UNUSED(args) +//} -void LocalServer::startProcess(const QStringList& messageArgs) -{ - if (messageArgs.size() < 1) { - return; - } +//void LocalServer::startProcess(const QStringList& messageArgs) +//{ +// if (messageArgs.size() < 1) { +// return; +// } - QProcess* process = new QProcess(); - connect(process, SIGNAL(started()), this, SLOT(onStarted())); - connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onFinished(int, QProcess::ExitStatus))); +// QProcess* process = new QProcess(); +// connect(process, SIGNAL(started()), this, SLOT(onStarted())); +// connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onFinished(int, QProcess::ExitStatus))); - const QString program = messageArgs.at(0); - QStringList args; - for (int i = 1; i < messageArgs.size(); i++) { - args.append(messageArgs.at(i)); - } +// const QString program = messageArgs.at(0); +// QStringList args; +// for (int i = 1; i < messageArgs.size(); i++) { +// args.append(messageArgs.at(i)); +// } - QFileInfo fi(program); - const QString baseName = fi.baseName(); - if (!fi.exists()) { - qWarning() << "This program does not exist"; - sendMessage(Message(Message::State::Started, QStringList({baseName}))); - sendMessage(Message(Message::State::Finished, QStringList({baseName, QString::number(-1)}))); - return; - } +// QFileInfo fi(program); +// const QString baseName = fi.baseName(); +// if (!fi.exists()) { +// qWarning() << "This program does not exist"; +// sendMessage(Message(Message::State::Started, QStringList({baseName}))); +// sendMessage(Message(Message::State::Finished, QStringList({baseName, QString::number(-1)}))); +// return; +// } - process->setObjectName(baseName); +// process->setObjectName(baseName); - qDebug().noquote() << QString("Start process '%1' - '%2' with args '%3'") - .arg(baseName).arg(program).arg(args.join(",")); +// qDebug().noquote() << QString("Start process '%1' - '%2' with args '%3'") +// .arg(baseName).arg(program).arg(args.join(",")); - process->start(program, args); - m_processList.append(process); -} +// process->start(program, args); +// m_processList.append(process); +//} -void LocalServer::routesAddRequest(const QStringList &messageArgs) -{ - Router::Instance().routeAddList(messageArgs.first(), messageArgs.mid(1)); -} +//void LocalServer::routesAddRequest(const QStringList &messageArgs) +//{ +// Router::Instance().routeAddList(messageArgs.first(), messageArgs.mid(1)); +//} -void LocalServer::routeDeleteRequest(const QStringList &messageArgs) -{ - Router::Instance().routeDelete(messageArgs.first()); -} +//void LocalServer::routeDeleteRequest(const QStringList &messageArgs) +//{ +// Router::Instance().routeDelete(messageArgs.first()); +//} -void LocalServer::checkAndInstallDriver(const QStringList &messageArgs) -{ +//void LocalServer::checkAndInstallDriver(const QStringList &messageArgs) +//{ -} +//} -void LocalServer::onFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitStatus) +//void LocalServer::onFinished(int exitCode, QProcess::ExitStatus exitStatus) +//{ +// Q_UNUSED(exitStatus) - QProcess* process = (QProcess*)sender(); - sendMessage(Message(Message::State::Finished, QStringList({process->objectName(), QString::number(exitCode)}))); -} +// QProcess* process = (QProcess*)sender(); +// sendMessage(Message(Message::State::Finished, QStringList({process->objectName(), QString::number(exitCode)}))); +//} -void LocalServer::onStarted() -{ - QProcess* process = (QProcess*)sender(); - sendMessage(Message(Message::State::Started, QStringList({process->objectName()}))); -} +//void LocalServer::onStarted() +//{ +// QProcess* process = (QProcess*)sender(); +// sendMessage(Message(Message::State::Started, QStringList({process->objectName()}))); +//} -void LocalServer::onDisconnected() -{ - if (!m_clientConnected) { - return; - } +//void LocalServer::onDisconnected() +//{ +// if (!m_clientConnected) { +// return; +// } - m_clientConnected = false; - QLocalSocket* clientConnection = (QLocalSocket*)sender(); - clientConnection->deleteLater(); +// m_clientConnected = false; +// QLocalSocket* clientConnection = (QLocalSocket*)sender(); +// clientConnection->deleteLater(); - qDebug() << "Diconnected"; -} +// qDebug() << "Diconnected"; +//} -void LocalServer::sendMessage(const Message& message) -{ - if (!m_clientConnection || !m_clientConnected) { - qDebug()<< "Cannot send data, remote peer is not connected"; - return; - } +//void LocalServer::sendMessage(const Message& message) +//{ +// if (!m_clientConnection || !m_clientConnected) { +// qDebug()<< "Cannot send data, remote peer is not connected"; +// return; +// } - const QString data = message.toString(); - bool status = m_clientConnection->write(QString(data + "\n").toUtf8()); +// const QString data = message.toString(); +// bool status = m_clientConnection->write(QString(data + "\n").toUtf8()); - qDebug().noquote() << QString("Send message '%1', status '%2'").arg(data).arg(Utils::toString(status)); -} +// qDebug().noquote() << QString("Send message '%1', status '%2'").arg(data).arg(Utils::toString(status)); +//} diff --git a/service/server/localserver.h b/service/server/localserver.h index 99c263b3..aabf3e8e 100644 --- a/service/server/localserver.h +++ b/service/server/localserver.h @@ -23,30 +23,30 @@ public: explicit LocalServer(QObject* parent = nullptr); ~LocalServer(); - bool isRunning() const; +// bool isRunning() const; protected slots: - void onDisconnected(); - void onNewConnection(); +// void onDisconnected(); +// void onNewConnection(); - void onFinished(int exitCode, QProcess::ExitStatus exitStatus); - void onStarted(); +// void onFinished(int exitCode, QProcess::ExitStatus exitStatus); +// void onStarted(); private: - void finishProcess(const QStringList& messageArgs); - void sendMessage(const Message& message); - void startProcess(const QStringList& messageArgs); +// void finishProcess(const QStringList& messageArgs); +// void sendMessage(const Message& message); +// void startProcess(const QStringList& messageArgs); - void routesAddRequest(const QStringList& messageArgs); - void routeDeleteRequest(const QStringList& messageArgs); +// void routesAddRequest(const QStringList& messageArgs); +// void routeDeleteRequest(const QStringList& messageArgs); - void checkAndInstallDriver(const QStringList& messageArgs); +// void checkAndInstallDriver(const QStringList& messageArgs); QSharedPointer m_server; - QPointer m_clientConnection; +// QPointer m_clientConnection; - QVector m_processList; - bool m_clientConnected; +// QVector m_processList; +// bool m_clientConnected; IpcServer m_ipcServer; QRemoteObjectHost m_serverNode; diff --git a/service/server/main.cpp b/service/server/main.cpp index 65be5e52..bff4fc04 100644 --- a/service/server/main.cpp +++ b/service/server/main.cpp @@ -10,9 +10,9 @@ int runApplication(int argc, char** argv) { QCoreApplication app(argc,argv); LocalServer localServer; - if (!localServer.isRunning()) { - return -1; - } +// if (!localServer.isRunning()) { +// return -1; +// } return app.exec(); } int main(int argc, char **argv) diff --git a/service/server/systemservice.cpp b/service/server/systemservice.cpp index 32a7f86f..3aae8404 100644 --- a/service/server/systemservice.cpp +++ b/service/server/systemservice.cpp @@ -13,9 +13,9 @@ void SystemService::start() QCoreApplication* app = application(); m_localServer = new LocalServer(); - if (!m_localServer->isRunning()) { - app->quit(); - } +// if (!m_localServer->isRunning()) { +// app->quit(); +// } } void SystemService::stop()