[gnome-software] Allow applications to have multiple source-ids



commit 6cb440c24293883eac535decd5aa496aa5591efa
Author: Richard Hughes <richard hughsie com>
Date:   Wed Oct 23 14:56:56 2013 +0100

    Allow applications to have multiple source-ids
    
    For PackageKit this is a list of the PackageIds, but for other plugins it can
    just be the desktop filename for example.
    
    This now allows PackageKit to install and remove applications that have multiple
    sources.

 src/gs-app.c                               |   67 ++++++++++++++++++++++++
 src/gs-app.h                               |    6 ++
 src/gs-plugin-loader.c                     |    4 +-
 src/plugins/README.md                      |    6 +-
 src/plugins/gs-plugin-epiphany.c           |   49 ++++++++++--------
 src/plugins/gs-plugin-packagekit-offline.c |    2 +-
 src/plugins/gs-plugin-packagekit-refine.c  |   22 ++++----
 src/plugins/gs-plugin-packagekit-updates.c |    2 +-
 src/plugins/gs-plugin-packagekit.c         |   78 +++++++++++++++++++++++-----
 src/plugins/gs-plugin-systemd-updates.c    |    4 +-
 src/plugins/packagekit-common.c            |    4 +-
 11 files changed, 184 insertions(+), 60 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index a09ea84..faa2655 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -59,6 +59,7 @@ struct GsAppPrivate
        gchar                   *name;
        gchar                   *icon;
        GPtrArray               *sources;
+       GPtrArray               *source_ids;
        gchar                   *project_group;
        gchar                   *version;
        gchar                   *version_ui;
@@ -242,6 +243,10 @@ gs_app_to_string (GsApp *app)
                tmp = g_ptr_array_index (priv->sources, i);
                g_string_append_printf (str, "\tsource-%02i:\t%s\n", i, tmp);
        }
+       for (i = 0; i < priv->source_ids->len; i++) {
+               tmp = g_ptr_array_index (priv->source_ids, i);
+               g_string_append_printf (str, "\tsource-id-%02i:\t%s\n", i, tmp);
+       }
        tmp = g_hash_table_lookup (priv->urls, GS_APP_URL_KIND_HOMEPAGE);
        if (tmp != NULL)
                g_string_append_printf (str, "\turl{homepage}:\t%s\n", tmp);
@@ -530,6 +535,8 @@ const gchar *
 gs_app_get_source_default (GsApp *app)
 {
        g_return_val_if_fail (GS_IS_APP (app), NULL);
+       if (app->priv->sources->len == 0)
+               return NULL;
        return g_ptr_array_index (app->priv->sources, 0);
 }
 
@@ -539,6 +546,7 @@ gs_app_get_source_default (GsApp *app)
 void
 gs_app_set_source_default (GsApp *app, const gchar *source)
 {
+       g_ptr_array_set_size (app->priv->sources, 0);
        g_ptr_array_add (app->priv->sources, g_strdup (source));
 }
 
@@ -571,6 +579,63 @@ gs_app_set_sources (GsApp *app, GPtrArray *sources)
 }
 
 /**
+ * gs_app_get_source_id_default:
+ */
+const gchar *
+gs_app_get_source_id_default (GsApp *app)
+{
+       g_return_val_if_fail (GS_IS_APP (app), NULL);
+       if (app->priv->source_ids->len == 0)
+               return NULL;
+       return g_ptr_array_index (app->priv->source_ids, 0);
+}
+
+/**
+ * gs_app_get_source_ids:
+ */
+GPtrArray *
+gs_app_get_source_ids (GsApp *app)
+{
+       g_return_val_if_fail (GS_IS_APP (app), NULL);
+       return app->priv->source_ids;
+}
+
+/**
+ * gs_app_set_source_ids:
+ * @app:       A #GsApp instance
+ * @source_id: The source-id, e.g. ["gnome-calculator;0.134;fedora"]
+ *             or ["/home/hughsie/.local/share/applications/0ad.desktop"]
+ *
+ * This ID is used internally to the controlling plugin.
+ */
+void
+gs_app_set_source_ids (GsApp *app, GPtrArray *source_ids)
+{
+       g_return_if_fail (GS_IS_APP (app));
+       if (app->priv->source_ids != NULL)
+               g_ptr_array_unref (app->priv->source_ids);
+       app->priv->source_ids = g_ptr_array_ref (source_ids);
+}
+
+/**
+ * gs_app_add_source_id:
+ */
+void
+gs_app_add_source_id (GsApp *app, const gchar *source_id)
+{
+       const gchar *tmp;
+       guint i;
+
+       /* only add if not already present */
+       for (i = 0; i < app->priv->source_ids->len; i++) {
+               tmp = g_ptr_array_index (app->priv->source_ids, i);
+               if (g_strcmp0 (tmp, source_id) == 0)
+                       return;
+       }
+       g_ptr_array_add (app->priv->source_ids, g_strdup (source_id));
+}
+
+/**
  * gs_app_get_project_group:
  */
 const gchar *
