~ubuntu-branches/ubuntu/oneiric/lxsession/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/01_upower.patch

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne, Andrew Lee (李健秋)
  • Date: 2010-07-28 23:16:56 UTC
  • Revision ID: james.westby@ubuntu.com-20100728231656-zo8t5r9girxdbgz3
Tags: 0.4.4-1ubuntu1
[ Andrew Lee (李健秋) ]
HAL-less LXDE!
* Backport upower patch from upstream.
* Support switch user with gdm3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
commit df577c699c5b4b6b74c57accc664db5a16fc9b09
 
2
Author: Marty Jack <martyj@linux.local>
 
3
Date:   Thu Apr 8 10:06:06 2010 -0400
 
4
 
 
5
    Convert DeviceKit/Power support to UPower support and remove conditional compilation
 
6
 
 
7
diff --git a/lxsession-logout/dbus-interface.c b/lxsession-logout/dbus-interface.c
 
8
index f05b752..940035b 100644
 
9
--- a/lxsession-logout/dbus-interface.c
 
10
+++ b/lxsession-logout/dbus-interface.c
 
11
@@ -54,7 +54,7 @@ static DBusConnection * dbus_connect(void)
 
12
 }
 
13
 
 
14
 /* Send a message. */
 
15
-static DBusMessage * dbus_send_message(DBusMessage * message)
 
16
+static DBusMessage * dbus_send_message(DBusMessage * message, char * * error_text)
 
17
 {
 
18
     /* Get a connection handle. */
 
19
     DBusConnection * connection = dbus_connect();
 
20
@@ -68,36 +68,25 @@ static DBusMessage * dbus_send_message(DBusMessage * message)
 
21
     dbus_message_unref(message);
 
22
     if (reply == NULL)
 
23
     {
 
24
-        g_warning(G_STRLOC ": DBUS: %s", error.message);
 
25
+        if ((error.name == NULL) || (strcmp(error.name, DBUS_ERROR_NO_REPLY) != 0))
 
26
+        {
 
27
+            if (error_text != NULL)
 
28
+                *error_text = g_strdup(error.message);
 
29
+            g_warning(G_STRLOC ": DBUS: %s", error.message);
 
30
+        }
 
31
         dbus_error_free(&error);
 
32
     }
 
33
     return reply;
 
34
 }
 
35
 
 
36
-/* Send a message with no reply expected. */
 
37
-static gboolean dbus_send_message_without_reply(DBusMessage * message)
 
38
-{
 
39
-    /* Get a connection handle. */
 
40
-    DBusConnection * connection = dbus_connect();
 
41
-    if (connection == NULL)
 
42
-        return FALSE;
 
43
-
 
44
-    /* Send the message in the blind. */
 
45
-    dbus_bool_t status = dbus_connection_send(connection, message, NULL);
 
46
-    dbus_message_unref(message);
 
47
-    if ( ! status)
 
48
-       g_warning(G_STRLOC ": DBUS: dbus_connection_send failed\n");
 
49
-    return status;
 
50
-}
 
51
-       
 
52
 /* Read a result for a method that returns void. */
 
53
-static gboolean dbus_read_result_void(DBusMessage * reply)
 
54
+static char * dbus_read_result_void(DBusMessage * reply)
 
55
 {
 
56
     if (reply != NULL)
 
57
         dbus_message_unref(reply);
 
58
 
 
59
     /* No result.  Assume success. */
 
60
-    return TRUE;
 
61
+    return NULL;
 
62
 }
 
63
 
 
64
 /* Read a result for a method that returns boolean. */
 
65
@@ -144,19 +133,21 @@ static DBusMessage * dbus_ConsoleKit_formulate_message(const char * const query)
 
66
 static gboolean dbus_ConsoleKit_query(const char * const query)
 
