2
* * Copyright (C) 2008-2009 Ali <aliov@xfce.org>
4
* Licensed under the GNU General Public License Version 2
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 of the License, or
9
* (at your option) any later version.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31
#include <libxfce4util/libxfce4util.h>
33
#include "libxfpm/hal-manager.h"
34
#include "libxfpm/xfpm-string.h"
35
#include "libxfpm/xfpm-common.h"
36
#include "libxfpm/xfpm-notify.h"
39
#include "xfpm-dpms.h"
42
#include "xfpm-engine.h"
43
#include "xfpm-supply.h"
44
#include "xfpm-adapter.h"
45
#include "xfpm-xfconf.h"
47
#include "xfpm-button.h"
48
#include "xfpm-inhibit.h"
49
#include "xfpm-backlight.h"
50
#include "xfpm-screen-saver.h"
51
#include "xfpm-shutdown.h"
52
#include "xfpm-button-hal.h"
53
#include "egg-idletime.h"
54
#include "xfpm-errors.h"
55
#include "xfpm-config.h"
56
#include "xfpm-enum-types.h"
57
#include "xfpm-debug.h"
59
static void xfpm_engine_finalize (GObject * object);
61
static void xfpm_engine_dbus_class_init (XfpmEngineClass * klass);
62
static void xfpm_engine_dbus_init (XfpmEngine * engine);
64
#define XFPM_ENGINE_GET_PRIVATE(o) \
65
(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_ENGINE, XfpmEnginePrivate))
67
struct XfpmEnginePrivate
72
#ifdef SYSTEM_IS_LINUX
78
XfpmShutdown *shutdown;
80
XfpmButtonHal *bt_hal;
88
guint8 power_management;
92
gboolean has_lcd_brightness;
103
static guint signals [LAST_SIGNAL] = { 0 };
105
G_DEFINE_TYPE (XfpmEngine, xfpm_engine, G_TYPE_OBJECT)
107
static gboolean xfpm_engine_do_suspend (XfpmEngine * engine)
109
GError *error = NULL;
111
xfpm_suspend (engine->priv->shutdown, &error);
115
g_warning ("%s", error->message);
116
g_error_free (error);
122
xfpm_engine_do_hibernate (XfpmEngine * engine)
124
GError *error = NULL;
126
xfpm_hibernate (engine->priv->shutdown, &error);
130
g_warning ("%s", error->message);
131
g_error_free (error);
137
xfpm_engine_do_shutdown (XfpmEngine * engine)
139
GError *error = NULL;
141
xfpm_shutdown (engine->priv->shutdown, &error);
145
g_warning ("%s", error->message);
146
g_error_free (error);
152
* Map of int to strings shutdown values
154
static const gchar * G_GNUC_PURE
155
xfpm_int_to_shutdown_string (gint val)
157
if ( val == XFPM_DO_NOTHING )
159
else if ( val == XFPM_DO_SUSPEND)
161
else if ( val == XFPM_DO_HIBERNATE)
163
else if ( val == XFPM_DO_SHUTDOWN)
165
else if ( val == XFPM_ASK)
172
xfpm_engine_shutdown_request (XfpmEngine * engine,
173
XfpmShutdownRequest shutdown, gboolean critical)
175
gboolean lock_screen;
176
const gchar *action = xfpm_int_to_shutdown_string (shutdown);
178
g_object_get (G_OBJECT (engine->priv->conf),
179
LOCK_SCREEN_ON_SLEEP, &lock_screen,
182
if (xfpm_strequal (action, "Nothing"))
184
TRACE ("Button is disabled in configuration");
187
else if ( xfpm_strequal (action, "Ask") && xfpm_strequal (action, "Invalid"))
189
g_warning ("Invalid configuration action %s", action);
192
else if ( engine->priv->inhibited == TRUE && critical == FALSE )
198
TRACE ("Going to do %s\n", action);
200
if (shutdown == XFPM_DO_SHUTDOWN)
202
xfpm_engine_do_shutdown (engine);
204
else if (shutdown == XFPM_DO_HIBERNATE)
206
xfpm_shutdown_add_callback (engine->priv->shutdown,
207
(GSourceFunc) xfpm_engine_do_hibernate,
211
else if (shutdown == XFPM_DO_SUSPEND)
213
xfpm_shutdown_add_callback (engine->priv->shutdown,
214
(GSourceFunc) xfpm_engine_do_suspend,
223
xfpm_engine_shutdown_request_battery_cb (XfpmSupply * supply,
225
XfpmShutdownRequest action,
228
if ( engine->priv->inhibited && critical == FALSE ) /* We can ignore the request here */
231
xfpm_engine_shutdown_request (engine, action, critical);
235
xfpm_engine_lid_event (XfpmButtonHal *bt_hal, gboolean pressed, XfpmEngine *engine)
237
XfpmLidTriggerAction action;
239
g_object_get (G_OBJECT (engine->priv->conf),
240
engine->priv->on_battery ? LID_SWITCH_ON_BATTERY_CFG : LID_SWITCH_ON_AC_CFG, &action,
245
XFPM_DEBUG_ENUM ("LID close event", action, XFPM_TYPE_LID_TRIGGER_ACTION);
247
if ( action == LID_TRIGGER_NOTHING )
249
if ( !xfpm_is_multihead_connected () )
250
xfpm_dpms_force_level (engine->priv->dpms, DPMSModeOff);
252
else if ( action == LID_TRIGGER_LOCK_SCREEN )
254
if ( !xfpm_is_multihead_connected () )
258
xfpm_engine_shutdown_request (engine, action, FALSE);
262
XFPM_DEBUG_ENUM ("LID opened", action, XFPM_TYPE_LID_TRIGGER_ACTION);
263
xfpm_dpms_force_level (engine->priv->dpms, DPMSModeOn);
268
xfpm_engine_button_pressed_cb (XfpmButton *button,
269
XfpmButtonKey type, XfpmEngine * engine)
271
XfpmShutdownRequest req = XFPM_DO_NOTHING;
273
XFPM_DEBUG_ENUM ("Received button press event", type, XFPM_TYPE_BUTTON_KEY);
275
if ( engine->priv->inhibited )
277
TRACE("Power manager automatic sleep is currently disabled");
281
if ( type == BUTTON_MON_BRIGHTNESS_DOWN || type == BUTTON_MON_BRIGHTNESS_UP )
284
if ( type == BUTTON_POWER_OFF )
286
g_object_get (G_OBJECT (engine->priv->conf),
287
POWER_SWITCH_CFG, &req,
290
else if ( type == BUTTON_SLEEP )
292
g_object_get (G_OBJECT (engine->priv->conf),
293
SLEEP_SWITCH_CFG, &req,
296
else if ( type == BUTTON_HIBERNATE )
298
g_object_get (G_OBJECT (engine->priv->conf),
299
HIBERNATE_SWITCH_CFG, &req,
304
g_return_if_reached ();
307
XFPM_DEBUG_ENUM ("Shutdown request : ", req, XFPM_TYPE_SHUTDOWN_REQUEST);
309
if ( req == XFPM_ASK )
310
xfpm_shutdown_ask (engine->priv->shutdown);
312
xfpm_engine_shutdown_request (engine, req, FALSE);
316
xfpm_engine_check_hal_iface (XfpmEngine * engine)
318
gboolean can_suspend, can_hibernate, caller;
320
g_object_get (G_OBJECT (engine->priv->shutdown),
321
"caller-privilege", &caller,
322
"can-suspend", &can_suspend,
323
"can-hibernate", &can_hibernate,
329
engine->priv->power_management |= SYSTEM_CAN_HIBERNATE;
331
engine->priv->power_management |= SYSTEM_CAN_SUSPEND;
334
//FIXME: Show errors here
338
xfpm_engine_supply_notify_cb (GObject *object, GParamSpec *spec, XfpmEngine *engine)
342
if ( xfpm_strequal (spec->name, "on-low-battery") )
344
g_object_get (object, "on-low-battery", &low_power, NULL);
345
TRACE ("On low battery changed %s", xfpm_bool_to_string (low_power));
346
g_signal_emit (G_OBJECT (engine), signals [LOW_BATTERY_CHANGED], 0, low_power);
351
xfpm_engine_load_all (gpointer data)
356
engine = XFPM_ENGINE (data);
358
xfpm_engine_check_hal_iface (engine);
360
manager = hal_manager_new ();
362
if ( hal_manager_get_is_laptop (manager))
363
engine->priv->is_laptop = TRUE;
365
engine->priv->is_laptop = FALSE;
367
g_object_unref (manager);
370
engine->priv->dpms = xfpm_dpms_new ();
373
#ifdef SYSTEM_IS_LINUX
374
if (engine->priv->is_laptop)
375
engine->priv->cpu = xfpm_cpu_new ();
378
engine->priv->supply = xfpm_supply_new (engine->priv->power_management);
379
g_signal_connect (G_OBJECT (engine->priv->supply), "shutdown-request",
380
G_CALLBACK (xfpm_engine_shutdown_request_battery_cb),
383
g_signal_connect (G_OBJECT (engine->priv->supply), "notify",
384
G_CALLBACK (xfpm_engine_supply_notify_cb), engine);
386
xfpm_supply_monitor (engine->priv->supply);
388
engine->priv->button = xfpm_button_new ();
390
g_signal_connect (engine->priv->button, "button-pressed",
391
G_CALLBACK (xfpm_engine_button_pressed_cb), engine);
393
engine->priv->bt_hal = xfpm_button_hal_get ();
394
g_signal_connect (engine->priv->bt_hal, "lid_event",
395
G_CALLBACK (xfpm_engine_lid_event), engine);
399
if (engine->priv->is_laptop)
401
engine->priv->bk = xfpm_backlight_new ();
402
engine->priv->has_lcd_brightness =
403
xfpm_backlight_has_hw (engine->priv->bk);
409
xfpm_engine_adapter_changed_cb (XfpmAdapter * adapter, gboolean present,
412
engine->priv->on_battery = !present;
413
g_signal_emit (G_OBJECT (engine), signals [ON_BATTERY_CHANGED], 0, engine->priv->on_battery);
414
egg_idletime_alarm_reset_all (engine->priv->idle);
418
xfpm_engine_inhibit_changed_cb (XfpmInhibit * inhibit, gboolean inhibited,
421
engine->priv->inhibited = inhibited;
425
xfpm_engine_set_inactivity_timeouts (XfpmEngine *engine)
427
guint on_ac, on_battery;
429
g_object_get (G_OBJECT (engine->priv->conf),
430
ON_AC_INACTIVITY_TIMEOUT, &on_ac,
431
ON_BATTERY_INACTIVITY_TIMEOUT, &on_battery,
436
TRACE ("setting inactivity sleep timeout on ac to never");
438
TRACE ("setting inactivity sleep timeout on ac to %d", on_ac);
439
if ( on_battery == 14 )
440
TRACE ("setting inactivity sleep timeout on battery to never");
442
TRACE ("setting inactivity sleep timeout on battery to %d", on_battery);
447
egg_idletime_alarm_remove (engine->priv->idle, TIMEOUT_INACTIVITY_ON_AC );
451
egg_idletime_alarm_set (engine->priv->idle, TIMEOUT_INACTIVITY_ON_AC, on_ac * 1000 * 60);
454
if ( on_battery == 14 )
456
egg_idletime_alarm_remove (engine->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY );
460
egg_idletime_alarm_set (engine->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY, on_battery * 1000 * 60);
465
xfpm_engine_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmEngine *engine)
467
XfpmShutdownRequest req = XFPM_DO_NOTHING;
471
TRACE ("Alarm inactivity timeout id %d", id);
473
if ( engine->priv->inhibited )
475
TRACE ("Power manager is currently inhibited");
479
saver = xfpm_screen_saver_get_inhibit (engine->priv->srv);
483
TRACE ("User disabled sleep on the context menu");
487
g_object_get (G_OBJECT (engine->priv->conf),
488
INACTIVITY_SLEEP_MODE, &sleep_mode,
491
if ( !g_strcmp0 (sleep_mode, "Suspend") )
492
req = XFPM_DO_SUSPEND;
494
req = XFPM_DO_HIBERNATE;
498
if ( id == TIMEOUT_INACTIVITY_ON_AC && engine->priv->on_battery == FALSE )
499
xfpm_engine_shutdown_request (engine, req, FALSE);
500
else if ( id == TIMEOUT_INACTIVITY_ON_BATTERY && engine->priv->is_laptop && engine->priv->on_battery )
501
xfpm_engine_shutdown_request (engine, req, FALSE);
506
xfpm_engine_settings_changed_cb (GObject *obj, GParamSpec *spec, XfpmEngine *engine)
508
if ( g_str_has_prefix (spec->name, "inactivity") )
509
xfpm_engine_set_inactivity_timeouts (engine);
513
xfpm_engine_class_init (XfpmEngineClass * klass)
515
GObjectClass *object_class = G_OBJECT_CLASS (klass);
517
signals [ON_BATTERY_CHANGED] =
518
g_signal_new("on-battery-changed",
521
G_STRUCT_OFFSET(XfpmEngineClass, on_battery_changed),
523
g_cclosure_marshal_VOID__BOOLEAN,
524
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
526
signals [LOW_BATTERY_CHANGED] =
527
g_signal_new("low-battery-changed",
530
G_STRUCT_OFFSET(XfpmEngineClass, low_battery_changed),
532
g_cclosure_marshal_VOID__BOOLEAN,
533
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
535
object_class->finalize = xfpm_engine_finalize;
537
g_type_class_add_private (klass, sizeof (XfpmEnginePrivate));
539
xfpm_engine_dbus_class_init (klass);
543
xfpm_engine_init (XfpmEngine * engine)
545
engine->priv = XFPM_ENGINE_GET_PRIVATE (engine);
547
engine->priv->shutdown = xfpm_shutdown_new ();
548
engine->priv->adapter = xfpm_adapter_new ();
549
engine->priv->notify = xfpm_notify_new ();
550
engine->priv->srv = xfpm_screen_saver_new ();
551
engine->priv->inhibit = xfpm_inhibit_new ();
552
engine->priv->inhibited = FALSE;
554
g_signal_connect (engine->priv->inhibit, "has-inhibit-changed",
555
G_CALLBACK (xfpm_engine_inhibit_changed_cb), engine);
557
engine->priv->conf = NULL;
558
engine->priv->supply = NULL;
560
engine->priv->dpms = NULL;
563
#ifdef SYSTEM_IS_LINUX
564
engine->priv->cpu = NULL;
567
engine->priv->button = NULL;
568
engine->priv->bk = NULL;
570
engine->priv->power_management = 0;
572
xfpm_engine_dbus_init (engine);
574
engine->priv->conf = xfpm_xfconf_new ();
576
engine->priv->on_battery =
577
!xfpm_adapter_get_present (engine->priv->adapter);
579
g_signal_connect (engine->priv->adapter, "adapter-changed",
580
G_CALLBACK (xfpm_engine_adapter_changed_cb), engine);
582
engine->priv->idle = egg_idletime_new ();
584
g_signal_connect (engine->priv->idle, "alarm-expired",
585
G_CALLBACK (xfpm_engine_alarm_timeout_cb), engine);
587
g_signal_connect (engine->priv->conf, "notify",
588
G_CALLBACK (xfpm_engine_settings_changed_cb), engine);
590
xfpm_engine_set_inactivity_timeouts (engine);
592
g_idle_add ((GSourceFunc)xfpm_engine_load_all, engine);
596
xfpm_engine_finalize (GObject * object)
600
engine = XFPM_ENGINE (object);
602
g_object_unref (engine->priv->conf);
604
g_object_unref (engine->priv->supply);
606
g_object_unref (engine->priv->button);
608
g_object_unref (engine->priv->idle);
609
g_object_unref (engine->priv->bt_hal);
612
if (engine->priv->dpms)
613
g_object_unref (engine->priv->dpms);
616
#ifdef SYSTEM_IS_LINUX
617
if (engine->priv->cpu)
618
g_object_unref (engine->priv->cpu);
621
g_object_unref (engine->priv->shutdown);
623
g_object_unref (engine->priv->adapter);
625
g_object_unref (engine->priv->srv);
627
if (engine->priv->bk)
628
g_object_unref (engine->priv->bk);
630
g_object_unref (engine->priv->notify);
632
G_OBJECT_CLASS (xfpm_engine_parent_class)->finalize (object);
636
xfpm_engine_new (void)
638
XfpmEngine *engine = NULL;
639
engine = g_object_new (XFPM_TYPE_ENGINE, NULL);
645
xfpm_engine_get_info (XfpmEngine * engine, GHashTable *hash)
647
guint8 mapped_buttons;
648
gboolean user_privilege = FALSE;
649
gboolean can_suspend = FALSE;
650
gboolean can_hibernate = FALSE;
651
gboolean has_sleep_button = FALSE;
652
gboolean has_hibernate_button = FALSE;
653
gboolean has_power_button = FALSE;
655
g_return_if_fail (XFPM_IS_ENGINE (engine));
657
g_object_get (G_OBJECT (engine->priv->shutdown),
658
"caller-privilege", &user_privilege,
659
"can-suspend", &can_suspend,
660
"can-hibernate", &can_hibernate, NULL);
663
mapped_buttons = xfpm_button_get_mapped (engine->priv->button);
665
if ( mapped_buttons & SLEEP_KEY )
666
has_sleep_button = TRUE;
667
if ( mapped_buttons & HIBERNATE_KEY )
668
has_hibernate_button = TRUE;
669
if ( mapped_buttons & POWER_KEY )
670
has_power_button = TRUE;
672
g_hash_table_insert (hash, g_strdup ("caller-privilege"), g_strdup (xfpm_bool_to_string (user_privilege)));
673
g_hash_table_insert (hash, g_strdup ("can-suspend"), g_strdup (xfpm_bool_to_string (can_suspend)));
674
g_hash_table_insert (hash, g_strdup ("can-hibernate"), g_strdup (xfpm_bool_to_string (can_hibernate)));
675
g_hash_table_insert (hash, g_strdup ("system-laptop"), g_strdup (xfpm_bool_to_string (engine->priv->is_laptop)));
676
g_hash_table_insert (hash, g_strdup ("has-brightness"), g_strdup (xfpm_bool_to_string (engine->priv->has_lcd_brightness)));
677
g_hash_table_insert (hash, g_strdup ("sleep-button"), g_strdup (xfpm_bool_to_string (has_sleep_button)));
678
g_hash_table_insert (hash, g_strdup ("power-button"), g_strdup (xfpm_bool_to_string (has_power_button)));
679
g_hash_table_insert (hash, g_strdup ("hibernate-button"), g_strdup (xfpm_bool_to_string (has_hibernate_button)));
682
void xfpm_engine_reload_hal_objects (XfpmEngine *engine)
684
g_return_if_fail (XFPM_IS_ENGINE (engine));
686
xfpm_adapter_reload (engine->priv->adapter);
687
xfpm_supply_reload (engine->priv->supply);
690
xfpm_shutdown_reload (engine->priv->shutdown);
692
if ( engine->priv->is_laptop )
694
xfpm_backlight_reload (engine->priv->bk);
695
#ifdef SYSTEM_IS_LINUX
696
xfpm_cpu_reload (engine->priv->cpu);
703
* DBus server implementation for org.freedesktop.PowerManagement
706
static gboolean xfpm_engine_dbus_shutdown (XfpmEngine *engine,
709
static gboolean xfpm_engine_dbus_reboot (XfpmEngine *engine,
712
static gboolean xfpm_engine_dbus_hibernate (XfpmEngine * engine,
715
static gboolean xfpm_engine_dbus_suspend (XfpmEngine * engine,
718
static gboolean xfpm_engine_dbus_can_reboot (XfpmEngine * engine,
719
gboolean * OUT_can_reboot,
722
static gboolean xfpm_engine_dbus_can_shutdown (XfpmEngine * engine,
723
gboolean * OUT_can_reboot,
726
static gboolean xfpm_engine_dbus_can_hibernate (XfpmEngine * engine,
727
gboolean * OUT_can_hibernate,
730
static gboolean xfpm_engine_dbus_can_suspend (XfpmEngine * engine,
731
gboolean * OUT_can_suspend,
734
static gboolean xfpm_engine_dbus_get_power_save_status (XfpmEngine * engine,
735
gboolean * OUT_save_power,
738
static gboolean xfpm_engine_dbus_get_on_battery (XfpmEngine * engine,
739
gboolean * OUT_on_battery,
742
static gboolean xfpm_engine_dbus_get_low_battery (XfpmEngine * engine,
743
gboolean * OUT_low_battery,
746
#include "org.freedesktop.PowerManagement.h"
749
xfpm_engine_dbus_class_init (XfpmEngineClass * klass)
751
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
752
&dbus_glib_xfpm_engine_object_info);
756
xfpm_engine_dbus_init (XfpmEngine * engine)
758
DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
760
dbus_g_connection_register_g_object (bus,
761
"/org/freedesktop/PowerManagement",
765
static gboolean xfpm_engine_dbus_shutdown (XfpmEngine *engine,
768
gboolean caller_privilege, can_hibernate;
770
TRACE ("Hibernate message received");
772
g_object_get (G_OBJECT (engine->priv->shutdown),
773
"caller-privilege", &caller_privilege,
774
"can-hibernate", &can_hibernate, NULL);
776
if (!caller_privilege)
778
g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
779
_("Permission denied"));
783
if ( engine->priv->inhibited )
786
xfpm_shutdown (engine->priv->shutdown, NULL);
791
static gboolean xfpm_engine_dbus_reboot (XfpmEngine *engine,
794
gboolean caller_privilege;
796
TRACE ("Reboot message received");
798
g_object_get (G_OBJECT (engine->priv->shutdown),
799
"caller-privilege", &caller_privilege,
802
if (!caller_privilege)
804
g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
805
_("Permission denied"));
809
if ( engine->priv->inhibited )
812
xfpm_reboot (engine->priv->shutdown, NULL);
818
xfpm_engine_dbus_hibernate (XfpmEngine * engine, GError ** error)
820
gboolean caller_privilege, can_hibernate;
822
TRACE ("Hibernate message received");
824
g_object_get (G_OBJECT (engine->priv->shutdown),
825
"caller-privilege", &caller_privilege,
826
"can-hibernate", &can_hibernate, NULL);
828
if (!caller_privilege)
830
g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
831
_("Permission denied"));
837
g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
838
_("Hibernate not supported"));
842
xfpm_engine_shutdown_request (engine, XFPM_DO_HIBERNATE, FALSE);
848
xfpm_engine_dbus_suspend (XfpmEngine * engine, GError ** error)
850
gboolean caller_privilege, can_suspend;
851
TRACE ("Suspend message received");
853
g_object_get (G_OBJECT (engine->priv->shutdown),
854
"caller-privilege", &caller_privilege,
855
"can-suspend", &can_suspend, NULL);
857
if (!caller_privilege)
859
g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
860
_("Permission denied"));
866
g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
867
_("Suspend not supported"));
871
xfpm_engine_shutdown_request (engine, XFPM_DO_SUSPEND, FALSE);
877
xfpm_engine_dbus_can_shutdown (XfpmEngine * engine,
878
gboolean * OUT_can_shutdown, GError ** error)
880
TRACE ("Can shutdown message received");
882
g_object_get (G_OBJECT (engine->priv->shutdown),
883
"caller-privilege", OUT_can_shutdown, NULL);
889
xfpm_engine_dbus_can_reboot (XfpmEngine * engine,
890
gboolean * OUT_can_reboot, GError ** error)
892
TRACE ("Can reboot message received");
894
g_object_get (G_OBJECT (engine->priv->shutdown),
895
"caller-privilege", OUT_can_reboot, NULL);
901
xfpm_engine_dbus_can_hibernate (XfpmEngine * engine,
902
gboolean * OUT_can_hibernate, GError ** error)
904
TRACE ("Can hibernate message received");
905
g_object_get (G_OBJECT (engine->priv->shutdown),
906
"can-hibernate", OUT_can_hibernate, NULL);
912
xfpm_engine_dbus_can_suspend (XfpmEngine * engine,
913
gboolean * OUT_can_suspend, GError ** error)
915
TRACE ("Can suspend message received");
916
g_object_get (G_OBJECT (engine->priv->shutdown),
917
"can-suspend", OUT_can_suspend, NULL);
922
static gboolean xfpm_engine_dbus_get_power_save_status (XfpmEngine * engine,
923
gboolean * OUT_save_power,
928
TRACE ("Can power save message received");
930
g_object_get (G_OBJECT (engine->priv->conf),
931
POWER_SAVE_ON_BATTERY, &save_power,
934
*OUT_save_power = save_power && engine->priv->on_battery;
940
xfpm_engine_dbus_get_on_battery (XfpmEngine * engine,
941
gboolean * OUT_on_battery, GError ** error)
943
TRACE ("On battery message received");
944
*OUT_on_battery = engine->priv->on_battery;
950
xfpm_engine_dbus_get_low_battery (XfpmEngine * engine,
951
gboolean * OUT_low_battery, GError ** error)
953
TRACE ("On low battery message received");
954
*OUT_low_battery = xfpm_supply_on_low_battery (engine->priv->supply);