[brasero] Some improvements to the packagekit code:



commit 148f65986f88cf7a3b0c68d076abb63b8f8c1e38
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Sun Nov 1 21:52:40 2009 +0100

    Some improvements to the packagekit code:
    - better handling of cancellation
    - quit using Gstreamer API and use a simple installation for common files (works better)
    - update Gstreamer registry after having installed a plugin

 libbrasero-utils/brasero-pk.c |   73 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 71 insertions(+), 2 deletions(-)
---
diff --git a/libbrasero-utils/brasero-pk.c b/libbrasero-utils/brasero-pk.c
index 905cece..3a76c3f 100644
--- a/libbrasero-utils/brasero-pk.c
+++ b/libbrasero-utils/brasero-pk.c
@@ -34,11 +34,13 @@
 #endif
 
 #include <sys/utsname.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <dbus/dbus-glib.h>
 
+#include <gst/gst.h>
 #include <gst/pbutils/install-plugins.h>
 #include <gst/pbutils/missing-plugins.h>
 
@@ -90,7 +92,12 @@ brasero_pk_cancelled (GCancellable *cancel,
 	BraseroPKPrivate *priv = BRASERO_PK_PRIVATE (package);
 
 	priv->res = FALSE;
-	g_main_loop_quit (priv->loop);
+
+	if (priv->call)
+		dbus_g_proxy_cancel_call (priv->proxy, priv->call);
+
+	if (priv->loop)
+		g_main_loop_quit (priv->loop);
 }
 
 static gboolean
@@ -109,7 +116,7 @@ brasero_pk_wait_for_call_end (BraseroPK *package,
 	sig_int = g_signal_connect (cancel,
 	                            "cancelled",
 	                            G_CALLBACK (brasero_pk_cancelled),
-	                            loop);
+	                            package);
 
 	GDK_THREADS_LEAVE ();
 	g_main_loop_run (loop);
@@ -154,6 +161,15 @@ brasero_pk_connect (BraseroPK *package)
 	return TRUE;
 }
 
+#if 0
+
+/**
+ * This would be the proper way to do it except
+ * it has two faults:
+ * - it cannot be cancelled
+ * - it does not work for elements
+ **/
+ 
 static void
 brasero_pk_install_gst_plugin_result (GstInstallPluginsReturn res,
                                       gpointer user_data)
@@ -215,6 +231,8 @@ brasero_pk_install_gstreamer_plugin (BraseroPK *package,
 	return res;
 }
 
+#endif
+
 static gboolean
 brasero_pk_install_file_requirement (BraseroPK *package,
                                      GPtrArray *missing_files,
@@ -334,6 +352,57 @@ brasero_pk_install_missing_library (BraseroPK *package,
 	return res;
 }
 
+gboolean
+brasero_pk_install_gstreamer_plugin (BraseroPK *package,
+                                     const gchar *element_name,
+                                     int xid,
+                                     GCancellable *cancel)
+{
+	gboolean res;
+	gchar *resource;
+	const gchar *name;
+	BraseroPKPrivate *priv;
+	GPtrArray *missing_files;
+
+	priv = BRASERO_PK_PRIVATE (package);
+
+	/* The whole function is gross but it works:
+	 * - on fedora */
+
+	/* This is a special case for ffmpeg plugin. It
+	 * comes as a single library for all elements
+	 * so we have to workaround this */
+	if (!strncmp (element_name, "ff", 2))
+		name = "ffmpeg";
+	else
+		name = element_name;
+
+	if (pk_gst_is_x64_arch ())
+		resource = g_strdup_printf ("/usr/lib64/gstreamer-0.10/libgst%s.so", name);
+	else
+		resource = g_strdup_printf ("/usr/lib/gstreamer-0.10/libgst%s.so", name);
+
+	if (g_slist_find_custom (already_tested, resource, (GCompareFunc) g_strcmp0)) {
+		g_free (resource);
+		return FALSE;
+	}
+	already_tested = g_slist_prepend (already_tested, g_strdup (resource));
+
+	missing_files = g_ptr_array_new ();
+	g_ptr_array_add (missing_files, resource);
+	g_ptr_array_add (missing_files, NULL);
+
+	res = brasero_pk_install_file_requirement (package, missing_files, xid, cancel);
+
+	if (res)
+		 res = gst_update_registry ();
+
+	g_strfreev ((gchar **) missing_files->pdata);
+	g_ptr_array_free (missing_files, FALSE);
+
+	return res;
+}
+
 static void
 brasero_pk_init (BraseroPK *object)
 {}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]