Lines 244-253
Link Here
|
244 |
return function_result; |
244 |
return function_result; |
245 |
} |
245 |
} |
246 |
|
246 |
|
247 |
static void |
247 |
static char * |
248 |
logind_call_function (const gchar *function, gboolean value, GError **error) |
248 |
logind_call_function (const gchar *function) |
249 |
{ |
249 |
{ |
250 |
GVariant *result; |
250 |
GVariant *result; |
|
|
251 |
GError *err = NULL; |
251 |
|
252 |
|
252 |
if (!logind_proxy) |
253 |
if (!logind_proxy) |
253 |
{ |
254 |
{ |
Lines 258-277
Link Here
|
258 |
"/org/freedesktop/login1", |
259 |
"/org/freedesktop/login1", |
259 |
"org.freedesktop.login1.Manager", |
260 |
"org.freedesktop.login1.Manager", |
260 |
NULL, |
261 |
NULL, |
261 |
error); |
262 |
&err); |
|
|
263 |
if (err != NULL) |
264 |
g_error_free(err); |
262 |
if (!logind_proxy) |
265 |
if (!logind_proxy) |
263 |
return; |
266 |
return NULL; |
264 |
} |
267 |
} |
265 |
|
268 |
|
266 |
result = g_dbus_proxy_call_sync (logind_proxy, |
269 |
result = g_dbus_proxy_call_sync (logind_proxy, |
267 |
function, |
270 |
function, |
268 |
g_variant_new ("(b)", value), |
271 |
g_variant_new ("(b)", TRUE), |
269 |
G_DBUS_CALL_FLAGS_NONE, |
272 |
G_DBUS_CALL_FLAGS_NONE, |
270 |
-1, |
273 |
-1, |
271 |
NULL, |
274 |
NULL, |
272 |
error); |
275 |
&err); |
273 |
g_variant_unref (result); |
276 |
if (result) |
274 |
return; |
277 |
g_variant_unref (result); |
|
|
278 |
if (err != NULL) { |
279 |
char *r = strdup(err->message); |
280 |
g_error_free(err); |
281 |
return r; |
282 |
} |
283 |
return NULL; |
275 |
} |
284 |
} |
276 |
|
285 |
|
277 |
gboolean |
286 |
gboolean |
Lines 280-289
Link Here
|
280 |
return logind_query ("CanPowerOff", FALSE, NULL); |
289 |
return logind_query ("CanPowerOff", FALSE, NULL); |
281 |
} |
290 |
} |
282 |
|
291 |
|
283 |
void |
292 |
char * |
284 |
dbus_logind_PowerOff (GError **error) |
293 |
dbus_logind_PowerOff (void) |
285 |
{ |
294 |
{ |
286 |
logind_call_function ("PowerOff", TRUE, error); |
295 |
return logind_call_function ("PowerOff"); |
287 |
} |
296 |
} |
288 |
|
297 |
|
289 |
gboolean |
298 |
gboolean |
Lines 292-301
Link Here
|
292 |
return logind_query ("CanReboot", FALSE, NULL); |
301 |
return logind_query ("CanReboot", FALSE, NULL); |
293 |
} |
302 |
} |
294 |
|
303 |
|
295 |
void |
304 |
char * |
296 |
dbus_logind_Reboot (GError **error) |
305 |
dbus_logind_Reboot (void) |
297 |
{ |
306 |
{ |
298 |
logind_call_function ("Reboot", TRUE, error); |
307 |
return logind_call_function ("Reboot"); |
299 |
} |
308 |
} |
300 |
|
309 |
|
301 |
gboolean |
310 |
gboolean |
Lines 304-313
Link Here
|
304 |
return logind_query ("CanSuspend", FALSE, NULL); |
313 |
return logind_query ("CanSuspend", FALSE, NULL); |
305 |
} |
314 |
} |
306 |
|
315 |
|
307 |
void |
316 |
char * |
308 |
dbus_logind_Suspend (GError **error) |
317 |
dbus_logind_Suspend (void) |
309 |
{ |
318 |
{ |
310 |
logind_call_function ("Suspend", TRUE, error); |
319 |
return logind_call_function ("Suspend"); |
311 |
} |
320 |
} |
312 |
|
321 |
|
313 |
gboolean |
322 |
gboolean |
Lines 316-325
Link Here
|
316 |
return logind_query ("CanHibernate", FALSE, NULL); |
325 |
return logind_query ("CanHibernate", FALSE, NULL); |
317 |
} |
326 |
} |
318 |
|
327 |
|
319 |
void |
328 |
char * |
320 |
dbus_logind_Hibernate (GError **error) |
329 |
dbus_logind_Hibernate (void) |
321 |
{ |
330 |
{ |
322 |
logind_call_function ("Hibernate", TRUE, error); |
331 |
return logind_call_function ("Hibernate"); |
323 |
} |
332 |
} |
324 |
|
333 |
|
325 |
/*** ConsoleKit mechanism ***/ |
334 |
/*** ConsoleKit mechanism ***/ |