gnome-packagekit r280 - trunk/src



Author: rhughes
Date: Fri Sep 12 14:51:47 2008
New Revision: 280
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=280&view=rev

Log:
from git

Modified:
   trunk/src/Makefile.am
   trunk/src/gpk-application-main.c
   trunk/src/gpk-application.c
   trunk/src/gpk-auto-refresh.c
   trunk/src/gpk-check-update.c
   trunk/src/gpk-common.c
   trunk/src/gpk-error.c
   trunk/src/gpk-firmware.c
   trunk/src/gpk-gnome.c
   trunk/src/gpk-log.c
   trunk/src/gpk-prefs.c
   trunk/src/gpk-repo.c
   trunk/src/gpk-self-test.c
   trunk/src/gpk-update-icon.c
   trunk/src/gpk-update-viewer.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Fri Sep 12 14:51:47 2008
@@ -11,6 +11,7 @@
 	$(LIBNOTIFY_CFLAGS)				\
 	$(LIBSEXY_CFLAGS)				\
 	$(PACKAGEKIT_CFLAGS)				\
+	$(UNIQUE_CFLAGS)				\
 	$(POLKIT_GNOME_CFLAGS)				\
 	$(GTK_CFLAGS)					\
 	-DBINDIR=\"$(bindir)\"			 	\
@@ -22,11 +23,6 @@
 	-DVERSION="\"$(VERSION)\"" 			\
 	-DPK_DATA=\"$(pkgdatadir)\"			\
 	-DEGG_LOG_FILE=\"\"				\
-	-I$(top_srcdir)/libunique			\
-	$(NULL)
-
-LIBUNIQUE_LIBS =					\
-	$(top_builddir)/libunique/libunique.la		\
 	$(NULL)
 
 bin_PROGRAMS =						\
@@ -49,6 +45,10 @@
 	egg-debug.h					\
 	egg-string.c					\
 	egg-string.h					\
+	egg-string-list.c				\
+	egg-string-list.h				\
+	egg-unique.c					\
+	egg-unique.h					\
 	egg-dbus-monitor.c				\
 	egg-dbus-monitor.h				\
 	gpk-marshal.c					\
@@ -96,8 +96,8 @@
 	$(GTK_LIBS)					\
 	$(LIBNOTIFY_LIBS)				\
 	$(PACKAGEKIT_LIBS)				\
+	$(UNIQUE_LIBS)					\
 	$(POLKIT_GNOME_LIBS)				\
-	$(LIBUNIQUE_LIBS)				\
 	$(NULL)
 
 gpk_install_provide_file_SOURCES =			\
@@ -185,6 +185,8 @@
 gpk_prefs_SOURCES =					\
 	egg-debug.c					\
 	egg-debug.h					\
+	egg-unique.c					\
+	egg-unique.h					\
 	gpk-prefs.c					\
 	gpk-gnome.c					\
 	gpk-gnome.h					\
@@ -275,13 +277,6 @@
 
 TESTS = gpk-self-test
 
-if PK_BUILD_GPROF
-clean-gprof:
-	rm -f *.out
-gprof: clean-gprof all check
-	gprof ./gpk-self-test > gprof.txt
-endif
-
 EXTRA_DIST =						\
 	gpk-marshal.list				\
 	gpk-interface.xml				\

Modified: trunk/src/gpk-application-main.c
==============================================================================
--- trunk/src/gpk-application-main.c	(original)
+++ trunk/src/gpk-application-main.c	Fri Sep 12 14:51:47 2008
@@ -32,7 +32,7 @@
 #include <locale.h>
 
 /* local .la */
-#include <libunique.h>
+#include <egg-unique.h>
 
 #include "egg-debug.h"
 #include "gpk-application.h"
@@ -54,7 +54,7 @@
  * gpk_application_activated_cb
  **/
 static void
-gpk_application_activated_cb (LibUnique *libunique, GpkApplication *application)
+gpk_application_activated_cb (EggUnique *egg_unique, GpkApplication *application)
 {
 	gpk_application_show (application);
 }
@@ -69,7 +69,7 @@
 	gboolean program_version = FALSE;
 	GpkApplication *application = NULL;
 	GOptionContext *context;
-	LibUnique *libunique;
+	EggUnique *egg_unique;
 	gboolean ret;
 
 	const GOptionEntry options[] = {
@@ -113,15 +113,15 @@
 	}
 
 	/* are we already activated? */
-	libunique = libunique_new ();
-	ret = libunique_assign (libunique, "org.freedesktop.PackageKit.Application");
+	egg_unique = egg_unique_new ();
+	ret = egg_unique_assign (egg_unique, "org.freedesktop.PackageKit.Application");
 	if (!ret) {
 		goto unique_out;
 	}
 
 	/* create a new application object */
 	application = gpk_application_new ();
-	g_signal_connect (libunique, "activated",
+	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpk_application_activated_cb), application);
 	g_signal_connect (application, "action-close",
 			  G_CALLBACK (gpk_application_close_cb), NULL);
@@ -131,7 +131,7 @@
 
 	g_object_unref (application);
 unique_out:
-	g_object_unref (libunique);
+	g_object_unref (egg_unique);
 	return 0;
 }
 

Modified: trunk/src/gpk-application.c
==============================================================================
--- trunk/src/gpk-application.c	(original)
+++ trunk/src/gpk-application.c	Fri Sep 12 14:51:47 2008
@@ -956,15 +956,13 @@
 	egg_debug ("package = %s:%s:%s", pk_info_enum_to_text (obj->info), obj->id->name, obj->summary);
 
 	/* ignore progress */
-	if (obj->info != PK_INFO_ENUM_INSTALLED && obj->info != PK_INFO_ENUM_AVAILABLE) {
+	if (obj->info != PK_INFO_ENUM_INSTALLED && obj->info != PK_INFO_ENUM_AVAILABLE)
 		return;
-	}
 
