Skip to content
Permalink
Browse files

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
  • Loading branch information...
EvanPurkhiser authored and mkrautz committed May 9, 2015
1 parent a96a8e7 commit 82ca8008030c223eed5b7baabd374e1f9538f8d4
Showing with 29 additions and 3 deletions.
  1. +7 −1 overlay_gl/overlay.c
  2. +11 −1 src/mumble/Overlay.cpp
  3. +11 −1 src/mumble/SocketRPC.cpp
@@ -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");
@@ -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()) {
@@ -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()) {

0 comments on commit 82ca800

Please sign in to comment.
You can’t perform that action at this time.