67
 {
 
68
 #ifdef HAVE_DBUS
 
69
-    return dbus_read_result_boolean(dbus_send_message(dbus_ConsoleKit_formulate_message(query)));
 
70
+    return dbus_read_result_boolean(dbus_send_message(dbus_ConsoleKit_formulate_message(query), NULL));
 
71
 #else
 
72
     return FALSE;
 
73
 #endif
 
74
 }
 
75
 
 
76
 /* Send a specified message to the ConsoleKit interface and process a void result. */
 
77
-static gboolean dbus_ConsoleKit_command(const char * const command)
 
78
+static char * dbus_ConsoleKit_command(const char * const command)
 
79
 {
 
80
 #ifdef HAVE_DBUS
 
81
-    return dbus_read_result_void(dbus_send_message(dbus_ConsoleKit_formulate_message(command)));
 
82
+    char * error = NULL;
 
83
+    dbus_read_result_void(dbus_send_message(dbus_ConsoleKit_formulate_message(command), &error));
 
84
+    return error;
 
85
 #else
 
86
-    return FALSE;
 
87
+    return NULL;
 
88
 #endif
 
89
 }
 
90
 
 
91
@@ -173,49 +164,49 @@ gboolean dbus_ConsoleKit_CanRestart(void)
 
92
 }
 
93
 
 
94
 /* Invoke the Stop method on ConsoleKit. */
 
95
-gboolean dbus_ConsoleKit_Stop(void)
 
96
+char * dbus_ConsoleKit_Stop(void)
 
97
 {
 
98
     return dbus_ConsoleKit_command("Stop");
 
99
 }
 
100
 
 
101
 /* Invoke the Restart method on ConsoleKit. */
 
102
-gboolean dbus_ConsoleKit_Restart(void)
 
103
+char * dbus_ConsoleKit_Restart(void)
 
104
 {
 
105
     return dbus_ConsoleKit_command("Restart");
 
106
 }
 
107
 
 
108
-/*** DeviceKit Power mechanism ***/
 
109
+/*** UPower mechanism ***/
 
110
 
 
111
 #ifdef HAVE_DBUS
 
112
-/* Formulate a message to the DeviceKit Power interface. */
 
113
-static DBusMessage * dbus_DeviceKit_formulate_command(const char * const command)
 
114
+/* Formulate a message to the UPower interface. */
 
115
+static DBusMessage * dbus_UPower_formulate_command(const char * const command)
 
116
 {
 
117
     return dbus_message_new_method_call(
 
118
-        "org.freedesktop.DeviceKit.Power",
 
119
-       "/org/freedesktop/DeviceKit/Power",
 
120
-       "org.freedesktop.DeviceKit.Power",
 
121
+        "org.freedesktop.UPower",
 
122
+       "/org/freedesktop/UPower",
 
123
+       "org.freedesktop.UPower",
 
124
         command);
 
125
 }
 
126
 #endif
 
127
 
 
128
-/* Send a specified message to the DeviceKit interface and process a boolean result. */
 
129
-static gboolean dbus_DeviceKit_query(const char * const query)
 
130
+/* Send a specified message to the UPower interface and process a boolean result. */
 
131
+static gboolean dbus_UPower_query(const char * const query)
 
132
 {
 
133
 #ifdef HAVE_DBUS
 
134
     /* Formulate a message to the Properties interface. */
 
135
     DBusMessage * message = dbus_message_new_method_call(
 
136
-        "org.freedesktop.DeviceKit.Power",
 
137
-       "/org/freedesktop/DeviceKit/Power",
 
138
+        "org.freedesktop.UPower",
 
139
+       "/org/freedesktop/UPower",
 
140
        "org.freedesktop.DBus.Properties",
 
141
         "Get");
 
142
-    const char * const interface_name = "org.freedesktop.DeviceKit.Power";
 
143
+    const char * const interface_name = "org.freedesktop.UPower";
 
144
     dbus_message_append_args(message,
 
145
         DBUS_TYPE_STRING, &interface_name,
 
146
         DBUS_TYPE_STRING, &query,
 
147
         DBUS_TYPE_INVALID);
 
148
 
 
149
     /* Send the message. */
 
150
-    DBusMessage * reply = dbus_send_message(message);
 
151
+    DBusMessage * reply = dbus_send_message(message, NULL);
 
152
     if (reply == NULL)
 
153
        return FALSE;
 
154
 
 
155
@@ -237,39 +228,40 @@ static gboolean dbus_DeviceKit_query(const char * const query)
 
156
 #endif
 
157
 }
 
