Follow XDG directory spec for RPC socket & overlay pipe

If the XDG_RUNTIME_DIR environment variable is present the overlay
pipe and RPC socket will be created at..

    $XDG_RUNTIME_DIR/MumbleSocket
    $XDG_RUNTIME_DIR/MumbleOverlayPipe
This commit is contained in:
Evan Purkhiser 2015-05-09 03:04:26 -07:00 committed by Mikkel Krautz
parent a96a8e79a2
commit 82ca800803
3 changed files with 29 additions and 3 deletions

View File

@ -180,7 +180,13 @@ static void newContext(Context * ctx) {
}
}
if (home) {
char *xdgRuntimeDir = getenv("XDG_RUNTIME_DIR");
if (xdgRuntimeDir != NULL) {
ctx->saName.sun_family = PF_UNIX;
strcpy(ctx->saName.sun_path, xdgRuntimeDir);
strcat(ctx->saName.sun_path, "/MumbleOverlayPipe");
} else if (home) {
ctx->saName.sun_family = PF_UNIX;
strcpy(ctx->saName.sun_path, home);
strcat(ctx->saName.sun_path, "/.MumbleOverlayPipe");

View File

@ -92,7 +92,17 @@ Overlay::Overlay() : QObject() {
#ifdef Q_OS_WIN
pipepath = QLatin1String("MumbleOverlayPipe");
#else
pipepath = QDir::home().absoluteFilePath(QLatin1String(".MumbleOverlayPipe"));
{
QString xdgRuntimePath = QProcessEnvironment::systemEnvironment().value(QLatin1String("XDG_RUNTIME_DIR"));
QDir xdgRuntimeDir = QDir(xdgRuntimePath);
if (! xdgRuntimePath.isNull() && xdgRuntimeDir.exists()) {
pipepath = xdgRuntimeDir.absoluteFilePath(QLatin1String("MumbleOverlayPipe"));
} else {
pipepath = QDir::home().absoluteFilePath(QLatin1String(".MumbleOverlayPipe"));
}
}
{
QFile f(pipepath);
if (f.exists()) {

View File

@ -231,7 +231,17 @@ SocketRPC::SocketRPC(const QString &basename, QObject *p) : QObject(p) {
#ifdef Q_OS_WIN
pipepath = basename;
#else
pipepath = QDir::home().absoluteFilePath(QLatin1String(".") + basename + QLatin1String("Socket"));
{
QString xdgRuntimePath = QProcessEnvironment::systemEnvironment().value(QLatin1String("XDG_RUNTIME_DIR"));
QDir xdgRuntimeDir = QDir(xdgRuntimePath);
if (! xdgRuntimePath.isNull() && xdgRuntimeDir.exists()) {
pipepath = xdgRuntimeDir.absoluteFilePath(basename + QLatin1String("Socket"));
} else {
pipepath = QDir::home().absoluteFilePath(QLatin1String(".") + basename + QLatin1String("Socket"));
}
}
{
QFile f(pipepath);
if (f.exists()) {