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