2019-01-11 01:04:13 +01:00
|
|
|
// The MIT License (MIT)
|
|
|
|
//
|
|
|
|
// Copyright (c) Itay Grudev 2015 - 2018
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
//
|
|
|
|
// W A R N I N G !!!
|
|
|
|
// -----------------
|
|
|
|
//
|
2019-08-26 02:00:47 +02:00
|
|
|
// This is a modified version of SingleApplication,
|
|
|
|
// The original version is at:
|
2019-01-11 01:04:13 +01:00
|
|
|
//
|
2019-08-26 02:00:47 +02:00
|
|
|
// https://github.com/itay-grudev/SingleApplication
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstddef>
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <pwd.h>
|
|
|
|
#endif
|
|
|
|
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QIODevice>
|
|
|
|
#include <QSharedMemory>
|
2019-08-26 02:00:47 +02:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <QDataStream>
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QLocalServer>
|
|
|
|
#include <QLocalSocket>
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QDir>
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
#include "singlecoreapplication.h"
|
|
|
|
#include "singlecoreapplication_p.h"
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
2019-08-26 02:00:47 +02:00
|
|
|
# include <windows.h>
|
|
|
|
# include <lmcons.h>
|
2019-01-11 01:04:13 +01:00
|
|
|
#endif
|
|
|
|
|
2020-04-23 21:00:43 +02:00
|
|
|
SingleCoreApplicationPrivate::SingleCoreApplicationPrivate(SingleCoreApplication *_q_ptr)
|
|
|
|
: q_ptr(_q_ptr),
|
2019-08-26 17:22:11 +02:00
|
|
|
memory(nullptr),
|
|
|
|
socket(nullptr),
|
|
|
|
server(nullptr),
|
|
|
|
instanceNumber(-1)
|
|
|
|
{}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
SingleCoreApplicationPrivate::~SingleCoreApplicationPrivate() {
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
if (socket != nullptr) {
|
|
|
|
socket->close();
|
|
|
|
delete socket;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory->lock();
|
|
|
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
|
|
|
if (server != nullptr) {
|
|
|
|
server->close();
|
|
|
|
delete server;
|
|
|
|
inst->primary = false;
|
|
|
|
inst->primaryPid = -1;
|
|
|
|
inst->checksum = blockChecksum();
|
|
|
|
}
|
|
|
|
memory->unlock();
|
|
|
|
|
|
|
|
delete memory;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
void SingleCoreApplicationPrivate::genBlockServerName() {
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
QCryptographicHash appData(QCryptographicHash::Sha256);
|
|
|
|
appData.addData("SingleApplication", 17);
|
|
|
|
appData.addData(SingleCoreApplication::app_t::applicationName().toUtf8());
|
|
|
|
appData.addData(SingleCoreApplication::app_t::organizationName().toUtf8());
|
|
|
|
appData.addData(SingleCoreApplication::app_t::organizationDomain().toUtf8());
|
|
|
|
|
|
|
|
if (!(options & SingleCoreApplication::Mode::ExcludeAppVersion)) {
|
|
|
|
appData.addData(SingleCoreApplication::app_t::applicationVersion().toUtf8());
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
if (!(options & SingleCoreApplication::Mode::ExcludeAppPath)) {
|
2019-01-11 01:04:13 +01:00
|
|
|
#ifdef Q_OS_WIN
|
2019-08-26 02:00:47 +02:00
|
|
|
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toLower().toUtf8());
|
2019-01-11 01:04:13 +01:00
|
|
|
#else
|
2019-08-26 02:00:47 +02:00
|
|
|
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toUtf8());
|
2019-01-11 01:04:13 +01:00
|
|
|
#endif
|
2019-08-26 02:00:47 +02:00
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// User level block requires a user specific data in the hash
|
|
|
|
if (options & SingleCoreApplication::Mode::User) {
|
2019-01-11 01:04:13 +01:00
|
|
|
#ifdef Q_OS_UNIX
|
2019-08-26 02:00:47 +02:00
|
|
|
QByteArray username;
|
|
|
|
#if defined(HAVE_GETEUID) && defined(HAVE_GETPWUID)
|
2019-11-15 00:23:06 +01:00
|
|
|
struct passwd *pw = getpwuid(geteuid());
|
|
|
|
if (pw) {
|
|
|
|
username = pw->pw_name;
|
2019-08-26 02:00:47 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (username.isEmpty()) username = qgetenv("USER");
|
|
|
|
appData.addData(username);
|
2019-01-11 01:04:13 +01:00
|
|
|
#endif
|
2019-08-26 02:00:47 +02:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
wchar_t username [ UNLEN + 1 ];
|
|
|
|
// Specifies size of the buffer on input
|
|
|
|
DWORD usernameLength = UNLEN + 1;
|
|
|
|
if (GetUserNameW(username, &usernameLength)) {
|
|
|
|
appData.addData(QString::fromWCharArray(username).toUtf8());
|
2019-01-11 01:04:13 +01:00
|
|
|
}
|
2019-08-26 17:31:49 +02:00
|
|
|
else {
|
|
|
|
appData.addData(qgetenv("USERNAME"));
|
|
|
|
}
|
2019-08-26 02:00:47 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with server naming requirements.
|
|
|
|
blockServerName = appData.result().toBase64().replace("/", "_");
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
void SingleCoreApplicationPrivate::initializeMemoryBlock() {
|
|
|
|
|
|
|
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
|
|
|
inst->primary = false;
|
|
|
|
inst->secondary = 0;
|
|
|
|
inst->primaryPid = -1;
|
|
|
|
inst->checksum = blockChecksum();
|
|
|
|
|
2019-01-11 01:04:13 +01:00
|
|
|
}
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
void SingleCoreApplicationPrivate::startPrimary() {
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
Q_Q(SingleCoreApplication);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// Successful creation means that no main process exists
|
|
|
|
// So we start a QLocalServer to listen for connections
|
|
|
|
QLocalServer::removeServer(blockServerName);
|
|
|
|
server = new QLocalServer();
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// Restrict access to the socket according to the
|
|
|
|
// SingleCoreApplication::Mode::User flag on User level or no restrictions
|
|
|
|
if (options & SingleCoreApplication::Mode::User) {
|
|
|
|
server->setSocketOptions(QLocalServer::UserAccessOption);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
server->setSocketOptions(QLocalServer::WorldAccessOption);
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
server->listen(blockServerName);
|
|
|
|
QObject::connect(server, &QLocalServer::newConnection, this, &SingleCoreApplicationPrivate::slotConnectionEstablished);
|
|
|
|
|
|
|
|
// Reset the number of connections
|
|
|
|
InstancesInfo* inst = static_cast <InstancesInfo*>(memory->data());
|
|
|
|
|
|
|
|
inst->primary = true;
|
|
|
|
inst->primaryPid = q->applicationPid();
|
|
|
|
inst->checksum = blockChecksum();
|
|
|
|
|
|
|
|
instanceNumber = 0;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
void SingleCoreApplicationPrivate::startSecondary() {}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2020-04-23 21:00:43 +02:00
|
|
|
void SingleCoreApplicationPrivate::connectToPrimary(const int msecs, const ConnectionType connectionType) {
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// Connect to the Local Server of the Primary Instance if not already connected.
|
|
|
|
if (socket == nullptr) {
|
|
|
|
socket = new QLocalSocket();
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// If already connected - we are done;
|
|
|
|
if (socket->state() == QLocalSocket::ConnectedState)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If not connect
|
|
|
|
if (socket->state() == QLocalSocket::UnconnectedState ||
|
|
|
|
socket->state() == QLocalSocket::ClosingState) {
|
|
|
|
socket->connectToServer(blockServerName);
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// Wait for being connected
|
|
|
|
if (socket->state() == QLocalSocket::ConnectingState) {
|
|
|
|
socket->waitForConnected(msecs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialisation message according to the SingleCoreApplication protocol
|
|
|
|
if (socket->state() == QLocalSocket::ConnectedState) {
|
|
|
|
// Notify the parent that a new instance had been started;
|
|
|
|
QByteArray initMsg;
|
|
|
|
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
writeStream.setVersion(QDataStream::Qt_5_6);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
writeStream << blockServerName.toLatin1();
|
|
|
|
writeStream << static_cast<quint8>(connectionType);
|
|
|
|
writeStream << instanceNumber;
|
|
|
|
quint16 checksum = qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length()));
|
|
|
|
writeStream << checksum;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// The header indicates the message length that follows
|
|
|
|
QByteArray header;
|
|
|
|
QDataStream headerStream(&header, QIODevice::WriteOnly);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
headerStream.setVersion(QDataStream::Qt_5_6);
|
2020-02-29 21:50:10 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
headerStream << static_cast <quint64>(initMsg.length());
|
|
|
|
|
|
|
|
socket->write(header);
|
|
|
|
socket->write(initMsg);
|
|
|
|
socket->flush();
|
|
|
|
socket->waitForBytesWritten(msecs);
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
quint16 SingleCoreApplicationPrivate::blockChecksum() {
|
|
|
|
|
|
|
|
return qChecksum(static_cast <const char*> (memory->data()), offsetof(InstancesInfo, checksum));
|
|
|
|
|
2019-01-11 01:04:13 +01:00
|
|
|
}
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
qint64 SingleCoreApplicationPrivate::primaryPid() {
|
|
|
|
|
|
|
|
qint64 pid;
|
|
|
|
|
|
|
|
memory->lock();
|
|
|
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
|
|
|
pid = inst->primaryPid;
|
|
|
|
memory->unlock();
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
return pid;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Executed when a connection has been made to the LocalServer
|
|
|
|
*/
|
2019-08-26 02:00:47 +02:00
|
|
|
void SingleCoreApplicationPrivate::slotConnectionEstablished() {
|
|
|
|
|
|
|
|
QLocalSocket *nextConnSocket = server->nextPendingConnection();
|
|
|
|
connectionMap.insert(nextConnSocket, ConnectionInfo());
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
|
|
|
|
[nextConnSocket, this]() {
|
|
|
|
auto &info = connectionMap[nextConnSocket];
|
|
|
|
Q_EMIT this->slotClientConnectionClosed(nextConnSocket, info.instanceId);
|
2019-01-11 01:04:13 +01:00
|
|
|
}
|
2019-08-26 02:00:47 +02:00
|
|
|
);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
QObject::connect(nextConnSocket, &QLocalSocket::disconnected,
|
|
|
|
[nextConnSocket, this](){
|
|
|
|
connectionMap.remove(nextConnSocket);
|
|
|
|
nextConnSocket->deleteLater();
|
2019-01-11 01:04:13 +01:00
|
|
|
}
|
2019-08-26 02:00:47 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(nextConnSocket, &QLocalSocket::readyRead,
|
|
|
|
[nextConnSocket, this]() {
|
|
|
|
auto &info = connectionMap[nextConnSocket];
|
|
|
|
switch(info.stage) {
|
|
|
|
case StageHeader:
|
|
|
|
readInitMessageHeader(nextConnSocket);
|
|
|
|
break;
|
|
|
|
case StageBody:
|
|
|
|
readInitMessageBody(nextConnSocket);
|
|
|
|
break;
|
|
|
|
case StageConnected:
|
|
|
|
Q_EMIT this->slotDataAvailable(nextConnSocket, info.instanceId);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SingleCoreApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
|
|
|
|
|
|
|
|
if (!connectionMap.contains(sock)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-15 17:59:02 +02:00
|
|
|
if (sock->bytesAvailable() < static_cast<qint64>(sizeof(quint64))) {
|
2019-08-26 02:00:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDataStream headerStream(sock);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
headerStream.setVersion(QDataStream::Qt_5_6);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// Read the header to know the message length
|
|
|
|
quint64 msgLen = 0;
|
|
|
|
headerStream >> msgLen;
|
|
|
|
ConnectionInfo &info = connectionMap[sock];
|
|
|
|
info.stage = StageBody;
|
|
|
|
info.msgLen = msgLen;
|
|
|
|
|
2020-06-15 17:59:02 +02:00
|
|
|
if (sock->bytesAvailable() >= static_cast<qint64>(msgLen)) {
|
2019-08-26 02:00:47 +02:00
|
|
|
readInitMessageBody(sock);
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
void SingleCoreApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
Q_Q(SingleCoreApplication);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
if (!connectionMap.contains(sock)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectionInfo &info = connectionMap[sock];
|
2020-06-15 17:59:02 +02:00
|
|
|
if (sock->bytesAvailable() < static_cast<qint64>(info.msgLen)) {
|
2019-08-26 02:00:47 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// Read the message body
|
|
|
|
QByteArray msgBytes = sock->read(info.msgLen);
|
|
|
|
QDataStream readStream(msgBytes);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
readStream.setVersion(QDataStream::Qt_5_6);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// server name
|
|
|
|
QByteArray latin1Name;
|
|
|
|
readStream >> latin1Name;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// connection type
|
|
|
|
ConnectionType connectionType = InvalidConnection;
|
|
|
|
quint8 connTypeVal = InvalidConnection;
|
|
|
|
readStream >> connTypeVal;
|
|
|
|
connectionType = static_cast <ConnectionType>(connTypeVal);
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// instance id
|
|
|
|
quint32 instanceId = 0;
|
|
|
|
readStream >> instanceId;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
// checksum
|
|
|
|
quint16 msgChecksum = 0;
|
|
|
|
readStream >> msgChecksum;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
const quint16 actualChecksum = qChecksum(msgBytes.constData(), static_cast<quint32>(msgBytes.length() - sizeof(quint16)));
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
bool isValid = readStream.status() == QDataStream::Ok && QLatin1String(latin1Name) == blockServerName && msgChecksum == actualChecksum;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
if (!isValid) {
|
|
|
|
sock->close();
|
|
|
|
return;
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
info.instanceId = instanceId;
|
|
|
|
info.stage = StageConnected;
|
2019-01-11 01:04:13 +01:00
|
|
|
|
2019-08-26 02:00:47 +02:00
|
|
|
if (connectionType == NewInstance || (connectionType == SecondaryInstance && options & SingleCoreApplication::Mode::SecondaryNotification)) {
|
|
|
|
Q_EMIT q->instanceStarted();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sock->bytesAvailable() > 0) {
|
|
|
|
Q_EMIT this->slotDataAvailable(sock, instanceId);
|
|
|
|
}
|
2019-01-11 01:04:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-23 21:00:43 +02:00
|
|
|
void SingleCoreApplicationPrivate::slotDataAvailable(QLocalSocket *dataSocket, const quint32 instanceId) {
|
2019-08-26 02:00:47 +02:00
|
|
|
|
|
|
|
Q_Q(SingleCoreApplication);
|
|
|
|
Q_EMIT q->receivedMessage(instanceId, dataSocket->readAll());
|
|
|
|
|
2019-01-11 01:04:13 +01:00
|
|
|
}
|
|
|
|
|
2020-04-23 21:00:43 +02:00
|
|
|
void SingleCoreApplicationPrivate::slotClientConnectionClosed(QLocalSocket *closedSocket, const quint32 instanceId) {
|
2019-08-26 02:00:47 +02:00
|
|
|
|
|
|
|
if (closedSocket->bytesAvailable() > 0)
|
|
|
|
Q_EMIT slotDataAvailable(closedSocket, instanceId);
|
|
|
|
|
2019-01-11 01:04:13 +01:00
|
|
|
}
|