Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 586302 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/egg-console-kit.c (+107 lines)
Lines 108-113 egg_console_kit_stop (EggConsoleKit *console, GError **error) Link Here
108
}
108
}
109
109
110
/**
110
/**
111
 * egg_console_kit_suspend:
112
 **/
113
gboolean
114
egg_console_kit_suspend (EggConsoleKit *console, GError **error)
115
{
116
	gboolean ret;
117
	GError *error_local = NULL;
118
119
	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
120
	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
121
122
	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Suspend", &error_local,
123
				 G_TYPE_BOOLEAN, TRUE,
124
				 G_TYPE_INVALID, G_TYPE_INVALID);
125
	if (!ret) {
126
		egg_warning ("Couldn't suspend: %s", error_local->message);
127
		if (error != NULL)
128
			*error = g_error_new (1, 0, "%s", error_local->message);
129
		g_error_free (error_local);
130
	}
131
	return ret;
132
}
133
134
/**
135
 * egg_console_kit_hibernate:
136
 **/
137
gboolean
138
egg_console_kit_hibernate (EggConsoleKit *console, GError **error)
139
{
140
	gboolean ret;
141
	GError *error_local = NULL;
142
143
	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
144
	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
145
146
	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Hibernate", &error_local,
147
				 G_TYPE_BOOLEAN, TRUE,
148
				 G_TYPE_INVALID, G_TYPE_INVALID);
149
	if (!ret) {
150
		egg_warning ("Couldn't hibernate: %s", error_local->message);
151
		if (error != NULL)
152
			*error = g_error_new (1, 0, "%s", error_local->message);
153
		g_error_free (error_local);
154
	}
155
	return ret;
156
}
157
158
/**
111
 * egg_console_kit_can_stop:
159
 * egg_console_kit_can_stop:
112
 **/
160
 **/
113
gboolean
161
gboolean
Lines 162-167 egg_console_kit_can_restart (EggConsoleKit *console, gboolean *can_restart, GErr Link Here
162
}
210
}
163
211
164
/**
212
/**
213
 * egg_console_kit_can_suspend:
214
 **/
215
gboolean
216
egg_console_kit_can_suspend (EggConsoleKit *console, gboolean *can_suspend, GError **error)
217
{
218
	GError *error_local = NULL;
219
	gboolean ret;
220
	gchar  *retval;
221
222
	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
223
	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
224
225
	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanSuspend", &error_local,
226
				 G_TYPE_INVALID,
227
				 G_TYPE_STRING, &retval, G_TYPE_INVALID);
228
	if (!ret) {
229
		egg_warning ("Couldn't do CanSuspend: %s", error_local->message);
230
		if (error != NULL)
231
			*error = g_error_new (1, 0, "%s", error_local->message);
232
		g_error_free (error_local);
233
	}
234
235
	*can_suspend = g_strcmp0 (retval, "yes") == 0 ||
236
		       g_strcmp0 (retval, "challenge") == 0;
237
238
	g_free (retval);
239
	return ret;
240
}
241
242
/**
243
 * egg_console_kit_can_hibernate:
244
 **/
245
246
gboolean
247
egg_console_kit_can_hibernate (EggConsoleKit *console, gboolean *can_hibernate, GError **error)
248
{
249
	GError *error_local = NULL;
250
	gboolean ret;
251
	gchar  *retval;
252
253
	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
254
	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
255
256
	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanHibernate", &error_local,
257
				 G_TYPE_INVALID,
258
				 G_TYPE_STRING, &retval, G_TYPE_INVALID);
259
	if (!ret) {
260
		egg_warning ("Couldn't do CanHibernate: %s", error_local->message);
261
		if (error != NULL)
262
			*error = g_error_new (1, 0, "%s", error_local->message);
263
		g_error_free (error_local);
264
	}
265
266
	*can_hibernate = g_strcmp0 (retval, "yes") == 0 ||
267
	                 g_strcmp0 (retval, "challenge") == 0;
268
	return ret;