158
 
 
159
-/* Send a specified message to the DeviceKit interface and process a void result. */
 
160
-static gboolean dbus_DeviceKit_command(const char * const command)
 
161
+/* Send a specified message to the UPower interface and process a void result. */
 
162
+static char * dbus_UPower_command(const char * const command)
 
163
 {
 
164
 #ifdef HAVE_DBUS
 
165
-    return dbus_read_result_void(dbus_send_message(dbus_DeviceKit_formulate_command(command)));
 
166
-//    return dbus_send_message_without_reply(dbus_DeviceKit_formulate_command(command));       It seems they don't send a reply; to be checked out
 
167
+    char * error = NULL;
 
168
+    dbus_read_result_void(dbus_send_message(dbus_UPower_formulate_command(command), &error));
 
169
+    return error;
 
170
 #else
 
171
-    return FALSE;
 
172
+    return NULL;
 
173
 #endif
 
174
 }
 
175
 
 
176
-/* Read the can-suspend property of DeviceKit/Power. */
 
177
-gboolean dbus_DeviceKit_CanSuspend(void)
 
178
+/* Read the can-suspend property of UPower. */
 
179
+gboolean dbus_UPower_CanSuspend(void)
 
180
 {
 
181
-    return dbus_DeviceKit_query("CanSuspend");
 
182
+    return dbus_UPower_query("CanSuspend");
 
183
 }
 
184
 
 
185
-/* Read the can-hibernate property of DeviceKit/Power. */
 
186
-gboolean dbus_DeviceKit_CanHibernate(void)
 
187
+/* Read the can-hibernate property of UPower. */
 
188
+gboolean dbus_UPower_CanHibernate(void)
 
189
 {
 
190
-    return dbus_DeviceKit_query("CanHibernate");
 
191
+    return dbus_UPower_query("CanHibernate");
 
192
 }
 
193
 
 
194
-/* Invoke the Suspend method on DeviceKit/Power. */
 
195
-gboolean dbus_DeviceKit_Suspend(void)
 
196
+/* Invoke the Suspend method on UPower. */
 
197
+char * dbus_UPower_Suspend(void)
 
198
 {
 
199
-    return dbus_DeviceKit_command("Suspend");
 
200
+    return dbus_UPower_command("Suspend");
 
201
 }
 
202
 
 
203
-/* Invoke the Hibernate method on DeviceKit/Power. */
 
204
-gboolean dbus_DeviceKit_Hibernate(void)
 
205
+/* Invoke the Hibernate method on UPower. */
 
206
+char * dbus_UPower_Hibernate(void)
 
207
 {
 
208
-    return dbus_DeviceKit_command("Hibernate");
 
209
+    return dbus_UPower_command("Hibernate");
 
210
 }
 
211
 
 
212
 /*** HAL mechanism ***/
 
213
@@ -318,7 +310,7 @@ static gboolean dbus_HAL_string_exists_query(const char * const property)
 
214
     DBusMessage * message = dbus_HAL_formulate_string_property_query(property);
 
215
     if (message == NULL)
 
216
         return FALSE;
 
217
-    DBusMessage * reply = dbus_send_message(message);
 
218
+    DBusMessage * reply = dbus_send_message(message, NULL);
 
219
     if (reply == NULL)
 
220
        return FALSE;
 
221
     dbus_message_unref(reply);
 
222
@@ -332,20 +324,20 @@ static gboolean dbus_HAL_string_exists_query(const char * const property)
 