+	/* use the localised summary if available */
 	summary_new = pk_extra_get_summary (application->priv->extra, obj->id->name);
-	if (summary_new == NULL) {
-		/* use the non-localised one */
+	if (summary_new == NULL)
 		summary_new = obj->summary;
-	}
 
 	/* mark as got so we don't warn */
 	application->priv->has_package = TRUE;
@@ -973,17 +971,20 @@
 	in_queue = pk_package_list_contains_obj (application->priv->package_list, obj);
 	installed = (obj->info == PK_INFO_ENUM_INSTALLED);
 
-	if (installed && in_queue) {
+	if (installed && in_queue)
 		state = GPK_STATE_INSTALLED_TO_BE_REMOVED;
-	} else if (installed && !in_queue) {
+	else if (installed && !in_queue)
 		state = GPK_STATE_INSTALLED;
-	} else if (!installed && in_queue) {
+	else if (!installed && in_queue)
 		state = GPK_STATE_AVAILABLE_TO_BE_INSTALLED;
-	} else if (!installed && !in_queue) {
+	else if (!installed && !in_queue)
 		state = GPK_STATE_AVAILABLE;
-	}
 
-	icon = gpk_application_state_get_icon (state);
+	/* use the application icon if available */
+	icon = pk_extra_get_icon_name (application->priv->extra, obj->id->name);
+	if (icon == NULL)
+		icon = gpk_application_state_get_icon (state);
+
 	checkbox = gpk_application_state_get_checkbox (state);
 
 	/* use two lines */
@@ -1008,9 +1009,8 @@
 
 	/* only process every n events else we re-order too many times */
 	if (package_cnt++ % 200 == 0) {
-		while (gtk_events_pending ()) {
+		while (gtk_events_pending ())
 			gtk_main_iteration ();
-		}
 	}
 }
 
@@ -1095,7 +1095,7 @@
 			    PACKAGES_COLUMN_CHECKBOX, FALSE,
 			    PACKAGES_COLUMN_CHECKBOX_ENABLE, FALSE,
 			    PACKAGES_COLUMN_TEXT, text,
-			    PACKAGES_COLUMN_IMAGE, "search",
+			    PACKAGES_COLUMN_IMAGE, "system-search",
 			    -1);
 	g_free (text);
 }
@@ -1682,7 +1682,7 @@
 
 	/* check we aren't a help line */
 	gtk_tree_model_get (model, &iter, PACKAGES_COLUMN_IMAGE, &image, -1);
-	ret = egg_strequal (image, "search");
+	ret = egg_strequal (image, "system-search");
 	g_free (image);
 	if (ret) {
 		egg_debug ("ignoring help click");
@@ -2561,7 +2561,7 @@
 			    PACKAGES_COLUMN_CHECKBOX, FALSE,
 			    PACKAGES_COLUMN_CHECKBOX_ENABLE, FALSE,
 			    PACKAGES_COLUMN_TEXT, welcome,
-			    PACKAGES_COLUMN_IMAGE, "search", -1);
+			    PACKAGES_COLUMN_IMAGE, "system-search", -1);
 }
 
 /**

Modified: trunk/src/gpk-auto-refresh.c
==============================================================================
--- trunk/src/gpk-auto-refresh.c	(original)
+++ trunk/src/gpk-auto-refresh.c	Fri Sep 12 14:51:47 2008
@@ -173,18 +173,14 @@
 		egg_warning ("no schema");
 		return 0;
 	}
-	if (freq == PK_FREQ_ENUM_NEVER) {
+	if (freq == PK_FREQ_ENUM_NEVER)
 		return 0;
-	}
-	if (freq == PK_FREQ_ENUM_HOURLY) {
+	if (freq == PK_FREQ_ENUM_HOURLY)
 		return 60*60;
-	}
-	if (freq == PK_FREQ_ENUM_DAILY) {
+	if (freq == PK_FREQ_ENUM_DAILY)
 		return 60*60*24;
-	}
-	if (freq == PK_FREQ_ENUM_WEEKLY) {
+	if (freq == PK_FREQ_ENUM_WEEKLY)
 		return 60*60*24*7;
-	}
 	egg_warning ("unknown frequency enum");
 	return 0;
 }
@@ -195,7 +191,7 @@
 static guint
 gpk_auto_refresh_convert_frequency_text (GpkAutoRefresh *arefresh, const gchar *key)
 {
-	const gchar *freq_text;
+	gchar *freq_text;
 	PkFreqEnum freq;
 
 	g_return_val_if_fail (GPK_IS_AUTO_REFRESH (arefresh), 0);
@@ -209,6 +205,7 @@
 
 	/* convert to enum and get seconds */
 	freq = pk_freq_enum_from_text (freq_text);
+	g_free (freq_text);
 	return gpk_auto_refresh_convert_frequency (freq);
 }
 

Modified: trunk/src/gpk-check-update.c
==============================================================================
--- trunk/src/gpk-check-update.c	(original)
+++ trunk/src/gpk-check-update.c	Fri Sep 12 14:51:47 2008
@@ -46,6 +46,7 @@
 #include <pk-package-id.h>
 #include <pk-package-ids.h>
 #include <pk-package-list.h>
+#include <pk-distro-upgrade-obj.h>
 
 #include "egg-debug.h"
 #include "egg-string.h"
@@ -915,8 +916,6 @@
 	g_idle_add ((GSourceFunc) gpk_check_update_query_updates_idle_cb, cupdate);
 }
 
-#include <pk-distro-upgrade-obj.h>
-
 /**
  * gpk_check_update_auto_get_upgrades_cb:
  **/