@@ -1451,6 +1516,7 @@ gs_app_init (GsApp *app)
        app->priv = GS_APP_GET_PRIVATE (app);
        app->priv->rating = -1;
        app->priv->sources = g_ptr_array_new_with_free_func (g_free);
+       app->priv->source_ids = g_ptr_array_new_with_free_func (g_free);
        app->priv->related = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
        app->priv->history = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
        app->priv->screenshots = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
@@ -1481,6 +1547,7 @@ gs_app_finalize (GObject *object)
        g_free (priv->licence);
        g_free (priv->menu_path);
        g_ptr_array_unref (priv->sources);
+       g_ptr_array_unref (priv->source_ids);
        g_free (priv->project_group);
        g_free (priv->version);
        g_free (priv->version_ui);
diff --git a/src/gs-app.h b/src/gs-app.h
index 9fedd7d..f6d029c 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -125,6 +125,12 @@ void                gs_app_set_source_default      (GsApp          *app,
 GPtrArray      *gs_app_get_sources             (GsApp          *app);
 void            gs_app_set_sources             (GsApp          *app,
                                                 GPtrArray      *sources);
+const gchar    *gs_app_get_source_id_default   (GsApp          *app);
+void            gs_app_add_source_id           (GsApp          *app,
+                                                const gchar    *source_id);
+GPtrArray      *gs_app_get_source_ids          (GsApp          *app);
+void            gs_app_set_source_ids          (GsApp          *app,
+                                                GPtrArray      *source_ids);
 const gchar    *gs_app_get_project_group       (GsApp          *app);
 void            gs_app_set_project_group       (GsApp          *app,
                                                 const gchar    *source);
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 964b1db..c7e00c1 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -411,8 +411,8 @@ gs_plugin_loader_get_app_str (GsApp *app)
        if (id != NULL)
                return id;
 
-       /* lastly try the package id */
-       id = gs_app_get_metadata_item (app, "PackageKit::package-id");
+       /* lastly try the source id */
+       id = gs_app_get_source_id_default (app);
        if (id != NULL)
                return id;
 
diff --git a/src/plugins/README.md b/src/plugins/README.md
index 8e83ed3..07cb292 100644
--- a/src/plugins/README.md
+++ b/src/plugins/README.md
@@ -106,8 +106,8 @@ Uses the system PackageKit instance to return package data.
 Overview:    | <p>
 -------------|---
 Methods:     | Search, AddUpdates, AddInstalled, AppInstall, AppRemove, AppUpdate
-Requires:    | `{PackageKit::package-id}`
-Refines:     | `{PackageKit::package-id}`, `[source]`, `{package-summary}`, `[update-details]`, 
`[management-plugin]`
+Requires:    | `[source-id]`
+Refines:     | `[source-id]`, `[source]`, `{package-summary}`, `[update-details]`, `[management-plugin]`
 
 ### packagekit-refine ###
 Uses the system PackageKit instance to return convert filenames to package-ids.
@@ -116,7 +116,7 @@ Overview:    | <p>
 -------------|---
 Methods:     | `nothing`
 Requires:    | `{DataDir::desktop-filename}`
-Refines:     | `{PackageKit::package-id}`, `[installed]`
+Refines:     | `[source-id]`, `[installed]`
 
 ### desktopdb ###
 Uses the PackageKit desktop.db cache to map package names to, desktop names.
diff --git a/src/plugins/gs-plugin-epiphany.c b/src/plugins/gs-plugin-epiphany.c
index adfdb3a..e7f27e7 100644
--- a/src/plugins/gs-plugin-epiphany.c
+++ b/src/plugins/gs-plugin-epiphany.c
@@ -163,7 +163,7 @@ gs_plugin_add_installed_file (GsPlugin *plugin,
                                             GS_APP_STATE_INSTALLED);
        gs_app_set_kind (*app, GS_APP_KIND_NORMAL);
        gs_app_set_id_kind (*app, GS_APP_ID_KIND_WEBAPP);
-       gs_app_set_metadata (*app, "Epiphany::desktop-filename", path);
+       gs_app_add_source_id (*app, path);
        gs_app_set_icon (*app, icon);
        ret = gs_app_load_icon (*app, error);
        if (!ret)
@@ -209,6 +209,7 @@ gs_plugin_epiphany_load_db (GsPlugin *plugin, GError **error)
                if (!ret)
                        goto out;
                if (app != NULL) {
+                       gs_app_set_management_plugin (app, "Epiphany");
                        gs_plugin_add_app (&plugin->priv->list, app);
                        g_clear_object (&app);
                }
@@ -335,15 +336,17 @@ gs_plugin_app_install (GsPlugin *plugin,
        const gchar *filename;
        gboolean ret = TRUE;
 
-       /* is this a web app */
-       filename = gs_app_get_metadata_item (app, "Epiphany::desktop-filename");
-       if (filename != NULL) {
-               gs_app_set_state (app, GS_APP_STATE_INSTALLING);
-               ret = gs_plugin_app_set_enabled (filename, TRUE, error);
-               if (!ret)
-                       goto out;
-               gs_app_set_state (app, GS_APP_STATE_INSTALLED);
-       }
+       /* only process this app if was created by this plugin */
+       if (g_strcmp0 (gs_app_get_management_plugin (app), "Epiphany") != 0)
+               goto out;
+       filename = gs_app_get_source_id_default (app);
+       if (filename == NULL)
+               goto out;
+       gs_app_set_state (app, GS_APP_STATE_INSTALLING);
+       ret = gs_plugin_app_set_enabled (filename, TRUE, error);
+       if (!ret)
+               goto out;
+       gs_app_set_state (app, GS_APP_STATE_INSTALLED);
 out:
        return ret;
 }
@@ -360,15 +363,18 @@ gs_plugin_app_remove (GsPlugin *plugin,
        const gchar *filename;
        gboolean ret = TRUE;
 
-       /* is this a web app */
-       filename = gs_app_get_metadata_item (app, "Epiphany::desktop-filename");
-       if (filename != NULL) {
-               gs_app_set_state (app, GS_APP_STATE_REMOVING);
-               ret = gs_plugin_app_set_enabled (filename, FALSE, error);
-               if (!ret)
-                       goto out;
-               gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
-       }
+       /* only process this app if was created by this plugin */
+       if (g_strcmp0 (gs_app_get_management_plugin (app), "Epiphany") != 0)
+               goto out;
+
+       filename = gs_app_get_source_id_default (app);
+       if (filename == NULL)
+               goto out;
+       gs_app_set_state (app, GS_APP_STATE_REMOVING);
+       ret = gs_plugin_app_set_enabled (filename, FALSE, error);
+       if (!ret)
+               goto out;
+       gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
 out:
        return ret;
 }
@@ -611,10 +617,11 @@ gs_plugin_refine_app (GsPlugin *plugin, GsApp *app, GError **error)
        ret = gs_plugin_write_file (app, path, error);
        if (!ret)
                goto out;
-       gs_app_set_metadata (app, "Epiphany::desktop-filename", path);
+       gs_app_add_source_id (app, path);
 
        /* we now know about this */
        gs_plugin_add_app (&plugin->priv->list, app);
+       gs_app_set_management_plugin (app, "Epiphany");
 out:
        g_free (hash);
        g_free (path);
@@ -643,7 +650,7 @@ gs_plugin_refine (GsPlugin *plugin,
                if (gs_app_get_id_kind (app) != GS_APP_ID_KIND_WEBAPP)
                        continue;
                gs_app_set_size (app, 4096);
-               tmp = gs_app_get_metadata_item (app, "Epiphany::desktop-filename");
+               tmp = gs_app_get_source_id_default (app);
                if (tmp != NULL)
                        continue;
                ret = gs_plugin_refine_app (plugin, app, error);
diff --git a/src/plugins/gs-plugin-packagekit-offline.c b/src/plugins/gs-plugin-packagekit-offline.c
index 69850d3..a05f473 100644
--- a/src/plugins/gs-plugin-packagekit-offline.c
+++ b/src/plugins/gs-plugin-packagekit-offline.c
@@ -104,7 +104,7 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
                gs_app_set_source_default (app, split[0]);
                gs_app_set_update_version (app, split[1]);
                gs_app_set_management_plugin (app, "PackageKit");
-               gs_app_set_metadata (app, "PackageKit::package-id", package_ids[i]);
+               gs_app_add_source_id (app, package_ids[i]);
                gs_app_set_state (app, GS_APP_STATE_UPDATABLE);
                gs_app_set_kind (app, GS_APP_KIND_PACKAGE);
                gs_plugin_add_app (list, app);
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index 28b4113..f1f6f0d 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -132,9 +132,7 @@ gs_plugin_packagekit_resolve_packages_app (GPtrArray *packages,
                        package = g_ptr_array_index (packages, i);
                        if (g_strcmp0 (pk_package_get_name (package), pkgname) == 0) {
                                gs_app_set_management_plugin (app, "PackageKit");
-                               //FIXME: this isn't going to work
-                               gs_app_set_metadata (app, "PackageKit::package-id",
-                                                    pk_package_get_id (package));
+                               gs_app_add_source_id (app, pk_package_get_id (package));
                                switch (pk_package_get_info (package)) {
                                case GS_APP_STATE_INSTALLED:
                                        number_installed++;
@@ -297,7 +295,7 @@ gs_plugin_packagekit_refine_from_desktop (GsPlugin *plugin,
        packages = pk_results_get_package_array (results);
        if (packages->len == 1) {
                package = g_ptr_array_index (packages, 0);
-               gs_app_set_metadata (app, "PackageKit::package-id", pk_package_get_id (package));
+               gs_app_add_source_id (app, pk_package_get_id (package));
                gs_app_set_state (app, GS_APP_STATE_INSTALLED);
                gs_app_set_management_plugin (app, "PackageKit");
        } else {
@@ -340,7 +338,7 @@ gs_plugin_packagekit_refine_updatedetails (GsPlugin *plugin,
        package_ids = g_new0 (const gchar *, size + 1);
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
-               package_id = gs_app_get_metadata_item (app, "PackageKit::package-id");
+               package_id = gs_app_get_source_id_default (app);
                package_ids[i++] = package_id;
        }
 
@@ -359,7 +357,7 @@ gs_plugin_packagekit_refine_updatedetails (GsPlugin *plugin,
        array = pk_results_get_update_detail_array (results);
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
-               package_id = gs_app_get_metadata_item (app, "PackageKit::package-id");
+               package_id = gs_app_get_source_id_default (app);
                for (i = 0; i < array->len; i++) {
                        /* right package? */
                        update_detail = g_ptr_array_index (array, i);
@@ -451,7 +449,7 @@ gs_plugin_packagekit_refine_details (GsPlugin *plugin,
        package_ids = g_new0 (const gchar *, size + 1);
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
-               package_id = gs_app_get_metadata_item (app, "PackageKit::package-id");
+               package_id = gs_app_get_source_id_default (app);
                package_ids[i++] = package_id;
        }
 
@@ -470,7 +468,7 @@ gs_plugin_packagekit_refine_details (GsPlugin *plugin,
        array = pk_results_get_details_array (results);
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
-               package_id = gs_app_get_metadata_item (app, "PackageKit::package-id");
+               package_id = gs_app_get_source_id_default (app);
                for (i = 0; i < array->len; i++) {
                        /* right package? */
                        details = g_ptr_array_index (array, i);
@@ -558,7 +556,7 @@ gs_plugin_refine_require_details (GsPlugin *plugin,
                    (gs_app_get_description (app) != NULL ||
                     g_getenv ("GNOME_SOFTWARE_USE_PKG_DESCRIPTIONS") == NULL))
                        continue;
-               if (gs_app_get_metadata_item (app, "PackageKit::package-id") == NULL)
+               if (gs_app_get_source_id_default (app) == NULL)
                        continue;
                list_tmp = g_list_prepend (list_tmp, app);
        }
@@ -611,7 +609,7 @@ gs_plugin_refine (GsPlugin *plugin,
        gs_profile_start_full (plugin->profile, "packagekit-refine[name->id]");
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
-               if (gs_app_get_metadata_item (app, "PackageKit::package-id") != NULL)
+               if (gs_app_get_source_id_default (app) != NULL)
                        continue;
                if (gs_app_get_id_kind (app) == GS_APP_ID_KIND_WEBAPP)
                        continue;
@@ -639,7 +637,7 @@ gs_plugin_refine (GsPlugin *plugin,
                if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION) == 0)
                        continue;
                app = GS_APP (l->data);
-               if (gs_app_get_metadata_item (app, "PackageKit::package-id") != NULL)
+               if (gs_app_get_source_id_default (app) != NULL)
                        continue;
                tmp = gs_app_get_metadata_item (app, "DataDir::desktop-filename");
                if (tmp == NULL)
@@ -662,7 +660,7 @@ gs_plugin_refine (GsPlugin *plugin,
                        continue;
                if (gs_app_get_update_details (app) != NULL)
                        continue;
-               if (gs_app_get_metadata_item (app, "PackageKit::package-id") == NULL)
+               if (gs_app_get_source_id_default (app) == NULL)
                        continue;
                updatedetails_all = g_list_prepend (updatedetails_all, app);
        }
diff --git a/src/plugins/gs-plugin-packagekit-updates.c b/src/plugins/gs-plugin-packagekit-updates.c
index 3a1cc8e..6533c8c 100644
--- a/src/plugins/gs-plugin-packagekit-updates.c
+++ b/src/plugins/gs-plugin-packagekit-updates.c
@@ -145,7 +145,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        for (i = 0; i < array->len; i++) {
                pkg = g_ptr_array_index (array, i);
                app = gs_app_new (NULL);
-               gs_app_set_source_default (app, pk_package_get_name (pkg));
+               gs_app_add_source_id (app, pk_package_get_name (pkg));
                gs_app_set_update_version (app, pk_package_get_version (pkg));
                gs_app_set_management_plugin (app, "PackageKit");
                gs_app_set_state (app, GS_APP_STATE_UPDATABLE);
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index b8e77b0..c860662 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -158,25 +158,49 @@ gs_plugin_app_install (GsPlugin *plugin,
                       GCancellable *cancellable,
                       GError **error)
 {
-       const gchar *package_id;
-       const gchar *to_array[] = { NULL, NULL };
-       gboolean ret = TRUE;
        GPtrArray *array = NULL;
+       GPtrArray *source_ids;
        PkError *error_code = NULL;
        PkResults *results = NULL;
+       const gchar *package_id;
+       gboolean ret = TRUE;
+       gchar **package_ids = NULL;
+       guint i;
+       guint cnt = 0;
+
+       /* only process this app if was created by this plugin */
+       if (g_strcmp0 (gs_app_get_management_plugin (app), "PackageKit") != 0)
+               goto out;
 
-       package_id = gs_app_get_metadata_item (app, "PackageKit::package-id");
-       if (package_id == NULL) {
+       /* get the list of available package ids to install */
+       source_ids = gs_app_get_source_ids (app);
+       if (source_ids->len == 0) {
+               ret = FALSE;
+               g_set_error_literal (error,
+                                    GS_PLUGIN_ERROR,
+                                    GS_PLUGIN_ERROR_NOT_SUPPORTED,
+                                    "installing not available");
+               goto out;
+       }
+       package_ids = g_new0 (gchar *, source_ids->len + 1);
+       for (i = 0; i < source_ids->len; i++) {
+               package_id = g_ptr_array_index (source_ids, i);
+               if (g_strstr_len (package_id, -1, ";installed") != NULL)
+                       continue;
+               package_ids[cnt++] = g_strdup (package_id);
+       }
+       if (cnt == 0) {
                ret = FALSE;
                g_set_error_literal (error,
                                     GS_PLUGIN_ERROR,
                                     GS_PLUGIN_ERROR_NOT_SUPPORTED,
-                                    "installing not supported");
+                                    "no packages to install");
                goto out;
        }
-       to_array[0] = package_id;
+
+       /* do the action */
        results = pk_task_install_packages_sync (plugin->priv->task,
-                                                (gchar **) to_array,
+                                                package_ids,
                                                 cancellable,
                                                 gs_plugin_packagekit_progress_cb, plugin,
                                                 error);
@@ -198,6 +222,7 @@ gs_plugin_app_install (GsPlugin *plugin,
                goto out;
        }
 out:
+       g_strfreev (package_ids);
        if (error_code != NULL)
                g_object_unref (error_code);
        if (array != NULL)
@@ -217,24 +242,48 @@ gs_plugin_app_remove (GsPlugin *plugin,
                      GError **error)
 {
        const gchar *package_id;
-       const gchar *to_array[] = { NULL, NULL };
+       gchar **package_ids = NULL;
        gboolean ret = TRUE;
        GPtrArray *array = NULL;
        PkError *error_code = NULL;
        PkResults *results = NULL;
+       GPtrArray *source_ids;
+       guint i;
+       guint cnt = 0;
+
+       /* only process this app if was created by this plugin */
+       if (g_strcmp0 (gs_app_get_management_plugin (app), "PackageKit") != 0)
+               goto out;
 
-       package_id = gs_app_get_metadata_item (app, "PackageKit::package-id");
-       if (package_id == NULL) {
+       /* get the list of available package ids to install */
+       source_ids = gs_app_get_source_ids (app);
+       if (source_ids->len == 0) {
+               ret = FALSE;
+               g_set_error_literal (error,
+                                    GS_PLUGIN_ERROR,
+                                    GS_PLUGIN_ERROR_NOT_SUPPORTED,
+                                    "removing not available");
+               goto out;
+       }
+       package_ids = g_new0 (gchar *, source_ids->len + 1);
+       for (i = 0; i < source_ids->len; i++) {
+               package_id = g_ptr_array_index (source_ids, i);
+               if (g_strstr_len (package_id, -1, ";installed") == NULL)
+                       continue;
+               package_ids[cnt++] = g_strdup (package_id);
+       }
+       if (cnt == 0) {
                ret = FALSE;
                g_set_error_literal (error,
                                     GS_PLUGIN_ERROR,
                                     GS_PLUGIN_ERROR_NOT_SUPPORTED,
-                                    "removing not supported");
+                                    "no packages to remove");
                goto out;
        }
-       to_array[0] = package_id;
+
+       /* do the action */
        results = pk_task_remove_packages_sync (plugin->priv->task,
-                                               (gchar **) to_array,
+                                               package_ids,
                                                TRUE, FALSE,
                                                cancellable,
                                                gs_plugin_packagekit_progress_cb, plugin,
@@ -257,6 +306,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
                goto out;
        }
 out:
+       g_strfreev (package_ids);
        if (error_code != NULL)
                g_object_unref (error_code);
        if (array != NULL)
diff --git a/src/plugins/gs-plugin-systemd-updates.c b/src/plugins/gs-plugin-systemd-updates.c
index 5c06412..07b1cd1 100644
--- a/src/plugins/gs-plugin-systemd-updates.c
+++ b/src/plugins/gs-plugin-systemd-updates.c
@@ -78,9 +78,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        for (i = 0; package_ids[i] != NULL; i++) {
                app = gs_app_new (NULL);
                gs_app_set_management_plugin (app, "PackageKit");
-               gs_app_set_metadata (app,
-                                    "PackageKit::package-id",
-                                    package_ids[i]);
+               gs_app_add_source_id (app, package_ids[i]);
                split = pk_package_id_split (package_ids[i]);
                gs_app_set_source_default (app, split[PK_PACKAGE_ID_NAME]);
                gs_app_set_update_version (app, split[PK_PACKAGE_ID_VERSION]);
diff --git a/src/plugins/packagekit-common.c b/src/plugins/packagekit-common.c
index 15a56c3..c3199a0 100644
--- a/src/plugins/packagekit-common.c
+++ b/src/plugins/packagekit-common.c
@@ -144,9 +144,7 @@ gs_plugin_packagekit_add_results (GsPlugin *plugin,
                package = g_ptr_array_index (array_filtered, i);
 
                app = gs_app_new (NULL);
-               gs_app_set_metadata (app,
-                                    "PackageKit::package-id",
-                                    pk_package_get_id (package));
+               gs_app_add_source_id (app, pk_package_get_id (package));
                gs_app_set_metadata (app,
                                     "PackageKit::package-summary",
                                     pk_package_get_summary (package));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]