[gnome-software/wip/rancell/ubuntu-ratings] Add support for downloading the distro upgrade
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/ubuntu-ratings] Add support for downloading the distro upgrade
- Date: Thu, 12 Nov 2015 02:28:43 +0000 (UTC)
commit d3be65ba3731ba0374a302c47772611058c5537b
Author: Richard Hughes <richard hughsie com>
Date: Thu Oct 29 18:05:52 2015 +0000
Add support for downloading the distro upgrade
src/gs-cmd.c | 10 ++++++++
src/gs-plugin-loader.c | 10 ++++++++
src/gs-plugin-loader.h | 2 +
src/gs-plugin.h | 4 +++
src/plugins/gs-plugin-packagekit-refine.c | 36 +++++++++++++++++++++++++++++
5 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index 3f123da..e518cbd 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -274,6 +274,16 @@ main (int argc, char **argv)
break;
}
}
+ } else if (argc == 3 && g_strcmp0 (argv[1], "action-upgrade-download") == 0) {
+ app = gs_app_new (argv[2]);
+ gs_app_set_kind (app, GS_APP_KIND_DISTRO_UPGRADE);
+ ret = gs_plugin_loader_app_action (plugin_loader,
+ app,
+ GS_PLUGIN_LOADER_ACTION_UPGRADE_DOWNLOAD,
+ NULL,
+ &error);
+ if (ret)
+ gs_plugin_add_app (&list, app);
} else if (argc == 3 && g_strcmp0 (argv[1], "refine") == 0) {
app = gs_app_new (argv[2]);
for (i = 0; i < repeat; i++) {
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index d6d0424..124e8a3 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -2602,6 +2602,16 @@ gs_plugin_loader_app_action_async (GsPluginLoader *plugin_loader,
state->state_success = AS_APP_STATE_UNKNOWN;
state->state_failure = AS_APP_STATE_UNKNOWN;
break;
+ case GS_PLUGIN_LOADER_ACTION_UPGRADE_DOWNLOAD:
+ state->function_name = "gs_plugin_app_upgrade_download";
+ state->state_success = AS_APP_STATE_UNKNOWN;
+ state->state_failure = AS_APP_STATE_UNKNOWN;
+ break;
+ case GS_PLUGIN_LOADER_ACTION_UPGRADE_TRIGGER:
+ state->function_name = "gs_plugin_app_upgrade_trigger";
+ state->state_success = AS_APP_STATE_UNKNOWN;
+ state->state_failure = AS_APP_STATE_UNKNOWN;
+ break;
default:
g_assert_not_reached ();
break;
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index 1181f19..cfa03c3 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -56,6 +56,8 @@ typedef enum {
GS_PLUGIN_LOADER_ACTION_INSTALL,
GS_PLUGIN_LOADER_ACTION_REMOVE,
GS_PLUGIN_LOADER_ACTION_SET_RATING,
+ GS_PLUGIN_LOADER_ACTION_UPGRADE_DOWNLOAD,
+ GS_PLUGIN_LOADER_ACTION_UPGRADE_TRIGGER,
GS_PLUGIN_LOADER_ACTION_LAST
} GsPluginLoaderAction;
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index c217ec0..f64c6e6 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -251,6 +251,10 @@ gboolean gs_plugin_app_set_rating (GsPlugin *plugin,
GsApp *app,
GCancellable *cancellable,
GError **error);
+gboolean gs_plugin_app_upgrade_download (GsPlugin *plugin,
+ GsApp *app,
+ GCancellable *cancellable,
+ GError **error);
gboolean gs_plugin_refresh (GsPlugin *plugin,
guint cache_age,
GsPluginRefreshFlags flags,
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index c3df283..e4ec3b0 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -797,6 +797,42 @@ gs_plugin_refine_requires_package_id (GsApp *app, GsPluginRefineFlags flags)
}
/**
+ * gs_plugin_app_upgrade_download:
+ */
+gboolean
+gs_plugin_app_upgrade_download (GsPlugin *plugin,
+ GsApp *app,
+ GCancellable *cancellable,
+ GError **error)
+{
+ ProgressData data;
+ g_autoptr(PkResults) results = NULL;
+
+ data.plugin = plugin;
+ data.ptask = NULL;
+
+ /* check is distro-upgrade */
+ if (gs_app_get_kind (app) != GS_APP_KIND_DISTRO_UPGRADE) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "app %s is not a distro upgrade",
+ gs_app_get_id (app));
+ return FALSE;
+ }
+
+ /* ask PK to download enough packages to upgrade the system */
+ results = pk_client_upgrade_system (plugin->priv->client,
+ pk_bitfield_from_enums (PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD,
-1),
+ gs_app_get_id (app),
+ PK_UPGRADE_KIND_ENUM_COMPLETE,
+ cancellable,
+ gs_plugin_packagekit_progress_cb, &data,
+ error);
+ return results != NULL;
+}
+
+/**
* gs_plugin_packagekit_refine_distro_upgrade:
**/
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]