summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKalev Lember <klember@redhat.com>2017-10-25 13:59:38 +0200
committerKalev Lember <klember@redhat.com>2017-10-25 13:59:38 +0200
commit376983f0c3e03dec56f57adf1b06296625cca685 (patch)
treea40c0b004ddcc946f8757634c14e0cc5874a41be /lib
parenta4c1905bde979a167e027fb70e551b6342f8b6aa (diff)
offline update: Save transaction role to the offline results file
This lets gnome-software handle distro upgrade and regular update results differently.
Diffstat (limited to 'lib')
-rw-r--r--lib/packagekit-glib2/pk-offline-private.c10
-rw-r--r--lib/packagekit-glib2/pk-offline.c9
-rw-r--r--lib/packagekit-glib2/pk-results.c22
-rw-r--r--lib/packagekit-glib2/pk-results.h2
4 files changed, 43 insertions, 0 deletions
diff --git a/lib/packagekit-glib2/pk-offline-private.c b/lib/packagekit-glib2/pk-offline-private.c
index 037032b54..f6998aa56 100644
--- a/lib/packagekit-glib2/pk-offline-private.c
+++ b/lib/packagekit-glib2/pk-offline-private.c
@@ -421,6 +421,7 @@ pk_offline_auth_set_results (PkResults *results, GError **error)
{
guint i;
PkPackage *package;
+ PkRoleEnum role;
g_autoptr(GError) error_local = NULL;
g_autofree gchar *data = NULL;
g_autoptr(GKeyFile) key_file = NULL;
@@ -451,6 +452,15 @@ pk_offline_auth_set_results (PkResults *results, GError **error)
TRUE);
}
+ /* save role */
+ role = pk_results_get_role (results);
+ if (role != PK_ROLE_ENUM_UNKNOWN) {
+ g_key_file_set_string (key_file,
+ PK_OFFLINE_RESULTS_GROUP,
+ "Role",
+ pk_role_enum_to_string (role));
+ }
+
/* save packages if any set */
packages = pk_results_get_package_array (results);
if (packages->len > 0) {
diff --git a/lib/packagekit-glib2/pk-offline.c b/lib/packagekit-glib2/pk-offline.c
index c08f0ad59..df991314b 100644
--- a/lib/packagekit-glib2/pk-offline.c
+++ b/lib/packagekit-glib2/pk-offline.c
@@ -563,6 +563,7 @@ pk_offline_get_results (GError **error)
guint i;
g_autoptr(GError) error_local = NULL;
g_autofree gchar *data = NULL;
+ g_autofree gchar *role_str = NULL;
g_autoptr(GKeyFile) file = NULL;
g_autoptr(PkError) pk_error = NULL;
g_autoptr(PkResults) results = NULL;
@@ -620,6 +621,14 @@ pk_offline_get_results (GError **error)
pk_results_set_exit_code (results, PK_EXIT_ENUM_SUCCESS);
}
+ /* set role */
+ role_str = g_key_file_get_string (file,
+ PK_OFFLINE_RESULTS_GROUP,
+ "Role",
+ NULL);
+ if (role_str != NULL)
+ pk_results_set_role (results, pk_role_enum_from_string (role_str));
+
/* add packages */
data = g_key_file_get_string (file, PK_OFFLINE_RESULTS_GROUP,
"Packages", NULL);
diff --git a/lib/packagekit-glib2/pk-results.c b/lib/packagekit-glib2/pk-results.c
index c64ce0d00..952916082 100644
--- a/lib/packagekit-glib2/pk-results.c
+++ b/lib/packagekit-glib2/pk-results.c
@@ -138,6 +138,28 @@ pk_results_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
/**
+ * pk_results_set_role:
+ * @results: a valid #PkResults instance
+ * @role: the role enum
+ *
+ * Sets the results object to have the given role enum.
+ *
+ * Return value: %TRUE if the value was set
+ *
+ * Since: 1.1.8
+ **/
+gboolean
+pk_results_set_role (PkResults *results, PkRoleEnum role)
+{
+ g_return_val_if_fail (PK_IS_RESULTS (results), FALSE);
+ g_return_val_if_fail (role != PK_ROLE_ENUM_UNKNOWN, FALSE);
+
+ results->priv->role = role;
+
+ return TRUE;
+}
+
+/**
* pk_results_set_exit_code:
* @results: a valid #PkResults instance
* @exit_enum: the exit code
diff --git a/lib/packagekit-glib2/pk-results.h b/lib/packagekit-glib2/pk-results.h
index 235d6856e..f6bca8d12 100644
--- a/lib/packagekit-glib2/pk-results.h
+++ b/lib/packagekit-glib2/pk-results.h
@@ -84,6 +84,8 @@ PkResults *pk_results_new (void);
/* set */
gboolean pk_results_set_exit_code (PkResults *results,
PkExitEnum exit_enum);
+gboolean pk_results_set_role (PkResults *results,
+ PkRoleEnum role);
gboolean pk_results_set_error_code (PkResults *results,
PkError *item);