[gnome-software/wip/temp/ubuntu-xenial-rebased: 121/329] Better handle setting app state



commit 30ff9a20dc819ce45e07383c752d9fcf1ef41b27
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Feb 26 09:55:22 2016 +1300

    Better handle setting app state

 src/plugins/gs-plugin-apt.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/gs-plugin-apt.c b/src/plugins/gs-plugin-apt.c
index f130707..da08bf0 100644
--- a/src/plugins/gs-plugin-apt.c
+++ b/src/plugins/gs-plugin-apt.c
@@ -460,8 +460,16 @@ gs_plugin_refine (GsPlugin *plugin,
 
                info = g_hash_table_lookup (plugin->priv->package_info, gs_app_get_source_default (app));
                if (info != NULL) {
-                       if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN && info->installed_version != 
NULL) {
-                               gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+                       if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN) {
+                               if (info->installed_version != NULL) {
+                                       if (info->update_version != NULL) {
+                                               gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
+                                       } else {
+                                               gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+                                       }
+                               } else {
+                                       gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
+                               }
                        }
                        if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) != 0 && gs_app_get_size (app) == 0) 
{
                                gs_app_set_size (app, info->installed_size * 1024);
@@ -477,7 +485,6 @@ gs_plugin_refine (GsPlugin *plugin,
                        if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE) != 0 && info->is_official) {
                                gs_app_set_provenance (app, TRUE);
                        }
-                       if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE) != 0)
                        if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE) != 0 && info->is_open_source) {
                                gs_app_set_licence (app, "@LicenseRef-ubuntu", GS_APP_QUALITY_HIGHEST);
                        }
@@ -517,7 +524,6 @@ gs_plugin_add_installed (GsPlugin *plugin,
                // FIXME: Since appstream marks all packages as owned by PackageKit and we are replacing 
PackageKit we need to accept those packages
                gs_app_set_management_plugin (app, "PackageKit");
                gs_app_add_source (app, info->name);
-               gs_app_set_state (app, AS_APP_STATE_INSTALLED);
                gs_plugin_add_app (list, app);
        }
 
@@ -779,7 +785,6 @@ gs_plugin_add_updates (GsPlugin *plugin,
                // FIXME: Since appstream marks all packages as owned by PackageKit and we are replacing 
PackageKit we need to accept those packages
                gs_app_set_management_plugin (app, "PackageKit");
                gs_app_add_source (app, info->name);
-               gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
                gs_plugin_add_app (list, app);
        }
 


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