223
 static gboolean dbus_HAL_boolean_query(const char * const property)
 
224
 {
 
225
 #ifdef HAVE_DBUS
 
226
-    return dbus_read_result_boolean(dbus_send_message(dbus_HAL_formulate_boolean_property_query(property)));
 
227
+    return dbus_read_result_boolean(dbus_send_message(dbus_HAL_formulate_boolean_property_query(property), NULL));
 
228
 #else
 
229
     return FALSE;
 
230
 #endif
 
231
 }
 
232
 
 
233
 /* Send a specified message to the HAL interface and process a void result. */
 
234
-static gboolean dbus_HAL_command(const char * const command)
 
235
+static char * dbus_HAL_command(const char * const command)
 
236
 {
 
237
 #ifdef HAVE_DBUS
 
238
     /* Formulate the message. */
 
239
     DBusMessage * message = dbus_HAL_formulate_message(command);
 
240
     if (message == NULL)
 
241
-       return FALSE;
 
242
+        return NULL;
 
243
 
 
244
     /* Suspend has an argument. */
 
245
     if (strcmp(command, "Suspend") == 0)
 
246
@@ -355,9 +347,11 @@ static gboolean dbus_HAL_command(const char * const command)
 
247
     }
 
248
 
 
249
     /* Send the message and wait for a reply. */
 
250
-    return dbus_read_result_void(dbus_send_message(message));
 
251
+    char * error = NULL;
 
252
+    dbus_read_result_void(dbus_send_message(message, &error));
 
253
+    return error;
 
254
 #else
 
255
-    return FALSE;
 
256
+    return NULL;
 
257
 #endif
 
258
 }
 
259
 
 
260
@@ -386,25 +380,25 @@ gboolean dbus_HAL_CanHibernate(void)
 
261
 }
 
262
 
 
263
 /* Invoke the Shutdown method on HAL. */
 
264
-gboolean dbus_HAL_Shutdown(void)
 
265
+char * dbus_HAL_Shutdown(void)
 
266
 {
 
267
     return dbus_HAL_command("Shutdown");
 
268
 }
 
269
 
 
270
 /* Invoke the Reboot method on HAL. */
 
271
-gboolean dbus_HAL_Reboot(void)
 
272
+char * dbus_HAL_Reboot(void)
 
273
 {
 
274
     return dbus_HAL_command("Reboot");
 
275
 }
 
276
 
 
277
 /* Invoke the Suspend method on HAL. */
 
278
-gboolean dbus_HAL_Suspend(void)
 
279
+char * dbus_HAL_Suspend(void)
 
280
 {
 
281
     return dbus_HAL_command("Suspend");
 
282
 }
 
283
 
 
284
 /* Invoke the Hibernate method on HAL. */
 
285
-gboolean dbus_HAL_Hibernate(void)
 
286
+char * dbus_HAL_Hibernate(void)
 
287
 {
 
288
     return dbus_HAL_command("Hibernate");
 
289
 }
 
290
diff --git a/lxsession-logout/dbus-interface.h b/lxsession-logout/dbus-interface.h
 
291
index 465d15a..4ea2d5b 100644
 
292
--- a/lxsession-logout/dbus-interface.h
 
293
+++ b/lxsession-logout/dbus-interface.h
 
294
@@ -24,14 +24,14 @@
 
295
 /* Interface to ConsoleKit for shutdown and reboot. */
 
296
 extern gboolean dbus_ConsoleKit_CanStop(void);
 
297
 extern gboolean dbus_ConsoleKit_CanRestart(void);
 
298
-extern gboolean dbus_ConsoleKit_Stop(void);
 
299
-extern gboolean dbus_ConsoleKit_Restart(void);
 
300
+extern char * dbus_ConsoleKit_Stop(void);
 
301
+extern char * dbus_ConsoleKit_Restart(void);
 
302
 
 
303
-/* Interface to DeviceKit/Power for suspend and hibernate. */
 
