patches/SUNWtgnome-xagent-01-trusted-extensions.diff
author gheet
Thu, 17 Sep 2009 10:59:21 +0000
changeset 16577 3d25f7c9cb60
parent 16227 215acc7b5592
child 22462 e8b2379726ad
permissions -rw-r--r--
2009-09-17 Ghee Teo <[email protected]> Cleaned up patch by removing duplicate mod to file. * patches/SUNWtgnome-xagent-01-trusted-extensions.diff:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16577
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     1
diff -urN -x '*.orig' gnome-session-2.27.92/gnome-session/Makefile.am ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/Makefile.am
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     2
--- gnome-session-2.27.92/gnome-session/Makefile.am	2009-09-17 11:40:52.971520127 +0100
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     3
+++ ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/Makefile.am	2009-09-17 11:41:50.458212056 +0100
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     4
@@ -1,6 +1,6 @@
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     5
 NULL =
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     6
 
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     7
-bin_PROGRAMS = gnome-session
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     8
+bin_PROGRAMS = tsoljds-xagent
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
     9
 
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    10
 noinst_LTLIBRARIES = libgsmutil.la
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    11
 
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    12
@@ -42,7 +42,7 @@
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    13
 	$(DBUS_GLIB_LIBS)			\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    14
 	$(NULL)
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    15
 
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    16
-gnome_session_LDADD =				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    17
+tsoljds_xagent_LDADD =				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    18
 	libgsmutil.la 				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    19
 	$(top_builddir)/egg/libeggdesktopfile.la \
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    20
 	$(SM_LIBS)				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    21
@@ -55,7 +55,7 @@
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    22
 	$(EXECINFO_LIBS)			\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    23
 	$(NULL)
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    24
 
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    25
-gnome_session_SOURCES =				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    26
+tsoljds_xagent_SOURCES =				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    27
 	gsm-app.h				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    28
 	gsm-app.c				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    29
 	gsm-autostart-app.h			\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    30
@@ -88,7 +88,7 @@
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    31
 	gdm-signal-handler.c			\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    32
 	gdm-log.h				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    33
 	gdm-log.c				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    34
-	main.c					\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    35
+	xagent.c				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    36
 	gsm-store.h				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    37
 	gsm-store.c				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    38
 	gsm-inhibitor.h				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    39
@@ -99,8 +99,6 @@
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    40
 	gsm-session-save.h			\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    41
 	gsm-xsmp-server.c			\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    42
 	gsm-xsmp-server.h			\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    43
-	trusted.h				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    44
-	trusted.c				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    45
 	$(NULL)
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    46
 
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    47
 libgsmutil_la_LIBADD = 				\
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    48
diff -urN -x '*.orig' gnome-session-2.27.92/gnome-session/xagent.c ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/xagent.c
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    49
--- gnome-session-2.27.92/gnome-session/xagent.c	1970-01-01 01:00:00.000000000 +0100
3d25f7c9cb60 2009-09-17 Ghee Teo <[email protected]>
gheet
parents: 16227
diff changeset
    50
+++ ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/xagent.c	2009-09-17 11:41:50.457672613 +0100
14405
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
    51
@@ -0,0 +1,384 @@
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    52
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    53
+ *
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    54
+ * Copyright (C) 2006 Novell, Inc.
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    55
+ * Copyright (C) 2008 Red Hat, Inc.
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    56
+ * Copyright (C) 2008 Sun Microsystems, Inc.
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    57
+ *
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    58
+ * This program is free software; you can redistribute it and/or
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    59
+ * modify it under the terms of the GNU General Public License as
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    60
+ * published by the Free Software Foundation; either version 2 of the
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    61
+ * License, or (at your option) any later version.
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    62
+ *
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    63
+ * This program is distributed in the hope that it will be useful, but
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    64
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    65
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    66
+ * Lesser General Public License for more details.
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    67
+ *
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    68
+ * You should have received a copy of the GNU General Public License
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    69
+ * along with this program; if not, write to the Free Software
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    70
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    71
+ * 02111-1307, USA.
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    72
+ */
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    73
+
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    74
+#ifdef HAVE_CONFIG_H
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    75
+#include <config.h>
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    76
+#endif
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    77
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    78
+#include <libintl.h>
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    79
+#include <signal.h>
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    80
+#include <stdlib.h>
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    81
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    82
+#include <glib/gi18n.h>
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    83
+#include <glib/goption.h>
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    84
+#include <gdk/gdkx.h>
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    85
+#include <gtk/gtklabel.h>
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    86
+#include <gtk/gtkvbox.h>
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
    87
