~ubuntu-branches/debian/experimental/brasero/experimental

« back to all changes in this revision

Viewing changes to src/burn-dbus.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2009-09-09 21:02:15 UTC
  • mfrom: (1.3.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20090909210215-2a78qki0a1wyvtah
Tags: 2.27.92-2
Let libbrasero-media-dev depend on libdbus-glib-1-dev as it's required
by libbrasero-burn.pc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2008 Luis Medinas <lmedinas@gmail.com>
2
 
 * Copyright 2008 Philippe Rouquier <brasero-app@wanadoo.fr>
3
 
 *
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.
8
 
 *
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.
13
 
 *
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.
19
 
 */
20
 
 
21
 
 
22
 
#ifdef HAVE_CONFIG_H
23
 
#  include <config.h>
24
 
#endif
25
 
 
26
 
#include <glib.h>
27
 
#include <dbus/dbus-glib.h>
28
 
#include "burn-dbus.h"
29
 
 
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"
33
 
 
34
 
void 
35
 
brasero_uninhibit_suspend (guint cookie)
36
 
{
37
 
        DBusGProxy      *proxy;
38
 
        gboolean        res;
39
 
        GError          *error = NULL;
40
 
        DBusGConnection *conn   = NULL;
41
 
 
42
 
        if (cookie < 0) {
43
 
                g_warning ("Invalid cookie");
44
 
                return;
45
 
        }
46
 
 
47
 
        conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
48
 
        if (!conn) {
49
 
                g_warning ("Couldn't get a DBUS connection: %s",
50
 
                            error->message);
51
 
                g_error_free (error);
52
 
                return;
53
 
        }
54
 
 
55
 
        proxy = dbus_g_proxy_new_for_name (conn,
56
 
                                           GPM_DBUS_SERVICE,
57
 
                                           GPM_DBUS_INHIBIT_PATH,
58
 
                                           GPM_DBUS_INHIBIT_INTERFACE);
59
 
        if (proxy == NULL) {
60
 
                g_warning ("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
61
 
                dbus_g_connection_unref (conn);
62
 
                return;
63
 
        }
64
 
 
65
 
        res = dbus_g_proxy_call (proxy,
66
 
                                 "UnInhibit", &error,
67
 
                                 G_TYPE_UINT, cookie,
68
 
                                 G_TYPE_INVALID,
69
 
                                 G_TYPE_INVALID);
70
 
        if (!res) {
71
 
                g_warning ("Failed to restore the system power manager: %s",
72
 
                            error->message);
73
 
                g_error_free (error);
74
 
        }
75
 
 
76
 
        g_object_unref (G_OBJECT (proxy));
77
 
        dbus_g_connection_unref (conn);
78
 
}
79
 
 
80
 
gint
81
 
brasero_inhibit_suspend (const char *reason)
82
 
{
83
 
        DBusGProxy      *proxy;
84
 
        guint            cookie;
85
 
        gboolean         res;
86
 
        GError          *error  = NULL;
87
 
        DBusGConnection *conn   = NULL;
88
 
 
89
 
        g_return_val_if_fail (reason != NULL, -1);
90
 
 
91
 
        conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
92
 
        if (!conn) {
93
 
                g_warning ("Couldn't get a DBUS connection: %s",
94
 
                            error->message);
95
 
                g_error_free (error);
96
 
                return -1;
97
 
        }
98
 
 
99
 
        proxy = dbus_g_proxy_new_for_name (conn,
100
 
                                           GPM_DBUS_SERVICE,
101
 
                                           GPM_DBUS_INHIBIT_PATH,
102
 
                                           GPM_DBUS_INHIBIT_INTERFACE);
103
 
        
104
 
        if (proxy == NULL) {
105
 
                g_warning ("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
106
 
                return -1;
107
 
        }
108
 
 
109
 
        res = dbus_g_proxy_call (proxy,
110
 
                                 "Inhibit", &error,
111
 
                                 G_TYPE_STRING, "Brasero",
112
 
                                 G_TYPE_STRING, reason,
113
 
                                 G_TYPE_INVALID,
114
 
                                 G_TYPE_UINT, &cookie,
115
 
                                 G_TYPE_INVALID);
116
 
        if (!res) {
117
 
                g_warning ("Failed to inhibit the system from suspending: %s",
118
 
                            error->message);
119
 
                g_error_free (error);
120
 
                cookie = -1;
121
 
        }
122
 
 
123
 
        g_object_unref (G_OBJECT (proxy));
124
 
        dbus_g_connection_unref (conn);
125
 
 
126
 
        return cookie;
127
 
}