Modified: trunk/src/gpk-common.c
==============================================================================
--- trunk/src/gpk-common.c	(original)
+++ trunk/src/gpk-common.c	Fri Sep 12 14:51:47 2008
@@ -53,7 +53,7 @@
 	{PK_INFO_ENUM_SECURITY,			"pk-update-security"},
 	{PK_INFO_ENUM_BUGFIX,			"pk-update-bugfix"},
 	{PK_INFO_ENUM_ENHANCEMENT,		"pk-update-enhancement"},
-	{PK_INFO_ENUM_BLOCKED,			"pk-setup"},
+	{PK_INFO_ENUM_BLOCKED,			"pk-package-blocked"},
 	{PK_INFO_ENUM_DOWNLOADING,		"pk-package-download"},
 	{PK_INFO_ENUM_UPDATING,			"pk-package-update"},
 	{PK_INFO_ENUM_INSTALLING,		"pk-package-add"},
@@ -153,9 +153,10 @@
 	{PK_GROUP_ENUM_NETWORK,			"network-wired"},
 	{PK_GROUP_ENUM_MAPS,			"applications-multimedia"},
 	{PK_GROUP_ENUM_REPOS,			"system-file-manager"},
-//	{PK_GROUP_ENUM_SCIENCE,			"application-certificate"},
-//	{PK_GROUP_ENUM_DOCUMENTATION,		"x-office-address-book"},
-//	{PK_GROUP_ENUM_ELECTRONICS,		"video-display"},
+	{PK_GROUP_ENUM_SCIENCE,			"application-certificate"},
+	{PK_GROUP_ENUM_DOCUMENTATION,		"x-office-address-book"},
+	{PK_GROUP_ENUM_ELECTRONICS,		"video-display"},
+	{PK_GROUP_ENUM_META_PACKAGES,		"pk-collection-installed"},
 	{0, NULL}
 };
 
@@ -453,6 +454,9 @@
 	case PK_ERROR_ENUM_FILE_NOT_FOUND:
 		text = _("The specified file could not be found");
 		break;
+	case PK_ERROR_ENUM_NO_MORE_MIRRORS_TO_TRY:
+		text = _("No more mirrors are available");
+		break;
 	default:
 		egg_warning ("Unknown error");
 	}
@@ -621,6 +625,10 @@
 		text = _("The specified file could not be found on the system.\n"
 			 "Check the file still exists and has not been deleted.");
 		break;
+	case PK_ERROR_ENUM_NO_MORE_MIRRORS_TO_TRY:
+		text = _("Required data could not be found on any of the configured software sources.\n"
+			 "There were no more download mirrors that could be tried.");
+		break;
 	default:
 		egg_warning ("Unknown error, please report a bug at " GPK_BUGZILLA_URL ".\n"
 			    "More information is available in the detailed report.");
@@ -882,7 +890,7 @@
 		text = g_strdup_printf (ngettext ("%i enhancement update", "%i enhancement updates", number), number);
 		break;
 	case PK_INFO_ENUM_BLOCKED:
-		text = g_strdup_printf (ngettext ("%i bloked update", "%i blocked updates", number), number);
+		text = g_strdup_printf (ngettext ("%i blocked update", "%i blocked updates", number), number);
 		break;
 	default:
 		egg_warning ("update info unrecognised: %s", pk_info_enum_to_text (info));
@@ -1306,6 +1314,9 @@
 	case PK_GROUP_ENUM_ELECTRONICS:
 		text = _("Electronics");
 		break;
+	case PK_GROUP_ENUM_META_PACKAGES:
+		text = _("Package collections");
+		break;
 	case PK_GROUP_ENUM_UNKNOWN:
 		text = _("Unknown group");
 		break;
@@ -1635,7 +1646,7 @@
 	PkPackageId *id;
 	EggTest *test = (EggTest *) data;
 
-	if (!egg_test_start (test, "GpkCommon")
+	if (!egg_test_start (test, "GpkCommon"))
 		return;
 
 	/************************************************************

Modified: trunk/src/gpk-error.c
==============================================================================
--- trunk/src/gpk-error.c	(original)
+++ trunk/src/gpk-error.c	Fri Sep 12 14:51:47 2008
@@ -51,6 +51,9 @@
 	GtkTextBuffer *buffer = NULL;
 	gchar *text;
 
+	g_return_val_if_fail (title != NULL, FALSE);
+	g_return_val_if_fail (message != NULL, FALSE);
+
 	glade_xml = glade_xml_new (PK_DATA "/gpk-error.glade", NULL, NULL);
 
 	/* connect up actions */
@@ -58,9 +61,8 @@
 	g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
 
 	/* make modal if window set */
-	if (window != NULL) {
+	if (window != NULL)
 		gtk_window_set_transient_for (GTK_WINDOW (widget), window);
-	}
 
 	/* set icon name */
 	gtk_window_set_icon_name (GTK_WINDOW (widget), GPK_ICON_SOFTWARE_INSTALLER);
@@ -99,13 +101,11 @@
 	gtk_main ();
 
 	/* hide window */
-	if (GTK_IS_WIDGET (widget)) {
+	if (GTK_IS_WIDGET (widget))
 		gtk_widget_hide (widget);
-	}
 	g_object_unref (glade_xml);
-	if (buffer != NULL) {
+	if (buffer != NULL)
 		g_object_unref (buffer);
-	}
 	return TRUE;
 }
 

Modified: trunk/src/gpk-firmware.c
==============================================================================
--- trunk/src/gpk-firmware.c	(original)
+++ trunk/src/gpk-firmware.c	Fri Sep 12 14:51:47 2008
@@ -43,6 +43,7 @@
 
 #include "egg-debug.h"
 #include "egg-string.h"
+#include "egg-string-list.h"
 
 #include "gpk-client.h"
 #include "gpk-common.h"
@@ -53,12 +54,13 @@
 static void     gpk_firmware_finalize	(GObject	  *object);
 
 #define GPK_FIRMWARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_FIRMWARE, GpkFirmwarePrivate))
