File gnome-packagekit-fate302445.patch of Package gnome-packagekit
Index: gnome-packagekit-2.30.1/src/gpk-update-icon.c
===================================================================
--- gnome-packagekit-2.30.1.orig/src/gpk-update-icon.c
+++ gnome-packagekit-2.30.1/src/gpk-update-icon.c
@@ -33,9 +33,11 @@
#include <libnotify/notify.h>
#include <packagekit-glib2/packagekit.h>
#include <unique/unique.h>
+#include <gconf/gconf-client.h>
#include "egg-debug.h"
#include "egg-dbus-monitor.h"
+#include "egg-string.h"
#include "gpk-check-update.h"
#include "gpk-watch.h"
@@ -43,6 +45,84 @@
#include "gpk-hardware.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"
+
+static void
+gpk_update_libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data)
+{
+ //GpkHardware *hardware = GPK_HARDWARE (data);
+ GConfClient *gclient = gconf_client_get_default ();
+
+ if (g_strcmp0 (action, GPK_UPDATE_HARDWARE_SEND_ACTION ) == 0) {
+ 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 (g_strcmp0 (action, GPK_UPDATE_HARDWARE_DONT_PROMPT_ACTION) == 0) {
+ 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;
+
+ NotifyNotification *notification;
+ GError *error = NULL;
+ gchar *body, *summary;
+ //gchar *body2;
+ gboolean ret;
+
+ 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/bin/smoltGui", G_FILE_TEST_EXISTS)) {
+ egg_debug ("don't collect hardware info because smoltGui is not installed");
+ return FALSE;
+ }
+
+ 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:
**/
@@ -123,6 +203,8 @@ main (int argc, char *argv[])
/* Only timeout if we have specified iton the command line */
if (timed_exit)
g_timeout_add_seconds (120, (GSourceFunc) gtk_main_quit, NULL);
+ else
+ g_timeout_add_seconds (5 * 60, check_for_collect_hardware_information, NULL);
/* wait */
gtk_main ();