~ubuntu-branches/ubuntu/maverick/brasero/maverick

« back to all changes in this revision

Viewing changes to libbrasero-utils/brasero-pk.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-09-14 10:23:22 UTC
  • mfrom: (1.1.44 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914102322-7eigq8pge5wqfol1
Tags: 2.31.92-0ubuntu1
* New upstream release:
  - Revert to libunique from GApplication (Luis Medinas)
  - Remove dbus-glib requires from pkgconfig file (Luis Medinas)
  - Some more debugging to find out about problems with encrypted DVDs
    (Philippe Rouquier)
  - Fix minor issues in gdbus conversion. (Luis Medinas)
  - Remove dbus-glib check from configure (Luis Medinas)
  - Replace last part of dbus-glib by GDBus (Luis Medinas)
  - Fix Inhibit() d-bus parameters (Robert Ancell)
  - Remove dbus libraries from the Makefile. (Luis Medinas)
  - Use --with-gtk switch for gtk 2/3 selection (Christian Persch)
  - Fix image checksuming that did not occur when GConf or GSetting returned 0
    as a value for the checksum type key (Philippe Rouquier)
  - Don't hardcode gconf gsettings backend (Robert Ancell)
  - Fix brasero plugin directory (Robert Ancell)
* debian/control:
  - build-dep on libunique
* debian/patches/010_lpi.patch,31_link_libice.patch:
  - adapt to latest code
* debian/patches/013_gsettings_backend.patch,014_plugin_directory.patch,
  015_inhibit_params.patch:
  - removed, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
#include <glib.h>
40
40
#include <gdk/gdk.h>
41
 
#include <dbus/dbus-glib.h>
42
41
 
43
42
#include <gst/gst.h>
44
43
#include <gst/pbutils/install-plugins.h>
52
51
typedef struct _BraseroPKPrivate BraseroPKPrivate;
53
52
struct _BraseroPKPrivate
54
53
{
55
 
        DBusGConnection *connection;
56
 
        DBusGProxy *proxy;
57
 
        DBusGProxyCall *call;
 
54
        GDBusConnection *connection;
 
55
        GDBusProxy *proxy;
58
56
 
 
57
        GVariant *values;
 
58
        GAsyncResult *result;
59
59
        GMainLoop *loop;
60
60
        gboolean res;
61
61
};
65
65
G_DEFINE_TYPE (BraseroPK, brasero_pk, G_TYPE_OBJECT);
66
66
 
67
67
static void
68
 
brasero_pk_install_missing_files_result (DBusGProxy *proxy,
69
 
                                         DBusGProxyCall *call,
 
68
brasero_pk_install_missing_files_result (GObject *source_object,
 
69
                                         GAsyncResult *result,
70
70
                                         gpointer user_data)
71
71
{
72
72
        GError *error = NULL;
73
73
        BraseroPKPrivate *priv = BRASERO_PK_PRIVATE (user_data);
74
74
 
75
 
        priv->call = NULL;
76
 
        priv->res = dbus_g_proxy_end_call (proxy,
77
 
                                           call,
78
 
                                           &error,
79
 
                                           G_TYPE_INVALID);
80
 
        if (!priv->res) {
 
75
        priv->proxy = G_DBUS_PROXY (source_object);
 
76
 
 
77
        priv->values = g_dbus_proxy_call_finish (priv->proxy, 
 
78
                                                 result, 
 
79
                                                 &error);
 
80
 
 
81
        if (priv->values == NULL) {
81
82
                BRASERO_UTILS_LOG ("%s", error->message);
82
83
                g_error_free (error);
83
84
        }
84
85
 
85
 
        g_main_loop_quit (priv->loop);
 
86
        if (priv->values != NULL)
 
87
                g_variant_unref (priv->values);
 
88
        g_object_unref (priv->proxy);
86
89
}
87
90
 
88
91
static void
89
92
brasero_pk_cancelled (GCancellable *cancel,
90
93
                      BraseroPK *package)
91
94
{
 
95
        GError *error = NULL;
92
96
        BraseroPKPrivate *priv = BRASERO_PK_PRIVATE (package);
93
97
 
94
98
        priv->res = FALSE;
95
99
 
96
 
        if (priv->call)
97
 
                dbus_g_proxy_cancel_call (priv->proxy, priv->call);
 
100
        if (priv->proxy)
 
101
                g_dbus_proxy_call_finish (priv->proxy, 
 
102
                                          priv->result,
 
103
                                          &error);
98
104
 
99
105
        if (priv->loop)
100
106
                g_main_loop_quit (priv->loop);
139
145
        priv = BRASERO_PK_PRIVATE (package);
140
146
 
141
147
        /* check dbus connections, exit if not valid */
142
 
        priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
 
148
        priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
143
149
        if (priv->connection == NULL) {
144
150
                BRASERO_UTILS_LOG ("%s", error->message);
145
151
                return FALSE;
146
152
        }
147
153
 
148
154
        /* get a connection */
149
 
        priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
150
 
                                                 "org.freedesktop.PackageKit",
151
 
                                                 "/org/freedesktop/PackageKit",
152
 
                                                 "org.freedesktop.PackageKit.Modify");
 
155
        priv->proxy = g_dbus_proxy_new_sync (priv->connection,
 
156
                                                                  G_DBUS_PROXY_FLAGS_NONE,
 
157
                                                                  NULL,
 
158
                                                                  "org.freedesktop.PackageKit",
 
159
                                                                  "/org/freedesktop/PackageKit",
 
160
                                                                  "org.freedesktop.PackageKit.Modify",
 
161
                                                                  NULL,
 
162
                                                                 &error);
153
163
        if (priv->proxy == NULL) {
154
164
                BRASERO_UTILS_LOG ("Cannot connect to session service");
155
165
                return FALSE;
156
166
        }
157
167
 
158
168
        /* don't timeout, as dbus-glib sets the timeout ~25 seconds */
159
 
        dbus_g_proxy_set_default_timeout (priv->proxy, INT_MAX);
 
169
        g_dbus_proxy_set_default_timeout (priv->proxy, INT_MAX);
160
170
 
161
171
        return TRUE;
162
172
}
199
209
brasero_pk_install_gstreamer_plugin (BraseroPK *package,
200
210
                                     const gchar *element_name,
201
211
                                     int xid,
202
 
                                    GCancellable *cancel)
 
212
                                     GCancellable *cancel)
203
213
{
204
214
        GstInstallPluginsContext *context;
205
215
        GPtrArray *gst_plugins = NULL;
237
247
brasero_pk_install_file_requirement (BraseroPK *package,
238
248
                                     GPtrArray *missing_files,
239
249
                                     int xid,
240
 
                                    GCancellable *cancel)
 
250
                                     GCancellable *cancel)
241
251
{
242
252
        BraseroPKPrivate *priv;
243
253
 
246
256
        if (!brasero_pk_connect (package))
247
257
                return FALSE;
248
258
 
249
 
        priv->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy, "InstallProvideFiles",
250
 
                                                           brasero_pk_install_missing_files_result,
251
 
                                                           package,
252
 
                                                           NULL,
253
 
                                                           INT_MAX,
254
 
                                                           G_TYPE_UINT, xid,
255
 
                                                           G_TYPE_STRV, missing_files->pdata,
256
 
                                                           G_TYPE_STRING, "hide-finished,hide-warnings",
257
 
                                                           G_TYPE_INVALID);
 
259
        g_dbus_proxy_call (priv->proxy,
 
260
                                      "InstallProvideFiles",
 
261
                                      g_variant_new ("(uass)",
 
262
                                                     xid,
 
263
                                                     package,
 
264
                                                     "hide-confirm-search,hide-finished,hide-warning"),
 
265
                                      G_DBUS_CALL_FLAGS_NONE,
 
266
                                      -1,
 
267
                                      NULL,
 
268
                                      brasero_pk_install_missing_files_result,
 
269
                                      package);
258
270
 
259
271
        return brasero_pk_wait_for_call_end (package, cancel);
260
272
}
358
370
                                     int xid,