-#define GPK_FIRMWARE_STATE_FILE		"/var/run/PackageKit/udev-firmware"
-#define GPK_FIRMWARE_LOGIN_DELAY	20 /* seconds */
+#define GPK_FIRMWARE_STATE_DIR		"/var/run/PackageKit/udev"
+#define GPK_FIRMWARE_LOGIN_DELAY	60 /* seconds */
 
 struct GpkFirmwarePrivate
 {
-	gchar			**files;
+	EggStrList		*array_found;
+	EggStrList		*array_requested;
 	GConfClient		*gconf_client;
 };
 
@@ -70,11 +72,26 @@
 static gboolean
 gpk_firmware_install_file (GpkFirmware *firmware)
 {
-	GpkClient *gclient;
+	guint i;
 	gboolean ret;
+	GpkClient *gclient;
+	GPtrArray *array;
+	GError *error = NULL;
+	const gchar *filename;
 
 	gclient = gpk_client_new ();
-	ret = gpk_client_install_provide_file (gclient, firmware->priv->files[0], NULL);
+	array = firmware->priv->array_found;
+
+	/* try to install each firmware file */
+	for (i=0; i<array->len; i++) {
+		filename = egg_str_list_index (array, i);
+		ret = gpk_client_install_provide_file (gclient, filename, &error);
+		if (!ret) {
+			egg_warning ("failed to open directory: %s", error->message);
+			g_error_free (error);
+			error = NULL;
+		}
+	}
 	g_object_unref (gclient);
 	return ret;
 }
@@ -97,18 +114,89 @@
 	}
 }
 
+/**
+ * gpk_firmware_check_available:
+ * @firmware: This class instance
+ * @filename: Firmware to search for
+ **/
 static gboolean
-gpk_firmware_timeout_cb (gpointer data)
+gpk_firmware_check_available (GpkFirmware *firmware, const gchar *filename)
 {
 	gboolean ret;
+	guint length;
+	PkClient *client = NULL;
+	PkPackageList *list = NULL;
 	GError *error = NULL;
+
+	/* actually check we can provide the firmware */
+	client = pk_client_new ();
+	pk_client_set_synchronous (client, TRUE, NULL);
+	pk_client_set_use_buffer (client, TRUE, NULL);
+	ret = pk_client_search_file (client, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED), filename, &error);
+	if (!ret) {
+		egg_warning ("failed to search file %s: %s", filename, error->message);
+		g_error_free (error);
+		error = NULL;
+		goto out;
+	}
+
+	/* make sure we have one package */
+	list = pk_client_get_package_list (client);
+	length = pk_package_list_get_size (list);
+	g_object_unref (list);
+	if (length == 0)
+		egg_debug ("no package providing %s found", filename);
+	else if (length != 1)
+		egg_warning ("not one package providing %s found (%i)", filename, length);
+
+out:
+	g_object_unref (client);
+	return (length == 1);
+}
+
+/**
+ * gpk_firmware_timeout_cb:
+ * @data: This class instance
+ **/
+static gboolean
+gpk_firmware_timeout_cb (gpointer data)
+{
+	guint i;
+	gboolean ret;
+	const gchar *filename;
 	const gchar *message;
 	GpkFirmware *firmware = GPK_FIRMWARE (data);
 	NotifyNotification *notification;
+	GPtrArray *array;
+	GError *error = NULL;
 
 	/* debug so we can catch polling */
 	egg_debug ("polling check");
 
+	/* try to find each firmware file in an available package */
+	array = firmware->priv->array_requested;
+	for (i=0; i<array->len; i++) {
+		filename = egg_str_list_index (array, i);
+		/* save to new array if we found one package for this file */
+		ret = gpk_firmware_check_available (firmware, filename);
+		if (ret)
+			egg_str_list_add (firmware->priv->array_found, filename);
+	}
+
+	/* nothing to do */
+	array = firmware->priv->array_found;
+	if (array->len == 0) {
+		egg_debug ("no packages providing any of the missing firmware");
+		goto out;
+	}
+
+	/* check we don't want the same package more than once */
+	egg_str_list_remove_duplicate (array);
+
+	/* debugging */
+	egg_debug ("need to install:");
+	egg_str_list_print (array);
+
 	message = _("Additional firmware is required to make hardware in this computer function correctly.");
 	notification = notify_notification_new (_("Additional firmware required"), message, "help-browser", NULL);
 	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
@@ -123,6 +211,7 @@
 		g_error_free (error);
 	}
 
+out:
 	/* never repeat */
 	return FALSE;
 }
@@ -147,11 +236,19 @@
 gpk_firmware_init (GpkFirmware *firmware)
 {
 	gboolean ret;
-	gchar *files;
+	gchar *contents;
 	GError *error = NULL;
+	GDir *dir;
+	const gchar *filename;
+	gchar *filename_path;
+	gchar **firmware_files;
+	guint i;
+	guint length;
+	GPtrArray *array;
 
 	firmware->priv = GPK_FIRMWARE_GET_PRIVATE (firmware);
-	firmware->priv->files = NULL;
+	firmware->priv->array_found = egg_str_list_new ();
+	firmware->priv->array_requested = egg_str_list_new ();
 	firmware->priv->gconf_client = gconf_client_get_default ();
 
 	/* should we check and show the user */
@@ -161,32 +258,62 @@
 		return;
 	}
 