+#include <gtk/gtkprogressbar.h>
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    88
+#include <gtk/gtk.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    89
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    90
+#include <dbus/dbus.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    91
+#include <dbus/dbus-glib.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    92
+#include <dbus/dbus-glib-bindings.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    93
+#include <dbus/dbus-glib-lowlevel.h>
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    94
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    95
+#include <unistd.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    96
+#include <sys/types.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    97
+#include <sys/stat.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    98
+#include <fcntl.h>
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
    99
+
13233
76c7ab7e7164 2008-08-21 Stephen Browne <[email protected]>
stephen
parents: 13232
diff changeset
   100
+#include <string.h>
76c7ab7e7164 2008-08-21 Stephen Browne <[email protected]>
stephen
parents: 13232
diff changeset
   101
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   102
+#include "gsm-gconf.h"
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   103
+#include "gsm-util.h"
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   104
+#include "gsm-manager.h"
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   105
+#include "gsm-xsmp-server.h"
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   106
+#include "gsm-store.h"
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   107
+#include "trusted.h"
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   108
+
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   109
+#define TSOLJDS_MIGRATION_SCRIPT "/usr/dt/config/tsoljds-migration"
13233
76c7ab7e7164 2008-08-21 Stephen Browne <[email protected]>
stephen
parents: 13232
diff changeset
   110
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   111
+#define GSM_DBUS_NAME "org.gnome.SessionManager"
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   112
+
13233
76c7ab7e7164 2008-08-21 Stephen Browne <[email protected]>
stephen
parents: 13232
diff changeset
   113
