diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp index 127c51fa1f..81e23760d6 100644 --- a/src/mirall/socketapi.cpp +++ b/src/mirall/socketapi.cpp @@ -35,6 +35,11 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#include +#endif + + // This is the version that is returned when the client asks for the VERSION. // The first number should be changed if there is an incompatible change that breaks old clients. // The second number should be changed when there are new features. @@ -232,14 +237,26 @@ SocketApi::SocketApi(QObject* parent) } #else QString socketPath; + if (Utility::isWindows()) { socketPath = QLatin1String("\\\\.\\pipe\\") + Theme::instance()->appName(); } else { - socketPath = MirallConfigFile().configPathWithAppName().append(QLatin1String("socket")); + QString runtimeDir; +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); +#else + runtimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR")); +#endif + socketPath = runtimeDir + "/" + Theme::instance()->appName() + "/socket"; } QLocalServer::removeServer(socketPath); + QFileInfo info(socketPath); + if (!info.dir().exists()) { + bool result = info.dir().mkpath("."); + DEBUG << "creating" << info.dir().path() << result; + } if(!_localServer.listen(socketPath)) { DEBUG << "can't start server" << socketPath; } else {