-	/* file exists? */
-	ret = g_file_test (GPK_FIRMWARE_STATE_FILE, G_FILE_TEST_EXISTS);
-	if (!ret) {
-		egg_debug ("file '%s' not found", GPK_FIRMWARE_STATE_FILE);
-		return;
-	}
-	/* can we get the contents */
-	ret = g_file_get_contents (GPK_FIRMWARE_STATE_FILE, &files, NULL, &error);
-	if (!ret) {
-		egg_warning ("can't open file %s, %s", GPK_FIRMWARE_STATE_FILE, error->message);
+	/* open the directory of requests */
+	dir = g_dir_open (GPK_FIRMWARE_STATE_DIR, 0, &error);
+	if (dir == NULL) {
+		egg_warning ("failed to open directory: %s", error->message);
 		g_error_free (error);
 		return;
 	}
 
-	/* split, as we can use multiple lines */
-	firmware->priv->files = g_strsplit (files, "\n", 0);
+	/* find all the firmware requests */
+	filename = g_dir_read_name (dir);
+	array = firmware->priv->array_requested;
+	while (filename != NULL) {
+
+		/* can we get the contents */
+		filename_path = g_build_filename (GPK_FIRMWARE_STATE_DIR, filename, NULL);
+		egg_debug ("opening %s", filename_path);
+		ret = g_file_get_contents (filename_path, &contents, NULL, &error);
+		if (!ret) {
+			egg_warning ("can't open file %s, %s", filename, error->message);
+			g_error_free (error);
+			error = NULL;
+			goto skip_file;
+		}
+
+		/* split, as we can use multiple requests in one file */
+		firmware_files = g_strsplit (contents, "\n", 0);
+		length = g_strv_length (firmware_files);
+		for (i=0; i<length; i++) {
+			if (!egg_strzero (firmware_files[i])) {
+				/* file still doesn't exist */
+				ret = g_file_test (firmware_files[i], G_FILE_TEST_EXISTS);
+				if (!ret)
+					egg_str_list_add (array, firmware_files[i]);
+			}
+		}
+		g_free (contents);
+		g_strfreev (firmware_files);
+skip_file:
+		g_free (filename_path);
+		/* next file */
+		filename = g_dir_read_name (dir);
+	}
+	g_dir_close (dir);
+
+	/* don't request duplicates */
+	egg_str_list_remove_duplicate (array);
 
-	/* file already exists */
-	ret = g_file_test (firmware->priv->files[0], G_FILE_TEST_EXISTS);
-	if (ret) {
-		egg_debug ("file '%s' already exists", firmware->priv->files[0]);
-		return;
+	/* debugging */
+	for (i=0; i<array->len; i++) {
+		filename = egg_str_list_index (array, i);
+		egg_debug ("requested: %s", filename);
 	}
 
-	/* don't spam the user at startup */
-	g_timeout_add_seconds (GPK_FIRMWARE_LOGIN_DELAY, gpk_firmware_timeout_cb, firmware);
+	/* don't spam the user at startup, so wait a little delay */
+	if (array->len > 0)
+		g_timeout_add_seconds (GPK_FIRMWARE_LOGIN_DELAY, gpk_firmware_timeout_cb, firmware);
 }
 
 /**
@@ -203,7 +330,8 @@
 	firmware = GPK_FIRMWARE (object);
 
 	g_return_if_fail (firmware->priv != NULL);
-	g_strfreev (firmware->priv->files);
+	egg_str_list_free (firmware->priv->array_found);
+	egg_str_list_free (firmware->priv->array_requested);
 	g_object_unref (firmware->priv->gconf_client);
 
 	G_OBJECT_CLASS (gpk_firmware_parent_class)->finalize (object);

Modified: trunk/src/gpk-gnome.c
==============================================================================
--- trunk/src/gpk-gnome.c	(original)
+++ trunk/src/gpk-gnome.c	Fri Sep 12 14:51:47 2008
@@ -41,9 +41,8 @@
 
 	data = g_strconcat ("gnome-open ", url, NULL);
 	ret = g_spawn_command_line_async (data, NULL);
-	if (ret == FALSE) {
+	if (!ret)
 		egg_warning ("spawn of '%s' failed", data);
-	}
 	g_free (data);
 	return ret;
 }
@@ -66,26 +65,21 @@
 
 	for (i = 0; langs[i]; i++) {
 		lang = langs[i];
-		if (strchr (lang, '.')) {
+		if (strchr (lang, '.'))
 			continue;
-		}
-		uri = g_build_filename(DATADIR,
-				       "/gnome/help/gnome-packagekit/",
-					lang,
-				       "/gnome-packagekit.xml",
-					NULL);
-		if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
-                    break;
-		}
+		uri = g_build_filename (DATADIR, "/gnome/help/gnome-packagekit/",
+					lang, "/gnome-packagekit.xml", NULL);
+		if (g_file_test (uri, G_FILE_TEST_EXISTS))
+			break;
+		g_free (uri);
 	}
-	if (link_id) {
+	if (link_id)
 		command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL);
-	} else {
-		command = g_strconcat ("gnome-open ghelp://", uri,  NULL);
-	}
+	else
+		command = g_strconcat ("gnome-open ghelp://", uri, NULL);
 	egg_debug ("using command %s", command);
 
-	gscreen = gdk_screen_get_default();
+	gscreen = gdk_screen_get_default ();
 	gdk_spawn_command_line_on_screen (gscreen, command, &error);
 	if (error != NULL) {
 		GtkWidget *d;

Modified: trunk/src/gpk-log.c
==============================================================================
--- trunk/src/gpk-log.c	(original)
+++ trunk/src/gpk-log.c	Fri Sep 12 14:51:47 2008
@@ -34,7 +34,7 @@
 #include <polkit-gnome/polkit-gnome.h>
 
 /* local .la */
-#include <libunique.h>
+#include <egg-unique.h>
 
 #include <pk-client.h>
 #include <pk-control.h>
@@ -317,7 +317,7 @@
  * gpk_log_activated_cb
  **/
 static void
-gpk_log_activated_cb (LibUnique *libunique, gpointer data)
+gpk_log_activated_cb (EggUnique *egg_unique, gpointer data)
 {
 	GtkWidget *widget;
 	widget = glade_xml_get_widget (glade_xml, "window_simple");
@@ -337,7 +337,7 @@
 	GtkTreeSelection *selection;
 	PkBitfield roles;
 	PkControl *control;
-	LibUnique *libunique;
+	EggUnique *egg_unique;
 	gboolean ret;
 
 	const GOptionEntry options[] = {
@@ -381,12 +381,12 @@
 	}
 
 	/* are we already activated? */
-	libunique = libunique_new ();
-	ret = libunique_assign (libunique, "org.freedesktop.PackageKit.LogViewer");
+	egg_unique = egg_unique_new ();
+	ret = egg_unique_assign (egg_unique, "org.freedesktop.PackageKit.LogViewer");
 	if (!ret) {
 		goto unique_out;
 	}
-	g_signal_connect (libunique, "activated",
+	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpk_log_activated_cb), NULL);
 
 	/* add application specific icons to search path */
@@ -464,6 +464,6 @@
 	g_object_unref (client);
 	g_free (transaction_id);
 unique_out:
-	g_object_unref (libunique);
+	g_object_unref (egg_unique);
 	return 0;
 }

