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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
diff --git a/configure.ac b/configure.ac
index 37bb191..a9e20ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,7 +70,6 @@ PKG_CHECK_MODULES(MATE_SESSION,
gio-2.0 >= $GIO_REQUIRED
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED
dbus-glib-1 >= $DBUS_GLIB_REQUIRED
- upower-glib >= $UPOWER_REQUIRED
)
PKG_CHECK_MODULES(SESSION_PROPERTIES,
@@ -128,6 +127,24 @@ AM_CONDITIONAL(HAVE_SYSTEMD, test "x$use_systemd" = "xyes")
AC_SUBST(HAVE_SYSTEMD)
dnl ====================================================================
+dnl UPOWER
+dnl ====================================================================
+
+AC_ARG_ENABLE(upower,
+ AS_HELP_STRING([--enable-upower],
+ [Use upower to suspend/hibernate]),
+ enable_upower=$enableval,
+ enable_upower=yes)
+if test "x$enable_upower" = "xyes"; then
+ PKG_CHECK_MODULES(UPOWER, upower-glib >= $UPOWER_REQUIRED, has_upower=yes, has_upower=no)
+ AC_DEFINE(HAVE_UPOWER, 1, [upower support])
+ AC_SUBST(UPOWER_CFLAGS)
+ AC_SUBST(UPOWER_LIBS)
+fi
+AM_CONDITIONAL(HAVE_UPOWER, test "x$enable_upower" = "xyes")
+AC_SUBST(HAVE_UPOWER)
+
+dnl ====================================================================
dnl X development libraries check
dnl ====================================================================
@@ -385,6 +402,7 @@ echo "
GTK+ version: ${with_gtk}
Default WM: ${with_default_wm}
Systemd support: ${use_systemd}
+ Upower support: ${enable_upower}
IPv6 support: ${have_full_ipv6}
Backtrace support: ${have_backtrace}
XRender support: ${have_xrender}
diff --git a/mate-session/Makefile.am b/mate-session/Makefile.am
index f37a0e2..53f0fc7 100644
--- a/mate-session/Makefile.am
+++ b/mate-session/Makefile.am
@@ -7,6 +7,7 @@ noinst_PROGRAMS = \
AM_CPPFLAGS = \
$(MATE_SESSION_CFLAGS) \
$(SYSTEMD_CFLAGS) \
+ $(UPOWER_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS)
AM_CFLAGS = $(WARN_CFLAGS)
@@ -76,6 +77,7 @@ mate_session_LDADD = \
$(XEXT_LIBS) \
$(MATE_SESSION_LIBS) \
$(SYSTEMD_LIBS) \
+ $(UPOWER_LIBS) \
$(EXECINFO_LIBS)
libgsmutil_la_SOURCES = \
diff --git a/mate-session/gsm-logout-dialog.c b/mate-session/gsm-logout-dialog.c
index 1a79875..323f123 100644
--- a/mate-session/gsm-logout-dialog.c
+++ b/mate-session/gsm-logout-dialog.c
@@ -27,7 +27,9 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#ifdef HAVE_UPOWER
#include <upower.h>
+#endif
#include "gsm-logout-dialog.h"
#ifdef HAVE_SYSTEMD
@@ -52,8 +54,9 @@
struct _GsmLogoutDialogPrivate
{
GsmDialogLogoutType type;
-
+#ifdef HAVE_UPOWER
UpClient *up_client;
+#endif
#ifdef HAVE_SYSTEMD
GsmSystemd *systemd;
#endif
@@ -147,9 +150,9 @@ enum {
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
gtk_window_stick (GTK_WINDOW (logout_dialog));
-
+#ifdef HAVE_UPOWER
logout_dialog->priv->up_client = up_client_new ();
-
+#endif
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING())
logout_dialog->priv->systemd = gsm_get_systemd ();
@@ -176,12 +179,12 @@ enum {
g_source_remove (logout_dialog->priv->timeout_id);
logout_dialog->priv->timeout_id = 0;
}
-
+#ifdef HAVE_UPOWER
if (logout_dialog->priv->up_client) {
g_object_unref (logout_dialog->priv->up_client);
logout_dialog->priv->up_client = NULL;
}
-
+#endif
#ifdef HAVE_SYSTEMD
if (logout_dialog->priv->systemd) {
g_object_unref (logout_dialog->priv->systemd);
@@ -201,13 +204,17 @@ enum {
gsm_logout_supports_system_suspend (GsmLogoutDialog *logout_dialog)
{
gboolean ret;
+ ret = FALSE;
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING())
ret = gsm_systemd_can_suspend (logout_dialog->priv->systemd);
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
else
#endif
+#ifdef HAVE_UPOWER
ret = up_client_get_can_suspend (logout_dialog->priv->up_client);
-
+#endif
return ret;
}
@@ -215,13 +222,17 @@ enum {
gsm_logout_supports_system_hibernate (GsmLogoutDialog *logout_dialog)
{
gboolean ret;
+ ret = FALSE;
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING())
ret = gsm_systemd_can_hibernate (logout_dialog->priv->systemd);
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
else
#endif
+#ifdef HAVE_UPOWER
ret = up_client_get_can_hibernate (logout_dialog->priv->up_client);
-
+#endif
return ret;
}
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c
index 79d0829..17a20b8 100644
--- a/mate-session/gsm-manager.c
+++ b/mate-session/gsm-manager.c
@@ -38,7 +38,9 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#ifdef HAVE_UPOWER
#include <upower.h>
+#endif
#include <gtk/gtk.h> /* for logout dialog */
#include <gio/gio.h> /* for gsettings */
@@ -144,9 +146,10 @@ struct GsmManagerPrivate
DBusGProxy *bus_proxy;
DBusGConnection *connection;
-
+#ifdef HAVE_UPOWER
/* Interface with other parts of the system */
UpClient *up_client;
+#endif
};
enum {
@@ -1097,10 +1100,11 @@ enum {
static void
manager_attempt_hibernate (GsmManager *manager)
{
+#ifdef HAVE_UPOWER
gboolean can_hibernate;
GError *error;
gboolean ret;
-
+#endif
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING()) {
@@ -1113,8 +1117,11 @@ enum {
gsm_systemd_attempt_hibernate (systemd);
}
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
else {
#endif
+#ifdef HAVE_UPOWER
can_hibernate = up_client_get_can_hibernate (manager->priv->up_client);
if (can_hibernate) {
@@ -1129,7 +1136,8 @@ enum {
g_error_free (error);
}
}
-#ifdef HAVE_SYSTEMD
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
}
#endif
}
@@ -1137,10 +1145,11 @@ enum {
static void
manager_attempt_suspend (GsmManager *manager)
{
+#ifdef HAVE_UPOWER
gboolean can_suspend;
GError *error;
gboolean ret;
-
+#endif
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING()) {
@@ -1153,8 +1162,11 @@ enum {
gsm_systemd_attempt_suspend (systemd);
}
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
else {
#endif
+#ifdef HAVE_UPOWER
can_suspend = up_client_get_can_suspend (manager->priv->up_client);
if (can_suspend) {
@@ -1169,7 +1181,8 @@ enum {
g_error_free (error);
}
}
-#ifdef HAVE_SYSTEMD
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
}
#endif
}
@@ -2341,12 +2354,12 @@ enum {
g_object_unref (manager->priv->settings_screensaver);
manager->priv->settings_screensaver = NULL;
}
-
+#ifdef HAVE_UPOWER
if (manager->priv->up_client != NULL) {
g_object_unref (manager->priv->up_client);
manager->priv->up_client = NULL;
}
-
+#endif
G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object);
}
@@ -2553,9 +2566,9 @@ enum {
"status-changed",
G_CALLBACK (on_presence_status_changed),
manager);
-
+#ifdef HAVE_UPOWER
manager->priv->up_client = up_client_new ();
-
+#endif
g_signal_connect (manager->priv->settings_session,
"changed",
G_CALLBACK (on_gsettings_key_changed),
@@ -3224,12 +3237,12 @@ enum {
#endif
gboolean can_suspend;
gboolean can_hibernate;
-
+#ifdef HAVE_UPOWER
g_object_get (manager->priv->up_client,
"can-suspend", &can_suspend,
"can-hibernate", &can_hibernate,
NULL);
-
+#endif
g_debug ("GsmManager: CanShutdown called");
g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
|