[gnome-software/wip/ubuntu-3-24: 18/18] apt plugin fixes



commit 8e5c1d36ef22fda5b3b6601eb9cd1cdd13a503f6
Author: Iain Lane <iain orangesquash org uk>
Date:   Mon May 15 17:45:46 2017 +0100

    apt plugin fixes

 meson.build                  |    2 +
 plugins/apt/gs-plugin-apt.cc |   55 ++++++++++++++++++++++-------------------
 src/gs-dbus-helper.c         |    1 +
 3 files changed, 32 insertions(+), 26 deletions(-)
---
diff --git a/meson.build b/meson.build
index ac04fcf..0f06e4e 100644
--- a/meson.build
+++ b/meson.build
@@ -89,6 +89,8 @@ foreach lang : ['c', 'cpp']
   )
 endforeach
 
+add_project_arguments('-Wno-aggregate-return', language: 'cpp')
+
 appstream_glib = dependency('appstream-glib', version : '>= 0.6.5')
 gdk_pixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.31.5')
 gio_unix = dependency('gio-unix-2.0')
diff --git a/plugins/apt/gs-plugin-apt.cc b/plugins/apt/gs-plugin-apt.cc
index efb1755..d606e8a 100644
--- a/plugins/apt/gs-plugin-apt.cc
+++ b/plugins/apt/gs-plugin-apt.cc
@@ -171,7 +171,6 @@ read_list_file_cb (GObject *object,
        g_autoptr(GFileInfo) info = NULL;
        g_auto(GStrv) file_lines = NULL;
        g_auto(GStrv) file_components = NULL;
-       gchar *line;
 
        file = G_FILE (object);
        data = (ReadListData *) user_data;
@@ -547,12 +546,6 @@ get_changelog (GsPlugin *plugin, GsApp *app)
 }
 
 static gboolean