Modified: trunk/src/gpk-prefs.c
==============================================================================
--- trunk/src/gpk-prefs.c	(original)
+++ trunk/src/gpk-prefs.c	Fri Sep 12 14:51:47 2008
@@ -33,7 +33,7 @@
 #include <gconf/gconf-client.h>
 
 /* local .la */
-#include <libunique.h>
+#include <egg-unique.h>
 
 #include <pk-control.h>
 #include <pk-client.h>
@@ -325,7 +325,7 @@
  * gpk_prefs_activated_cb
  **/
 static void
-gpk_prefs_activated_cb (LibUnique *libunique, gpointer data)
+gpk_prefs_activated_cb (EggUnique *egg_unique, gpointer data)
 {
 	GtkWidget *widget;
 	widget = glade_xml_get_widget (glade_xml, "window_prefs");
@@ -346,7 +346,7 @@
 	PkBitfield roles;
 	PkClient *client;
 	PkControl *control;
-	LibUnique *libunique;
+	EggUnique *egg_unique;
 	gboolean ret;
 
 	const GOptionEntry options[] = {
@@ -384,12 +384,12 @@
 	gtk_init (&argc, &argv);
 
 	/* are we already activated? */
-	libunique = libunique_new ();
-	ret = libunique_assign (libunique, "org.freedesktop.PackageKit.Prefs");
+	egg_unique = egg_unique_new ();
+	ret = egg_unique_assign (egg_unique, "org.freedesktop.PackageKit.Prefs");
 	if (!ret) {
 		goto unique_out;
 	}
-	g_signal_connect (libunique, "activated",
+	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpk_prefs_activated_cb), NULL);
 
 	client = pk_client_new ();
@@ -442,7 +442,7 @@
 	g_object_unref (glade_xml);
 	g_object_unref (client);
 unique_out:
-	g_object_unref (libunique);
+	g_object_unref (egg_unique);
 
 	return 0;
 }

Modified: trunk/src/gpk-repo.c
==============================================================================
--- trunk/src/gpk-repo.c	(original)
+++ trunk/src/gpk-repo.c	Fri Sep 12 14:51:47 2008
@@ -33,7 +33,7 @@
 #include <gconf/gconf-client.h>
 
 /* local .la */
-#include <libunique.h>
+#include <egg-unique.h>
 
 #include <pk-common.h>
 #include <pk-client.h>
@@ -297,7 +297,7 @@
  * gpk_repo_activated_cb
  **/
 static void
-gpk_repo_activated_cb (LibUnique *libunique, gpointer data)
+gpk_repo_activated_cb (EggUnique *egg_unique, gpointer data)
 {
 	GtkWidget *widget;
 	widget = glade_xml_get_widget (glade_xml, "window_repo");
@@ -331,7 +331,7 @@
 	GtkWidget *widget;
 	GtkTreeSelection *selection;
 	PkControl *control;
-	LibUnique *libunique;
+	EggUnique *egg_unique;
 	gboolean ret;
 
 	const GOptionEntry options[] = {
@@ -368,12 +368,12 @@
 	}
 
 	/* are we already activated? */
-	libunique = libunique_new ();
-	ret = libunique_assign (libunique, "org.freedesktop.PackageKit.Repo");
+	egg_unique = egg_unique_new ();
+	ret = egg_unique_assign (egg_unique, "org.freedesktop.PackageKit.Repo");
 	if (!ret) {
 		goto unique_out;
 	}
-	g_signal_connect (libunique, "activated",
+	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpk_repo_activated_cb), NULL);
 
 	gconf_client = gconf_client_get_default ();
@@ -462,7 +462,7 @@
 	g_object_unref (client);
 	g_object_unref (control);
 unique_out:
-	g_object_unref (libunique);
+	g_object_unref (egg_unique);
 
 	return 0;
 }

Modified: trunk/src/gpk-self-test.c
==============================================================================
--- trunk/src/gpk-self-test.c	(original)
+++ trunk/src/gpk-self-test.c	Fri Sep 12 14:51:47 2008
@@ -25,6 +25,8 @@
 #include "egg-debug.h"
 #include "gpk-common.h"
 
+void egg_string_test (EggTest *test);
+
 int
 main (int argc, char **argv)
 {
@@ -37,6 +39,7 @@
 	egg_debug_init (TRUE);
 
 	/* tests go here */
+	egg_string_test (test);
 	gpk_common_test (test);
 
 	return egg_test_finish (test);

Modified: trunk/src/gpk-update-icon.c
==============================================================================
--- trunk/src/gpk-update-icon.c	(original)
+++ trunk/src/gpk-update-icon.c	Fri Sep 12 14:51:47 2008
@@ -83,9 +83,8 @@
 	g_object_unref (G_OBJECT (bus_proxy));
 
 	/* already running */
-	if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+	if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
 		return FALSE;
-	}
 
 	dbus_g_object_type_install_info (GPK_TYPE_DBUS, &dbus_glib_gpk_dbus_object_info);
 	dbus_g_error_domain_register (GPK_DBUS_ERROR, NULL, GPK_DBUS_TYPE_ERROR);
