| 81 | } |
| 82 | |
| 83 | bool singleInstanceHandler::isRunning(QString name, QStringList args) |
| 84 | { |
| 85 | DEBUG_SINGLEISNTANCE("singleInstanceHandler::isRunning %s", name.toLatin1().data()); |
| 86 | |
| 87 | QLocalSocket socket; |
| 88 | socket.connectToServer(name, QLocalSocket::ReadWrite); |
| 89 | |
| 90 | if (socket.waitForConnected()) |
| 91 | { |
| 92 | DEBUG_SINGLEISNTANCE( |
| 93 | "singleInstanceHandler::isRunning Connected to other instance. Sending data."); |
| 94 | |
| 95 | QByteArray buffer; |
| 96 | for (auto &item : args) |
| 97 | buffer.append(QString(item + "\n").toLatin1()); |
| 98 | socket.write(buffer); |
| 99 | socket.waitForBytesWritten(); |
| 100 | return true; |
| 101 | } |
| 102 | |
| 103 | DEBUG_SINGLEISNTANCE("singleInstanceHandler::isRunning we are the first session - %s", |
| 104 | socket.errorString().toLatin1().data()); |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | void singleInstanceHandler::listen(QString name) |
| 109 | { |
no test coverage detected