summaryrefslogtreecommitdiff
blob: 91d15836241a5de8842defcf8b15121131eca719 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Taken from: 
http://svnweb.mageia.org/packages/cauldron/lxsession/current/SOURCES/lxsession-0.4.9.2-fix-logind-dbus-calls.patch?revision=549605&view=co&pathrev=549606

--- lxsession-0.4.9.2/lxsession-logout/dbus-interface.c.0000	2013-04-12 22:02:19.000000000 +0100
+++ lxsession-0.4.9.2/lxsession-logout/dbus-interface.c	2013-11-05 11:00:34.038965063 +0000
@@ -244,10 +244,11 @@
     return function_result;
 }
 
-static void
-logind_call_function (const gchar *function, gboolean value, GError **error)
+static char *
+logind_call_function (const gchar *function)
 {
     GVariant *result;
+    GError *err = NULL;
 
     if (!logind_proxy)
     {
@@ -258,20 +259,28 @@
                                                       "/org/freedesktop/login1",
                                                       "org.freedesktop.login1.Manager",
                                                       NULL,
-                                                      error);
+                                                      &err);
+        if (err != NULL)
+            g_error_free(err);
         if (!logind_proxy)
-            return;
+            return NULL;
     }
 
     result = g_dbus_proxy_call_sync (logind_proxy,
                                      function,
-                                     g_variant_new ("(b)", value),
+                                     g_variant_new ("(b)", TRUE),
                                      G_DBUS_CALL_FLAGS_NONE,
                                      -1,
                                      NULL,
-                                     error);
-    g_variant_unref (result);
-    return;
+                                     &err);
+    if (result)
+        g_variant_unref (result);
+    if (err != NULL) {
+        char *r = strdup(err->message);
+        g_error_free(err);
+        return r;
+    }
+    return NULL;
 }
 
 gboolean
@@ -280,10 +289,10 @@
     return logind_query ("CanPowerOff", FALSE, NULL);
 }
 
-void
-dbus_logind_PowerOff (GError **error)
+char *
+dbus_logind_PowerOff (void)
 {
-    logind_call_function ("PowerOff", TRUE, error);
+    return logind_call_function ("PowerOff");
 }
 
 gboolean
@@ -292,10 +301,10 @@
     return logind_query ("CanReboot", FALSE, NULL);
 }
 
-void
-dbus_logind_Reboot (GError **error)
+char *
+dbus_logind_Reboot (void)
 {
-    logind_call_function ("Reboot", TRUE, error);
+    return logind_call_function ("Reboot");
 }
 
 gboolean
@@ -304,10 +313,10 @@
     return logind_query ("CanSuspend", FALSE, NULL);
 }
 
-void
-dbus_logind_Suspend (GError **error)
+char *
+dbus_logind_Suspend (void)
 {
-    logind_call_function ("Suspend", TRUE, error);
+    return logind_call_function ("Suspend");
 }
 
 gboolean
@@ -316,10 +325,10 @@
     return logind_query ("CanHibernate", FALSE, NULL);
 }
 
-void
-dbus_logind_Hibernate (GError **error)
+char *
+dbus_logind_Hibernate (void)
 {
-    logind_call_function ("Hibernate", TRUE, error);
+    return logind_call_function ("Hibernate");
 }
 
 /*** ConsoleKit mechanism ***/