@@ -112,6 +111,7 @@
 {
 	gboolean verbose = FALSE;
 	gboolean program_version = FALSE;
+	gboolean timed_exit = FALSE;
 	GpkCheckUpdate *cupdate = NULL;
 	GpkWatch *watch = NULL;
 	GpkDbus *dbus = NULL;
@@ -124,9 +124,11 @@
 
 	const GOptionEntry options[] = {
 		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
-		  N_("Show extra debugging information"), NULL },
+		  _("Show extra debugging information"), NULL },
+		{ "timed-exit", '\0', 0, G_OPTION_ARG_NONE, &timed_exit,
+		  _("Exit after a small delay"), NULL },
 		{ "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
-		  N_("Show the program version and exit"), NULL },
+		  _("Show the program version and exit"), NULL },
 		{ NULL}
 	};
 
@@ -136,9 +138,8 @@
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-	if (! g_thread_supported ()) {
+	if (! g_thread_supported ())
 		g_thread_init (NULL);
-	}
 	dbus_g_thread_init ();
 	g_type_init ();
 	notify_init ("gpk-update-icon");
@@ -160,9 +161,8 @@
 
 	/* are we running privileged */
 	ret = gpk_check_privileged_user (_("Update applet"));
-	if (!ret) {
+	if (!ret)
 		return 1;
-	}
 
 	/* add application specific icons to search path */
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -195,6 +195,10 @@
 		goto out;
 	}
 
+	/* Only timeout if we have specified iton the command line */
+	if (timed_exit)
+		g_timeout_add_seconds (120, (GSourceFunc) gtk_main_quit, NULL);
+
 	/* wait */
 	gtk_main ();
 
@@ -207,3 +211,4 @@
 
 	return 0;
 }
+

Modified: trunk/src/gpk-update-viewer.c
==============================================================================
--- trunk/src/gpk-update-viewer.c	(original)
+++ trunk/src/gpk-update-viewer.c	Fri Sep 12 14:51:47 2008
@@ -34,9 +34,6 @@
 
 #include <polkit-gnome/polkit-gnome.h>
 
-/* local .la */
-#include <libunique.h>
-
 #include <pk-client.h>
 #include <pk-control.h>
 #include <pk-common.h>
@@ -47,6 +44,7 @@
 
 #include "egg-debug.h"
 #include "egg-string.h"
+#include "egg-unique.h"
 
 #include "gpk-common.h"
 #include "gpk-gnome.h"
@@ -67,6 +65,7 @@
 static gchar *cached_package_id = NULL;
 static GpkClient *gclient = NULL;
 static gboolean are_updates_available = FALSE;
+static guint description_event_id = 0;
 
 static PolKitGnomeAction *refresh_action = NULL;
 static PolKitGnomeAction *update_system_action = NULL;
@@ -104,6 +103,8 @@
 	PACKAGES_COLUMN_ID,
 	PACKAGES_COLUMN_INFO,
 	PACKAGES_COLUMN_SELECT,
+	PACKAGES_COLUMN_SENSITIVE,
+	PACKAGES_COLUMN_CLICKABLE,
 	PACKAGES_COLUMN_LAST
 };
 
@@ -327,10 +328,10 @@
 }
 
 /**
- * gpk_update_viewer_description_animation_start:
+ * gpk_update_viewer_description_animation_start_really:
  **/
-static void
-gpk_update_viewer_description_animation_start (void)
+static gboolean
+gpk_update_viewer_description_animation_start_really (void)
 {
 	GtkWidget *widget;
 	gchar *text_bold;
@@ -351,6 +352,25 @@
 
 	widget = glade_xml_get_widget (glade_xml, "scrolledwindow_description");
 	gtk_widget_hide (widget);
+
+	/* we've done the event */
+	description_event_id = 0;
+
+	/* never repeat */
+	return FALSE;
+}
+
+/**
+ * gpk_update_viewer_description_animation_start:
+ **/
+static void
+gpk_update_viewer_description_animation_start (void)
+{
+	/* only clear the last data and show the spinner if it takes a little
+	 * while, else we flicker the display too much */
+	if (description_event_id > 0)
+		g_source_remove (description_event_id);
+	description_event_id = g_timeout_add (100, (GSourceFunc) gpk_update_viewer_description_animation_start_really, NULL);
 }
 
 /**
@@ -361,6 +381,13 @@
 {
 	GtkWidget *widget;
 
+	/* if we are not showing, clear timeout and return */
+	if (description_event_id > 0) {
+		g_source_remove (description_event_id);
+		description_event_id = 0;
+		return;
+	}
+
 	widget = glade_xml_get_widget (glade_xml, "image_animation_description");
 	gpk_animated_icon_enable_animation (GPK_ANIMATED_ICON (widget), FALSE);
 
@@ -460,6 +487,7 @@
 	guint num_security = 0;
 	guint num_bugfix = 0;
 	guint num_enhancement = 0;
+	guint num_blocked = 0;
 	const gchar *icon;
 	gchar *text;
 
@@ -482,6 +510,8 @@
 				num_bugfix++;
 			} else if (obj->info == PK_INFO_ENUM_ENHANCEMENT) {
 				num_enhancement++;
+			} else if (obj->info == PK_INFO_ENUM_BLOCKED) {
+				num_blocked++;
 			} else {
 				num_normal++;
 			}
@@ -515,6 +545,12 @@
 			gpk_update_viewer_add_preview_item (icon, text, FALSE);
 			g_free (text);
 		}