+
14405
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   114
+gboolean defaultsession = FALSE;
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   115
+gboolean nosession = FALSE;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   116
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   117
+static GOptionEntry entries[] = {
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   118
+  { "defaultsession", '\0', 0, G_OPTION_ARG_NONE, &defaultsession,
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   119
+    N_("Do not load user-specified applications"),
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   120
+    NULL },
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   121
+  { "nosession", '\0', 0, G_OPTION_ARG_NONE, &nosession,
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   122
+    N_("Do not startup any applications"),
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   123
+    NULL },
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   124
+  { NULL, 0, 0, 0, NULL, NULL, NULL }
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   125
+};
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   126
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   127
+int
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   128
+XAgentXErrorHandler (Display *dpy, XErrorEvent *error)
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   129
+{
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   130
+  char err_msg[132];
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   131
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   132
+  XGetErrorText (dpy, error->error_code, err_msg, sizeof (err_msg));
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   133
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   134
+  return 0;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   135
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   136
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   137
+static void
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   138
+so_long_pipe (gpointer data)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   139
+{
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   140
+  /*
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   141
+   * The pipe is bust which probably means the stripe
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   142
+   * has died. So there's nothing to do but die.
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   143
+   */
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   144
+  exit (2);
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   145
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   146
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   147
+static void
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   148
+parse_exec_string (char *exec, int *screen, char **command)
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   149
+{
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   150
+  gchar **tokens = g_strsplit (exec, ":", 2);
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   151
+
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   152
+  if (tokens[0]) {
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   153
+	*screen = atoi (tokens[0]);
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   154
+  } else {
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   155
+	*screen = 0;
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   156
+  }
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   157
+
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   158
+  if (tokens[1]) {
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   159
+	*command = g_strdup (tokens[1]);
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   160
+  } else {
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   161
+	*command = g_strdup (exec);
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   162
+  }
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   163
+
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   164
+  g_strfreev (tokens);
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   165
+
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   166
+}
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   167
+
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   168
+static gboolean
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   169
+handle_pipe_input (GIOChannel *source,
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   170
+                   GIOCondition condition,
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   171
+                   gpointer data)
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   172
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   173
+#define BUFSIZE 1024
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   174
+  gsize byteread, pos;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   175
+  gchar *str;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   176
+  GError *error = NULL;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   177
+  GIOStatus status=0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   178
+  int screen_num;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   179
+  gchar *real_cmd;
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   180
+  GdkDisplay *gdk_dpy;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   181
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   182
+  if (condition & G_IO_ERR) return FALSE;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   183
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   184
+  if (condition & G_IO_HUP) return FALSE;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   185
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   186
+  if (condition & G_IO_IN) {
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   187
+    status = g_io_channel_read_line (source, &str, &byteread, &pos, &error);
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   188
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   189
+    switch (status)
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   190
+    {
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   191
+	case G_IO_STATUS_NORMAL:
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   192
+	str[pos] = '\0';
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   193
+        parse_exec_string (str, &screen_num, &real_cmd);
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   194
+        gdk_dpy = gdk_display_get_default ();
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   195
+	gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   196
+                                          screen_num), real_cmd, &error);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   197
+        g_free (real_cmd);
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   198
+        return TRUE;
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   199
+	case G_IO_STATUS_AGAIN:
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   200
+	return FALSE;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   201
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   202
+	case G_IO_STATUS_EOF:
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   203
+	sleep(1);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   204
+	return FALSE;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   205
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   206
+	case G_IO_STATUS_ERROR:
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   207
+	return FALSE;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   208
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   209
+	default:
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   210
+	g_assert_not_reached ();
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   211
+	return FALSE;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   212
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   213
+  }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   214
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   215
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   216
+static void
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   217
+on_bus_name_lost (DBusGProxy *bus_proxy,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   218
+                  const char *name,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   219
+                  gpointer    data)
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   220
+{
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   221
+        g_warning ("Lost name on bus: %s, exiting", name);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   222
+        exit (1);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   223
+}
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   224
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   225
+static gboolean
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   226
+acquire_name_on_proxy (DBusGProxy *bus_proxy,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   227
+                       const char *name)
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   228
+{
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   229
+        GError     *error;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   230
+        guint       result;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   231
+        gboolean    res;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   232
+        gboolean    ret;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   233
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   234
+        ret = FALSE;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   235
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   236
+        if (bus_proxy == NULL) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   237
+                goto out;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   238
+        }
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   239
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   240
+        error = NULL;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   241
+        res = dbus_g_proxy_call (bus_proxy,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   242
+                                 "RequestName",
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   243
+                                 &error,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   244
+                                 G_TYPE_STRING, name,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   245
+                                 G_TYPE_UINT, 0,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   246
+                                 G_TYPE_INVALID,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   247
+                                 G_TYPE_UINT, &result,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   248
+                                 G_TYPE_INVALID);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   249
+        if (! res) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   250
+                if (error != NULL) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   251
+                        g_warning ("Failed to acquire %s: %s", name, error->message);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   252
+                        g_error_free (error);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   253
+                } else {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   254
+                        g_warning ("Failed to acquire %s", name);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   255
+                }
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   256
+                goto out;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   257
+        }
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   258
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   259
+        if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   260
+                if (error != NULL) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   261
+                        g_warning ("Failed to acquire %s: %s", name, error->message);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   262
+                        g_error_free (error);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   263
+                } else {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   264
+                        g_warning ("Failed to acquire %s", name);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   265
+                }
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   266
+                goto out;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   267
+        }
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   268
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   269
+        /* register for name lost */
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   270
+        dbus_g_proxy_add_signal (bus_proxy,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   271
+                                 "NameLost",
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   272
+                                 G_TYPE_STRING,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   273
+                                 G_TYPE_INVALID);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   274
+        dbus_g_proxy_connect_signal (bus_proxy,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   275
+                                     "NameLost",
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   276
+                                     G_CALLBACK (on_bus_name_lost),
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   277
+                                     NULL,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   278
+                                     NULL);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   279
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   280
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   281
+        ret = TRUE;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   282
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   283
+ out:
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   284
+        return ret;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   285
+}
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   286
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   287
+static gboolean
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   288
+acquire_name (void)
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   289
+{
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   290
+        DBusGProxy      *bus_proxy;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   291
+        GError          *error;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   292
+        DBusGConnection *connection;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   293
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   294
+        error = NULL;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   295
+        connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   296
+        if (connection == NULL) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   297
+                gsm_util_init_error (TRUE,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   298
+                                     "Could not connect to session bus: %s",
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   299
+                                     error->message);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   300
+                /* not reached */
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   301
+        }
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   302
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   303
+        bus_proxy = dbus_g_proxy_new_for_name (connection,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   304
+                                               DBUS_SERVICE_DBUS,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   305
+                                               DBUS_PATH_DBUS,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   306
+                                               DBUS_INTERFACE_DBUS);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   307
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   308
+        if (! acquire_name_on_proxy (bus_proxy, GSM_DBUS_NAME) ) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   309
+                gsm_util_init_error (TRUE,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   310
+                                     "Could not acquire name on session bus: %s",
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   311
+                                     error->message);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   312
+                /* not reached */
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   313
+        }
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   314
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   315
+        g_object_unref (bus_proxy);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   316
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   317
+        return TRUE;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   318
+}
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   319
+
14405
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   320
+static void
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   321
+xagent_start_dbus (void) {
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   322
+
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   323
+	gchar *out, *err, *chr;
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   324
+	gint status;
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   325
+	GError *error;
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   326
+	
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   327
+	g_spawn_command_line_sync ("/usr/bin/dbus-launch --exit-with-session",
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   328
+				   &out, &err, &status, &error);
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   329
+
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   330
+	chr = strchr (out, '\n');
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   331
+	*chr = '\0';
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   332
+
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   333
+	putenv (out);
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   334
+}
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   335
+
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   336
+static void
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   337
+xagent_start_default_clients (void) {
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   338
+	
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   339
+	char **app_path = NULL;
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   340
+
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   341
+	char *default_apps[] = {"/usr/bin/nautilus --no-default-window", 
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   342
+				NULL };
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   343
+
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   344
+	for (app_path = default_apps; *app_path != NULL; app_path++) {
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   345
+		g_spawn_command_line_async (*app_path, NULL);
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   346
+	}
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   347
+}
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   348
+
12871
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   349
+int
156442027c9f 2008-07-21 Stephen Browne <[email protected]>
stephen
parents: 12617
diff changeset
   350
