lib/vmCheck/Makefile \
lib/vmSignal/Makefile \
lib/wiper/Makefile \
+ lib/xdg/Makefile \
services/Makefile \
services/vmtoolsd/Makefile \
services/plugins/Makefile \
SUBDIRS += vmCheck
SUBDIRS += vmSignal
SUBDIRS += wiper
+SUBDIRS += xdg
*********************************************************/
/*
- * ghiX11.h
+ * xdg.h --
*
- * Declarations specific to GHI/X11.
+ * vmware-xdg-* script wrapper library.
*/
-#ifndef _GHIX11_H_
-#define _GHIX11_H_
+#ifndef _VMWARE_XDG_H_
+#define _VMWARE_XDG_H_
#define INCLUDE_ALLOW_USERLEVEL
#include "includeCheck.h"
-const char *GHIX11DetectDesktopEnv(void);
+extern const char *Xdg_DetectDesktopEnv(void);
-#endif // ifndef _GHIX11_H_
+#endif // ifndef _VMWARE_XDG_H_
--- /dev/null
+################################################################################
+### Copyright 2010 VMware, Inc. All rights reserved.
+###
+### This program is free software; you can redistribute it and/or modify
+### it under the terms of version 2 of the GNU General Public License as
+### published by the Free Software Foundation.
+###
+### This program is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with this program; if not, write to the Free Software
+### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+################################################################################
+
+noinst_LTLIBRARIES = libXdg.la
+
+libXdg_la_SOURCES =
+libXdg_la_SOURCES += xdg.c
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2010 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * xdg.c --
+ *
+ * vmware-xdg-* script wrapper library.
+ */
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "vmware.h"
+#include "vmstdio.h"
+#include "xdg.h"
+
+
+/*
+ * Local data
+ */
+
+
+/* Name of helper script used by Xdg_DetectDesktopEnv. */
+static const char xdgDetectDEExec[] = "vmware-xdg-detect-de";
+
+
+/*
+ * Global functions
+ */
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Xdg_DetectDesktopEnv --
+ *
+ * Captures output from external vmware-xdg-detect-de script to determine
+ * which desktop environment we're running under.
+ *
+ * Results:
+ * Returns a pointer to a string specifying the desktop environment on
+ * success or NULL on failure.
+ *
+ * This function only guarantees that the returned string matches the
+ * pattern ^[A-Z]*$.
+ *
+ * Side effects:
+ * Allocates memory for outbuf on first call for duration of program.
+ * Uses popen(), relying on $PATH, to find and execute xdgDetectDeExec.
+ * Caller must not modify returned string.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+const char *
+Xdg_DetectDesktopEnv(void)
+{
+ static char *outbuf = NULL;
+
+ if (outbuf == NULL) {
+ FILE *cmdPipe = popen(xdgDetectDEExec, "r");
+
+ if (cmdPipe) {
+ static const size_t maxSize = sizeof "TEHLONGISTDESKTOPENVEVAR";
+ size_t outLen; // Doesn't include NUL.
+ int status;
+
+ if (StdIO_ReadNextLine(cmdPipe, &outbuf, maxSize, &outLen)
+ == StdIO_Success) {
+ char *i;
+
+ for (i = outbuf; i < &outbuf[outLen]; i++) {
+ /* We expect a string in all capitals. */
+ if (*i < 'A' || *i > 'Z') {
+ free(outbuf);
+ outbuf = NULL;
+ break;
+ }
+ }
+ }
+
+ status = pclose(cmdPipe);
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
+ free(outbuf);
+ outbuf = NULL;
+ }
+ }
+ }
+
+ return outbuf;
+}
--- /dev/null
+#!/bin/sh
+#
+# vmware-xdg-detect-de --
+#
+# Determines which Freedesktop.Org compliant desktop environment we're
+# running under.
+#
+# usage: vmware-xdg-detect-de
+#
+# Simply prints the detected environment (GNOME, KDE, or XFCE). Shamelessly
+# lifted from detectDE() routine found in many Portland xdg-* scripts.
+#
+
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+if [ x"$KDE_FULL_SESSION" = x"true" ]; then
+ DE=KDE;
+elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then
+ DE=GNOME;
+elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager >/dev/null 2>&1` ; then
+ DE=GNOME;
+elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then
+ DE=XFCE;
+fi
+
+if [ x"$DE" = x ]; then
+ exit 1
+fi
+
+echo $DE
libunity_la_LIBADD += $(top_builddir)/lib/image/libImage.la
libunity_la_LIBADD += $(top_builddir)/lib/raster/libRaster.la
libunity_la_LIBADD += $(top_builddir)/lib/region/libRegion.la
+libunity_la_LIBADD += $(top_builddir)/lib/xdg/libXdg.la
libunity_la_SOURCES =
#include "vmware.h"
}
-#include "ghiX11.h"
#include "ghiX11icon.h"
#include "mntinfo.h"
#include "guest_msg_def.h"
#include "Uri.h"
+#include "xdg.h"
};
#define URI_TEXTRANGE_EQUAL(textrange, str) \
#include "appUtil.h"
#include "ghIntegration.h"
#include "ghIntegrationInt.h"
-#include "ghiX11.h"
#include "ghiX11icon.h"
#ifdef REDIST_GMENU
Bool
GHIPlatformIsSupported(void)
{
- return GHIX11DetectDesktopEnv() != NULL;
+ const char *desktopEnv = Xdg_DetectDesktopEnv();
+ return (strcmp(desktopEnv, "GNOME") == 0) || (strcmp(desktopEnv, "KDE") == 0);
}
ghip->nativeEnviron.push_back(*tmp);
}
- desktopEnv = GHIX11DetectDesktopEnv();
+ desktopEnv = Xdg_DetectDesktopEnv();
g_desktop_app_info_set_desktop_env(desktopEnv);
#ifdef REDIST_GMENU
}
} else {
std::vector<Glib::ustring> argv;
- Glib::ustring de = GHIX11DetectDesktopEnv();
+ Glib::ustring de = Xdg_DetectDesktopEnv();
// XXX Really we should just use xdg-open exclusively, but xdg-open
// as shipped with xdg-utils 1.0.2 is broken. It is fixed
// in portland CVS, but we need to import into modsource and
}
-/*
- *-----------------------------------------------------------------------------
- *
- * GHIX11DetectDesktopEnv --
- *
- * Query environment and/or root window properties to determine if we're
- * under GNOME or KDE.
- *
- * XXX Consider moving this to another library.
- * XXX Investigate whether this requires legal review, since it's cribbed
- * from xdg-utils' detectDE subroutine (MIT license).
- * XXX Add the _DT_SESSION bit for XFCE detection.
- *
- * Results:
- * Pointer to a valid string on success, NULL on failure.
- *
- * Side effects:
- * None.
- *
- *-----------------------------------------------------------------------------
- */
-
-const char *
-GHIX11DetectDesktopEnv(void)
-{
- static const char *desktopEnvironment = NULL;
- const char *tmp;
-
- if (desktopEnvironment) {
- return desktopEnvironment;
- }
-
- if (g_strcmp0(g_getenv("KDE_FULL_SESSION"), "true") == 0) {
- desktopEnvironment = "KDE";
- } else if ((tmp = g_getenv("GNOME_DESKTOP_SESSION_ID")) && *tmp) {
- desktopEnvironment = "GNOME";
- }
-
- return desktopEnvironment;
-}
-
-
/*
*-----------------------------------------------------------------------------
*
$(INSTALL) -d $(DESTDIR)/usr/share/pixmaps/vmware
$(INSTALL) -m 644 bigIcon.xpm \
$(DESTDIR)/usr/share/pixmaps/vmware/vmware-toolbox.xpm
+ $(INSTALL) -m 755 ../scripts/common/vmware-xdg-detect-de \
+ $(DESTDIR)$(bindir)
uninstall-hook:
rm -f $(DESTDIR)$(datadir)/share/applications/vmware-toolbox.desktop
rm -rf $(DESTDIR)/usr/share/pixmaps/vmware