+		if (num_blocked > 0) {
+			icon = gpk_info_enum_to_icon_name (PK_INFO_ENUM_BLOCKED);
+			text = gpk_update_enum_to_localised_text (PK_INFO_ENUM_BLOCKED, num_blocked);
+			gpk_update_viewer_add_preview_item (icon, text, FALSE);
+			g_free (text);
+		}
 		if (num_low > 0) {
 			icon = gpk_info_enum_to_icon_name (PK_INFO_ENUM_LOW);
 			text = gpk_update_enum_to_localised_text (PK_INFO_ENUM_LOW, num_low);
@@ -554,6 +590,7 @@
 	gchar **package_ids;
 	GtkTreeIter iter;
 	gboolean ret;
+	gboolean selected;
 
 	/* spin */
 	gpk_update_viewer_description_animation_start ();
@@ -587,12 +624,15 @@
 		icon_name = gpk_info_enum_to_icon_name (obj->info);
 		gtk_list_store_append (list_store_details, &iter);
 		package_id = pk_package_id_to_string (obj->id);
+		selected = (obj->info != PK_INFO_ENUM_BLOCKED);
 		gtk_list_store_set (list_store_details, &iter,
 				    PACKAGES_COLUMN_TEXT, text,
 				    PACKAGES_COLUMN_ID, package_id,
 				    PACKAGES_COLUMN_ICON, icon_name,
 				    PACKAGES_COLUMN_INFO, obj->info,
-				    PACKAGES_COLUMN_SELECT, TRUE,
+				    PACKAGES_COLUMN_SELECT, selected,
+				    PACKAGES_COLUMN_SENSITIVE, selected,
+				    PACKAGES_COLUMN_CLICKABLE, selected,
 				    -1);
 		g_free (package_id);
 		g_free (text);
@@ -1053,7 +1093,10 @@
 	renderer = gtk_cell_renderer_toggle_new ();
 	model = gtk_tree_view_get_model (treeview);
 	g_signal_connect (renderer, "toggled", G_CALLBACK (gpk_update_viewer_treeview_update_toggled), model);
-	column = gtk_tree_view_column_new_with_attributes ("Update", renderer, "active", PACKAGES_COLUMN_SELECT, NULL);
+	column = gtk_tree_view_column_new_with_attributes ("Update", renderer,
+							   "active", PACKAGES_COLUMN_SELECT,
+							   "activatable", PACKAGES_COLUMN_CLICKABLE,
+							   "sensitive", PACKAGES_COLUMN_SENSITIVE, NULL);
 
 	/* set this column to a fixed sizing (of 50 pixels) */
 	gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
@@ -1073,13 +1116,10 @@
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 	gchar *package_id;
-	GtkWidget *widget;
 	GError *error = NULL;
 	gboolean ret;
 	gchar **package_ids;
 
-	widget = glade_xml_get_widget (glade_xml, "scrolledwindow_description");
-
 	/* This will only work in single or browse selection mode! */
 	if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
 		gtk_tree_model_get (model, &iter,
@@ -1461,14 +1501,16 @@
 	gboolean valid;
 	GtkTreeIter iter;
 	GtkTreeModel *model;
+	PkStatusEnum info;
 
 	/* get the first iter in the list */
 	model = gtk_tree_view_get_model (treeview);
 	valid = gtk_tree_model_get_iter_first (model, &iter);
 	while (valid) {
-		gtk_tree_model_get (model, &iter, -1);
-		gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-				    PACKAGES_COLUMN_SELECT, TRUE, -1);
+		gtk_tree_model_get (model, &iter, PACKAGES_COLUMN_INFO, &info, -1);
+		if (info != PK_INFO_ENUM_BLOCKED)
+			gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+					    PACKAGES_COLUMN_SELECT, TRUE, -1);
 		valid = gtk_tree_model_iter_next (model, &iter);
 	}
 }
@@ -1743,7 +1785,7 @@
  * gpk_update_viewer_activated_cb
  **/
 static void
-gpk_update_viewer_activated_cb (LibUnique *libunique, gpointer data)
+gpk_update_viewer_activated_cb (EggUnique *egg_unique, gpointer data)
 {
 	GtkWidget *widget;
 	widget = glade_xml_get_widget (glade_xml, "window_updates");
@@ -1765,7 +1807,7 @@
 	PkBitfield roles;
 	gboolean ret;
 	GError *error = NULL;
-	LibUnique *libunique;
+	EggUnique *egg_unique;
 
 	const GOptionEntry options[] = {
 		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
@@ -1806,12 +1848,12 @@
 					   PK_DATA G_DIR_SEPARATOR_S "icons");
 
 	/* are we already activated? */
-	libunique = libunique_new ();
-	ret = libunique_assign (libunique, "org.freedesktop.PackageKit.UpdateViewer");
+	egg_unique = egg_unique_new ();
+	ret = egg_unique_assign (egg_unique, "org.freedesktop.PackageKit.UpdateViewer");
 	if (!ret) {
 		goto unique_out;
 	}
-	g_signal_connect (libunique, "activated",
+	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpk_update_viewer_activated_cb), NULL);
 
 	/* we have to do this before we connect up the glade file */
@@ -1925,7 +1967,8 @@
 
 	/* create list stores */
 	list_store_details = gtk_list_store_new (PACKAGES_COLUMN_LAST, G_TYPE_STRING,
-						 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN);
+						 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT,
+						 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
 	list_store_preview = gtk_list_store_new (PREVIEW_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF);
 	list_store_description = gtk_list_store_new (DESC_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 
@@ -2008,7 +2051,7 @@
 	g_object_unref (client_action);
 	g_free (cached_package_id);
 unique_out:
-	g_object_unref (libunique);
+	g_object_unref (egg_unique);
 
 	return 0;
 }



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