+main (int argc, char **argv)
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   351
+{
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   352
+        struct sigaction sa;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   353
+        GError          *error;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   354
+        char            *display_str;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   355
+	Display *xdisp;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   356
+	GdkDisplay *gdisp;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   357
+        GsmManager      *manager;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   358
+        GsmStore        *client_store;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   359
+        GsmXsmpServer   *xsmp_server;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   360
+	int dummy_fd, pipe_fd;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   361
+	GIOChannel *channel;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   362
+	guint result;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   363
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   364
+        bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   365
+        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   366
+        textdomain (GETTEXT_PACKAGE);
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   367
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   368
+	int fd = open ("/dev/null", O_RDWR);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   369
+ 	dup2 (fd, 1);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   370
+	dup2 (fd, 2);
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   371
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   372
+	sa.sa_handler = SIG_IGN;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   373
+	sa.sa_flags = 0;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   374
+	sigemptyset (&sa.sa_mask);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   375
+	sigaction (SIGPIPE, &sa, 0);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   376
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   377
+	if ((pipe_fd = dup (fileno(stdin))) != -1) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   378
+		close (fileno(stdin));
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   379
+		dummy_fd = open ("/dev/null", O_RDONLY);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   380
+		fcntl (pipe_fd, F_SETFD, 1);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   381
+	} else {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   382
+		pipe_fd = fileno (stdin);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   383
+	}
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   384
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   385
+        error = NULL;
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   386
+        gtk_init_with_args (&argc, &argv,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   387
+                            (char *) _(" - the GNOME session manager"),
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   388
+                            entries, GETTEXT_PACKAGE,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   389
+                            &error);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   390
+        if (error != NULL) {
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   391
+                gsm_util_init_error (TRUE, "%s", error->message);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   392
+        }
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   393
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   394
+        /* Set DISPLAY explicitly for all our children, in case --display
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   395
+         * was specified on the command line.
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   396
+         */
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   397
+        display_str = gdk_get_display ();
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   398
+        gsm_util_setenv ("DISPLAY", display_str);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   399
+        g_free (display_str);
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   400
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   401
+	gdisp = gdk_display_get_default ();
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   402
+	xdisp = gdk_x11_display_get_xdisplay (gdisp);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   403
+	XInternAtom (xdisp, "GNOME_SM_DESKTOP", FALSE);
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   404
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   405
+	XSetErrorHandler (XAgentXErrorHandler);
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   406
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   407
+	if (!nosession) {
14405
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   408
+ xagent_start_dbus ();        	/* Start up gconfd if not already running. */
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   409
+        	gsm_gconf_init ();
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   410
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   411
+        	gsm_gconf_check ();
13235
18437e8f6a57 2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents: 13233
diff changeset
   412
+	}
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   413
+	
13235
18437e8f6a57 2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents: 13233
diff changeset
   414
+	if (g_file_test (TSOLJDS_MIGRATION_SCRIPT, G_FILE_TEST_IS_EXECUTABLE)) {
18437e8f6a57 2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents: 13233
diff changeset
   415
+		system (TSOLJDS_MIGRATION_SCRIPT);
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   416
+	}
13235
18437e8f6a57 2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents: 13233
diff changeset
   417
+	/*start the session*/
14405
c6935ce9119d 2008-10-01 Stephen Browne <[email protected]>
stephen
parents: 13235
diff changeset
   418
+	xagent_start_default_clients ();
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   419
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   420
+	/* we may have to spawn an exec immediately */
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   421
+	gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdisp, 0),
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   422
+					  g_getenv("LABEL_EXEC_COMMAND"), &error);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   423
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   424
+	channel = g_io_channel_unix_new (pipe_fd);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   425
+	result = g_io_add_watch_full (channel, G_PRIORITY_HIGH,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   426
+				      G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   427
+				      (GIOFunc)handle_pipe_input, NULL, 
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   428
+				      so_long_pipe);
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   429
+
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   430
+        gtk_main ();
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   431
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   432
+        gsm_gconf_shutdown ();
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   433
+
13200
ce28d13036a6 2008-08-20 Stephen Browne <[email protected]>
stephen
parents: 13029
diff changeset
   434
+        return 0;
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   435
+}