1.1.9
by Gauvain Pocentek
Import upstream version 4.3.99.2 |
1 |
/* $Id: xfsm-compat-gnome.c 22949 2006-08-30 11:15:03Z benny $ */
|
1.1.1
by Yves-Alexis Perez
Import upstream version 4.2.3 |
2 |
/*-
|
1.1.2
by Jani Monoses
Import upstream version 4.3.0svn+r19775 |
3 |
* Copyright (c) 2004-2005 Benedikt Meurer <benny@xfce.org>
|
1.1.1
by Yves-Alexis Perez
Import upstream version 4.2.3 |
4 |
* All rights reserved.
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2, or (at your option)
|
|
9 |
* any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
19 |
* 02111-1307, USA.
|
|
20 |
*
|
|
21 |
* Most parts of this file where taken from gnome-session.
|
|
22 |
*/
|
|
23 |
||
24 |
#ifdef HAVE_CONFIG_H
|
|
25 |
#include <config.h> |
|
26 |
#endif
|
|
27 |
||
28 |
#ifdef HAVE_SYS_TYPES_H
|
|
29 |
#include <sys/types.h> |
|
30 |
#endif
|
|
31 |
#ifdef HAVE_SYS_WAIT_H
|
|
32 |
#include <sys/wait.h> |
|
33 |
#endif
|
|
34 |
||
35 |
#ifdef HAVE_SIGNAL_H
|
|
36 |
#include <signal.h> |
|
37 |
#endif
|
|
38 |
#ifdef HAVE_STDLIB_H
|
|
39 |
#include <stdlib.h> |
|
40 |
#endif
|
|
41 |
#ifdef HAVE_STRING_H
|
|
42 |
#include <string.h> |
|
43 |
#endif
|
|
44 |
#ifdef HAVE_UNISTD_H
|
|
45 |
#include <unistd.h> |
|
46 |
#endif
|
|
47 |
||
48 |
#include <X11/Xatom.h> |
|
49 |
#include <X11/Xlib.h> |
|
50 |
||
51 |
#include <gdk/gdkx.h> |
|
52 |
||
53 |
#include <libxfce4util/libxfce4util.h> |
|
54 |
||
1.1.2
by Jani Monoses
Import upstream version 4.3.0svn+r19775 |
55 |
#ifdef HAVE_GNOME
|
1.1.1
by Yves-Alexis Perez
Import upstream version 4.2.3 |
56 |
#include <gconf/gconf-client.h> |
57 |
#endif
|
|
58 |
||
59 |
#include <xfce4-session/xfsm-compat-gnome.h> |
|
60 |
||
61 |
||
1.1.2
by Jani Monoses
Import upstream version 4.3.0svn+r19775 |
62 |
#ifdef HAVE_GNOME
|
1.1.1
by Yves-Alexis Perez
Import upstream version 4.2.3 |
63 |
#define ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility"
|
64 |
#define AT_STARTUP_KEY "/desktop/gnome/accessibility/startup/exec_ats"
|
|
65 |
||
66 |
static GConfClient *gnome_conf_client = NULL; |
|
67 |
#endif
|
|
68 |
||
69 |
||
70 |
static pid_t gnome_keyring_daemon_pid = 0; |
|
71 |
static Window gnome_smproxy_window = None; |
|
72 |
||
73 |
||
74 |
static void |
|
75 |
gnome_keyring_daemon_startup (void) |
|
76 |
{
|
|
77 |
GError *error = NULL; |
|
78 |
gchar *sout; |
|
79 |
gchar **lines; |
|
80 |
gint status; |
|
81 |
long pid; |
|
82 |
gchar *pid_str; |
|
83 |
gchar *end; |
|
84 |
||
85 |
// FIXME: use async spawn!
|
|
86 |
g_spawn_command_line_sync ("gnome-keyring-daemon", |
|
87 |
&sout, NULL, &status, &error); |
|
88 |
||
89 |
if (error != NULL) |
|
90 |
{
|
|
91 |
g_printerr ("Failed to run gnome-keyring-daemon: %s\n", |
|
92 |
error->message); |
|
93 |
g_error_free (error); |
|
94 |
}
|
|
95 |
else
|
|
96 |
{
|
|
97 |
if (WIFEXITED (status) && WEXITSTATUS (status) == 0 && sout != NULL) |
|
98 |
{
|
|
99 |
lines = g_strsplit (sout, "\n", 3); |
|
100 |
||
101 |
if (lines[0] != NULL && lines[1] != NULL |
|
102 |
&& g_str_has_prefix (lines[1], "GNOME_KEYRING_PID=")) |
|
103 |
{
|
|
104 |
pid_str = lines[1] + strlen ("GNOME_KEYRING_PID="); |
|
105 |
pid = strtol (pid_str, &end, 10); |
|
106 |
||
107 |
if (end != pid_str) |
|
108 |
{
|
|
109 |
gnome_keyring_daemon_pid = pid; |
|
110 |
xfce_putenv (lines[0]); |
|
111 |
}
|
|
112 |
}
|
|
113 |
||
114 |
g_strfreev (lines); |
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
/* daemon failed for some reason */
|
|
119 |
g_printerr ("gnome-keyring-daemon failed to start correctly, " |
|
120 |
"exit code: %d\n", WEXITSTATUS (status)); |
|
121 |
}
|
|
122 |
||
123 |
g_free (sout); |
|
124 |
}
|
|
125 |
}
|
|
126 |
||
127 |
static void |
|
128 |
gnome_keyring_daemon_shutdown (void) |
|
129 |
{
|
|
130 |
if (gnome_keyring_daemon_pid != 0) |
|
131 |
{
|
|
132 |
kill (gnome_keyring_daemon_pid, SIGTERM); |
|
133 |
gnome_keyring_daemon_pid = 0; |
|
134 |
}
|
|
135 |
}
|
|
136 |
||
137 |
||
1.1.2
by Jani Monoses
Import upstream version 4.3.0svn+r19775 |
138 |
#ifdef HAVE_GNOME
|
1.1.1
by Yves-Alexis Perez
Import upstream version 4.2.3 |
139 |
static void |
140 |
gnome_ast_startup (void) |
|
141 |
{
|
|
142 |
GError *error = NULL; |
|
143 |
GSList *list; |
|
144 |
GSList *lp; |
|
145 |
gchar *path; |
|
146 |
||
147 |
list = gconf_client_get_list (gnome_conf_client, AT_STARTUP_KEY, |
|
148 |
GCONF_VALUE_STRING, &error); |
|
149 |
||
150 |
if (error != NULL) |
|
151 |
{
|
|
152 |
g_warning ("Failed to query value of " AT_STARTUP_KEY ": %s", |
|
153 |
error->message); |
|
154 |
g_error_free (error); |
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
for (lp = list; lp != NULL; lp = lp->next) |
|
159 |
{
|
|
160 |
path = g_find_program_in_path ((const gchar *) lp->data); |
|
161 |
if (path != NULL) |
|
162 |
{
|
|
163 |
g_spawn_command_line_async (path, &error); |
|
164 |
if (error != NULL) |
|
165 |
{
|
|
166 |
g_warning ("Failed to execute assistive helper %s: %s", |
|
167 |
path, error->message); |
|
168 |
g_error_free (error); |
|
169 |
}
|
|
170 |
else
|
|
171 |
{
|
|
172 |
/* give it some time to fire up */
|
|
173 |
g_usleep (50 * 1000); |
|
174 |
}
|
|
175 |
g_free (path); |
|
176 |
}
|
|
177 |
g_free (lp->data); |
|
178 |
}
|
|
179 |
g_slist_free (list); |
|
180 |
}
|
|
181 |
}
|
|
182 |
#endif
|
|
183 |
||
184 |
||
185 |
static void |
|
186 |
xfsm_compat_gnome_smproxy_startup (void) |
|
187 |
{
|
|
188 |
Atom gnome_sm_proxy; |
|
189 |
Display *dpy; |
|
190 |
Window root; |
|
191 |
||
192 |
gdk_error_trap_push (); |
|
193 |
||
194 |
/* Set GNOME_SM_PROXY property, since some apps (like OOo) seem to require
|
|
195 |
* it to behave properly. Thanks to Jasper/Francois for reporting this.
|
|
196 |
* This has another advantage, since it prevents people from running
|
|
197 |
* gnome-smproxy in xfce4, which would cause trouble otherwise.
|
|
198 |
*/
|
|
199 |
dpy = gdk_display; |
|
200 |
root = RootWindow (dpy, 0); |
|
201 |
||
202 |
if (gnome_smproxy_window != None) |
|
203 |
XDestroyWindow (dpy, gnome_smproxy_window); |
|
204 |
||
205 |
gnome_sm_proxy = XInternAtom (dpy, "GNOME_SM_PROXY", False); |
|
206 |
gnome_smproxy_window = XCreateSimpleWindow (dpy, root, 1, 1, 1, 1, 0, 0, 0); |
|
207 |
||
208 |
XChangeProperty (dpy, gnome_smproxy_window, gnome_sm_proxy, |
|
209 |
XA_CARDINAL, 32, PropModeReplace, |
|
210 |
(unsigned char *) (void *) &gnome_smproxy_window, 1); |
|
211 |
XChangeProperty (dpy, root, gnome_sm_proxy, |
|
212 |
XA_CARDINAL, 32, PropModeReplace, |
|
213 |
(unsigned char *) (void *) &gnome_smproxy_window, 1); |
|
214 |
||
215 |
XSync (dpy, False); |
|
216 |
||
217 |
gdk_error_trap_pop (); |
|
218 |
}
|
|
219 |
||
220 |
||
221 |
static void |
|
222 |
xfsm_compat_gnome_smproxy_shutdown (void) |
|
223 |
{
|
|
224 |
gdk_error_trap_push (); |
|
225 |
||
226 |
if (gnome_smproxy_window != None) |
|
227 |
{
|
|
228 |
XDestroyWindow (gdk_display, gnome_smproxy_window); |
|
229 |
XSync (gdk_display, False); |
|
230 |
gnome_smproxy_window = None; |
|
231 |
}
|
|
232 |
||
233 |
gdk_error_trap_pop (); |
|
234 |
}
|
|
235 |
||
236 |
||
237 |
void
|
|
238 |
xfsm_compat_gnome_startup (XfsmSplashScreen *splash) |
|
239 |
{
|
|
240 |
xfsm_compat_gnome_smproxy_startup (); |
|
241 |
||
242 |
/* fire up the keyring daemon */
|
|
243 |
if (G_LIKELY (splash != NULL)) |
|
244 |
xfsm_splash_screen_next (splash, _("Starting The Gnome Keyring Daemon")); |
|
245 |
gnome_keyring_daemon_startup (); |
|
246 |
||
1.1.2
by Jani Monoses
Import upstream version 4.3.0svn+r19775 |
247 |
#ifdef HAVE_GNOME
|
1.1.1
by Yves-Alexis Perez
Import upstream version 4.2.3 |
248 |
/* connect to the GConf daemon */
|
249 |
gnome_conf_client = gconf_client_get_default (); |
|
250 |
if (gnome_conf_client != NULL) |
|
251 |
{
|
|
252 |
if (gconf_client_get_bool (gnome_conf_client, ACCESSIBILITY_KEY, NULL)) |
|
253 |
{
|
|
254 |
if (G_LIKELY (splash != NULL)) |
|
255 |
{
|
|
256 |
xfsm_splash_screen_next (splash, _("Starting Gnome Assistive Technologies")); |
|
257 |
}
|
|
258 |
||
259 |
gnome_ast_startup (); |
|
260 |
}
|
|
261 |
}
|
|
262 |
#endif
|
|
263 |
}
|
|
264 |
||
265 |
||
266 |
void
|
|
267 |
xfsm_compat_gnome_shutdown (void) |
|
268 |
{
|
|
269 |
GError *error = NULL; |
|
270 |
gint status; |
|
271 |
||
272 |
/* shutdown the keyring daemon */
|
|
273 |
gnome_keyring_daemon_shutdown (); |
|
274 |
||
1.1.2
by Jani Monoses
Import upstream version 4.3.0svn+r19775 |
275 |
#ifdef HAVE_GNOME
|
1.1.1
by Yves-Alexis Perez
Import upstream version 4.2.3 |
276 |
if (gnome_conf_client != NULL) |
277 |
{
|
|
278 |
g_object_unref (G_OBJECT (gnome_conf_client)); |
|
279 |
gnome_conf_client = NULL; |
|
280 |
}
|
|
281 |
#endif
|
|
282 |
||
283 |
/* shutdown the GConf daemon */
|
|
284 |
if (!g_spawn_command_line_sync ("gconftool-2 --shutdown", NULL, |
|
285 |
NULL, &status, &error)) |
|
286 |
{
|
|
287 |
g_warning ("Failed to shutdown the GConf daemon on logout: %s", |
|
288 |
error->message); |
|
289 |
g_error_free (error); |
|
290 |
}
|
|
291 |
else if (status != 0) |
|
292 |
{
|
|
293 |
g_warning ("Failed to shutdown the GConf daemon on logout: " |
|
294 |
"gconftool-2 returned status %d", status); |
|
295 |
}
|
|
296 |
||
297 |
xfsm_compat_gnome_smproxy_shutdown (); |
|
298 |
}
|
|
299 |