Merge lp:~jamesodhunt/ubuntu/trusty/gnome-session/bug-1256262 into lp:ubuntu/trusty/gnome-session
- Trusty (14.04)
- bug-1256262
- Merge into trusty
Proposed by
James Hunt
Status: | Merged |
---|---|
Merge reported by: | Dimitri John Ledkov |
Merged at revision: | not available |
Proposed branch: | lp:~jamesodhunt/ubuntu/trusty/gnome-session/bug-1256262 |
Merge into: | lp:ubuntu/trusty/gnome-session |
Diff against target: |
809 lines (+10/-762) 5 files modified
.pc/103_kill_the_fail_whale.patch/gnome-session/gsm-fail-whale.c (+0/-47) .pc/13_display_session_properties.patch/data/session-properties.desktop.in.in (+0/-15) .pc/git_fix_wrong_unref_call.patch/gnome-session/gsm-shell.c (+0/-700) debian/changelog (+7/-0) debian/gnome-session.user-session.upstart (+3/-0) |
To merge this branch: | bzr merge lp:~jamesodhunt/ubuntu/trusty/gnome-session/bug-1256262 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dimitri John Ledkov | Approve | ||
Review via email: mp+197663@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file '.pc/103_kill_the_fail_whale.patch/gnome-session/gsm-fail-whale.c' | |||
2 | --- .pc/103_kill_the_fail_whale.patch/gnome-session/gsm-fail-whale.c 2013-06-19 10:37:29 +0000 | |||
3 | +++ .pc/103_kill_the_fail_whale.patch/gnome-session/gsm-fail-whale.c 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,47 +0,0 @@ | |||
5 | 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
6 | 2 | * gsm-fail-whale.c | ||
7 | 3 | * Copyright (C) 2012 Red Hat, Inc | ||
8 | 4 | * | ||
9 | 5 | * This program is free software; you can redistribute it and/or | ||
10 | 6 | * modify it under the terms of the GNU General Public License as | ||
11 | 7 | * published by the Free Software Foundation; either version 2 of the | ||
12 | 8 | * License, or (at your option) any later version. | ||
13 | 9 | * | ||
14 | 10 | * This program is distributed in the hope that it will be useful, but | ||
15 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | 13 | * Lesser General Public License for more details. | ||
18 | 14 | * | ||
19 | 15 | * You should have received a copy of the GNU General Public License | ||
20 | 16 | * along with this program; if not, write to the Free Software | ||
21 | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
22 | 18 | * 02111-1307, USA. | ||
23 | 19 | */ | ||
24 | 20 | |||
25 | 21 | #include <config.h> | ||
26 | 22 | |||
27 | 23 | #include <glib/gi18n.h> | ||
28 | 24 | #include <glib/gstdio.h> | ||
29 | 25 | |||
30 | 26 | #include "gsm-fail-whale.h" | ||
31 | 27 | |||
32 | 28 | void | ||
33 | 29 | gsm_fail_whale_dialog_we_failed (gboolean debug_mode, | ||
34 | 30 | gboolean allow_logout, | ||
35 | 31 | GsmShellExtensions *extensions) | ||
36 | 32 | { | ||
37 | 33 | gint i; | ||
38 | 34 | gchar *argv[5]; | ||
39 | 35 | |||
40 | 36 | i = 0; | ||
41 | 37 | argv[i++] = LIBEXECDIR "/gnome-session-failed"; | ||
42 | 38 | if (debug_mode) | ||
43 | 39 | argv[i++] = "--debug"; | ||
44 | 40 | if (allow_logout) | ||
45 | 41 | argv[i++] = "--allow-logout"; | ||
46 | 42 | if (extensions != NULL && gsm_shell_extensions_n_extensions (extensions) > 0) | ||
47 | 43 | argv[i++] = "--extensions"; | ||
48 | 44 | argv[i++] = NULL; | ||
49 | 45 | |||
50 | 46 | g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL); | ||
51 | 47 | } | ||
52 | 48 | 0 | ||
53 | === removed directory '.pc/13_display_session_properties.patch' | |||
54 | === removed directory '.pc/13_display_session_properties.patch/data' | |||
55 | === removed file '.pc/13_display_session_properties.patch/data/session-properties.desktop.in.in' | |||
56 | --- .pc/13_display_session_properties.patch/data/session-properties.desktop.in.in 2012-09-05 00:53:57 +0000 | |||
57 | +++ .pc/13_display_session_properties.patch/data/session-properties.desktop.in.in 1970-01-01 00:00:00 +0000 | |||
58 | @@ -1,15 +0,0 @@ | |||
59 | 1 | [Desktop Entry] | ||
60 | 2 | _Name=Startup Applications | ||
61 | 3 | _Comment=Choose what applications to start when you log in | ||
62 | 4 | Exec=gnome-session-properties | ||
63 | 5 | Icon=session-properties | ||
64 | 6 | Terminal=false | ||
65 | 7 | Type=Application | ||
66 | 8 | StartupNotify=true | ||
67 | 9 | Categories=GTK;GNOME;Settings;X-GNOME-PersonalSettings; | ||
68 | 10 | OnlyShowIn=GNOME;Unity; | ||
69 | 11 | NoDisplay=true | ||
70 | 12 | X-GNOME-Bugzilla-Bugzilla=GNOME | ||
71 | 13 | X-GNOME-Bugzilla-Product=gnome-session | ||
72 | 14 | X-GNOME-Bugzilla-Component=gnome-session-properties | ||
73 | 15 | X-GNOME-Bugzilla-Version=@VERSION@ | ||
74 | 16 | 0 | ||
75 | === removed directory '.pc/git_fix_wrong_unref_call.patch' | |||
76 | === removed directory '.pc/git_fix_wrong_unref_call.patch/gnome-session' | |||
77 | === removed file '.pc/git_fix_wrong_unref_call.patch/gnome-session/gsm-shell.c' | |||
78 | --- .pc/git_fix_wrong_unref_call.patch/gnome-session/gsm-shell.c 2013-10-11 15:45:25 +0000 | |||
79 | +++ .pc/git_fix_wrong_unref_call.patch/gnome-session/gsm-shell.c 1970-01-01 00:00:00 +0000 | |||
80 | @@ -1,700 +0,0 @@ | |||
81 | 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
82 | 2 | * | ||
83 | 3 | * Copyright (C) 2010 Red Hat, Inc | ||
84 | 4 | * | ||
85 | 5 | * This program is free software; you can redistribute it and/or modify | ||
86 | 6 | * it under the terms of the GNU General Public License as published by | ||
87 | 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
88 | 8 | * any later version. | ||
89 | 9 | * | ||
90 | 10 | * This program is distributed in the hope that it will be useful, | ||
91 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
92 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
93 | 13 | * GNU General Public License for more details. | ||
94 | 14 | * | ||
95 | 15 | * You should have received a copy of the GNU General Public License | ||
96 | 16 | * along with this program; if not, write to the Free Software | ||
97 | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
98 | 18 | * 02111-1307, USA. | ||
99 | 19 | */ | ||
100 | 20 | |||
101 | 21 | #include "config.h" | ||
102 | 22 | |||
103 | 23 | #include <errno.h> | ||
104 | 24 | #include <string.h> | ||
105 | 25 | #include <unistd.h> | ||
106 | 26 | |||
107 | 27 | #include <glib.h> | ||
108 | 28 | #include <glib-object.h> | ||
109 | 29 | #include <glib/gi18n.h> | ||
110 | 30 | |||
111 | 31 | #include <dbus/dbus-glib.h> | ||
112 | 32 | #include <dbus/dbus-glib-lowlevel.h> | ||
113 | 33 | |||
114 | 34 | #include "gsm-inhibitor.h" | ||
115 | 35 | #include "gsm-shell.h" | ||
116 | 36 | |||
117 | 37 | #define SHELL_NAME "org.gnome.Shell" | ||
118 | 38 | #define SHELL_PATH "/org/gnome/Shell" | ||
119 | 39 | #define SHELL_INTERFACE "org.gnome.Shell" | ||
120 | 40 | |||
121 | 41 | #define SHELL_END_SESSION_DIALOG_PATH "/org/gnome/SessionManager/EndSessionDialog" | ||
122 | 42 | #define SHELL_END_SESSION_DIALOG_INTERFACE "org.gnome.SessionManager.EndSessionDialog" | ||
123 | 43 | |||
124 | 44 | #define GSM_SHELL_DBUS_TYPE_G_OBJECT_PATH_ARRAY (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH)) | ||
125 | 45 | |||
126 | 46 | #define AUTOMATIC_ACTION_TIMEOUT 60 | ||
127 | 47 | |||
128 | 48 | #define GSM_SHELL_GET_PRIVATE(o) \ | ||
129 | 49 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_SHELL, GsmShellPrivate)) | ||
130 | 50 | |||
131 | 51 | struct _GsmShellPrivate | ||
132 | 52 | { | ||
133 | 53 | DBusGConnection *bus_connection; | ||
134 | 54 | DBusGProxy *bus_proxy; | ||
135 | 55 | DBusGProxy *proxy; | ||
136 | 56 | DBusGProxy *end_session_dialog_proxy; | ||
137 | 57 | GsmStore *inhibitors; | ||
138 | 58 | |||
139 | 59 | guint32 is_running : 1; | ||
140 | 60 | |||
141 | 61 | DBusGProxyCall *end_session_open_call; | ||
142 | 62 | GsmShellEndSessionDialogType end_session_dialog_type; | ||
143 | 63 | |||
144 | 64 | guint update_idle_id; | ||
145 | 65 | }; | ||
146 | 66 | |||
147 | 67 | enum { | ||
148 | 68 | PROP_0, | ||
149 | 69 | PROP_IS_RUNNING | ||
150 | 70 | }; | ||
151 | 71 | |||
152 | 72 | enum { | ||
153 | 73 | END_SESSION_DIALOG_OPENED = 0, | ||
154 | 74 | END_SESSION_DIALOG_OPEN_FAILED, | ||
155 | 75 | END_SESSION_DIALOG_CLOSED, | ||
156 | 76 | END_SESSION_DIALOG_CANCELED, | ||
157 | 77 | END_SESSION_DIALOG_CONFIRMED_LOGOUT, | ||
158 | 78 | END_SESSION_DIALOG_CONFIRMED_SHUTDOWN, | ||
159 | 79 | END_SESSION_DIALOG_CONFIRMED_REBOOT, | ||
160 | 80 | NUMBER_OF_SIGNALS | ||
161 | 81 | }; | ||
162 | 82 | |||
163 | 83 | static guint signals[NUMBER_OF_SIGNALS] = { 0 }; | ||
164 | 84 | |||
165 | 85 | static void gsm_shell_class_init (GsmShellClass *klass); | ||
166 | 86 | static void gsm_shell_init (GsmShell *ck); | ||
167 | 87 | static void gsm_shell_finalize (GObject *object); | ||
168 | 88 | |||
169 | 89 | static void gsm_shell_disconnect_from_bus (GsmShell *shell); | ||
170 | 90 | |||
171 | 91 | static DBusHandlerResult gsm_shell_bus_filter (DBusConnection *connection, | ||
172 | 92 | DBusMessage *message, | ||
173 | 93 | void *user_data); | ||
174 | 94 | |||
175 | 95 | static void gsm_shell_on_name_owner_changed (DBusGProxy *bus_proxy, | ||
176 | 96 | const char *name, | ||
177 | 97 | const char *prev_owner, | ||
178 | 98 | const char *new_owner, | ||
179 | 99 | GsmShell *shell); | ||
180 | 100 | static void queue_end_session_dialog_update (GsmShell *shell); | ||
181 | 101 | |||
182 | 102 | G_DEFINE_TYPE (GsmShell, gsm_shell, G_TYPE_OBJECT); | ||
183 | 103 | |||
184 | 104 | static void | ||
185 | 105 | gsm_shell_get_property (GObject *object, | ||
186 | 106 | guint prop_id, | ||
187 | 107 | GValue *value, | ||
188 | 108 | GParamSpec *pspec) | ||
189 | 109 | { | ||
190 | 110 | GsmShell *shell = GSM_SHELL (object); | ||
191 | 111 | |||
192 | 112 | switch (prop_id) { | ||
193 | 113 | case PROP_IS_RUNNING: | ||
194 | 114 | g_value_set_boolean (value, | ||
195 | 115 | shell->priv->is_running); | ||
196 | 116 | break; | ||
197 | 117 | |||
198 | 118 | default: | ||
199 | 119 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, | ||
200 | 120 | prop_id, | ||
201 | 121 | pspec); | ||
202 | 122 | } | ||
203 | 123 | } | ||
204 | 124 | |||
205 | 125 | static void | ||
206 | 126 | gsm_shell_class_init (GsmShellClass *shell_class) | ||
207 | 127 | { | ||
208 | 128 | GObjectClass *object_class; | ||
209 | 129 | GParamSpec *param_spec; | ||
210 | 130 | |||
211 | 131 | object_class = G_OBJECT_CLASS (shell_class); | ||
212 | 132 | |||
213 | 133 | object_class->finalize = gsm_shell_finalize; | ||
214 | 134 | object_class->get_property = gsm_shell_get_property; | ||
215 | 135 | |||
216 | 136 | param_spec = g_param_spec_boolean ("is-running", | ||
217 | 137 | "Is running", | ||
218 | 138 | "Whether GNOME Shell is running in the session", | ||
219 | 139 | FALSE, | ||
220 | 140 | G_PARAM_READABLE); | ||
221 | 141 | |||
222 | 142 | g_object_class_install_property (object_class, PROP_IS_RUNNING, | ||
223 | 143 | param_spec); | ||
224 | 144 | |||
225 | 145 | signals [END_SESSION_DIALOG_OPENED] = | ||
226 | 146 | g_signal_new ("end-session-dialog-opened", | ||
227 | 147 | G_OBJECT_CLASS_TYPE (object_class), | ||
228 | 148 | G_SIGNAL_RUN_LAST, | ||
229 | 149 | G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_opened), | ||
230 | 150 | NULL, NULL, NULL, | ||
231 | 151 | G_TYPE_NONE, 0); | ||
232 | 152 | |||
233 | 153 | signals [END_SESSION_DIALOG_OPEN_FAILED] = | ||
234 | 154 | g_signal_new ("end-session-dialog-open-failed", | ||
235 | 155 | G_OBJECT_CLASS_TYPE (object_class), | ||
236 | 156 | G_SIGNAL_RUN_LAST, | ||
237 | 157 | G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_open_failed), | ||
238 | 158 | NULL, NULL, NULL, | ||
239 | 159 | G_TYPE_NONE, 0); | ||
240 | 160 | |||
241 | 161 | signals [END_SESSION_DIALOG_CLOSED] = | ||
242 | 162 | g_signal_new ("end-session-dialog-closed", | ||
243 | 163 | G_OBJECT_CLASS_TYPE (object_class), | ||
244 | 164 | G_SIGNAL_RUN_LAST, | ||
245 | 165 | G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_closed), | ||
246 | 166 | NULL, NULL, NULL, | ||
247 | 167 | G_TYPE_NONE, 0); | ||
248 | 168 | |||
249 | 169 | signals [END_SESSION_DIALOG_CANCELED] = | ||
250 | 170 | g_signal_new ("end-session-dialog-canceled", | ||
251 | 171 | G_OBJECT_CLASS_TYPE (object_class), | ||
252 | 172 | G_SIGNAL_RUN_LAST, | ||
253 | 173 | G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_canceled), | ||
254 | 174 | NULL, NULL, NULL, | ||
255 | 175 | G_TYPE_NONE, 0); | ||
256 | 176 | |||
257 | 177 | signals [END_SESSION_DIALOG_CONFIRMED_LOGOUT] = | ||
258 | 178 | g_signal_new ("end-session-dialog-confirmed-logout", | ||
259 | 179 | G_OBJECT_CLASS_TYPE (object_class), | ||
260 | 180 | G_SIGNAL_RUN_LAST, | ||
261 | 181 | G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_logout), | ||
262 | 182 | NULL, NULL, NULL, | ||
263 | 183 | G_TYPE_NONE, 0); | ||
264 | 184 | |||
265 | 185 | signals [END_SESSION_DIALOG_CONFIRMED_SHUTDOWN] = | ||
266 | 186 | g_signal_new ("end-session-dialog-confirmed-shutdown", | ||
267 | 187 | G_OBJECT_CLASS_TYPE (object_class), | ||
268 | 188 | G_SIGNAL_RUN_LAST, | ||
269 | 189 | G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_shutdown), | ||
270 | 190 | NULL, NULL, NULL, | ||
271 | 191 | G_TYPE_NONE, 0); | ||
272 | 192 | |||
273 | 193 | signals [END_SESSION_DIALOG_CONFIRMED_REBOOT] = | ||
274 | 194 | g_signal_new ("end-session-dialog-confirmed-reboot", | ||
275 | 195 | G_OBJECT_CLASS_TYPE (object_class), | ||
276 | 196 | G_SIGNAL_RUN_LAST, | ||
277 | 197 | G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_reboot), | ||
278 | 198 | NULL, NULL, NULL, | ||
279 | 199 | G_TYPE_NONE, 0); | ||
280 | 200 | |||
281 | 201 | g_type_class_add_private (shell_class, sizeof (GsmShellPrivate)); | ||
282 | 202 | } | ||
283 | 203 | |||
284 | 204 | static DBusHandlerResult | ||
285 | 205 | gsm_shell_bus_filter (DBusConnection *connection, | ||
286 | 206 | DBusMessage *message, | ||
287 | 207 | void *user_data) | ||
288 | 208 | { | ||
289 | 209 | GsmShell *shell; | ||
290 | 210 | |||
291 | 211 | shell = GSM_SHELL (user_data); | ||
292 | 212 | |||
293 | 213 | if (dbus_message_is_signal (message, | ||
294 | 214 | DBUS_INTERFACE_LOCAL, "Disconnected") && | ||
295 | 215 | strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0) { | ||
296 | 216 | gsm_shell_disconnect_from_bus (shell); | ||
297 | 217 | /* let other filters get this disconnected signal, so that they | ||
298 | 218 | * can handle it too */ | ||
299 | 219 | } | ||
300 | 220 | |||
301 | 221 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | ||
302 | 222 | } | ||
303 | 223 | |||
304 | 224 | static gboolean | ||
305 | 225 | gsm_shell_ensure_connection (GsmShell *shell, | ||
306 | 226 | GError **error) | ||
307 | 227 | { | ||
308 | 228 | GError *connection_error; | ||
309 | 229 | gboolean is_running; | ||
310 | 230 | |||
311 | 231 | connection_error = NULL; | ||
312 | 232 | |||
313 | 233 | if (shell->priv->bus_connection == NULL) { | ||
314 | 234 | DBusConnection *connection; | ||
315 | 235 | |||
316 | 236 | shell->priv->bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, | ||
317 | 237 | &connection_error); | ||
318 | 238 | |||
319 | 239 | if (shell->priv->bus_connection == NULL) { | ||
320 | 240 | g_propagate_error (error, connection_error); | ||
321 | 241 | is_running = FALSE; | ||
322 | 242 | goto out; | ||
323 | 243 | } | ||
324 | 244 | |||
325 | 245 | connection = dbus_g_connection_get_connection (shell->priv->bus_connection); | ||
326 | 246 | dbus_connection_set_exit_on_disconnect (connection, FALSE); | ||
327 | 247 | dbus_connection_add_filter (connection, | ||
328 | 248 | gsm_shell_bus_filter, | ||
329 | 249 | shell, NULL); | ||
330 | 250 | } | ||
331 | 251 | |||
332 | 252 | if (shell->priv->bus_proxy == NULL) { | ||
333 | 253 | shell->priv->bus_proxy = | ||
334 | 254 | dbus_g_proxy_new_for_name_owner (shell->priv->bus_connection, | ||
335 | 255 | DBUS_SERVICE_DBUS, | ||
336 | 256 | DBUS_PATH_DBUS, | ||
337 | 257 | DBUS_INTERFACE_DBUS, | ||
338 | 258 | &connection_error); | ||
339 | 259 | |||
340 | 260 | if (shell->priv->bus_proxy == NULL) { | ||
341 | 261 | g_propagate_error (error, connection_error); | ||
342 | 262 | is_running = FALSE; | ||
343 | 263 | goto out; | ||
344 | 264 | } | ||
345 | 265 | |||
346 | 266 | dbus_g_proxy_add_signal (shell->priv->bus_proxy, | ||
347 | 267 | "NameOwnerChanged", | ||
348 | 268 | G_TYPE_STRING, | ||
349 | 269 | G_TYPE_STRING, | ||
350 | 270 | G_TYPE_STRING, | ||
351 | 271 | G_TYPE_INVALID); | ||
352 | 272 | |||
353 | 273 | dbus_g_proxy_connect_signal (shell->priv->bus_proxy, | ||
354 | 274 | "NameOwnerChanged", | ||
355 | 275 | G_CALLBACK (gsm_shell_on_name_owner_changed), | ||
356 | 276 | shell, NULL); | ||
357 | 277 | } | ||
358 | 278 | |||
359 | 279 | if (shell->priv->proxy == NULL) { | ||
360 | 280 | shell->priv->proxy = | ||
361 | 281 | dbus_g_proxy_new_for_name_owner (shell->priv->bus_connection, | ||
362 | 282 | SHELL_NAME, | ||
363 | 283 | SHELL_PATH, | ||
364 | 284 | SHELL_INTERFACE, | ||
365 | 285 | &connection_error); | ||
366 | 286 | |||
367 | 287 | if (shell->priv->proxy == NULL) { | ||
368 | 288 | g_propagate_error (error, connection_error); | ||
369 | 289 | is_running = FALSE; | ||
370 | 290 | goto out; | ||
371 | 291 | } | ||
372 | 292 | } | ||
373 | 293 | |||
374 | 294 | g_debug ("GsmShell: Connected to the shell"); | ||
375 | 295 | |||
376 | 296 | is_running = TRUE; | ||
377 | 297 | |||
378 | 298 | out: | ||
379 | 299 | if (shell->priv->is_running != is_running) { | ||
380 | 300 | shell->priv->is_running = is_running; | ||
381 | 301 | g_object_notify (G_OBJECT (shell), "is-running"); | ||
382 | 302 | } | ||
383 | 303 | |||
384 | 304 | if (!is_running) { | ||
385 | 305 | g_debug ("GsmShell: Not connected to the shell"); | ||
386 | 306 | |||
387 | 307 | if (shell->priv->bus_connection == NULL) { | ||
388 | 308 | g_clear_object (&shell->priv->bus_proxy); | ||
389 | 309 | g_clear_object (&shell->priv->proxy); | ||
390 | 310 | } else if (shell->priv->bus_proxy == NULL) { | ||
391 | 311 | g_clear_object (&shell->priv->proxy); | ||
392 | 312 | } | ||
393 | 313 | } | ||
394 | 314 | |||
395 | 315 | return is_running; | ||
396 | 316 | } | ||
397 | 317 | |||
398 | 318 | static void | ||
399 | 319 | gsm_shell_on_name_owner_changed (DBusGProxy *bus_proxy, | ||
400 | 320 | const char *name, | ||
401 | 321 | const char *prev_owner, | ||
402 | 322 | const char *new_owner, | ||
403 | 323 | GsmShell *shell) | ||
404 | 324 | { | ||
405 | 325 | if (name != NULL && strcmp (name, SHELL_NAME) != 0) { | ||
406 | 326 | return; | ||
407 | 327 | } | ||
408 | 328 | |||
409 | 329 | g_clear_object (&shell->priv->proxy); | ||
410 | 330 | |||
411 | 331 | gsm_shell_ensure_connection (shell, NULL); | ||
412 | 332 | } | ||
413 | 333 | |||
414 | 334 | static void | ||
415 | 335 | gsm_shell_init (GsmShell *shell) | ||
416 | 336 | { | ||
417 | 337 | shell->priv = GSM_SHELL_GET_PRIVATE (shell); | ||
418 | 338 | |||
419 | 339 | gsm_shell_ensure_connection (shell, NULL); | ||
420 | 340 | } | ||
421 | 341 | |||
422 | 342 | static void | ||
423 | 343 | gsm_shell_disconnect_from_bus (GsmShell *shell) | ||
424 | 344 | { | ||
425 | 345 | g_clear_object (&shell->priv->bus_proxy); | ||
426 | 346 | g_clear_object (&shell->priv->proxy); | ||
427 | 347 | |||
428 | 348 | if (shell->priv->bus_connection != NULL) { | ||
429 | 349 | DBusConnection *connection; | ||
430 | 350 | connection = dbus_g_connection_get_connection (shell->priv->bus_connection); | ||
431 | 351 | dbus_connection_remove_filter (connection, | ||
432 | 352 | gsm_shell_bus_filter, | ||
433 | 353 | shell); | ||
434 | 354 | |||
435 | 355 | dbus_g_connection_unref (shell->priv->bus_connection); | ||
436 | 356 | shell->priv->bus_connection = NULL; | ||
437 | 357 | } | ||
438 | 358 | } | ||
439 | 359 | |||
440 | 360 | static void | ||
441 | 361 | gsm_shell_finalize (GObject *object) | ||
442 | 362 | { | ||
443 | 363 | GsmShell *shell; | ||
444 | 364 | GObjectClass *parent_class; | ||
445 | 365 | |||
446 | 366 | shell = GSM_SHELL (object); | ||
447 | 367 | |||
448 | 368 | parent_class = G_OBJECT_CLASS (gsm_shell_parent_class); | ||
449 | 369 | |||
450 | 370 | g_object_unref (shell->priv->inhibitors); | ||
451 | 371 | |||
452 | 372 | gsm_shell_disconnect_from_bus (shell); | ||
453 | 373 | |||
454 | 374 | if (parent_class->finalize != NULL) { | ||
455 | 375 | parent_class->finalize (object); | ||
456 | 376 | } | ||
457 | 377 | } | ||
458 | 378 | |||
459 | 379 | GsmShell * | ||
460 | 380 | gsm_shell_new (void) | ||
461 | 381 | { | ||
462 | 382 | GsmShell *shell; | ||
463 | 383 | |||
464 | 384 | shell = g_object_new (GSM_TYPE_SHELL, NULL); | ||
465 | 385 | |||
466 | 386 | return shell; | ||
467 | 387 | } | ||
468 | 388 | |||
469 | 389 | GsmShell * | ||
470 | 390 | gsm_get_shell (void) | ||
471 | 391 | { | ||
472 | 392 | static GsmShell *shell = NULL; | ||
473 | 393 | |||
474 | 394 | if (shell == NULL) { | ||
475 | 395 | shell = gsm_shell_new (); | ||
476 | 396 | } | ||
477 | 397 | |||
478 | 398 | return g_object_ref (shell); | ||
479 | 399 | } | ||
480 | 400 | |||
481 | 401 | gboolean | ||
482 | 402 | gsm_shell_is_running (GsmShell *shell) | ||
483 | 403 | { | ||
484 | 404 | gsm_shell_ensure_connection (shell, NULL); | ||
485 | 405 | |||
486 | 406 | return shell->priv->is_running; | ||
487 | 407 | } | ||
488 | 408 | |||
489 | 409 | static gboolean | ||
490 | 410 | add_inhibitor_to_array (const char *id, | ||
491 | 411 | GsmInhibitor *inhibitor, | ||
492 | 412 | GPtrArray *array) | ||
493 | 413 | { | ||
494 | 414 | |||
495 | 415 | g_ptr_array_add (array, | ||
496 | 416 | g_strdup (gsm_inhibitor_peek_id (inhibitor))); | ||
497 | 417 | return FALSE; | ||
498 | 418 | } | ||
499 | 419 | |||
500 | 420 | static GPtrArray * | ||
501 | 421 | get_array_from_store (GsmStore *inhibitors) | ||
502 | 422 | { | ||
503 | 423 | GPtrArray *array; | ||
504 | 424 | |||
505 | 425 | array = g_ptr_array_new (); | ||
506 | 426 | |||
507 | 427 | gsm_store_foreach (inhibitors, | ||
508 | 428 | (GsmStoreFunc) add_inhibitor_to_array, | ||
509 | 429 | array); | ||
510 | 430 | |||
511 | 431 | return array; | ||
512 | 432 | } | ||
513 | 433 | |||
514 | 434 | static void | ||
515 | 435 | on_open_finished (DBusGProxy *proxy, | ||
516 | 436 | DBusGProxyCall *call, | ||
517 | 437 | GsmShell *shell) | ||
518 | 438 | { | ||
519 | 439 | GError *error; | ||
520 | 440 | gboolean res; | ||
521 | 441 | |||
522 | 442 | g_assert (shell->priv->end_session_open_call == call); | ||
523 | 443 | |||
524 | 444 | error = NULL; | ||
525 | 445 | res = dbus_g_proxy_end_call (proxy, | ||
526 | 446 | call, | ||
527 | 447 | &error, | ||
528 | 448 | G_TYPE_INVALID); | ||
529 | 449 | shell->priv->end_session_open_call = NULL; | ||
530 | 450 | |||
531 | 451 | if (shell->priv->update_idle_id != 0) { | ||
532 | 452 | g_source_remove (shell->priv->update_idle_id); | ||
533 | 453 | shell->priv->update_idle_id = 0; | ||
534 | 454 | } | ||
535 | 455 | |||
536 | 456 | if (!res) { | ||
537 | 457 | g_warning ("Unable to open shell end session dialog"); | ||
538 | 458 | g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_OPEN_FAILED], 0); | ||
539 | 459 | return; | ||
540 | 460 | } | ||
541 | 461 | |||
542 | 462 | g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_OPENED], 0); | ||
543 | 463 | } | ||
544 | 464 | |||
545 | 465 | static void | ||
546 | 466 | on_end_session_dialog_closed (DBusGProxy *proxy, | ||
547 | 467 | GsmShell *shell) | ||
548 | 468 | { | ||
549 | 469 | if (shell->priv->update_idle_id != 0) { | ||
550 | 470 | g_source_remove (shell->priv->update_idle_id); | ||
551 | 471 | shell->priv->update_idle_id = 0; | ||
552 | 472 | } | ||
553 | 473 | |||
554 | 474 | g_signal_handlers_disconnect_by_func (shell->priv->inhibitors, | ||
555 | 475 | G_CALLBACK (queue_end_session_dialog_update), | ||
556 | 476 | shell); | ||
557 | 477 | |||
558 | 478 | g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CLOSED], 0); | ||
559 | 479 | } | ||
560 | 480 | |||
561 | 481 | static void | ||
562 | 482 | on_end_session_dialog_canceled (DBusGProxy *proxy, | ||
563 | 483 | GsmShell *shell) | ||
564 | 484 | { | ||
565 | 485 | if (shell->priv->update_idle_id != 0) { | ||
566 | 486 | g_source_remove (shell->priv->update_idle_id); | ||
567 | 487 | shell->priv->update_idle_id = 0; | ||
568 | 488 | } | ||
569 | 489 | |||
570 | 490 | g_signal_handlers_disconnect_by_func (shell->priv->inhibitors, | ||
571 | 491 | G_CALLBACK (queue_end_session_dialog_update), | ||
572 | 492 | shell); | ||
573 | 493 | |||
574 | 494 | g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CANCELED], 0); | ||
575 | 495 | } | ||
576 | 496 | |||
577 | 497 | static void | ||
578 | 498 | on_end_session_dialog_confirmed_logout (DBusGProxy *proxy, | ||
579 | 499 | GsmShell *shell) | ||
580 | 500 | { | ||
581 | 501 | if (shell->priv->update_idle_id != 0) { | ||
582 | 502 | g_source_remove (shell->priv->update_idle_id); | ||
583 | 503 | shell->priv->update_idle_id = 0; | ||
584 | 504 | } | ||
585 | 505 | |||
586 | 506 | g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_LOGOUT], 0); | ||
587 | 507 | } | ||
588 | 508 | |||
589 | 509 | static void | ||
590 | 510 | on_end_session_dialog_confirmed_shutdown (DBusGProxy *proxy, | ||
591 | 511 | GsmShell *shell) | ||
592 | 512 | { | ||
593 | 513 | if (shell->priv->update_idle_id != 0) { | ||
594 | 514 | g_source_remove (shell->priv->update_idle_id); | ||
595 | 515 | shell->priv->update_idle_id = 0; | ||
596 | 516 | } | ||
597 | 517 | |||
598 | 518 | g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_SHUTDOWN], 0); | ||
599 | 519 | } | ||
600 | 520 | |||
601 | 521 | static void | ||
602 | 522 | on_end_session_dialog_confirmed_reboot (DBusGProxy *proxy, | ||
603 | 523 | GsmShell *shell) | ||
604 | 524 | { | ||
605 | 525 | if (shell->priv->update_idle_id != 0) { | ||
606 | 526 | g_source_remove (shell->priv->update_idle_id); | ||
607 | 527 | shell->priv->update_idle_id = 0; | ||
608 | 528 | } | ||
609 | 529 | |||
610 | 530 | g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_REBOOT], 0); | ||
611 | 531 | } | ||
612 | 532 | |||
613 | 533 | static void | ||
614 | 534 | on_end_session_dialog_proxy_destroyed (DBusGProxy *proxy, | ||
615 | 535 | GsmShell *shell) | ||
616 | 536 | { | ||
617 | 537 | /* FIXME - is this right? */ | ||
618 | 538 | if (shell->priv->end_session_dialog_proxy != NULL) { | ||
619 | 539 | g_object_unref (shell->priv->proxy); | ||
620 | 540 | shell->priv->end_session_dialog_proxy = NULL; | ||
621 | 541 | } | ||
622 | 542 | } | ||
623 | 543 | |||
624 | 544 | static gboolean | ||
625 | 545 | on_need_end_session_dialog_update (GsmShell *shell) | ||
626 | 546 | { | ||
627 | 547 | /* No longer need an update */ | ||
628 | 548 | if (shell->priv->update_idle_id == 0) | ||
629 | 549 | return FALSE; | ||
630 | 550 | |||
631 | 551 | shell->priv->update_idle_id = 0; | ||
632 | 552 | |||
633 | 553 | gsm_shell_open_end_session_dialog (shell, | ||
634 | 554 | shell->priv->end_session_dialog_type, | ||
635 | 555 | shell->priv->inhibitors); | ||
636 | 556 | return FALSE; | ||
637 | 557 | } | ||
638 | 558 | |||
639 | 559 | static void | ||
640 | 560 | queue_end_session_dialog_update (GsmShell *shell) | ||
641 | 561 | { | ||
642 | 562 | if (shell->priv->update_idle_id != 0) | ||
643 | 563 | return; | ||
644 | 564 | |||
645 | 565 | shell->priv->update_idle_id = g_idle_add ((GSourceFunc) on_need_end_session_dialog_update, | ||
646 | 566 | shell); | ||
647 | 567 | } | ||
648 | 568 | |||
649 | 569 | gboolean | ||
650 | 570 | gsm_shell_open_end_session_dialog (GsmShell *shell, | ||
651 | 571 | GsmShellEndSessionDialogType type, | ||
652 | 572 | GsmStore *inhibitors) | ||
653 | 573 | { | ||
654 | 574 | DBusGProxyCall *call; | ||
655 | 575 | GPtrArray *inhibitor_array; | ||
656 | 576 | GError *error; | ||
657 | 577 | |||
658 | 578 | error = NULL; | ||
659 | 579 | if (!gsm_shell_ensure_connection (shell, &error)) { | ||
660 | 580 | g_warning ("Could not connect to the shell: %s", | ||
661 | 581 | error->message); | ||
662 | 582 | g_error_free (error); | ||
663 | 583 | return FALSE; | ||
664 | 584 | } | ||
665 | 585 | |||
666 | 586 | if (shell->priv->end_session_open_call != NULL) { | ||
667 | 587 | g_return_val_if_fail (shell->priv->end_session_dialog_type == type, | ||
668 | 588 | FALSE); | ||
669 | 589 | |||
670 | 590 | return TRUE; | ||
671 | 591 | } | ||
672 | 592 | |||
673 | 593 | if (shell->priv->end_session_dialog_proxy == NULL) { | ||
674 | 594 | DBusGProxy *proxy; | ||
675 | 595 | |||
676 | 596 | proxy = dbus_g_proxy_new_for_name (shell->priv->bus_connection, | ||
677 | 597 | SHELL_NAME, | ||
678 | 598 | SHELL_END_SESSION_DIALOG_PATH, | ||
679 | 599 | SHELL_END_SESSION_DIALOG_INTERFACE); | ||
680 | 600 | |||
681 | 601 | g_assert (proxy != NULL); | ||
682 | 602 | |||
683 | 603 | shell->priv->end_session_dialog_proxy = proxy; | ||
684 | 604 | |||
685 | 605 | g_signal_connect (proxy, "destroy", | ||
686 | 606 | G_CALLBACK (on_end_session_dialog_proxy_destroyed), | ||
687 | 607 | shell); | ||
688 | 608 | |||
689 | 609 | dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy, | ||
690 | 610 | "Closed", G_TYPE_INVALID); | ||
691 | 611 | dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy, | ||
692 | 612 | "Closed", | ||
693 | 613 | G_CALLBACK (on_end_session_dialog_closed), | ||
694 | 614 | shell, NULL); | ||
695 | 615 | |||
696 | 616 | dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy, | ||
697 | 617 | "Canceled", G_TYPE_INVALID); | ||
698 | 618 | dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy, | ||
699 | 619 | "Canceled", | ||
700 | 620 | G_CALLBACK (on_end_session_dialog_canceled), | ||
701 | 621 | shell, NULL); | ||
702 | 622 | dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy, | ||
703 | 623 | "ConfirmedLogout", G_TYPE_INVALID); | ||
704 | 624 | dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy, | ||
705 | 625 | "ConfirmedLogout", | ||
706 | 626 | G_CALLBACK (on_end_session_dialog_confirmed_logout), | ||
707 | 627 | shell, NULL); | ||
708 | 628 | dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy, | ||
709 | 629 | "ConfirmedShutdown", G_TYPE_INVALID); | ||
710 | 630 | dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy, | ||
711 | 631 | "ConfirmedShutdown", | ||
712 | 632 | G_CALLBACK (on_end_session_dialog_confirmed_shutdown), | ||
713 | 633 | shell, NULL); | ||
714 | 634 | dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy, | ||
715 | 635 | "ConfirmedReboot", G_TYPE_INVALID); | ||
716 | 636 | dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy, | ||
717 | 637 | "ConfirmedReboot", | ||
718 | 638 | G_CALLBACK (on_end_session_dialog_confirmed_reboot), | ||
719 | 639 | shell, NULL); | ||
720 | 640 | } | ||
721 | 641 | |||
722 | 642 | inhibitor_array = get_array_from_store (inhibitors); | ||
723 | 643 | |||
724 | 644 | call = dbus_g_proxy_begin_call_with_timeout (shell->priv->end_session_dialog_proxy, | ||
725 | 645 | "Open", | ||
726 | 646 | (DBusGProxyCallNotify) | ||
727 | 647 | on_open_finished, | ||
728 | 648 | shell, | ||
729 | 649 | NULL, | ||
730 | 650 | INT_MAX, | ||
731 | 651 | G_TYPE_UINT, | ||
732 | 652 | (guint) type, | ||
733 | 653 | G_TYPE_UINT, | ||
734 | 654 | (guint) 0, | ||
735 | 655 | G_TYPE_UINT, | ||
736 | 656 | AUTOMATIC_ACTION_TIMEOUT, | ||
737 | 657 | GSM_SHELL_DBUS_TYPE_G_OBJECT_PATH_ARRAY, | ||
738 | 658 | inhibitor_array, | ||
739 | 659 | G_TYPE_INVALID); | ||
740 | 660 | g_ptr_array_foreach (inhibitor_array, (GFunc) g_free, NULL); | ||
741 | 661 | g_ptr_array_free (inhibitor_array, TRUE); | ||
742 | 662 | |||
743 | 663 | if (call == NULL) { | ||
744 | 664 | g_warning ("Unable to make Open call"); | ||
745 | 665 | return FALSE; | ||
746 | 666 | } | ||
747 | 667 | |||
748 | 668 | g_object_ref (inhibitors); | ||
749 | 669 | |||
750 | 670 | if (shell->priv->inhibitors != NULL) { | ||
751 | 671 | g_signal_handlers_disconnect_by_func (shell->priv->inhibitors, | ||
752 | 672 | G_CALLBACK (queue_end_session_dialog_update), | ||
753 | 673 | shell); | ||
754 | 674 | g_object_unref (shell->priv->inhibitors); | ||
755 | 675 | } | ||
756 | 676 | |||
757 | 677 | shell->priv->inhibitors = inhibitors; | ||
758 | 678 | |||
759 | 679 | g_signal_connect_swapped (inhibitors, "added", | ||
760 | 680 | G_CALLBACK (queue_end_session_dialog_update), | ||
761 | 681 | shell); | ||
762 | 682 | |||
763 | 683 | g_signal_connect_swapped (inhibitors, "removed", | ||
764 | 684 | G_CALLBACK (queue_end_session_dialog_update), | ||
765 | 685 | shell); | ||
766 | 686 | |||
767 | 687 | shell->priv->end_session_open_call = call; | ||
768 | 688 | shell->priv->end_session_dialog_type = type; | ||
769 | 689 | |||
770 | 690 | return TRUE; | ||
771 | 691 | } | ||
772 | 692 | |||
773 | 693 | void | ||
774 | 694 | gsm_shell_close_end_session_dialog (GsmShell *shell) | ||
775 | 695 | { | ||
776 | 696 | if (!shell->priv->end_session_dialog_proxy) | ||
777 | 697 | return; | ||
778 | 698 | |||
779 | 699 | dbus_g_proxy_call_no_reply (shell->priv->end_session_dialog_proxy, "Close", G_TYPE_INVALID); | ||
780 | 700 | } | ||
781 | 701 | 0 | ||
782 | === modified file 'debian/changelog' | |||
783 | --- debian/changelog 2013-10-11 15:45:25 +0000 | |||
784 | +++ debian/changelog 2013-12-04 09:35:55 +0000 | |||
785 | @@ -1,3 +1,10 @@ | |||
786 | 1 | gnome-session (3.9.90-0ubuntu4) UNRELEASED; urgency=low | ||
787 | 2 | |||
788 | 3 | * debian/gnome-session.user-session.upstart: Unset Upstart event | ||
789 | 4 | variables to avoid stop(8) from stopping the users session (LP: #1256262). | ||
790 | 5 | |||
791 | 6 | -- James Hunt <james.hunt@ubuntu.com> Wed, 04 Dec 2013 09:31:07 +0000 | ||
792 | 7 | |||
793 | 1 | gnome-session (3.9.90-0ubuntu3) saucy; urgency=low | 8 | gnome-session (3.9.90-0ubuntu3) saucy; urgency=low |
794 | 2 | 9 | ||
795 | 3 | * debian/patches/git_fix_wrong_unref_call.patch: | 10 | * debian/patches/git_fix_wrong_unref_call.patch: |
796 | 4 | 11 | ||
797 | === modified file 'debian/gnome-session.user-session.upstart' | |||
798 | --- debian/gnome-session.user-session.upstart 2013-05-22 12:55:52 +0000 | |||
799 | +++ debian/gnome-session.user-session.upstart 2013-12-04 09:35:55 +0000 | |||
800 | @@ -9,7 +9,10 @@ | |||
801 | 9 | emits desktop-start | 9 | emits desktop-start |
802 | 10 | emits desktop-end | 10 | emits desktop-end |
803 | 11 | 11 | ||
804 | 12 | script | ||
805 | 13 | unset UPSTART_EVENTS UPSTART_INSTANCE UPSTART_JOB | ||
806 | 12 | exec gnome-session --session=$DESKTOP_SESSION | 14 | exec gnome-session --session=$DESKTOP_SESSION |
807 | 15 | end script | ||
808 | 13 | 16 | ||
809 | 14 | post-start exec initctl emit desktop-start DESKTOP_SESSION=$DESKTOP_SESSION | 17 | post-start exec initctl emit desktop-start DESKTOP_SESSION=$DESKTOP_SESSION |
810 | 15 | 18 |
"Merged" into lp:~ubuntu-desktop/gnome-session/ubuntu sans quilt brain-deadness =)
ANd uploaded.