[gnome-packagekit/glib2: 33/79] moo
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-packagekit/glib2: 33/79] moo
- Date: Tue, 6 Oct 2009 09:47:30 +0000 (UTC)
commit 567c7f74ede48301429d8ca9dfd5255c56ba7a07
Author: Richard Hughes <richard hughsie com>
Date: Mon Sep 21 11:49:18 2009 +0100
moo
src/gpk-application.c | 73 +-------------
src/gpk-dbus-task.c | 260 ++---------------------------------------------
src/gpk-update-viewer.c | 35 +------
3 files changed, 11 insertions(+), 357 deletions(-)
---
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 3f08ea8..4e26a34 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -1044,16 +1044,11 @@ gpk_application_package_cb (PkClient *client, const PkItemPackage *item, GpkAppl
g_return_if_fail (GPK_IS_APPLICATION (application));
/* ignore not search data */
-#if PK_CHECK_VERSION(0,5,1)
g_object_get (client,
"role", &role,
NULL);
-#else
- pk_client_get_role (client, &role, NULL, NULL);
-#endif
if (role == PK_ROLE_ENUM_GET_DEPENDS ||
- role == PK_ROLE_ENUM_GET_REQUIRES ||
- role == PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES)
+ role == PK_ROLE_ENUM_GET_REQUIRES)
return;
/* ignore progress */
@@ -1359,13 +1354,9 @@ gpk_application_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runti
g_return_if_fail (GPK_IS_APPLICATION (application));
/* get role */
-#if PK_CHECK_VERSION(0,5,1)
g_object_get (client,
"role", &role,
NULL);
-#else
- pk_client_get_role (client, &role, NULL, NULL);
-#endif
egg_debug ("role: %s, exit: %s", pk_role_enum_to_text (role), pk_exit_enum_to_text (exit_enum));
widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "progressbar_progress"));
@@ -1389,23 +1380,6 @@ gpk_application_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runti
gpk_application_categories_finished (application);
}
-#if PK_CHECK_VERSION(0,5,2)
- /* simulating */
- if (role == PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES &&
- exit_enum == PK_EXIT_ENUM_SUCCESS) {
- list = pk_results_get_package_array (application->priv->client_primary);
- gpk_helper_deps_install_show (application->priv->helper_deps_install, application->priv->package_list, list);
- g_object_unref (list);
- }
-
- /* get reqs */
- if (role == PK_ROLE_ENUM_SIMULATE_REMOVE_PACKAGES &&
- exit_enum == PK_EXIT_ENUM_SUCCESS) {
- list = pk_results_get_package_array (application->priv->client_primary);
- gpk_helper_deps_remove_show (application->priv->helper_deps_remove, application->priv->package_list, list);
- g_object_unref (list);
- }
-
/* get deps */
if (role == PK_ROLE_ENUM_GET_DEPENDS &&
exit_enum == PK_EXIT_ENUM_SUCCESS) {
@@ -1421,29 +1395,6 @@ gpk_application_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runti
gpk_application_finished_get_requires (application, list);
g_object_unref (list);
}
-#else
- /* get deps */
- if (role == PK_ROLE_ENUM_GET_DEPENDS &&
- exit_enum == PK_EXIT_ENUM_SUCCESS) {
- list = pk_results_get_package_array (application->priv->client_primary);
- if (application->priv->dep_check_info_only)
- gpk_application_finished_get_depends (application, list);
- else
- gpk_helper_deps_install_show (application->priv->helper_deps_install, application->priv->package_list, list);
- g_object_unref (list);
- }
-
- /* get reqs */
- if (role == PK_ROLE_ENUM_GET_REQUIRES &&
- exit_enum == PK_EXIT_ENUM_SUCCESS) {
- list = pk_results_get_package_array (application->priv->client_primary);
- if (application->priv->dep_check_info_only)
- gpk_application_finished_get_requires (application, list);
- else
- gpk_helper_deps_remove_show (application->priv->helper_deps_remove, application->priv->package_list, list);
- g_object_unref (list);
- }
-#endif
/* we've just agreed to auth or a EULA */
if (role == PK_ROLE_ENUM_INSTALL_SIGNATURE ||
@@ -1918,12 +1869,7 @@ gpk_application_button_apply_cb (GtkWidget *widget, GpkApplication *application)
if (application->priv->action == PK_ACTION_INSTALL) {
/* install */
-#if PK_CHECK_VERSION(0,5,2)
- ret = pk_client_simulate_install_packages (application->priv->client_primary, package_ids, &error);
-#else
- application->priv->dep_check_info_only = FALSE;
- ret = pk_client_get_depends (application->priv->client_primary, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED), package_ids, TRUE, &error);
-#endif
+ ret = pk_client_install_packages (application->priv->client_primary, package_ids, &error);
if (!ret) {
egg_warning ("failed to get depends: %s", error->message);
g_error_free (error);
@@ -1937,10 +1883,7 @@ gpk_application_button_apply_cb (GtkWidget *widget, GpkApplication *application)
if (application->priv->action == PK_ACTION_REMOVE) {
/* install */
-#if !PK_CHECK_VERSION(0,5,2)
- application->priv->dep_check_info_only = FALSE;
-#endif
- ret = pk_client_get_requires (application->priv->client_primary, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), package_ids, TRUE, &error);
+ ret = pk_client_remove_packages (application->priv->client_primary, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), package_ids, TRUE, &error);
if (!ret) {
egg_warning ("failed to get requires: %s", error->message);
g_error_free (error);
@@ -2937,11 +2880,7 @@ gpk_application_deps_install_event_cb (GpkHelperDepsInstall *helper_deps_install
/* actually remove packages this time */
package_ids = pk_package_array_to_strv (application->priv->package_list);
-#if PK_CHECK_VERSION(0,5,0)
ret = pk_client_install_packages (application->priv->client_primary, TRUE, package_ids, &error);
-#else
- ret = pk_client_install_packages (application->priv->client_primary, package_ids, &error);
-#endif
if (!ret) {
egg_warning ("cannot install packages: %s", error->message);
g_error_free (error);
@@ -3218,11 +3157,7 @@ gpk_application_categories_finished (GpkApplication *application)
gpk_application_group_row_separator_func, NULL, NULL);
/* get return values */
-#if PK_CHECK_VERSION(0,5,0)
list = pk_client_get_category_list (application->priv->client_primary);
-#else
- list = pk_client_get_cached_objects (application->priv->client_primary); /* removed in 0.5.x */
-#endif
if (list->len == 0) {
egg_warning ("no results from GetCategories");
goto out;
@@ -3627,10 +3562,8 @@ gpk_application_init (GpkApplication *application)
G_CALLBACK (gpk_application_repo_signature_required_cb), application);
g_signal_connect (application->priv->client_primary, "eula-required",
G_CALLBACK (gpk_application_eula_required_cb), application);
-#if PK_CHECK_VERSION(0,4,7)
g_signal_connect (application->priv->client_primary, "media-change-required",
G_CALLBACK (gpk_application_media_change_required_cb), application);
-#endif
/* this is for auth and eula callbacks */
application->priv->client_secondary = pk_client_new ();
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 28cbb6d..050fcb9 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -175,7 +175,6 @@ gpk_dbus_task_set_timestamp (GpkDbusTask *task, guint32 timestamp)
}
static void gpk_dbus_task_install_package_files_internal (GpkDbusTask *task, gboolean trusted);
-static void gpk_dbus_task_install_package_ids_dep_check (GpkDbusTask *task);
/**
* gpk_dbus_task_chooser_event_cb:
@@ -208,7 +207,7 @@ gpk_dbus_task_chooser_event_cb (GpkHelperChooser *helper_chooser, GtkResponseTyp
task->priv->package_ids = pk_package_ids_from_id (package_id);
/* install these packages with deps */
- gpk_dbus_task_install_package_ids_dep_check (task);
+ gpk_dbus_task_install_package_ids (task);
out:
if (error != NULL)
@@ -320,74 +319,6 @@ out:
}
/**
- * gpk_dbus_task_install_package_ids_dep_check:
- * @task: a valid #GpkDbusTask instance
- **/
-static void
-gpk_dbus_task_install_package_ids_dep_check (GpkDbusTask *task)
-{
- gboolean ret;
- GError *error = NULL;
- GError *error_local = NULL;
-
- g_return_if_fail (GPK_IS_DBUS_TASK (task));
- g_return_if_fail (task->priv->package_ids != NULL);
-
- /* are we dumb and can't check for depends? */
-#if PK_CHECK_VERSION(0,5,2)
- if (!pk_bitfield_contain (task->priv->roles, PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES)) {
-#else
- if (!pk_bitfield_contain (task->priv->roles, PK_ROLE_ENUM_GET_DEPENDS)) {
-#endif
- egg_warning ("skipping depends check");
- gpk_dbus_task_install_package_ids (task);
- goto out;
- }
-
- /* have we previously said we don't want to be shown the confirmation */
- ret = gconf_client_get_bool (task->priv->gconf_client, GPK_CONF_SHOW_DEPENDS, NULL);
- if (!ret) {
- egg_warning ("we've said we don't want the dep dialog");
- gpk_dbus_task_install_package_ids (task);
- goto out;
- }
-
- /* optional */
- if (!task->priv->show_confirm_deps) {
- egg_warning ("skip confirm as not allowed to interact with user");
- gpk_dbus_task_install_package_ids (task);
- goto out;
- }
-
- gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, GPK_MODAL_DIALOG_PACKAGE_PADDING);
- /* TRANSLATORS: finding a list of packages that we would also need to download */
- gpk_modal_dialog_set_title (task->priv->dialog, _("Finding other packages we require"));
- gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-finding-depends");
-
- /* setup the UI */
- if (task->priv->show_progress)
- gpk_modal_dialog_present (task->priv->dialog);
-
- /* find out if this would drag in other packages */
- ret = pk_client_simulate_install_packages (task->priv->client, task->priv->package_ids, &error_local);
- if (!ret) {
- /* TRANSLATORS: error: could not get the extra package list when installing a package */
- gpk_dbus_task_error_msg (task, _("Could not work out what packages would be also installed"), error_local);
- error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
- dbus_g_method_return_error (task->priv->context, error);
- goto out;
- }
-
- /* wait for async reply */
-
-out:
- if (error != NULL)
- g_error_free (error);
- if (error_local != NULL)
- g_error_free (error_local);
-}
-
-/**
* gpk_dbus_task_error_from_exit_enum:
**/
static GError *
@@ -416,38 +347,6 @@ out:
return error;
}
-/**
- * gpk_dbus_task_install_package_ids_dep_check_idle_cb:
- **/
-static gboolean
-gpk_dbus_task_install_package_ids_dep_check_idle_cb (GpkDbusTask *task)
-{
- egg_warning ("idle add install package ids dep check");
- gpk_dbus_task_install_package_ids_dep_check (task);
- return FALSE;
-}
-
-/**
- * gpk_dbus_task_install_package_ids_idle_cb:
- **/
-static gboolean
-gpk_dbus_task_install_package_ids_idle_cb (GpkDbusTask *task)
-{
- egg_warning ("idle add install package ids");
- gpk_dbus_task_install_package_ids (task);
- return FALSE;
-}
-
-/**
- * gpk_dbus_task_install_files_idle_cb:
- **/
-static gboolean
-gpk_dbus_task_install_files_idle_cb (GpkDbusTask *task)
-{
- egg_warning ("idle add install files");
- gpk_dbus_task_install_files (task);
- return FALSE;
-}
/**
* gpk_dbus_task_finished_cb:
@@ -602,94 +501,11 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
task->priv->package_ids = pk_package_ids_from_id (id);
/* install these packages with deps */
- g_idle_add ((GSourceFunc) gpk_dbus_task_install_package_ids_dep_check_idle_cb, task);
+ gpk_dbus_task_install_package_ids (task);
goto out;
}
/* from InstallPackageIds */
-#if PK_CHECK_VERSION(0,5,2)
- if (role == PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES ||
- role == PK_ROLE_ENUM_SIMULATE_INSTALL_FILES) {
-#else
- if (role == PK_ROLE_ENUM_GET_DEPENDS) {
-#endif
- GPtrArray *new;
-
- /* these are the new packages */
- list = pk_results_get_package_array (task->priv->client);
- new = g_ptr_array_new_with_free_func_xxx ();
- for (i=0; i<list->len; i++) {
- item = g_ptr_array_index (list, i);
-
-#if PK_CHECK_VERSION(0,5,2)
- /* not interesting */
- if (item->info != PK_INFO_ENUM_UPDATING &&
- item->info != PK_INFO_ENUM_INSTALLING)
- continue;
-#endif
-
- /* is this package already local */
- if (g_strcmp0 (item->package_id->data, "local") == 0)
- continue;
-
- g_ptr_array_add_xxxwithrecount (new, item->info, item->package_id, item->summary);
- }
-
- /* these are the new packages */
- if (new->len == 0) {
- egg_debug ("no deps");
- goto skip_checks;
- }
-
- /* TRANSLATORS: title: tell the user we have to install additional packages */
- title = g_strdup_printf (ngettext ("%i additional package also has to be installed",
- "%i additional packages also have to be installed",
- len), len);
-
- /* message */
- if (role == PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES)
- text = gpk_dialog_package_id_name_join_locale (task->priv->package_ids);
- else {
- gchar **files;
- len = g_strv_length (task->priv->files);
- files = g_new0 (gchar *, len+1);
- for (i=0; i<len; i++)
- files[i] = g_path_get_basename (task->priv->files[i]);
- text = gpk_strv_join_locale (files);
- g_strfreev (files);
- }
- /* TRANSLATORS: message: explain to the user what we are doing in more detail */
- message = g_strdup_printf (ngettext ("To install %s, an additional package also has to be downloaded.",
- "To install %s, additional packages also have to be downloaded.",
- len), text);
- g_free (text);
-
- gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
- gpk_modal_dialog_set_package_list (task->priv->dialog, new);
- g_object_unref (new);
- gpk_modal_dialog_set_title (task->priv->dialog, title);
- gpk_modal_dialog_set_message (task->priv->dialog, message);
- /* TRANSLATORS: title: installing package */
- gpk_modal_dialog_set_action (task->priv->dialog, _("Install"));
- gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-install-other-packages");
- gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
- button = gpk_modal_dialog_run (task->priv->dialog);
-
- /* did we click no or exit the window? */
- if (button != GTK_RESPONSE_OK) {
- gpk_modal_dialog_close (task->priv->dialog);
- error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to additional deps");
- dbus_g_method_return_error (task->priv->context, error);
- goto out;
- }
-skip_checks:
- if (role == PK_ROLE_ENUM_SIMULATE_INSTALL_PACKAGES)
- g_idle_add ((GSourceFunc) gpk_dbus_task_install_package_ids_idle_cb, task);
- else
- g_idle_add ((GSourceFunc) gpk_dbus_task_install_files_idle_cb, task);
- }
-
- /* from InstallPackageIds */
if (role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
role == PK_ROLE_ENUM_INSTALL_FILES) {
@@ -829,7 +645,7 @@ skip_checks:
task->priv->package_ids = pk_package_array_to_strv (list);
/* install these packages with deps */
- g_idle_add ((GSourceFunc) gpk_dbus_task_install_package_ids_dep_check_idle_cb, task);
+ gpk_dbus_task_install_package_ids (task);
goto out;
}
@@ -1686,68 +1502,6 @@ gpk_dbus_task_install_files (GpkDbusTask *task)
}
/**
- * gpk_dbus_task_install_files_dep_check:
- **/
-static void
-gpk_dbus_task_install_files_dep_check (GpkDbusTask *task)
-{
- gboolean ret;
- GError *error = NULL;
- GError *error_local = NULL;
-
- g_return_if_fail (GPK_IS_DBUS_TASK (task));
- g_return_if_fail (task->priv->files != NULL);
-
- /* are we dumb and can't check for depends? */
- if (!pk_bitfield_contain (task->priv->roles, PK_ROLE_ENUM_SIMULATE_INSTALL_FILES)) {
- egg_warning ("skipping depends check");
- gpk_dbus_task_install_package_ids (task);
- goto out;
- }
-
- /* have we previously said we don't want to be shown the confirmation */
- ret = gconf_client_get_bool (task->priv->gconf_client, GPK_CONF_SHOW_DEPENDS, NULL);
- if (!ret) {
- egg_warning ("we've said we don't want the dep dialog");
- gpk_dbus_task_install_package_ids (task);
- goto out;
- }
-
- /* optional */
- if (!task->priv->show_confirm_deps) {
- egg_warning ("skip confirm as not allowed to interact with user");
- gpk_dbus_task_install_files (task);
- goto out;
- }
-
- gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, GPK_MODAL_DIALOG_PACKAGE_PADDING);
- /* TRANSLATORS: finding a list of packages that we would also need to download */
- gpk_modal_dialog_set_title (task->priv->dialog, _("Finding other packages we require"));
- gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-finding-depends");
-
- /* setup the UI */
- if (task->priv->show_progress)
- gpk_modal_dialog_present (task->priv->dialog);
-
- /* find out if this would drag in other packages */
- ret = pk_client_simulate_install_files (task->priv->client, task->priv->files, &error_local);
- if (!ret) {
- /* TRANSLATORS: error: could not get the extra package list when installing a package */
- gpk_dbus_task_error_msg (task, _("Could not work out what packages would be also installed"), error_local);
- error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
- dbus_g_method_return_error (task->priv->context, error);
- goto out;
- }
-
- /* wait for async reply */
-out:
- if (error != NULL)
- g_error_free (error);
- if (error_local != NULL)
- g_error_free (error_local);
-}
-
-/**
* gpk_dbus_task_install_package_files:
* @task: a valid #GpkDbusTask instance
* @file_rel: a file such as <literal>./hal-devel-0.10.0.rpm</literal>
@@ -1803,7 +1557,7 @@ gpk_dbus_task_install_package_files (GpkDbusTask *task, gchar **files_rel)
/* check for deps */
task->priv->files = pk_ptr_array_to_strv (array);
- gpk_dbus_task_install_files_dep_check (task);
+ gpk_dbus_task_install_files_internal (task);
/* wait for async reply */
out:
@@ -2294,7 +2048,7 @@ skip_checks:
skip_checks2:
/* install with deps */
task->priv->package_ids = pk_package_array_to_strv (list);
- gpk_dbus_task_install_package_ids_dep_check (task);
+ gpk_dbus_task_install_package_ids (task);
out:
if (list != NULL)
g_object_unref (list);
@@ -2696,7 +2450,7 @@ skip_checks:
skip_checks2:
/* convert to list of package id's */
task->priv->package_ids = pk_package_array_to_strv (list);
- gpk_dbus_task_install_package_ids_dep_check (task);
+ gpk_dbus_task_install_package_ids (task);
out:
if (error != NULL)
@@ -2837,7 +2591,7 @@ skip_checks:
skip_checks2:
/* convert to list of package id's */
task->priv->package_ids = pk_package_array_to_strv (list);
- gpk_dbus_task_install_package_ids_dep_check (task);
+ gpk_dbus_task_install_package_ids (task);
out:
if (error != NULL)
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index 5073172..e864547 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -419,11 +419,7 @@ gpk_update_viewer_button_install_cb (GtkWidget *widget, gpointer data)
install_package_ids = g_strdupv (package_ids);
/* get packages that also have to be updated */
-#if PK_CHECK_VERSION(0,5,2)
- ret = pk_client_simulate_update_packages (client_primary, package_ids, &error);
-#else
- ret = pk_client_get_depends (client_primary, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED), package_ids, TRUE, &error);
-#endif
+ ret = pk_client_update_packages (client_primary, package_ids, &error);
if (!ret) {
egg_warning ("cannot get depends for updates: %s", error->message);
g_error_free (error);
@@ -576,19 +572,6 @@ gpk_update_viewer_package_cb (PkClient *client, const PkItemPackage *item, gpoin
egg_debug ("role = %s, package = %s:%s:%s", pk_role_enum_to_text (role),
pk_info_enum_to_text (item->info), "xxx", item->summary);
- /* are we simulating to get deps? */
-#if PK_CHECK_VERSION(0,5,2)
- if (role == PK_ROLE_ENUM_SIMULATE_UPDATE_PACKAGES) {
- egg_debug ("ignoring %s as we are simulating", item->package_id);
- goto out;
- }
-#else
- if (role == PK_ROLE_ENUM_GET_DEPENDS) {
- egg_debug ("ignoring %s as we are in the depends phase", item->package_id);
- goto out;
- }
-#endif
-
/* used for progress */
if (!gpk_update_viewer_is_update_info (item->info)) {
g_free (package_id_last);
@@ -1664,11 +1647,7 @@ gpk_update_viewer_deps_update_event_cb (GpkHelperDepsUpdate *helper, GtkResponse
gpk_update_viewer_reconsider_info (model);
/* actually install packages this time */
-#if PK_CHECK_VERSION(0,5,0)
ret = pk_client_update_packages (client_primary, TRUE, install_package_ids, &error);
-#else
- ret = pk_client_update_packages (client_primary, install_package_ids, &error);
-#endif
if (!ret) {
egg_warning ("cannot install packages: %s", error->message);
g_error_free (error);
@@ -1727,18 +1706,6 @@ gpk_update_viewer_finished_cb (PkClient *client, PkExitEnum exit, guint runtime,
return;
}
- /* finished depends check, show any extras */
-#if PK_CHECK_VERSION(0,5,2)
- if (exit == PK_EXIT_ENUM_SUCCESS && role == PK_ROLE_ENUM_SIMULATE_UPDATE_PACKAGES) {
-#else
- if (exit == PK_EXIT_ENUM_SUCCESS && role == PK_ROLE_ENUM_GET_DEPENDS) {
-#endif
- /* show deps dialog */
- list = pk_results_get_package_array (client);
- gpk_helper_deps_update_show (helper_deps_update, list);
- g_object_unref (list);
- }
-
if (role == PK_ROLE_ENUM_GET_UPDATES) {
/* get the download sizes */
if (update_list != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]