304
-extern gboolean dbus_DeviceKit_CanSuspend(void);
 
305
-extern gboolean dbus_DeviceKit_CanHibernate(void);
 
306
-extern gboolean dbus_DeviceKit_Suspend(void);
 
307
-extern gboolean dbus_DeviceKit_Hibernate(void);
 
308
+/* Interface to UPower for suspend and hibernate. */
 
309
+extern gboolean dbus_UPower_CanSuspend(void);
 
310
+extern gboolean dbus_UPower_CanHibernate(void);
 
311
+extern char * dbus_UPower_Suspend(void);
 
312
+extern char * dbus_UPower_Hibernate(void);
 
313
 
 
314
 /* Interface to HAL for shutdown, reboot, suspend, and hibernate.
 
315
  * HAL is being replaced by the above two mechanisms; this support is legacy. */
 
316
@@ -39,9 +39,9 @@ extern gboolean dbus_HAL_CanShutdown(void);
 
317
 extern gboolean dbus_HAL_CanReboot(void);
 
318
 extern gboolean dbus_HAL_CanSuspend(void);
 
319
 extern gboolean dbus_HAL_CanHibernate(void);
 
320
-gboolean dbus_HAL_Shutdown(void);
 
321
-gboolean dbus_HAL_Reboot(void);
 
322
-gboolean dbus_HAL_Suspend(void);
 
323
-gboolean dbus_HAL_Hibernate(void);
 
324
+extern char * dbus_HAL_Shutdown(void);
 
325
+extern char * dbus_HAL_Reboot(void);
 
326
+extern char * dbus_HAL_Suspend(void);
 
327
+extern char * dbus_HAL_Hibernate(void);
 
328
 
 
329
 #endif
 
330
diff --git a/lxsession-logout/lxsession-logout.c b/lxsession-logout/lxsession-logout.c
 
331
index a4183fc..435216c 100644
 
332
--- a/lxsession-logout/lxsession-logout.c
 
333
+++ b/lxsession-logout/lxsession-logout.c
 
334
@@ -52,6 +52,7 @@ static GOptionEntry opt_entries[] =
 
335
 
 
336
 typedef struct {
 
337
     GPid lxsession_pid;                        /* Process ID of lxsession */
 
338
+    GtkWidget * error_label;           /* Text of an error, if we get one */
 
339
 
 
340
     int shutdown_available : 1;                /* Shutdown is available */
 
341
     int reboot_available : 1;          /* Reboot is available */
 
342
@@ -61,19 +62,20 @@ typedef struct {
 
343
 
 
344
     int shutdown_ConsoleKit : 1;       /* Shutdown is available via ConsoleKit */
 
345
     int reboot_ConsoleKit : 1;         /* Reboot is available via ConsoleKit */
 
346
-    int suspend_DeviceKit : 1;         /* Suspend is available via DeviceKit */
 
347
-    int hibernate_DeviceKit : 1;       /* Hibernate is available via DeviceKit */
 
348
+    int suspend_UPower : 1;            /* Suspend is available via UPower */
 
349
+    int hibernate_UPower : 1;          /* Hibernate is available via UPower */
 
350
     int shutdown_HAL : 1;              /* Shutdown is available via HAL */
 
351
     int reboot_HAL : 1;                        /* Reboot is available via HAL */
 
352
     int suspend_HAL : 1;               /* Suspend is available via HAL */
 
353
     int hibernate_HAL : 1;             /* Hibernate is available via HAL */
 
354
     int switch_user_GDM : 1;           /* Switch User is available via GDM */
 
355
     int switch_user_KDM : 1;           /* Switch User is available via KDM */
 
356
-    int ltsp : 1; /* under LTSP environment */
 
357
+    int ltsp : 1;                      /* Shutdown and reboot is accomplished via LTSP */
 
358
 } HandlerContext;
 
359
 
 
360
 static gboolean verify_running(char * display_manager, char * executable);
 
361
 static void logout_clicked(GtkButton * button, HandlerContext * handler_context);
 
362
+static void change_root_property(GtkWidget* w, const char* prop_name, const char* value);
 
363
 static void shutdown_clicked(GtkButton * button, HandlerContext * handler_context);
 
364
 static void reboot_clicked(GtkButton * button, HandlerContext * handler_context);
 
365
 static void suspend_clicked(GtkButton * button, HandlerContext * handler_context);
 
366
@@ -145,6 +147,7 @@ static void logout_clicked(GtkButton * button, HandlerContext * handler_context)
 
367
     gtk_main_quit();
 
368
 }
 
