1
/* Copyright 2008 Luis Medinas <lmedinas@gmail.com>
2
* Copyright 2008 Philippe Rouquier <brasero-app@wanadoo.fr>
4
* Brasero is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* Brasero is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Library General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to:
16
* The Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor
18
* Boston, MA 02110-1301, USA.
27
#include <dbus/dbus-glib.h>
28
#include "burn-dbus.h"
30
#define GPM_DBUS_SERVICE "org.freedesktop.PowerManagement"
31
#define GPM_DBUS_INHIBIT_PATH "/org/freedesktop/PowerManagement/Inhibit"
32
#define GPM_DBUS_INHIBIT_INTERFACE "org.freedesktop.PowerManagement.Inhibit"
35
brasero_uninhibit_suspend (guint cookie)
40
DBusGConnection *conn = NULL;
43
g_warning ("Invalid cookie");
47
conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
49
g_warning ("Couldn't get a DBUS connection: %s",
55
proxy = dbus_g_proxy_new_for_name (conn,
57
GPM_DBUS_INHIBIT_PATH,
58
GPM_DBUS_INHIBIT_INTERFACE);
60
g_warning ("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
61
dbus_g_connection_unref (conn);
65
res = dbus_g_proxy_call (proxy,
71
g_warning ("Failed to restore the system power manager: %s",
76
g_object_unref (G_OBJECT (proxy));
77
dbus_g_connection_unref (conn);
81
brasero_inhibit_suspend (const char *reason)
87
DBusGConnection *conn = NULL;
89
g_return_val_if_fail (reason != NULL, -1);
91
conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
93
g_warning ("Couldn't get a DBUS connection: %s",
99
proxy = dbus_g_proxy_new_for_name (conn,
101
GPM_DBUS_INHIBIT_PATH,
102
GPM_DBUS_INHIBIT_INTERFACE);
105
g_warning ("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
109
res = dbus_g_proxy_call (proxy,
111
G_TYPE_STRING, "Brasero",
112
G_TYPE_STRING, reason,
114
G_TYPE_UINT, &cookie,
117
g_warning ("Failed to inhibit the system from suspending: %s",
119
g_error_free (error);
123
g_object_unref (G_OBJECT (proxy));
124
dbus_g_connection_unref (conn);