From 9c431dcdb2fa83740d9dd756669f900d7c73fbd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Thu, 22 Mar 2018 07:17:10 +0100 Subject: [PATCH 01/10] get disconnection events --- include/CuteIPCInterface.h | 5 ++++- src/CuteIPCInterface.cpp | 8 ++++++++ src/CuteIPCInterfaceConnection.cpp | 3 +++ src/CuteIPCInterfaceConnection_p.h | 1 + src/CuteIPCInterfaceWorker.cpp | 7 +++++++ src/CuteIPCInterfaceWorker.h | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/CuteIPCInterface.h b/include/CuteIPCInterface.h index 9948fcd..31c347f 100644 --- a/include/CuteIPCInterface.h +++ b/include/CuteIPCInterface.h @@ -21,7 +21,7 @@ class CuteIPCInterface : public QObject bool connectToServer(const QHostAddress& host, quint16 port); void disconnectFromServer(); - + bool isConnected(); bool remoteConnect(const char* signal, QObject* object, const char* method); bool remoteSlotConnect(QObject* localObject, const char* signal, const char* remoteSlot); @@ -52,6 +52,9 @@ class CuteIPCInterface : public QObject QString lastError() const; + signals: + void disconnected(); + protected: CuteIPCInterfacePrivate* const d_ptr; CuteIPCInterface(CuteIPCInterfacePrivate& dd, QObject* parent); diff --git a/src/CuteIPCInterface.cpp b/src/CuteIPCInterface.cpp index 5a798fe..e3a72fb 100644 --- a/src/CuteIPCInterface.cpp +++ b/src/CuteIPCInterface.cpp @@ -135,6 +135,7 @@ bool CuteIPCInterfacePrivate::sendSynchronousRequest(const QByteArray& request, QEventLoop loop; QObject::connect(&connection, SIGNAL(callFinished()), &loop, SLOT(quit())); + QObject::connect(&connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); QObject::connect(&connection, SIGNAL(socketDisconnected()), &loop, SLOT(quit())); connection.sendCallRequest(request); loop.exec(); @@ -161,6 +162,7 @@ bool CuteIPCInterfacePrivate::sendSynchronousRequest(const QByteArray& request, QEventLoop loop; QObject::connect(&connection, SIGNAL(callFinished()), &loop, SLOT(quit())); + QObject::connect(&connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); QObject::connect(&connection, SIGNAL(socketDisconnected()), &loop, SLOT(quit())); connection.sendCallRequest(request); loop.exec(); @@ -325,6 +327,12 @@ CuteIPCInterface::CuteIPCInterface(CuteIPCInterfacePrivate& dd, QObject* parent) } +bool CuteIPCInterface::isConnected() { + Q_D(CuteIPCInterface); + d->q_ptr = this; + return d->m_worker->isConnected(); +} + /*! Destroyes the object. */ diff --git a/src/CuteIPCInterfaceConnection.cpp b/src/CuteIPCInterfaceConnection.cpp index 9930fe8..d630e12 100644 --- a/src/CuteIPCInterfaceConnection.cpp +++ b/src/CuteIPCInterfaceConnection.cpp @@ -31,6 +31,9 @@ CuteIPCInterfaceConnection::CuteIPCInterfaceConnection(QTcpSocket* socket, QObje connect(socket, SIGNAL(readyRead()), SLOT(readyRead())); } +bool CuteIPCInterfaceConnection::isConnected() { + return m_socket && m_socket->isOpen(); +} void CuteIPCInterfaceConnection::sendCallRequest(const QByteArray& request) { diff --git a/src/CuteIPCInterfaceConnection_p.h b/src/CuteIPCInterfaceConnection_p.h index c53d212..3b9eff1 100644 --- a/src/CuteIPCInterfaceConnection_p.h +++ b/src/CuteIPCInterfaceConnection_p.h @@ -22,6 +22,7 @@ class CuteIPCInterfaceConnection : public QObject void sendCallRequest(const QByteArray& request); void setReturnedObject(QGenericReturnArgument returnedObject); bool lastCallSuccessful() const; + bool isConnected(); signals: void callFinished(); diff --git a/src/CuteIPCInterfaceWorker.cpp b/src/CuteIPCInterfaceWorker.cpp index cd5cb7e..1799cd1 100644 --- a/src/CuteIPCInterfaceWorker.cpp +++ b/src/CuteIPCInterfaceWorker.cpp @@ -28,6 +28,7 @@ void CuteIPCInterfaceWorker::connectToServer(const QString& name, void* successf QLocalSocket* socket = new QLocalSocket; socket->connectToServer(name); + bool connected = socket->waitForConnected(5000); if (!connected) { @@ -42,6 +43,7 @@ void CuteIPCInterfaceWorker::connectToServer(const QString& name, void* successf this, SIGNAL(invokeRemoteSignal(QString, CuteIPCMessage::Arguments))); connect(m_connection, SIGNAL(errorOccured(QString)), this, SIGNAL(setLastError(QString))); + connect(m_connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); connect(m_connection, SIGNAL(socketDisconnected()), m_connection, SLOT(deleteLater())); connect(m_connection, SIGNAL(socketDisconnected()), socket, SLOT(deleteLater())); @@ -88,6 +90,7 @@ void CuteIPCInterfaceWorker::connectToTcpServer(const QHostAddress& host, const this, SIGNAL(invokeRemoteSignal(QString, CuteIPCMessage::Arguments))); connect(m_connection, SIGNAL(errorOccured(QString)), this, SIGNAL(setLastError(QString))); + connect(m_connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); connect(m_connection, SIGNAL(socketDisconnected()), m_connection, SLOT(deleteLater())); connect(m_connection, SIGNAL(socketDisconnected()), socket, SLOT(deleteLater())); @@ -131,6 +134,10 @@ void CuteIPCInterfaceWorker::disconnectFromServer() } +void CuteIPCInterfaceWorker::isConnected() { + return m_connection->isConnected(); +} + void CuteIPCInterfaceWorker::sendCallRequest(const QByteArray& request) { if (!m_connection) diff --git a/src/CuteIPCInterfaceWorker.h b/src/CuteIPCInterfaceWorker.h index dc09e23..8874515 100644 --- a/src/CuteIPCInterfaceWorker.h +++ b/src/CuteIPCInterfaceWorker.h @@ -21,8 +21,10 @@ class CuteIPCInterfaceWorker : public QObject explicit CuteIPCInterfaceWorker(QObject* parent = 0); ~CuteIPCInterfaceWorker(); + bool isConnected(); signals: void setLastError(const QString& error); + void disconnected(); // slot finish signals void connectToServerFinished(); From bf49b60c0e729f847d357313f7759d35052d0a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Thu, 22 Mar 2018 07:43:23 +0100 Subject: [PATCH 02/10] disconnected event --- src/CuteIPCInterface.cpp | 5 +++-- src/CuteIPCInterfaceConnection.cpp | 1 + src/CuteIPCInterfaceWorker.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/CuteIPCInterface.cpp b/src/CuteIPCInterface.cpp index e3a72fb..6e2ef6d 100644 --- a/src/CuteIPCInterface.cpp +++ b/src/CuteIPCInterface.cpp @@ -135,7 +135,8 @@ bool CuteIPCInterfacePrivate::sendSynchronousRequest(const QByteArray& request, QEventLoop loop; QObject::connect(&connection, SIGNAL(callFinished()), &loop, SLOT(quit())); - QObject::connect(&connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); + + QObject::connect(&connection, SIGNAL(socketDisconnected()), q_ptr, SIGNAL(disconnected())); QObject::connect(&connection, SIGNAL(socketDisconnected()), &loop, SLOT(quit())); connection.sendCallRequest(request); loop.exec(); @@ -162,7 +163,6 @@ bool CuteIPCInterfacePrivate::sendSynchronousRequest(const QByteArray& request, QEventLoop loop; QObject::connect(&connection, SIGNAL(callFinished()), &loop, SLOT(quit())); - QObject::connect(&connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); QObject::connect(&connection, SIGNAL(socketDisconnected()), &loop, SLOT(quit())); connection.sendCallRequest(request); loop.exec(); @@ -298,6 +298,7 @@ CuteIPCInterface::CuteIPCInterface(QObject* parent) Q_D(CuteIPCInterface); d->q_ptr = this; + connect(d->m_worker, SIGNAL(disconnected()), SIGNAL(disconnected())); connect(d->m_worker, SIGNAL(setLastError(QString)), SLOT(_q_setLastError(QString))); connect(d->m_worker, SIGNAL(invokeRemoteSignal(QString, CuteIPCMessage::Arguments)), SLOT(_q_invokeRemoteSignal(QString, CuteIPCMessage::Arguments))); diff --git a/src/CuteIPCInterfaceConnection.cpp b/src/CuteIPCInterfaceConnection.cpp index d630e12..a39d831 100644 --- a/src/CuteIPCInterfaceConnection.cpp +++ b/src/CuteIPCInterfaceConnection.cpp @@ -15,6 +15,7 @@ CuteIPCInterfaceConnection::CuteIPCInterfaceConnection(QLocalSocket* socket, QOb m_socket(socket), m_nextBlockSize(0) { + connect(socket, SIGNAL(disconnected()), SIGNAL(socketDisconnected())); connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)), SLOT(errorOccured(QLocalSocket::LocalSocketError))); connect(socket, SIGNAL(readyRead()), SLOT(readyRead())); diff --git a/src/CuteIPCInterfaceWorker.cpp b/src/CuteIPCInterfaceWorker.cpp index 1799cd1..b9527dd 100644 --- a/src/CuteIPCInterfaceWorker.cpp +++ b/src/CuteIPCInterfaceWorker.cpp @@ -91,7 +91,7 @@ void CuteIPCInterfaceWorker::connectToTcpServer(const QHostAddress& host, const connect(m_connection, SIGNAL(errorOccured(QString)), this, SIGNAL(setLastError(QString))); connect(m_connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); - connect(m_connection, SIGNAL(socketDisconnected()), m_connection, SLOT(deleteLater())); + connect(m_connection, SIGNAL(socketDisconnected()), m_connection, SLOT(deleteLater())); connect(m_connection, SIGNAL(socketDisconnected()), socket, SLOT(deleteLater())); DEBUG << "CuteIPC:" << "Connected over network:" << host << port << connected; @@ -134,7 +134,7 @@ void CuteIPCInterfaceWorker::disconnectFromServer() } -void CuteIPCInterfaceWorker::isConnected() { +bool CuteIPCInterfaceWorker::isConnected() { return m_connection->isConnected(); } From b460bf1fe1ffa56d3ae5ad1f46e51d7d620b7c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Thu, 22 Mar 2018 07:48:48 +0100 Subject: [PATCH 03/10] fix whitespaces --- src/CuteIPCInterface.cpp | 6 +++--- src/CuteIPCInterfaceConnection.cpp | 2 +- src/CuteIPCInterfaceWorker.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CuteIPCInterface.cpp b/src/CuteIPCInterface.cpp index 6e2ef6d..95c9ebe 100644 --- a/src/CuteIPCInterface.cpp +++ b/src/CuteIPCInterface.cpp @@ -329,9 +329,9 @@ CuteIPCInterface::CuteIPCInterface(CuteIPCInterfacePrivate& dd, QObject* parent) bool CuteIPCInterface::isConnected() { - Q_D(CuteIPCInterface); - d->q_ptr = this; - return d->m_worker->isConnected(); + Q_D(CuteIPCInterface); + d->q_ptr = this; + return d->m_worker->isConnected(); } /*! diff --git a/src/CuteIPCInterfaceConnection.cpp b/src/CuteIPCInterfaceConnection.cpp index a39d831..46050be 100644 --- a/src/CuteIPCInterfaceConnection.cpp +++ b/src/CuteIPCInterfaceConnection.cpp @@ -33,7 +33,7 @@ CuteIPCInterfaceConnection::CuteIPCInterfaceConnection(QTcpSocket* socket, QObje } bool CuteIPCInterfaceConnection::isConnected() { - return m_socket && m_socket->isOpen(); + return m_socket && m_socket->isOpen(); } void CuteIPCInterfaceConnection::sendCallRequest(const QByteArray& request) diff --git a/src/CuteIPCInterfaceWorker.h b/src/CuteIPCInterfaceWorker.h index 8874515..ba115b8 100644 --- a/src/CuteIPCInterfaceWorker.h +++ b/src/CuteIPCInterfaceWorker.h @@ -21,7 +21,7 @@ class CuteIPCInterfaceWorker : public QObject explicit CuteIPCInterfaceWorker(QObject* parent = 0); ~CuteIPCInterfaceWorker(); - bool isConnected(); + bool isConnected(); signals: void setLastError(const QString& error); void disconnected(); From e22bdf21fbf84d4f87e861ccb7fd086c1ebb41a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Thu, 22 Mar 2018 09:03:20 +0100 Subject: [PATCH 04/10] more cleanups --- include/CuteIPCInterface.h | 5 +++-- src/CuteIPCInterface.cpp | 2 +- src/CuteIPCInterfaceWorker.cpp | 8 ++++---- src/CuteIPCInterfaceWorker.h | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/CuteIPCInterface.h b/include/CuteIPCInterface.h index 31c347f..818de36 100644 --- a/include/CuteIPCInterface.h +++ b/include/CuteIPCInterface.h @@ -21,7 +21,7 @@ class CuteIPCInterface : public QObject bool connectToServer(const QHostAddress& host, quint16 port); void disconnectFromServer(); - bool isConnected(); + bool isConnected(); bool remoteConnect(const char* signal, QObject* object, const char* method); bool remoteSlotConnect(QObject* localObject, const char* signal, const char* remoteSlot); @@ -53,7 +53,8 @@ class CuteIPCInterface : public QObject QString lastError() const; signals: - void disconnected(); + void disconnected(); + protected: CuteIPCInterfacePrivate* const d_ptr; diff --git a/src/CuteIPCInterface.cpp b/src/CuteIPCInterface.cpp index 95c9ebe..f79c47d 100644 --- a/src/CuteIPCInterface.cpp +++ b/src/CuteIPCInterface.cpp @@ -136,7 +136,7 @@ bool CuteIPCInterfacePrivate::sendSynchronousRequest(const QByteArray& request, QEventLoop loop; QObject::connect(&connection, SIGNAL(callFinished()), &loop, SLOT(quit())); - QObject::connect(&connection, SIGNAL(socketDisconnected()), q_ptr, SIGNAL(disconnected())); + QObject::connect(&connection, SIGNAL(socketDisconnected()), q_ptr, SIGNAL(disconnected())); QObject::connect(&connection, SIGNAL(socketDisconnected()), &loop, SLOT(quit())); connection.sendCallRequest(request); loop.exec(); diff --git a/src/CuteIPCInterfaceWorker.cpp b/src/CuteIPCInterfaceWorker.cpp index b9527dd..b07a835 100644 --- a/src/CuteIPCInterfaceWorker.cpp +++ b/src/CuteIPCInterfaceWorker.cpp @@ -28,7 +28,7 @@ void CuteIPCInterfaceWorker::connectToServer(const QString& name, void* successf QLocalSocket* socket = new QLocalSocket; socket->connectToServer(name); - + bool connected = socket->waitForConnected(5000); if (!connected) { @@ -43,7 +43,7 @@ void CuteIPCInterfaceWorker::connectToServer(const QString& name, void* successf this, SIGNAL(invokeRemoteSignal(QString, CuteIPCMessage::Arguments))); connect(m_connection, SIGNAL(errorOccured(QString)), this, SIGNAL(setLastError(QString))); - connect(m_connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); + connect(m_connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); connect(m_connection, SIGNAL(socketDisconnected()), m_connection, SLOT(deleteLater())); connect(m_connection, SIGNAL(socketDisconnected()), socket, SLOT(deleteLater())); @@ -90,8 +90,8 @@ void CuteIPCInterfaceWorker::connectToTcpServer(const QHostAddress& host, const this, SIGNAL(invokeRemoteSignal(QString, CuteIPCMessage::Arguments))); connect(m_connection, SIGNAL(errorOccured(QString)), this, SIGNAL(setLastError(QString))); - connect(m_connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); - connect(m_connection, SIGNAL(socketDisconnected()), m_connection, SLOT(deleteLater())); + connect(m_connection, SIGNAL(socketDisconnected()), SIGNAL(disconnected())); + connect(m_connection, SIGNAL(socketDisconnected()), m_connection, SLOT(deleteLater())); connect(m_connection, SIGNAL(socketDisconnected()), socket, SLOT(deleteLater())); DEBUG << "CuteIPC:" << "Connected over network:" << host << port << connected; diff --git a/src/CuteIPCInterfaceWorker.h b/src/CuteIPCInterfaceWorker.h index ba115b8..19ed516 100644 --- a/src/CuteIPCInterfaceWorker.h +++ b/src/CuteIPCInterfaceWorker.h @@ -21,10 +21,10 @@ class CuteIPCInterfaceWorker : public QObject explicit CuteIPCInterfaceWorker(QObject* parent = 0); ~CuteIPCInterfaceWorker(); - bool isConnected(); + bool isConnected(); signals: void setLastError(const QString& error); - void disconnected(); + void disconnected(); // slot finish signals void connectToServerFinished(); From c815c8b474793b80783587ab0980e64478208e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Thu, 22 Mar 2018 09:05:08 +0100 Subject: [PATCH 05/10] more cleanups --- src/CuteIPCInterfaceConnection_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CuteIPCInterfaceConnection_p.h b/src/CuteIPCInterfaceConnection_p.h index 3b9eff1..74d55ea 100644 --- a/src/CuteIPCInterfaceConnection_p.h +++ b/src/CuteIPCInterfaceConnection_p.h @@ -22,7 +22,7 @@ class CuteIPCInterfaceConnection : public QObject void sendCallRequest(const QByteArray& request); void setReturnedObject(QGenericReturnArgument returnedObject); bool lastCallSuccessful() const; - bool isConnected(); + bool isConnected(); signals: void callFinished(); From fac538c134eef53083c3cb987eca59d7332ba61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Fri, 23 Mar 2018 14:29:50 +0100 Subject: [PATCH 06/10] connected() signal + cleanups --- include/CuteIPCInterface.h | 1 + src/CuteIPCInterface.cpp | 18 +++++++++++------- src/CuteIPCInterfaceConnection.cpp | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/CuteIPCInterface.h b/include/CuteIPCInterface.h index 818de36..63e4f8f 100644 --- a/include/CuteIPCInterface.h +++ b/include/CuteIPCInterface.h @@ -53,6 +53,7 @@ class CuteIPCInterface : public QObject QString lastError() const; signals: + void connected(); void disconnected(); diff --git a/src/CuteIPCInterface.cpp b/src/CuteIPCInterface.cpp index f79c47d..894a503 100644 --- a/src/CuteIPCInterface.cpp +++ b/src/CuteIPCInterface.cpp @@ -330,7 +330,6 @@ CuteIPCInterface::CuteIPCInterface(CuteIPCInterfacePrivate& dd, QObject* parent) bool CuteIPCInterface::isConnected() { Q_D(CuteIPCInterface); - d->q_ptr = this; return d->m_worker->isConnected(); } @@ -353,16 +352,18 @@ CuteIPCInterface::~CuteIPCInterface() bool CuteIPCInterface::connectToServer(const QString& name) { Q_D(CuteIPCInterface); - bool connected; + bool isConnected; QEventLoop loop; connect(d->m_worker, SIGNAL(connectToServerFinished()), &loop, SLOT(quit())); - QMetaObject::invokeMethod(d->m_worker, "connectToServer", Q_ARG(QString, name), Q_ARG(void*, &connected)); + QMetaObject::invokeMethod(d->m_worker, "connectToServer", Q_ARG(QString, name), Q_ARG(void*, &isConnected)); loop.exec(); d->m_localServer = name; + if (isConnected) + emit connected(); - return connected; + return isConnected; } /*! @@ -376,15 +377,18 @@ bool CuteIPCInterface::connectToServer(const QString& name) bool CuteIPCInterface::connectToServer(const QHostAddress& host, quint16 port) { Q_D(CuteIPCInterface); - bool connected; + bool isConnected; QEventLoop loop; connect(d->m_worker, SIGNAL(connectToServerFinished()), &loop, SLOT(quit())); - QMetaObject::invokeMethod(d->m_worker, "connectToTcpServer", Q_ARG(QHostAddress, host), Q_ARG(quint16, port), Q_ARG(void*, &connected)); + QMetaObject::invokeMethod(d->m_worker, "connectToTcpServer", Q_ARG(QHostAddress, host), Q_ARG(quint16, port), Q_ARG(void*, &isConnected)); loop.exec(); d->m_tcpAddress = qMakePair(host, port); - return connected; + if (isConnected) + emit connected(); + + return isConnected; } diff --git a/src/CuteIPCInterfaceConnection.cpp b/src/CuteIPCInterfaceConnection.cpp index 46050be..b4a3df1 100644 --- a/src/CuteIPCInterfaceConnection.cpp +++ b/src/CuteIPCInterfaceConnection.cpp @@ -15,7 +15,6 @@ CuteIPCInterfaceConnection::CuteIPCInterfaceConnection(QLocalSocket* socket, QOb m_socket(socket), m_nextBlockSize(0) { - connect(socket, SIGNAL(disconnected()), SIGNAL(socketDisconnected())); connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)), SLOT(errorOccured(QLocalSocket::LocalSocketError))); connect(socket, SIGNAL(readyRead()), SLOT(readyRead())); From 3263d751dd7f57693937699994f9eb2fc68ff15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Wed, 4 Apr 2018 16:19:08 +0200 Subject: [PATCH 07/10] win build --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5134a4d..ff3c6f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,4 +114,14 @@ ADD_SUBDIRECTORY(example/client) ADD_SUBDIRECTORY(example/server) ADD_SUBDIRECTORY(test) -INSTALL(TARGETS ${lib_target} LIBRARY DESTINATION lib) +#INSTALL(TARGETS ${lib_target} LIBRARY DESTINATION lib) + +if(WIN32) + INSTALL(TARGETS ${lib_target} + RUNTIME DESTINATION lib + ) +else() + INSTALL(TARGETS ${lib_target} + LIBRARY DESTINATION lib + ) +endif() From 95bf5357755984f50897e967505a6d49e0a8566b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Fri, 6 Apr 2018 07:06:37 +0200 Subject: [PATCH 08/10] QLocalServer::SocketOptions on listen() --- include/CuteIPCService.h | 5 +++-- src/CuteIPCService.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/CuteIPCService.h b/include/CuteIPCService.h index 080c39f..a18ec6b 100644 --- a/include/CuteIPCService.h +++ b/include/CuteIPCService.h @@ -4,6 +4,7 @@ // Qt #include #include +#include // Local class CuteIPCServicePrivate; @@ -16,8 +17,8 @@ class CuteIPCService : public QObject explicit CuteIPCService(QObject* parent = 0); ~CuteIPCService(); - bool listen(const QString& name = QString(), QObject* subject = 0); - bool listen(QObject* subject); + bool listen(const QString& name = QString(), QObject* subject = 0, QLocalServer::SocketOptions options=QLocalServer::NoOptions); + bool listen(QObject* subject, QLocalServer::SocketOptions options=QLocalServer::NoOptions); QString serverName() const; bool listenTcp(const QHostAddress& address = QHostAddress::Any, quint16 port = 0, QObject* subject = 0); diff --git a/src/CuteIPCService.cpp b/src/CuteIPCService.cpp index b853d28..e8ee6ce 100644 --- a/src/CuteIPCService.cpp +++ b/src/CuteIPCService.cpp @@ -303,7 +303,7 @@ QHostAddress CuteIPCService::tcpAddress() const object itself. Previous subject will be replaced. Returns true on success, otherwise false. */ -bool CuteIPCService::listen(const QString& serverName, QObject* subject) +bool CuteIPCService::listen(const QString& serverName, QObject* subject, QLocalServer::SocketOptions options) { Q_D(CuteIPCService); QString name = serverName; @@ -312,6 +312,7 @@ bool CuteIPCService::listen(const QString& serverName, QObject* subject) DEBUG << "Trying to listen" << name; d->registerLocalServer(); + d->m_localServer->setSocketOptions(options); bool ok = d->m_localServer->listen(name); if (!ok) @@ -335,9 +336,9 @@ bool CuteIPCService::listen(const QString& serverName, QObject* subject) /*! * This is an overloaded member function. */ -bool CuteIPCService::listen(QObject* subject) +bool CuteIPCService::listen(QObject* subject, QLocalServer::SocketOptions options) { - return listen(QString(), subject); + return listen(QString(), subject, options); } From d3d7139cf02e87dc17f8b42dd0e22a58ab63e37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Fri, 6 Apr 2018 11:24:45 +0200 Subject: [PATCH 09/10] translated russian messages to english --- src/CuteIPCInterface.cpp | 4 ++-- src/CuteIPCInterfaceConnection.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CuteIPCInterface.cpp b/src/CuteIPCInterface.cpp index 894a503..8b588fb 100644 --- a/src/CuteIPCInterface.cpp +++ b/src/CuteIPCInterface.cpp @@ -123,7 +123,7 @@ bool CuteIPCInterfacePrivate::sendSynchronousRequest(const QByteArray& request, if (!connected) { socket.disconnectFromServer(); - QString error("CuteIPC: Не удалось подключиться к серверу при вызове синхронного метода"); + QString error("CuteIPC: Could not connect to the server when the synchronous method was called"); qWarning() << error; _q_setLastError(error); return false; @@ -151,7 +151,7 @@ bool CuteIPCInterfacePrivate::sendSynchronousRequest(const QByteArray& request, if (!connected) { socket.disconnectFromHost(); - QString error("CuteIPC: Не удалось подключиться к серверу при вызове синхронного метода"); + QString error("CuteIPC: Could not connect to the server when the synchronous method was called"); qWarning() << error; _q_setLastError(error); return false; diff --git a/src/CuteIPCInterfaceConnection.cpp b/src/CuteIPCInterfaceConnection.cpp index b4a3df1..2d58de0 100644 --- a/src/CuteIPCInterfaceConnection.cpp +++ b/src/CuteIPCInterfaceConnection.cpp @@ -111,7 +111,7 @@ bool CuteIPCInterfaceConnection::readMessageFromSocket() } case CuteIPCMessage::AboutToCloseSocket: { - DEBUG << "Сервер сообщает о закрытии соединения"; + DEBUG << "The server reports that the connection is closed"; CuteIPCMessage message = CuteIPCMarshaller::demarshallMessage(m_block); CuteIPCMarshaller::freeArguments(message.arguments()); m_lastCallSuccessful = false; From d7226509bff6fcdd4752123e13c171b585ce01e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Collonvill=C3=A9?= Date: Tue, 10 Apr 2018 10:36:33 +0200 Subject: [PATCH 10/10] Prevent event loop if QCoreApplication is over --- src/CuteIPCService.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/CuteIPCService.cpp b/src/CuteIPCService.cpp index e8ee6ce..f75c066 100644 --- a/src/CuteIPCService.cpp +++ b/src/CuteIPCService.cpp @@ -6,6 +6,7 @@ #include "CuteIPCSignalHandler_p.h" // Qt +#include #include #include #include @@ -62,11 +63,13 @@ CuteIPCServicePrivate::~CuteIPCServicePrivate() } // Clients reaction timeout - QEventLoop loop; - QTimer timer; - QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.start(CLIENTS_DISCONNECT_TIMEOUT); - loop.exec(); + if ( QCoreApplication::instance() ) { + QEventLoop loop; + QTimer timer; + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(CLIENTS_DISCONNECT_TIMEOUT); + loop.exec(); + } }