File gnome-packagekit-fate302445.patch of Package gnome-packagekit

Index: gnome-packagekit-0.3.11/src/gpk-update-icon.c
===================================================================
--- gnome-packagekit-0.3.11.orig/src/gpk-update-icon.c
+++ gnome-packagekit-0.3.11/src/gpk-update-icon.c
@@ -31,9 +31,11 @@
 #include <gtk/gtk.h>
 #include <locale.h>
 #include <libnotify/notify.h>
+#include <gconf/gconf-client.h>
 #include <packagekit-glib/packagekit.h>
 
 #include "egg-debug.h"
+#include "egg-string.h"
 #include "egg-dbus-monitor.h"
 
 #include "gpk-check-update.h"
@@ -44,6 +46,10 @@
 #include "org.freedesktop.PackageKit.h"
 #include "gpk-common.h"
 
+#define GPK_CONF_HARDWARE_ASKED_TO_COLLECT "/apps/gnome-packagekit/updater_asked_to_collect_hardware_information"
+#define GPK_UPDATE_HARDWARE_SEND_ACTION "gpk-update-icon hardware info - send "
+#define GPK_UPDATE_HARDWARE_DONT_PROMPT_ACTION "gpk-update-icon hardware info - don't ask again"
+
 /**
  * gpk_object_register:
  * @connection: What we want to register to
@@ -103,6 +109,86 @@ pk_dbus_connection_replaced_cb (EggDbusM
 	gtk_main_quit ();
 }
 
+static void
+gpk_update_libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data)
+{
+	//GpkHardware *hardware = GPK_HARDWARE (data);
+	GConfClient *gclient = gconf_client_get_default ();
+
+	if (egg_strequal (action, GPK_UPDATE_HARDWARE_SEND_ACTION )) {
+		gboolean retval = g_spawn_command_line_async ("/usr/bin/smoltGui", NULL);
+		if (!retval) {
+			egg_debug ("Failure launching smoltGui");
+		}
+		egg_debug ("set %s to TRUE because done", GPK_CONF_HARDWARE_ASKED_TO_COLLECT);
+		gconf_client_set_bool (gclient, GPK_CONF_HARDWARE_ASKED_TO_COLLECT, TRUE, NULL);
+	} else if (egg_strequal (action, GPK_UPDATE_HARDWARE_DONT_PROMPT_ACTION)) {
+		egg_debug ("set %s to TRUE because user said no", GPK_CONF_HARDWARE_ASKED_TO_COLLECT);
+		gconf_client_set_bool (gclient, GPK_CONF_HARDWARE_ASKED_TO_COLLECT, TRUE, NULL);
+	} else {
+		egg_warning ("unknown action id: %s", action);
+	}
+
+	g_object_unref (gclient);
+}
+
+static gboolean
+check_for_collect_hardware_information (gpointer data)
+{
+	GConfClient *gclient = gconf_client_get_default ();
+	gboolean asked_to_collect = FALSE;
+	asked_to_collect = gconf_client_get_bool (gclient, GPK_CONF_HARDWARE_ASKED_TO_COLLECT, NULL);
+	g_object_unref (gclient);
+	if (asked_to_collect)
+	{
+		egg_debug ("don't collect hardware info because already done");
+		return FALSE;
+	}
+
+	if (! g_file_test ("/var/run/smolt_do_opensuse_run", G_FILE_TEST_EXISTS))
+	{
+		egg_debug ("don't collect hardware info yet until smolt is updated - BNC#450105");
+		return TRUE;
+	}
+	if (! g_file_test ("/usr/share/applications/YaST2/suse_register.desktop", G_FILE_TEST_EXISTS))
+	{
+		egg_debug ("don't collect hardware info because this isn't opensuse");
+		return FALSE;
+	}
+	if (! g_file_test ("/usr/bin/smoltGui", G_FILE_TEST_EXISTS))
+	{
+		egg_debug ("don't collect hardware info because smoltGui is not installed");
+		return FALSE;
+	}
+
+	NotifyNotification *notification;
+	GError *error = NULL;
+	gchar *body, *summary;
+	//gchar *body2;
+	gboolean ret;
+
+	summary = g_strdup_printf ("%s", _("openSUSE Updater"));
+	//body = g_strdup_printf ("%s", _("Driver development is prioritized based on hardware popularity.<br>Please send your system profile to influence this work."));
+	body = g_strdup_printf ("%s", _("Driver development is prioritized based on hardware popularity. Please send your system profile to influence this work."));
+	//body2 = g_markup_escape_text (body, -1);
+	notification = notify_notification_new (summary, body, "help-browser", NULL);
+	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
+	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+	notify_notification_add_action (notification, GPK_UPDATE_HARDWARE_SEND_ACTION,
+			_("Send now"), gpk_update_libnotify_cb, NULL, NULL);
+	notify_notification_add_action (notification, GPK_UPDATE_HARDWARE_DONT_PROMPT_ACTION,
+			_("Do not show this again"), gpk_update_libnotify_cb, NULL, NULL);
+	ret = notify_notification_show (notification, &error);
+	if (!ret) {
+		egg_warning ("error: %s", error->message);
+		g_error_free (error);
+	}
+
+	g_free (summary);
+	g_free (body);
+	return FALSE;
+}
+
 /**
  * main:
  **/
@@ -166,6 +252,8 @@ main (int argc, char *argv[])
 	if (!ret)
 		return 1;
 
+	g_timeout_add_seconds (5 * 60, check_for_collect_hardware_information, NULL);
+
 	/* add application specific icons to search path */
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
 					   GPK_DATA G_DIR_SEPARATOR_S "icons");
openSUSE Build Service is sponsored by