293 lines
14 KiB
Diff
293 lines
14 KiB
Diff
diff --git a/plugins/updates/gsd-updates-manager.c b/plugins/updates/gsd-updates-manager.c
|
|
index 3aff29a..901840e 100644
|
|
--- a/plugins/updates/gsd-updates-manager.c
|
|
+++ b/plugins/updates/gsd-updates-manager.c
|
|
@@ -66,13 +66,11 @@ struct GsdUpdatesManagerPrivate
|
|
GVolumeMonitor *volume_monitor;
|
|
guint failed_get_updates_count;
|
|
GPtrArray *update_packages;
|
|
- GFile *offline_update_file;
|
|
- GFileMonitor *offline_update_monitor;
|
|
- gboolean offline_update_notified;
|
|
};
|
|
|
|
static void gsd_updates_manager_class_init (GsdUpdatesManagerClass *klass);
|
|
static void gsd_updates_manager_init (GsdUpdatesManager *updates_manager);
|
|
+static void restart_and_install_updates (void);
|
|
|
|
G_DEFINE_TYPE (GsdUpdatesManager, gsd_updates_manager, G_TYPE_OBJECT)
|
|
|
|
@@ -245,6 +243,8 @@ libnotify_action_cb (NotifyNotification *notification,
|
|
GsdUpdatesManager *manager = GSD_UPDATES_MANAGER (user_data);
|
|
|
|
notify_notification_close (notification, NULL);
|
|
+ if (g_strcmp0 (action, "ignore") == 0)
|
|
+ goto out;
|
|
if (g_strcmp0 (action, "distro-upgrade-info") == 0) {
|
|
ret = g_spawn_command_line_async (DATADIR "/PackageKit/pk-upgrade-distro.sh",
|
|
&error);
|
|
@@ -281,6 +281,10 @@ libnotify_action_cb (NotifyNotification *notification,
|
|
show_offline_updates_error (manager);
|
|
goto out;
|
|
}
|
|
+ if (g_strcmp0 (action, "install") == 0) {
|
|
+ restart_and_install_updates ();
|
|
+ goto out;
|
|
+ }
|
|
if (g_strcmp0 (action, "cancel") == 0) {
|
|
/* try to cancel */
|
|
g_cancellable_cancel (manager->priv->cancellable);
|
|
@@ -383,6 +387,11 @@ get_distro_upgrades_finished_cb (GObject *object,
|
|
notify_notification_set_app_name (notification, _("Software Updates"));
|
|
notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
|
|
notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
|
|
+ notify_notification_add_action (notification, "ignore",
|
|
+ /* TRANSLATORS: don't install updates now */
|
|
+ _("Not Now"),
|
|
+ libnotify_action_cb,
|
|
+ manager, NULL);
|
|
notify_notification_add_action (notification, "distro-upgrade-info",
|
|
/* TRANSLATORS: provides more information about the upgrade */
|
|
_("More information"),
|
|
@@ -514,9 +523,26 @@ notify_critical_updates (GsdUpdatesManager *manager, GPtrArray *array)
|
|
notify_notification_set_app_name (notification, _("Software Updates"));
|
|
notify_notification_set_timeout (notification, 15000);
|
|
notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL);
|
|
- notify_notification_add_action (notification, "show-update-viewer",
|
|
- /* TRANSLATORS: button: open the update viewer to install updates*/
|
|
- _("Install updates"), libnotify_action_cb, manager, NULL);
|
|
+ notify_notification_add_action (notification, "ignore",
|
|
+ /* TRANSLATORS: don't install updates now */
|
|
+ _("Not Now"),
|
|
+ libnotify_action_cb,
|
|
+ manager, NULL);
|
|
+ if (g_find_program_in_path ("gnome-software")) {
|
|
+ notify_notification_add_action (notification, "show-update-viewer",
|
|
+ /* TRANSLATORS: view available updates */
|
|
+ _("View"),
|
|
+ libnotify_action_cb, manager, NULL);
|
|
+ notify_notification_add_action (notification, "install",
|
|
+ /* TRANSLATORS: install available updates */
|
|
+ _("Restart & Install"),
|
|
+ libnotify_action_cb,
|
|
+ manager, NULL);
|
|
+ } else {
|
|
+ notify_notification_add_action (notification, "show-update-viewer",
|
|
+ /* TRANSLATORS: button: open the update viewer to install updates*/
|
|
+ _("Install updates"), libnotify_action_cb, manager, NULL);
|
|
+ }
|
|
g_signal_connect (notification, "closed",
|
|
G_CALLBACK (on_notification_closed), NULL);
|
|
ret = notify_notification_show (notification, &error);
|
|
@@ -578,9 +604,26 @@ notify_normal_updates_maybe (GsdUpdatesManager *manager, GPtrArray *array)
|
|
notify_notification_set_app_name (notification, _("Software Updates"));
|
|
notify_notification_set_timeout (notification, 15000);
|
|
notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
|
|
- notify_notification_add_action (notification, "show-update-viewer",
|
|
- /* TRANSLATORS: button: open the update viewer to install updates*/
|
|
- _("Install updates"), libnotify_action_cb, manager, NULL);
|
|
+ notify_notification_add_action (notification, "ignore",
|
|
+ /* TRANSLATORS: don't install updates now */
|
|
+ _("Not Now"),
|
|
+ libnotify_action_cb,
|
|
+ manager, NULL);
|
|
+ if (g_find_program_in_path ("gnome-software")) {
|
|
+ notify_notification_add_action (notification, "show-update-viewer",
|
|
+ /* TRANSLATORS: view available updates */
|
|
+ _("View"),
|
|
+ libnotify_action_cb, manager, NULL);
|
|
+ notify_notification_add_action (notification, "install",
|
|
+ /* TRANSLATORS: install available updates */
|
|
+ _("Restart & Install"),
|
|
+ libnotify_action_cb,
|
|
+ manager, NULL);
|
|
+ } else {
|
|
+ notify_notification_add_action (notification, "show-update-viewer",
|
|
+ /* TRANSLATORS: button: open the update viewer to install updates*/
|
|
+ _("Install updates"), libnotify_action_cb, manager, NULL);
|
|
+ }
|
|
g_signal_connect (notification, "closed",
|
|
G_CALLBACK (on_notification_closed), NULL);
|
|
ret = notify_notification_show (notification, &error);
|
|
@@ -742,7 +785,6 @@ auto_download_updates (GsdUpdatesManager *manager)
|
|
package_ids[i] = g_strdup (pk_package_get_id (pkg));
|
|
}
|
|
|
|
-#if PK_CHECK_VERSION(0,8,1)
|
|
/* we've set only-download in PkTask */
|
|
pk_task_update_packages_async (manager->priv->task,
|
|
package_ids,
|
|
@@ -750,16 +792,6 @@ auto_download_updates (GsdUpdatesManager *manager)
|
|
NULL, NULL,
|
|
(GAsyncReadyCallback) package_download_finished_cb,
|
|
manager);
|
|
-#else
|
|
- /* download them all */
|
|
- pk_client_download_packages_async (PK_CLIENT(manager->priv->task),
|
|
- package_ids,
|
|
- NULL, /* this means system cache */
|
|
- manager->priv->cancellable,
|
|
- NULL, NULL,
|
|
- (GAsyncReadyCallback) package_download_finished_cb,
|
|
- manager);
|
|
-#endif
|
|
g_strfreev (package_ids);
|
|
}
|
|
|
|
@@ -1375,120 +1407,6 @@ restart_and_install_updates (void)
|
|
g_object_unref (bus);
|
|
}
|
|
|
|
-static void
|
|
-view_updates (void)
|
|
-{
|
|
- gboolean ret;
|
|
- GError *error = NULL;
|
|
-
|
|
- ret = g_spawn_command_line_async (BINDIR "/gnome-software --mode updates", &error);
|
|
- if (!ret) {
|
|
- g_warning ("Failure launching gnome-software: %s",
|
|
- error->message);
|
|
- g_error_free (error);
|
|
- }
|
|
-}
|
|
-
|
|
-static void
|
|
-offline_update_action_cb (NotifyNotification *notification,
|
|
- gchar *action,
|
|
- gpointer user_data)
|
|
-{
|
|
-
|
|
- notify_notification_close (notification, NULL);
|
|
-
|
|
- if (g_strcmp0 (action, "view") == 0) {
|
|
- view_updates ();
|
|
- }
|
|
- else if (g_strcmp0 (action, "install") == 0) {
|
|
- restart_and_install_updates ();
|
|
- }
|
|
-}
|
|
-
|
|
-static gboolean
|
|
-reenable_offline_update (gpointer data)
|
|
-{
|
|
- GsdUpdatesManager *manager = data;
|
|
-
|
|
- manager->priv->offline_update_notified = FALSE;
|
|
-
|
|
- return G_SOURCE_REMOVE;
|
|
-}
|
|
-
|
|
-static void
|
|
-notify_offline_update_available (GsdUpdatesManager *manager)
|
|
-{
|
|
- NotifyNotification *notification;
|
|
- const gchar *title;
|
|
- const gchar *body;
|
|
- gboolean ret;
|
|
- GError *error = NULL;
|
|
-
|
|
- if (!g_file_query_exists (manager->priv->offline_update_file, NULL))
|
|
- return;
|
|
-
|
|
- if (manager->priv->offline_update_notified)
|
|
- return;
|
|
-
|
|
- manager->priv->offline_update_notified = TRUE;
|
|
-
|
|
- /* don't notify more often than every 5 minutes */
|
|
- g_timeout_add_seconds (300, reenable_offline_update, manager);
|
|
-
|
|
- title = _("Software Updates available");
|
|
- body = _("Important OS and application updates are ready to be installed");
|
|
- notification = notify_notification_new (title, body,
|
|
- GSD_UPDATES_ICON_NORMAL);
|
|
- notify_notification_set_hint_string (notification, "desktop-entry", "gnome-software");
|
|
- notify_notification_set_app_name (notification, _("GNOME Software"));
|
|
- notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
|
|
- notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
|
|
- notify_notification_add_action (notification, "ignore",
|
|
- /* TRANSLATORS: don't install updates now */
|
|
- _("Not Now"),
|
|
- offline_update_action_cb,
|
|
- manager, NULL);
|
|
- if (g_find_program_in_path ("gnome-software"))
|
|
- notify_notification_add_action (notification, "view",
|
|
- /* TRANSLATORS: view available updates */
|
|
- _("View"),
|
|
- offline_update_action_cb,
|
|
- manager, NULL);
|
|
- else
|
|
- notify_notification_add_action (notification, "install",
|
|
- /* TRANSLATORS: install available updates */
|
|
- _("Restart & Install"),
|
|
- offline_update_action_cb,
|
|
- manager, NULL);
|
|
- g_signal_connect (notification, "closed",
|
|
- G_CALLBACK (on_notification_closed), NULL);
|
|
- ret = notify_notification_show (notification, &error);
|
|
- if (!ret) {
|
|
- g_warning ("error: %s", error->message);
|
|
- g_error_free (error);
|
|
- }
|
|
-}
|
|
-
|
|
-static void
|
|
-offline_update_cb (GFileMonitor *monitor,
|
|
- GFile *file,
|
|
- GFile *other_file,
|
|
- GFileMonitorEvent event_type,
|
|
- GsdUpdatesManager *manager)
|
|
-{
|
|
- notify_offline_update_available (manager);
|
|
-}
|
|
-
|
|
-static gboolean
|
|
-initial_offline_update_check (gpointer data)
|
|
-{
|
|
- GsdUpdatesManager *manager = data;
|
|
-
|
|
- notify_offline_update_available (manager);
|
|
-
|
|
- return G_SOURCE_REMOVE;
|
|
-}
|
|
-
|
|
gboolean
|
|
gsd_updates_manager_start (GsdUpdatesManager *manager,
|
|
GError **error)
|
|
@@ -1506,9 +1424,7 @@ gsd_updates_manager_start (GsdUpdatesManager *manager,
|
|
g_object_set (manager->priv->task,
|
|
"background", TRUE,
|
|
"interactive", FALSE,
|
|
-#if PK_CHECK_VERSION(0,8,1)
|
|
"only-download", TRUE,
|
|
-#endif
|
|
NULL);
|
|
|
|
/* watch UDev for missing firmware */
|
|
@@ -1574,15 +1490,6 @@ gsd_updates_manager_start (GsdUpdatesManager *manager,
|
|
check_offline_update_cb,
|
|
manager);
|
|
|
|
- manager->priv->offline_update_file = g_file_new_for_path ("/var/lib/PackageKit/prepared-update");
|
|
- manager->priv->offline_update_monitor = g_file_monitor_file (manager->priv->offline_update_file, 0, NULL, NULL);
|
|
- g_signal_connect (manager->priv->offline_update_monitor, "changed",
|
|
- G_CALLBACK (offline_update_cb), manager);
|
|
-
|
|
- g_timeout_add_seconds (300,
|
|
- initial_offline_update_check,
|
|
- manager);
|
|
-
|
|
/* success */
|
|
ret = TRUE;
|
|
g_debug ("Started updates manager");
|
|
@@ -1605,8 +1512,6 @@ gsd_updates_manager_stop (GsdUpdatesManager *manager)
|
|
g_clear_object (&manager->priv->firmware);
|
|
g_clear_object (&manager->priv->proxy_session);
|
|
g_clear_object (&manager->priv->volume_monitor);
|
|
- g_clear_object (&manager->priv->offline_update_file);
|
|
- g_clear_object (&manager->priv->offline_update_monitor);
|
|
if (manager->priv->cancellable) {
|
|
g_cancellable_cancel (manager->priv->cancellable);
|
|
g_clear_object (&manager->priv->cancellable);
|