| 18 | } |
| 19 | |
| 20 | bool Server::start() |
| 21 | { |
| 22 | server_.setSocketOptions(QLocalServer::UserAccessOption); |
| 23 | |
| 24 | #if defined(Q_OS_MACOS) |
| 25 | const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + |
| 26 | "/" WS_SETTINGS_ORG "/ipc"; |
| 27 | QDir runtimeDirObj(runtimeDir); |
| 28 | if (!runtimeDirObj.mkpath(".")) { |
| 29 | qCCritical(LOG_IPC) << "IPC server could not create runtime directory:" << runtimeDir; |
| 30 | return false; |
| 31 | } |
| 32 | QFile::setPermissions(runtimeDir, |
| 33 | QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner); |
| 34 | const QString path = runtimeDir + "/" WS_PRODUCT_NAME_LOWER "-localipc.sock"; |
| 35 | QFile::remove(path); |
| 36 | bool b = server_.listen(path); |
| 37 | #elif defined(Q_OS_LINUX) |
| 38 | const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); |
| 39 | const QString path = runtimeDir + "/" WS_PRODUCT_NAME_LOWER "-localipc.sock"; |
| 40 | QFile::remove(path); |
| 41 | bool b = server_.listen(path); |
| 42 | #else |
| 43 | bool b = server_.listen(WS_APP_IDENTIFIER "8rM7bza5OR"); |
| 44 | #endif |
| 45 | |
| 46 | if (!b) |
| 47 | qCCritical(LOG_IPC) << "IPC server listen error:" << server_.errorString(); |
| 48 | return b; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | void Server::onNewConnection() |
no test coverage detected