-is_official (PackageInfo *info)
-{
-       return g_strcmp0 (info->origin, "Ubuntu") == 0;
-}
-
-static gboolean
 is_open_source (PackageInfo *info)
 {
        const gchar *open_source_components[] = { "main", "universe", NULL };
@@ -609,7 +602,6 @@ gs_plugin_refine_app (GsPlugin *plugin,
                      GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
-       GList *link;
        PackageInfo *info;
        const gchar *tmp;
        g_autoptr(GMutexLocker) locker = NULL;
@@ -635,7 +627,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
                        break;
                }
 
-               if (!g_file_test (fn, G_FILE_TEST_EXISTS)) {
+               if (!fn || !g_file_test (fn, G_FILE_TEST_EXISTS)) {
                        g_debug ("ignoring %s as does not exist", fn);
                } else {
                        package = (gchar *) g_hash_table_lookup (priv->installed_files,
@@ -671,7 +663,8 @@ gs_plugin_refine_app (GsPlugin *plugin,
        if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN) != 0) {
                g_autofree gchar *origin = get_origin (info);
                gs_app_set_origin (app, origin);
-               gs_app_set_origin_ui (app, info->origin);
+               if (g_strcmp0 (info->origin, "Ubuntu") == 0)
+                       gs_app_set_origin_hostname (app, "https://www.ubuntu.com";);
        }
 
        if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) != 0) {
@@ -754,7 +747,7 @@ typedef struct {
        GsPlugin *plugin;
        GCancellable *cancellable;
        GsApp *app;
-       GList *apps;
+       GsAppList *apps;
        gchar *result;
        GMainContext *context;
        GMainLoop *loop;
@@ -819,7 +812,7 @@ transaction_property_changed_cb (GDBusConnection *connection,
 {
        TransactionData *data = (TransactionData *) user_data;
        const gchar *name;
-       GList *i;
+       guint length;
        g_autoptr(GVariant) value = NULL;
 
        if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(sv)"))) {
@@ -827,8 +820,12 @@ transaction_property_changed_cb (GDBusConnection *connection,
                if (g_strcmp0 (name, "Progress") == 0) {
                        if (data->app)
                                gs_app_set_progress (data->app, g_variant_get_int32 (value));
-                       for (i = data->apps; i != NULL; i = i->next)
-                               gs_app_set_progress (GS_APP (i->data), g_variant_get_int32 (value));
+                       if (data->apps) {
+                               length = gs_app_list_length (data->apps);
+                               for (guint i = 0; i < length; ++i)
+                                       gs_app_set_progress (gs_app_list_index (data->apps, i),
+                                                            g_variant_get_int32 (value));
+                       }
                }
        } else {
                g_warning ("Unknown parameters in %s.%s: %s",
@@ -914,7 +911,7 @@ debconf_client_read_cb (gint fd, GIOCondition condition, gpointer user_data)
 {
        TransactionData *data = (TransactionData *) user_data;
        gchar buffer[1024];
-       gsize n_read;
+       gssize n_read;
        g_autoptr(GError) error = NULL;
 
        n_read = read (fd, buffer, 1024);
@@ -982,7 +979,7 @@ static gboolean
 aptd_transaction (GsPlugin     *plugin,
                  const gchar  *method,
                  GsApp        *app,
-                 GList        *apps,
+                 GsAppList    *apps,
                  GVariant     *parameters,
                  GCancellable *cancellable,
                  GError      **error)
@@ -1229,6 +1226,8 @@ gs_plugin_add_updates (GsPlugin *plugin,
                gs_app_set_management_plugin (app, "apt");
                gs_app_set_name (app, GS_APP_QUALITY_LOWEST, info->name);
                gs_app_set_kind (app, AS_APP_KIND_GENERIC);
+               gs_app_set_version (app, info->installed_version);
+               gs_app_set_update_version (app, info->update_version);
                gs_app_add_source (app, info->name);
                gs_app_list_add (list, app);
        }
@@ -1237,17 +1236,19 @@ gs_plugin_add_updates (GsPlugin *plugin,
 }
 
 static void
-set_list_state (GList      *apps,
+set_list_state (GsAppList  *apps,
                AsAppState  state)
 {
-       GList *i;
+       guint length;
        guint j;
        GsApp *app_i;
        GsApp *app_j;
        GPtrArray *related;
 
-       for (i = apps; i != NULL; i = i->next) {
-               app_i = GS_APP (i->data);
+       length = gs_app_list_length (apps);
+
+       for (guint i = 0; i < length; ++i) {
+               app_i = gs_app_list_index (apps, i);
                gs_app_set_state (app_i, state);
 
                if (g_strcmp0 (gs_app_get_id (app_i), "os-update.virtual") == 0) {
@@ -1263,17 +1264,19 @@ set_list_state (GList      *apps,
 
 gboolean
 gs_plugin_update (GsPlugin      *plugin,
-                 GList         *apps,
+                 GsAppList     *apps,
                  GCancellable  *cancellable,
                  GError       **error)
 {
-       GList *i;
        GsApp *app_i;
+       guint length;
 
-       for (i = apps; i != NULL; i = i->next) {
-               app_i = GS_APP (i->data);
+       length = gs_app_list_length (apps);
 
-               if (g_strcmp0 (gs_app_get_id (app_i), "os-update.virtual") == 0) {
+       for (guint i = 0; i < length; ++i) {
+               app_i = gs_app_list_index (apps, i);
+
+               if (g_strcmp0 (gs_app_get_id (app_i), "org.gnome.Software.OsUpdate") == 0) {
                        set_list_state (apps, AS_APP_STATE_INSTALLING);
 
                        if (aptd_transaction (plugin,
@@ -1311,7 +1314,7 @@ gs_plugin_update_app (GsPlugin *plugin,
        guint i;
        GVariantBuilder builder;
 
-       if (g_strcmp0 (gs_app_get_id (app), "os-update.virtual") == 0) {
+       if (g_strcmp0 (gs_app_get_id (app), "org.gnome.Software.OsUpdate") == 0) {
                apps = gs_app_get_related (app);
 
                g_variant_builder_init (&builder, G_VARIANT_TYPE ("(as)"));
diff --git a/src/gs-dbus-helper.c b/src/gs-dbus-helper.c
index 41525de..e3f80fa 100644
--- a/src/gs-dbus-helper.c
+++ b/src/gs-dbus-helper.c
@@ -29,6 +29,7 @@
 
 #include "gnome-software-private.h"
 
+#include "gs-common.h"
 #include "gs-dbus-helper.h"
 #include "gs-packagekit-generated.h"
 #include "gs-packagekit-modify2-generated.h"


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