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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
--- gnome-session/gsm-manager.c.orig 2009-07-28 21:51:22.000000000 -0400
+++ gnome-session/gsm-manager.c 2009-08-26 14:54:08.000000000 -0400
@@ -38,8 +38,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <devkit-power-gobject/devicekit-power.h>
-
#include <gtk/gtk.h> /* for logout dialog */
#include <gconf/gconf-client.h>
@@ -60,6 +58,7 @@
#include "gsm-logout-dialog.h"
#include "gsm-inhibit-dialog.h"
#include "gsm-consolekit.h"
+#include "gsm-power-manager.h"
#include "gsm-session-save.h"
#define GSM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_MANAGER, GsmManagerPrivate))
@@ -131,9 +130,6 @@ struct GsmManagerPrivate
DBusGProxy *bus_proxy;
DBusGConnection *connection;
-
- /* Interface with other parts of the system */
- DkpClient *dkp_client;
};
enum {
@@ -927,47 +923,29 @@ manager_switch_user (GsmManager *manager
static void
manager_attempt_hibernate (GsmManager *manager)
{
- gboolean can_hibernate;
- GError *error;
- gboolean ret;
+ GsmPowerManager *power_manager;
- g_object_get (manager->priv->dkp_client,
- "can-hibernate", &can_hibernate,
- NULL);
-
- if (can_hibernate) {
- error = NULL;
- ret = dkp_client_hibernate (manager->priv->dkp_client, &error);
+ power_manager = gsm_get_power_manager ();
- if (!ret) {
- g_warning ("Unexpected hibernate failure: %s",
- error->message);
- g_error_free (error);
- }
+ if (gsm_power_manager_can_hibernate (power_manager)) {
+ gsm_power_manager_attempt_hibernate (power_manager);
}
+
+ g_object_unref (power_manager);
}
static void
manager_attempt_suspend (GsmManager *manager)
{
- gboolean can_suspend;
- GError *error;
- gboolean ret;
+ GsmPowerManager *power_manager;
- g_object_get (manager->priv->dkp_client,
- "can-suspend", &can_suspend,
- NULL);
-
- if (can_suspend) {
- error = NULL;
- ret = dkp_client_suspend (manager->priv->dkp_client, &error);
+ power_manager = gsm_get_power_manager ();
- if (!ret) {
- g_warning ("Unexpected suspend failure: %s",
- error->message);
- g_error_free (error);
- }
+ if (gsm_power_manager_can_suspend (power_manager)) {
+ gsm_power_manager_attempt_suspend (power_manager);
}
+
+ g_object_unref (power_manager);
}
static void
@@ -2140,11 +2118,6 @@ gsm_manager_dispose (GObject *object)
manager->priv->gconf_client = NULL;
}
- if (manager->priv->dkp_client != NULL) {
- g_object_unref (manager->priv->dkp_client);
- manager->priv->dkp_client = NULL;
- }
-
G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object);
}
@@ -2373,8 +2346,6 @@ gsm_manager_init (GsmManager *manager)
G_CALLBACK (on_presence_status_changed),
manager);
- manager->priv->dkp_client = dkp_client_new ();
-
/* GConf setup */
gconf_client_add_dir (manager->priv->gconf_client,
KEY_DESKTOP_DIR,
@@ -2894,24 +2865,20 @@ gsm_manager_can_shutdown (GsmManager *ma
GError **error)
{
GsmConsolekit *consolekit;
- gboolean can_suspend;
- gboolean can_hibernate;
-
- g_object_get (manager->priv->dkp_client,
- "can-suspend", &can_suspend,
- "can-hibernate", &can_hibernate,
- NULL);
+ GsmPowerManager *power_manager;
g_debug ("GsmManager: CanShutdown called");
g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
consolekit = gsm_get_consolekit ();
+ power_manager = gsm_get_power_manager ();
*shutdown_available = gsm_consolekit_can_stop (consolekit)
|| gsm_consolekit_can_restart (consolekit)
- || can_suspend
- || can_hibernate;
+ || gsm_power_manager_can_suspend (power_manager)
+ || gsm_power_manager_can_hibernate (power_manager);
g_object_unref (consolekit);
+ g_object_unref (power_manager);
return TRUE;
}
|