17810N/Adiff -urN yelp.orig/src/Makefile.am yelp.new/src/Makefile.am
17810N/A--- yelp.orig/src/Makefile.am 2009-06-12 11:32:27.311453656 +0100
17810N/A+++ yelp.new/src/Makefile.am 2009-06-12 11:42:32.735084451 +0100
17810N/A@@ -28,7 +28,8 @@
17810N/A yelp-info-parser.c yelp-info-parser.h \
17810N/A gtkentryaction.c gtkentryaction.h \
17810N/A yelp-search.c yelp-search.h \
17810N/A- yelp-search-parser.c yelp-search-parser.h
17810N/A+ yelp-search-parser.c yelp-search-parser.h \
17810N/A+ yelp-tx.c yelp-tx.h
17810N/A
17810N/A YELP_DEFINES = \
17810N/A -DG_LOG_DOMAIN=\"Yelp\" \
17810N/Adiff -urN yelp.orig/src/yelp-main.c yelp.new/src/yelp-main.c
17810N/A--- yelp.orig/src/yelp-main.c 2009-06-12 11:32:27.316918730 +0100
17810N/A+++ yelp.new/src/yelp-main.c 2009-06-12 15:02:32.145926917 +0100
17810N/A@@ -30,6 +30,7 @@
17810N/A #include <dbus/dbus-glib-bindings.h>
17810N/A #include <string.h>
17810N/A #include <stdlib.h>
17810N/A+#include <zone.h>
17810N/A
17810N/A #ifdef WITH_SMCLIENT
17810N/A #include "eggsmclient.h"
17810N/A@@ -38,6 +39,7 @@
17810N/A #include "yelp-window.h"
17810N/A #include "yelp-base.h"
17810N/A #include "yelp-html.h"
17810N/A+#include "yelp-tx.h"
17810N/A
17810N/A static gchar *cache_dir;
17810N/A static gchar *open_urls;
17810N/A@@ -337,6 +339,7 @@
17810N/A gboolean session_started = FALSE;
17810N/A gchar *local_id;
17810N/A GOptionContext *context;
17810N/A+ char *command;
17810N/A
17810N/A g_thread_init(NULL);
17810N/A
17810N/A@@ -344,6 +347,15 @@
17810N/A bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
17810N/A textdomain(GETTEXT_PACKAGE);
17810N/A
17810N/A+ if (getzoneid () == 0 && /* global zone */
17810N/A+ tx_is_multi_label_session () &&
17810N/A+ tx_is_non_global_display_zone ()) {
17810N/A+ command = g_strdup_printf ("0:%s", g_strjoinv (" ", argv));
17810N/A+ tx_proxy_app_launch (command);
17810N/A+ g_free (command);
17810N/A+ return 0;
17810N/A+ }
17810N/A+
17810N/A local_id = (gchar *) g_getenv ("DESKTOP_STARTUP_ID");
17810N/A
17810N/A if (local_id != NULL && *local_id != '\0') {
17810N/Adiff -urN yelp.orig/src/yelp-tx.c yelp.new/src/yelp-tx.c
17810N/A--- yelp.orig/src/yelp-tx.c 1970-01-01 01:00:00.000000000 +0100
17810N/A+++ yelp.new/src/yelp-tx.c 2009-06-15 08:43:33.465438182 +0100
17810N/A@@ -0,0 +1,99 @@
17810N/A+/*
17810N/A+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
17810N/A+ * Use is subject to license terms.
17810N/A+ */
17810N/A+
17810N/A+#include <config.h>
17810N/A+#include <gdk/gdk.h>
17810N/A+#include <gdk/gdkx.h>
17810N/A+#include <X11/Xlib.h>
17810N/A+#include <stdlib.h>
17810N/A+#include <strings.h>
17810N/A+#include <user_attr.h>
17810N/A+#include <sys/types.h>
17810N/A+#include <unistd.h>
17810N/A+
17810N/A+#define ATOM "_LABEL_EXEC_COMMAND"
17810N/A+
17810N/A+gboolean
17810N/A+tx_is_multi_label_session (void)
17810N/A+{
17810N/A+ static int trusted = -1;
17810N/A+
17810N/A+ if (trusted < 0) {
17810N/A+ if (getenv ("TRUSTED_SESSION")) {
17810N/A+ trusted = 1;
17810N/A+ } else {
17810N/A+ trusted = 0;
17810N/A+ }
17810N/A+ }
17810N/A+
17810N/A+ return trusted ? TRUE : FALSE;
17810N/A+}
17810N/A+
17810N/A+gboolean
17810N/A+tx_is_non_global_display_zone (void)
17810N/A+{
17810N/A+ char *zoneid;
17810N/A+ Display *xdpy;
17810N/A+ Window root;
17810N/A+ Atom atom, utf8_string;
17810N/A+ unsigned long nitems;
17810N/A+ unsigned long bytesafter;
17810N/A+ unsigned char *prop_data = NULL;
17810N/A+ Atom type = None;
17810N/A+ int format;
17810N/A+
17810N/A+ xdpy = XOpenDisplay (NULL);
17810N/A+
17810N/A+ utf8_string = XInternAtom (xdpy, "UTF8_STRING", FALSE);
17810N/A+
17810N/A+ root = DefaultRootWindow (xdpy);
17810N/A+
17810N/A+ atom = XInternAtom (xdpy, "NAUTILUS_ACTIVE_DESKTOP_ID", FALSE);
17810N/A+
17810N/A+ gdk_error_trap_push ();
17810N/A+
17810N/A+ XGetWindowProperty (xdpy, root, atom, 0L, (long)1024, FALSE,
17810N/A+ utf8_string, &type, &format, &nitems,
17810N/A+ &bytesafter, (unsigned char **)&prop_data);
17810N/A+
17810N/A+ gdk_error_trap_pop ();
17810N/A+
17810N/A+ zoneid = strchr (prop_data, '_') + 1;
17810N/A+ if (strncmp (zoneid, "0", 1) == 0 ){
17810N/A+ return FALSE;
17810N/A+ } else {
17810N/A+ return TRUE;
17810N/A+ }
17810N/A+}
17810N/A+
17810N/A+void
17810N/A+tx_proxy_app_launch (char *command)
17810N/A+{
17810N/A+ Display *xdpy;
17810N/A+ Window root;
17810N/A+ Atom atom, utf8_string;
17810N/A+
17810N/A+ if (!command) return;
17810N/A+
17810N/A+ xdpy = XOpenDisplay (NULL);
17810N/A+
17810N/A+ utf8_string = XInternAtom (xdpy, "UTF8_STRING", FALSE);
17810N/A+
17810N/A+ root = DefaultRootWindow (xdpy);
17810N/A+
17810N/A+ atom = XInternAtom (xdpy, ATOM, FALSE);
17810N/A+
17810N/A+ gdk_error_trap_push ();
17810N/A+
17810N/A+ XChangeProperty (xdpy, root, atom, utf8_string, 8, PropModeReplace,
17810N/A+ command, strlen (command));
17810N/A+
17810N/A+ XSync (xdpy, False);
17810N/A+
17810N/A+ gdk_error_trap_pop ();
17810N/A+
17810N/A+ XCloseDisplay (xdpy);
17810N/A+}
17810N/A+
17810N/Adiff -urN yelp.orig/src/yelp-tx.h yelp.new/src/yelp-tx.h
17810N/A--- yelp.orig/src/yelp-tx.h 1970-01-01 01:00:00.000000000 +0100
17810N/A+++ yelp.new/src/yelp-tx.h 2009-06-15 08:41:35.454570771 +0100
17810N/A@@ -0,0 +1,9 @@
17810N/A+/*
17810N/A+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
17810N/A+ * Use is subject to license terms.
17810N/A+ */
17810N/A+
17810N/A+gboolean tx_is_multi_label_session (void);
17810N/A+gboolean tx_is_non_global_display_zone (void);
17810N/A+void tx_proxy_app_launch (char *command);
17810N/A+