369
 
 
370
+/* Replace a property on the root window. */
 
371
 static void change_root_property(GtkWidget* w, const char* prop_name, const char* value)
 
372
 {
 
373
     GdkDisplay* dpy = gtk_widget_get_display(w);
 
374
@@ -157,56 +160,82 @@ static void change_root_property(GtkWidget* w, const char* prop_name, const char
 
375
 /* Handler for "clicked" signal on Shutdown button. */
 
376
 static void shutdown_clicked(GtkButton * button, HandlerContext * handler_context)
 
377
 {
 
378
-    if (G_UNLIKELY(handler_context->ltsp))
 
379
+    char * error_result = NULL;
 
380
+    gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
 
381
+
 
382
+    if (handler_context->ltsp)
 
383
     {
 
384
         change_root_property(GTK_WIDGET(button), "LTSP_LOGOUT_ACTION", "HALT");
 
385
         kill(handler_context->lxsession_pid, SIGTERM);
 
386
     }
 
387
     else if (handler_context->shutdown_ConsoleKit)
 
388
-        dbus_ConsoleKit_Stop();
 
389
+        error_result = dbus_ConsoleKit_Stop();
 
390
     else if (handler_context->shutdown_HAL)
 
391
-        dbus_HAL_Shutdown();
 
392
-    gtk_main_quit();
 
393
+        error_result = dbus_HAL_Shutdown();
 
394
+
 
395
+    if (error_result != NULL)
 
396
+        gtk_label_set_text(GTK_LABEL(handler_context->error_label), error_result);
 
397
+        else gtk_main_quit();
 
398
 }
 
399
 
 
400
 /* Handler for "clicked" signal on Reboot button. */
 
401
 static void reboot_clicked(GtkButton * button, HandlerContext * handler_context)
 
402
 {
 
403
-    if (G_UNLIKELY(handler_context->ltsp))
 
404
+    char * error_result = NULL;
 
405
+    gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
 
406
+
 
407
+    if (handler_context->ltsp)
 
408
     {
 
409
         change_root_property(GTK_WIDGET(button), "LTSP_LOGOUT_ACTION", "REBOOT");
 
410
         kill(handler_context->lxsession_pid, SIGTERM);
 
411
     }
 
412
     else if (handler_context->reboot_ConsoleKit)
 
413
-        dbus_ConsoleKit_Restart();
 
414
+        error_result = dbus_ConsoleKit_Restart();
 
415
     else if (handler_context->reboot_HAL)
 
416
-        dbus_HAL_Reboot();
 
417
-    gtk_main_quit();
 
418
+        error_result = dbus_HAL_Reboot();
 
419
+
 
420
+    if (error_result != NULL)
 
421
+        gtk_label_set_text(GTK_LABEL(handler_context->error_label), error_result);
 
422
+        else gtk_main_quit();
 
423
 }
 
424
 
 
425
 /* Handler for "clicked" signal on Suspend button. */
 
426
 static void suspend_clicked(GtkButton * button, HandlerContext * handler_context)
 
427
 {
 
428
-    if (handler_context->suspend_DeviceKit)
 
429
-        dbus_DeviceKit_Suspend();
 
430
+    char * error_result = NULL;
 
431
+    gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
 
432
+
 
433
+    if (handler_context->suspend_UPower)
 
434
+        error_result = dbus_UPower_Suspend();
 
435
     else if (handler_context->suspend_HAL)
 
436
-        dbus_HAL_Suspend();
 
437
-    gtk_main_quit();
 
438
+        error_result = dbus_HAL_Suspend();
 
439
+
 
440
+    if (error_result != NULL)
 
441
+        gtk_label_set_text(GTK_LABEL(handler_context->error_label), error_result);
 
442
+        else gtk_main_quit();
 
443
 }
 
444
 
 
445
 /* Handler for "clicked" signal on Hibernate button. */
 
446
 static void hibernate_clicked(GtkButton * button, HandlerContext * handler_context)
 
447
 {
 
448
-    if (handler_context->hibernate_DeviceKit)
 
449
-        dbus_DeviceKit_Hibernate();
 
450
+    char * error_result = NULL;
 
451
+    gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
 
452
+
 
453
+    if (handler_context->hibernate_UPower)
 
454
+        error_result = dbus_UPower_Hibernate();
 
455
     else if (handler_context->hibernate_HAL)
 
456
-        dbus_HAL_Hibernate();
 
457
-    gtk_main_quit();
 
458
+        error_result = dbus_HAL_Hibernate();
 
459
+
 
460
+    if (error_result != NULL)
 
461
+        gtk_label_set_text(GTK_LABEL(handler_context->error_label), error_result);
 
462
+        else gtk_main_quit();
 
463
 }
 
464
 
 
465
 /* Handler for "clicked" signal on Switch User button. */
 
466
 static void switch_user_clicked(GtkButton * button, HandlerContext * handler_context)
 
467
 {
 
468
+    gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
 
469
+
 
470
     if (handler_context->switch_user_GDM)
 
471
         g_spawn_command_line_sync("gdmflexiserver --startnew", NULL, NULL, NULL, NULL);
 
472
     else if (handler_context->switch_user_KDM)
 
473
@@ -341,19 +370,17 @@ int main(int argc, char * argv[])
 
474
         handler_context.reboot_ConsoleKit = TRUE;
 
475
     }
 
476
 
 
477
-#ifdef LATENT_DEVICEKIT_SUPPORT
 
478
-    /* Initialize capabilities of the DeviceKit mechanism. */
 
479
-    if (dbus_DeviceKit_CanSuspend())
 
480
+    /* Initialize capabilities of the UPower mechanism. */
 
481
+    if (dbus_UPower_CanSuspend())
 
482
     {
 
483
         handler_context.suspend_available = TRUE;
 
484
-        handler_context.suspend_DeviceKit = TRUE;
 
485
+        handler_context.suspend_UPower = TRUE;
 
486
     }
 
487
-    if (dbus_DeviceKit_CanHibernate())
 
488
+    if (dbus_UPower_CanHibernate())
 
489
     {
 
490
         handler_context.hibernate_available = TRUE;
 
491
-        handler_context.hibernate_DeviceKit = TRUE;
 
492
+        handler_context.hibernate_UPower = TRUE;
 
493
     }
 
494
-#endif
 
495
 
 
496
     /* Initialize capabilities of the HAL mechanism. */
 
497
     if (!handler_context.shutdown_available && dbus_HAL_CanShutdown())
 
498
@@ -552,6 +579,11 @@ int main(int argc, char * argv[])
 
499
     g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(cancel_clicked), NULL);
 
500
     gtk_box_pack_start(GTK_BOX(controls), cancel_button, FALSE, FALSE, 4);
 
501
 
 
502
+    /* Create the error text. */
 
503
+    handler_context.error_label = gtk_label_new("");
 
504
+    gtk_label_set_justify(GTK_LABEL(handler_context.error_label), GTK_JUSTIFY_CENTER);
 
505
+    gtk_box_pack_start(GTK_BOX(controls), handler_context.error_label, FALSE, FALSE, 4);
 
506
+
 
507
     /* Show everything. */
 
508
     gtk_widget_show_all(window);
 
509