359
371
                                     GCancellable *cancel)
360
372
{
361
 
        gboolean res;
362
373
        gchar *resource;
363
374
        const gchar *name;
364
375
        BraseroPKPrivate *priv;
392
403
        g_ptr_array_add (missing_files, resource);
393
404
        g_ptr_array_add (missing_files, NULL);
394
405
 
395
 
        res = brasero_pk_install_file_requirement (package, missing_files, xid, cancel);
 
406
        priv->res = brasero_pk_install_file_requirement (package, missing_files, xid, cancel);
396
407
 
397
 
        if (res)
398
 
                 res = gst_update_registry ();
 
408
        if (priv->res)
 
409
                 priv->res = gst_update_registry ();
399
410
 
400
411
        g_strfreev ((gchar **) missing_files->pdata);
401
412
        g_ptr_array_free (missing_files, FALSE);
402
413
 
403
 
        return res;
 
414
        return priv->res;
404
415
}
405
416
 
406
417
static void
410
421
static void
411
422
brasero_pk_finalize (GObject *object)
412
423
{
 
424
        GError *error = NULL;
413
425
        BraseroPKPrivate *priv;
414
426
 
415
427
        priv = BRASERO_PK_PRIVATE (object);
416
428
 
417
 
        if (priv->call)
418
 
                dbus_g_proxy_cancel_call (priv->proxy, priv->call);
 
429
        if (priv->proxy)
 
430
                g_dbus_proxy_call_finish (priv->proxy, priv->result, &error);
419
431
 
420
432
        if (priv->loop)
421
433
                g_main_loop_quit (priv->loop);
426
438
        }
427
439
 
428
440
        if (priv->connection) {
429
 
                dbus_g_connection_unref (priv->connection);
 
441
                g_object_unref (priv->connection);
430
442
                priv->connection = NULL;
431
443
        }
432
444