269
}
270
271
/**
165
 * egg_console_kit_is_local:
272
 * egg_console_kit_is_local:
166
 *
273
 *
167
 * Return value: Returns whether the session is local
274
 * Return value: Returns whether the session is local
(-)a/src/egg-console-kit.h (+10 lines)
Lines 58-69 gboolean egg_console_kit_stop (EggConsoleKit *console, Link Here
58
							 GError		**error);
58
							 GError		**error);
59
gboolean	 egg_console_kit_restart		(EggConsoleKit	*console,
59
gboolean	 egg_console_kit_restart		(EggConsoleKit	*console,
60
							 GError		**error);
60
							 GError		**error);
61
gboolean	 egg_console_kit_suspend		(EggConsoleKit	*console,
62
							 GError		**error);
63
gboolean	 egg_console_kit_hibernate		(EggConsoleKit	*console,
64
							 GError		**error);
61
gboolean	 egg_console_kit_can_stop		(EggConsoleKit	*console,
65
gboolean	 egg_console_kit_can_stop		(EggConsoleKit	*console,
62
							 gboolean	*can_stop,
66
							 gboolean	*can_stop,
63
							 GError		**error);
67
							 GError		**error);
64
gboolean	 egg_console_kit_can_restart		(EggConsoleKit	*console,
68
gboolean	 egg_console_kit_can_restart		(EggConsoleKit	*console,
65
							 gboolean	*can_restart,
69
							 gboolean	*can_restart,
66
							 GError		**error);
70
							 GError		**error);
71
gboolean	 egg_console_kit_can_suspend		(EggConsoleKit	*console,
72
							 gboolean	*can_restart,
73
							 GError		**error);
74
gboolean	 egg_console_kit_can_hibernate		(EggConsoleKit	*console,
75
							 gboolean	*can_restart,
76
							 GError		**error);
67
77
68
G_END_DECLS
78
G_END_DECLS
69
79
(-)a/src/gpm-control.c (-7 / +10 lines)
Lines 39-45 Link Here
39
#include <glib/gi18n.h>
39
#include <glib/gi18n.h>
40
#include <dbus/dbus-glib.h>
40
#include <dbus/dbus-glib.h>
41
#include <dbus/dbus-glib-lowlevel.h>
41
#include <dbus/dbus-glib-lowlevel.h>
42
#define UPOWER_ENABLE_DEPRECATED
43
#include <libupower-glib/upower.h>
42
#include <libupower-glib/upower.h>
44
43
45
#ifdef WITH_KEYRING
44
#ifdef WITH_KEYRING
Lines 212-217 gpm_control_suspend (GpmControl *control, GError **error) Link Here
212
	gboolean ret = FALSE;
211
	gboolean ret = FALSE;
213
	gboolean do_lock;
212
	gboolean do_lock;
214
	gboolean nm_sleep;
213
	gboolean nm_sleep;
214
	EggConsoleKit *console;
215
	GpmScreensaver *screensaver;
215
	GpmScreensaver *screensaver;
216
	guint32 throttle_cookie = 0;
216
	guint32 throttle_cookie = 0;
217
#ifdef WITH_KEYRING
217
#ifdef WITH_KEYRING
Lines 293-303 gpm_control_suspend (GpmControl *control, GError **error) Link Here
293
		}
293
		}
294
		g_object_unref(proxy);
294
		g_object_unref(proxy);
295
	}
295
	}
296
#if !UP_CHECK_VERSION(0, 99, 0)
297
	else {
296
	else {
298
		ret = up_client_suspend_sync (control->priv->client, NULL, error);
297
		console = egg_console_kit_new ();
298
		ret = egg_console_kit_suspend (console, error);
299
		g_object_unref (console);
299
	}
300
	}
300
#endif
301
301
	egg_debug ("emitting resume");
302
	egg_debug ("emitting resume");
302
	g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_SUSPEND);
303
	g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_SUSPEND);
303
304
Lines 326-331 gpm_control_hibernate (GpmControl *control, GError **error) Link Here
326
	gboolean ret = FALSE;
327
	gboolean ret = FALSE;
327
	gboolean do_lock;
328
	gboolean do_lock;
328
	gboolean nm_sleep;
329
	gboolean nm_sleep;
330
	EggConsoleKit *console;
329
	GpmScreensaver *screensaver;
331
	GpmScreensaver *screensaver;
330
	guint32 throttle_cookie = 0;
332
	guint32 throttle_cookie = 0;
331
#ifdef WITH_KEYRING
333
#ifdef WITH_KEYRING
Lines 406-416 gpm_control_hibernate (GpmControl *control, GError **error) Link Here
406
			ret = TRUE;
408
			ret = TRUE;
407
		}
409
		}
408
	}
410
	}
409
#if !UP_CHECK_VERSION(0, 99, 0)
410
	else {
411
	else {
411
		ret = up_client_hibernate_sync (control->priv->client, NULL, error);
412
		console = egg_console_kit_new ();
413
		ret = egg_console_kit_hibernate (console, error);
414
		g_object_unref (console);
412
	}
415
	}
413
#endif
416
414
	egg_debug ("emitting resume");
417
	egg_debug ("emitting resume");
415
	g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_HIBERNATE);
418
	g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_HIBERNATE);
416
419
(-)a/src/gpm-prefs-core.c (-8 / +3 lines)
Lines 30-36 Link Here
30
#include <dbus/dbus-glib.h>
30
#include <dbus/dbus-glib.h>
31
#include <math.h>
31
#include <math.h>
32
#include <string.h>
32
#include <string.h>
33
#define UPOWER_ENABLE_DEPRECATED
34
#include <libupower-glib/upower.h>
33
#include <libupower-glib/upower.h>
35
34
36
#include "egg-debug.h"
35
#include "egg-debug.h"
Lines 756-768 gpm_prefs_init (GpmPrefs *prefs) Link Here
756
		g_object_unref(proxy);
755
		g_object_unref(proxy);
757
	}
756
	}
758
	else {
757
	else {
759
		/* are we allowed to shutdown? */
758
		/* Get values from ConseleKit */
760
		egg_console_kit_can_stop (prefs->priv->console, &prefs->priv->can_shutdown, NULL);
759
		egg_console_kit_can_stop (prefs->priv->console, &prefs->priv->can_shutdown, NULL);
761
#if !UP_CHECK_VERSION(0, 99, 0)
760
		egg_console_kit_can_suspend (prefs->priv->console, &prefs->priv->can_suspend, NULL);
762
		/* get values from UpClient */
761
		egg_console_kit_can_hibernate (prefs->priv->console, &prefs->priv->can_hibernate, NULL);
763
		prefs->priv->can_suspend = up_client_get_can_suspend (prefs->priv->client);
764
		prefs->priv->can_hibernate = up_client_get_can_hibernate (prefs->priv->client);
765
#endif
766
	}
762
	}
767
763
768
	if (LOGIND_RUNNING()) {
764
	if (LOGIND_RUNNING()) {
769
- 

Return to bug 586302