[gnome-software] fwupd: Don't use custom GsApp GTypes for results
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] fwupd: Don't use custom GsApp GTypes for results
- Date: Wed, 18 Oct 2017 11:29:28 +0000 (UTC)
commit de2297755c4c842446419b769cb83c9b76cecc73
Author: Richard Hughes <richard hughsie com>
Date: Tue Oct 17 14:19:42 2017 +0100
fwupd: Don't use custom GsApp GTypes for results
This does not work so well when we adopt applications.
plugins/fwupd/gs-fwupd-app.c | 79 ++++-----------------------------------
plugins/fwupd/gs-fwupd-app.h | 4 --
plugins/fwupd/gs-plugin-fwupd.c | 3 -
3 files changed, 8 insertions(+), 78 deletions(-)
---
diff --git a/plugins/fwupd/gs-fwupd-app.c b/plugins/fwupd/gs-fwupd-app.c
index 7246dc6..43d4a99 100644
--- a/plugins/fwupd/gs-fwupd-app.c
+++ b/plugins/fwupd/gs-fwupd-app.c
@@ -25,82 +25,42 @@
#include "gs-fwupd-app.h"
-struct _GsFwupdApp
-{
- GsApp parent_instance;
- gchar *device_id;
- gchar *update_uri;
- gboolean is_locked;
-};
-
-G_DEFINE_TYPE (GsFwupdApp, gs_fwupd_app, GS_TYPE_APP)
-
-static gboolean
-_g_set_str (gchar **str_ptr, const gchar *new_str)
-{
- if (*str_ptr == new_str || g_strcmp0 (*str_ptr, new_str) == 0)
- return FALSE;
- g_free (*str_ptr);
- *str_ptr = g_strdup (new_str);
- return TRUE;
-}
-
-static void
-gs_fwupd_app_to_string (GsApp *app, GString *str)
-{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (app);
- if (fwupd_app->device_id != NULL) {
- gs_utils_append_key_value (str, 20, "fwupd::device-id",
- fwupd_app->device_id);
- }
- if (fwupd_app->update_uri != NULL) {
- gs_utils_append_key_value (str, 20, "fwupd::update-uri",
- fwupd_app->update_uri);
- }
- gs_utils_append_key_value (str, 20, "fwupd::is-locked",
- fwupd_app->is_locked ? "yes" : "no");
-}
-
const gchar *
gs_fwupd_app_get_device_id (GsApp *app)
{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (app);
- return fwupd_app->device_id;
+ return gs_app_get_metadata_item (app, "fwupd::DeviceID");
}
const gchar *
gs_fwupd_app_get_update_uri (GsApp *app)
{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (app);
- return fwupd_app->update_uri;
+ return gs_app_get_metadata_item (app, "fwupd::UpdateID");
}
gboolean
gs_fwupd_app_get_is_locked (GsApp *app)
{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (app);
- return fwupd_app->is_locked;
+ GVariant *tmp = gs_app_get_metadata_variant (app, "fwupd::IsLocked");
+ return g_variant_get_boolean (tmp);
}
void
gs_fwupd_app_set_device_id (GsApp *app, const gchar *device_id)
{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (app);
- _g_set_str (&fwupd_app->device_id, device_id);
+ gs_app_set_metadata (app, "fwupd::DeviceID", device_id);
}
void
gs_fwupd_app_set_update_uri (GsApp *app, const gchar *update_uri)
{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (app);
- _g_set_str (&fwupd_app->update_uri, update_uri);
+ gs_app_set_metadata (app, "fwupd::UpdateID", update_uri);
}
void
gs_fwupd_app_set_is_locked (GsApp *app, gboolean is_locked)
{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (app);
- fwupd_app->is_locked = is_locked;
+ g_autoptr(GVariant) tmp = g_variant_new_boolean (is_locked);
+ gs_app_set_metadata_variant (app, "fwupd::IsLocked", tmp);
}
void
@@ -201,27 +161,4 @@ gs_fwupd_app_set_from_release (GsApp *app, FwupdRelease *rel)
}
}
-static void
-gs_fwupd_app_finalize (GObject *object)
-{
- GsFwupdApp *fwupd_app = GS_FWUPD_APP (object);
- g_free (fwupd_app->device_id);
- g_free (fwupd_app->update_uri);
- G_OBJECT_CLASS (gs_fwupd_app_parent_class)->finalize (object);
-}
-
-static void
-gs_fwupd_app_class_init (GsFwupdAppClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GsAppClass *klass_app = GS_APP_CLASS (klass);
- klass_app->to_string = gs_fwupd_app_to_string;
- object_class->finalize = gs_fwupd_app_finalize;
-}
-
-static void
-gs_fwupd_app_init (GsFwupdApp *fwupd_app)
-{
-}
-
/* vim: set noexpandtab: */
diff --git a/plugins/fwupd/gs-fwupd-app.h b/plugins/fwupd/gs-fwupd-app.h
index d79cefd..e35fa74 100644
--- a/plugins/fwupd/gs-fwupd-app.h
+++ b/plugins/fwupd/gs-fwupd-app.h
@@ -27,10 +27,6 @@
G_BEGIN_DECLS
-#define GS_TYPE_FWUPD_APP (gs_fwupd_app_get_type ())
-
-G_DECLARE_FINAL_TYPE (GsFwupdApp, gs_fwupd_app, GS, FWUPD_APP, GsApp)
-
const gchar *gs_fwupd_app_get_device_id (GsApp *app);
const gchar *gs_fwupd_app_get_update_uri (GsApp *app);
gboolean gs_fwupd_app_get_is_locked (GsApp *app);
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 7c1559b..a2972d1 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -120,9 +120,6 @@ gs_plugin_initialize (GsPlugin *plugin)
}
#endif
- /* unique to us */
- gs_plugin_set_app_gtype (plugin, GS_TYPE_FWUPD_APP);
-
/* set name of MetaInfo file */
gs_plugin_set_appstream_id (plugin, "org.gnome.Software.Plugin.Fwupd");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]