[gnome-software] Set a management plugin for each GsApp so that multiple action plugins can exist



commit b91297f355d7299359393f99434ddd9a00b39ecd
Author: Richard Hughes <richard hughsie com>
Date:   Tue Sep 10 10:54:34 2013 +0100

    Set a management plugin for each GsApp so that multiple action plugins can exist

 src/gs-app.h                                   |    3 +++
 src/plugins/README.md                          |    4 ++--
 src/plugins/gs-plugin-datadir-filename-local.c |    1 -
 src/plugins/gs-plugin-packagekit-refine.c      |    2 ++
 src/plugins/gs-plugin-packagekit.c             |    4 ++--
 5 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-app.h b/src/gs-app.h
index c4a9aeb..62aef8a 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -117,6 +117,9 @@ void                 gs_app_set_update_version      (GsApp          *app,
 const gchar    *gs_app_get_update_details      (GsApp          *app);
 void            gs_app_set_update_details      (GsApp          *app,
                                                 const gchar    *update_details);
+const gchar    *gs_app_get_management_plugin   (GsApp          *app);
+void            gs_app_set_management_plugin   (GsApp          *app,
+                                                const gchar    *management_plugin);
 GdkPixbuf      *gs_app_get_pixbuf              (GsApp          *app);
 void            gs_app_set_pixbuf              (GsApp          *app,
                                                 GdkPixbuf      *pixbuf);
diff --git a/src/plugins/README.md b/src/plugins/README.md
index e8e0a9c..8e83ed3 100644
--- a/src/plugins/README.md
+++ b/src/plugins/README.md
@@ -107,7 +107,7 @@ Overview:    | <p>
 -------------|---
 Methods:     | Search, AddUpdates, AddInstalled, AppInstall, AppRemove, AppUpdate
 Requires:    | `{PackageKit::package-id}`
-Refines:     | `{PackageKit::package-id}`, `[source]`, `{package-summary}`, `[update-details]`, 
`{install-kind}`
+Refines:     | `{PackageKit::package-id}`, `[source]`, `{package-summary}`, `[update-details]`, 
`[management-plugin]`
 
 ### packagekit-refine ###
 Uses the system PackageKit instance to return convert filenames to package-ids.
@@ -165,4 +165,4 @@ Overview:    | <p>
 -------------|---
 Methods:     | `nothing`
 Requires:    | `nothing`
-Refines:     | `{DataDir::desktop-filename}->[state]`, `{install-kind}`
+Refines:     | `{DataDir::desktop-filename}->[state]`, `[management-plugin]`
diff --git a/src/plugins/gs-plugin-datadir-filename-local.c b/src/plugins/gs-plugin-datadir-filename-local.c
index 1a57093..b330162 100644
--- a/src/plugins/gs-plugin-datadir-filename-local.c
+++ b/src/plugins/gs-plugin-datadir-filename-local.c
@@ -68,7 +68,6 @@ gs_plugin_refine (GsPlugin *plugin,
                        g_debug ("Desktop file not in /usr, assuming installed");
                        gs_app_set_state (app, GS_APP_STATE_INSTALLED);
                        gs_app_set_kind (app, GS_APP_KIND_NORMAL);
-                       gs_app_set_metadata (app, "install-kind", "local");
                }
        }
        return TRUE;
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index bd60292..5cf882e 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -191,6 +191,7 @@ gs_plugin_packagekit_refine_packages (GsPlugin *plugin,
                for (i = 0; i < packages->len; i++) {
                        package = g_ptr_array_index (packages, i);
                        if (g_strcmp0 (pk_package_get_name (package), pkgname) == 0) {
+                               gs_app_set_management_plugin (app, "PackageKit");
                                gs_app_set_metadata (app, "PackageKit::package-id", pk_package_get_id 
(package));
                                if (gs_app_get_state (app) == GS_APP_STATE_UNKNOWN) {
                                        gs_app_set_state (app,
@@ -267,6 +268,7 @@ gs_plugin_packagekit_refine_from_desktop (GsPlugin      *plugin,
                package = g_ptr_array_index (packages, 0);
                gs_app_set_metadata (app, "PackageKit::package-id", pk_package_get_id (package));
                gs_app_set_state (app, GS_APP_STATE_INSTALLED);
+               gs_app_set_management_plugin (app, "PackageKit");
        } else {
                g_warning ("Failed to find one package for %s, %s, [%d]",
                           gs_app_get_id (app), filename, packages->len);
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index 7b9cef2..1ef61e2 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -198,7 +198,7 @@ gs_plugin_packagekit_add_installed_results (GsPlugin *plugin,
                                     "package-summary",
                                     pk_package_get_summary (package));
                gs_app_set_source (app, pk_package_get_name (package));
-               gs_app_set_metadata (app, "install-kind", "package");
+               gs_app_set_management_plugin (app, "PackageKit");
                gs_app_set_version (app, pk_package_get_version (package));
                switch (pk_package_get_info (package)) {
                case PK_INFO_ENUM_INSTALLED:
@@ -375,7 +375,7 @@ gs_plugin_packagekit_add_updates_results (GsPlugin *plugin,
                gs_app_set_source (app, split[PK_PACKAGE_ID_NAME]);
                gs_app_set_update_details (app, update_text);
                gs_app_set_update_version (app, split[PK_PACKAGE_ID_VERSION]);
-               gs_app_set_metadata (app, "install-kind", "package");
+               gs_app_set_management_plugin (app, "PackageKit");
                gs_app_set_state (app, GS_APP_STATE_UPDATABLE);
                gs_app_set_kind (app, GS_APP_KIND_PACKAGE);
                gs_plugin_add_app (list, app);


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