[gnome-software/wip/hughsie/flatpak3: 4/9] flatpak: Use a specific GsFlatpakApp object rather than abusing GsApp metadata
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/flatpak3: 4/9] flatpak: Use a specific GsFlatpakApp object rather than abusing GsApp metadata
- Date: Fri, 14 Jul 2017 14:54:57 +0000 (UTC)
commit 36e2f88dcd57abc8b9f7923e7a79560d0420031d
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 13 16:07:57 2017 +0100
flatpak: Use a specific GsFlatpakApp object rather than abusing GsApp metadata
plugins/flatpak/gs-flatpak-app.c | 296 +++++++++++++++++++++++++++++++++++
plugins/flatpak/gs-flatpak-app.h | 83 ++++++++++
plugins/flatpak/gs-flatpak-utils.c | 11 +-
plugins/flatpak/gs-flatpak-utils.h | 17 --
plugins/flatpak/gs-flatpak.c | 195 ++++++++++-------------
plugins/flatpak/gs-plugin-flatpak.c | 14 +-
plugins/flatpak/gs-self-test.c | 18 ++-
plugins/flatpak/meson.build | 3 +
8 files changed, 493 insertions(+), 144 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak-app.c b/plugins/flatpak/gs-flatpak-app.c
new file mode 100644
index 0000000..baf551f
--- /dev/null
+++ b/plugins/flatpak/gs-flatpak-app.c
@@ -0,0 +1,296 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2017 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include "gs-flatpak-app.h"
+
+struct _GsFlatpakApp
+{
+ GsApp parent_instance;
+ FlatpakRefKind ref_kind;
+ gchar *ref_arch;
+ gchar *ref_branch;
+ gchar *ref_display;
+ gchar *ref_name;
+ gchar *commit;
+ gchar *object_id;
+ gchar *repo_gpgkey;
+ gchar *repo_url;
+ GsFlatpakAppFileKind file_kind;
+};
+
+G_DEFINE_TYPE (GsFlatpakApp, gs_flatpak_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 const gchar *
+gs_flatpak_app_file_kind_to_string (GsFlatpakAppFileKind file_kind)
+{
+ if (file_kind == GS_FLATPAK_APP_FILE_KIND_REPO)
+ return "flatpakrepo";
+ if (file_kind == GS_FLATPAK_APP_FILE_KIND_REF)
+ return "flatpakref";
+ if (file_kind == GS_FLATPAK_APP_FILE_KIND_BUNDLE)
+ return "flatpak";
+ return NULL;
+}
+
+static void
+gs_flatpak_app_to_string (GsApp *app, GString *str)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ gs_utils_append_key_value (str, 20, "flatpak::ref-kind",
+ gs_flatpak_app_get_ref_kind_as_str (app));
+ if (flatpak_app->ref_name != NULL) {
+ gs_utils_append_key_value (str, 20, "flatpak::ref-name",
+ flatpak_app->ref_name);
+ }
+ if (flatpak_app->ref_arch != NULL) {
+ gs_utils_append_key_value (str, 20, "flatpak::ref-arch",
+ flatpak_app->ref_arch);
+ }
+ if (flatpak_app->ref_branch != NULL) {
+ gs_utils_append_key_value (str, 20, "flatpak::ref-branch",
+ flatpak_app->ref_branch);
+ }
+ if (flatpak_app->ref_display != NULL) {
+ gs_utils_append_key_value (str, 20, "flatpak::ref-display",
+ flatpak_app->ref_display);
+ }
+ if (flatpak_app->commit != NULL)
+ gs_utils_append_key_value (str, 20, "flatpak::commit",
+ flatpak_app->commit);
+ if (flatpak_app->object_id != NULL) {
+ gs_utils_append_key_value (str, 20, "flatpak::object-id",
+ flatpak_app->object_id);
+ }
+ if (flatpak_app->repo_gpgkey != NULL) {
+ gs_utils_append_key_value (str, 20, "flatpak::repo-gpgkey",
+ flatpak_app->repo_gpgkey);
+ }
+ if (flatpak_app->repo_url != NULL) {
+ gs_utils_append_key_value (str, 20, "flatpak::repo-url",
+ flatpak_app->repo_url);
+ }
+ if (flatpak_app->file_kind != GS_FLATPAK_APP_FILE_KIND_UNKNOWN) {
+ gs_utils_append_key_value (str, 20, "flatpak::file-kind",
+ gs_flatpak_app_file_kind_to_string (flatpak_app->file_kind));
+ }
+}
+
+const gchar *
+gs_flatpak_app_get_ref_name (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->ref_name;
+}
+
+const gchar *
+gs_flatpak_app_get_ref_arch (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->ref_arch;
+}
+
+const gchar *
+gs_flatpak_app_get_ref_branch (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->ref_branch;
+}
+
+const gchar *
+gs_flatpak_app_get_commit (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->commit;
+}
+
+GsFlatpakAppFileKind
+gs_flatpak_app_get_file_kind (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->file_kind;
+}
+
+FlatpakRefKind
+gs_flatpak_app_get_ref_kind (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->ref_kind;
+}
+
+const gchar *
+gs_flatpak_app_get_ref_kind_as_str (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ if (flatpak_app->ref_kind == FLATPAK_REF_KIND_APP)
+ return "app";
+ if (flatpak_app->ref_kind == FLATPAK_REF_KIND_RUNTIME)
+ return "runtime";
+ return NULL;
+}
+
+const gchar *
+gs_flatpak_app_get_object_id (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->object_id;
+}
+
+const gchar *
+gs_flatpak_app_get_repo_gpgkey (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->repo_gpgkey;
+}
+
+const gchar *
+gs_flatpak_app_get_repo_url (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->repo_url;
+}
+
+const gchar *
+gs_flatpak_app_get_ref_display (GsApp *app)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ return flatpak_app->ref_display;
+}
+
+void
+gs_flatpak_app_set_ref_name (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->ref_name, val);
+}
+
+void
+gs_flatpak_app_set_ref_arch (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->ref_arch, val);
+}
+
+void
+gs_flatpak_app_set_ref_branch (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->ref_branch, val);
+}
+
+void
+gs_flatpak_app_set_commit (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->commit, val);
+}
+
+void
+gs_flatpak_app_set_file_kind (GsApp *app, GsFlatpakAppFileKind file_kind)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ flatpak_app->file_kind = file_kind;
+}
+
+void
+gs_flatpak_app_set_ref_kind (GsApp *app, FlatpakRefKind ref_kind)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ flatpak_app->ref_kind = ref_kind;
+}
+
+void
+gs_flatpak_app_set_object_id (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->object_id, val);
+}
+
+void
+gs_flatpak_app_set_repo_gpgkey (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->repo_gpgkey, val);
+}
+
+void
+gs_flatpak_app_set_repo_url (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->repo_url, val);
+}
+
+void
+gs_flatpak_app_set_ref_display (GsApp *app, const gchar *val)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
+ _g_set_str (&flatpak_app->ref_display, val);
+}
+
+static void
+gs_flatpak_app_finalize (GObject *object)
+{
+ GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (object);
+ g_free (flatpak_app->ref_arch);
+ g_free (flatpak_app->ref_branch);
+ g_free (flatpak_app->ref_display);
+ g_free (flatpak_app->ref_name);
+ g_free (flatpak_app->commit);
+ g_free (flatpak_app->object_id);
+ g_free (flatpak_app->repo_gpgkey);
+ g_free (flatpak_app->repo_url);
+ G_OBJECT_CLASS (gs_flatpak_app_parent_class)->finalize (object);
+}
+
+static void
+gs_flatpak_app_class_init (GsFlatpakAppClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GsAppClass *klass_app = GS_APP_CLASS (klass);
+ klass_app->to_string = gs_flatpak_app_to_string;
+ object_class->finalize = gs_flatpak_app_finalize;
+}
+
+static void
+gs_flatpak_app_init (GsFlatpakApp *flatpak_app)
+{
+}
+
+GsApp *
+gs_flatpak_app_new (const gchar *id)
+{
+ return GS_APP (g_object_new (GS_TYPE_FLATPAK_APP, "id", id, NULL));
+}
+
+/* vim: set noexpandtab: */
diff --git a/plugins/flatpak/gs-flatpak-app.h b/plugins/flatpak/gs-flatpak-app.h
new file mode 100644
index 0000000..7cdaca3
--- /dev/null
+++ b/plugins/flatpak/gs-flatpak-app.h
@@ -0,0 +1,83 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2017 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GS_FLATPAK_APP_H
+#define __GS_FLATPAK_APP_H
+
+#include <gnome-software.h>
+#include <flatpak.h>
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_FLATPAK_APP (gs_flatpak_app_get_type ())
+
+G_DECLARE_FINAL_TYPE (GsFlatpakApp, gs_flatpak_app, GS, FLATPAK_APP, GsApp)
+
+typedef enum {
+ GS_FLATPAK_APP_FILE_KIND_UNKNOWN,
+ GS_FLATPAK_APP_FILE_KIND_REPO,
+ GS_FLATPAK_APP_FILE_KIND_REF,
+ GS_FLATPAK_APP_FILE_KIND_BUNDLE,
+ GS_FLATPAK_APP_FILE_KIND_LAST,
+} GsFlatpakAppFileKind;
+
+GsApp *gs_flatpak_app_new (const gchar *id);
+
+const gchar *gs_flatpak_app_get_ref_name (GsApp *app);
+const gchar *gs_flatpak_app_get_ref_arch (GsApp *app);
+const gchar *gs_flatpak_app_get_ref_branch (GsApp *app);
+FlatpakRefKind gs_flatpak_app_get_ref_kind (GsApp *app);
+const gchar *gs_flatpak_app_get_ref_kind_as_str (GsApp *app);
+const gchar *gs_flatpak_app_get_ref_display (GsApp *app);
+
+const gchar *gs_flatpak_app_get_commit (GsApp *app);
+const gchar *gs_flatpak_app_get_object_id (GsApp *app);
+const gchar *gs_flatpak_app_get_repo_gpgkey (GsApp *app);
+const gchar *gs_flatpak_app_get_repo_url (GsApp *app);
+GsFlatpakAppFileKind gs_flatpak_app_get_file_kind (GsApp *app);
+
+void gs_flatpak_app_set_ref_name (GsApp *app,
+ const gchar *val);
+void gs_flatpak_app_set_ref_arch (GsApp *app,
+ const gchar *val);
+void gs_flatpak_app_set_ref_branch (GsApp *app,
+ const gchar *val);
+void gs_flatpak_app_set_ref_kind (GsApp *app,
+ FlatpakRefKind ref_kind);
+void gs_flatpak_app_set_ref_display (GsApp *app,
+ const gchar *val);
+
+void gs_flatpak_app_set_commit (GsApp *app,
+ const gchar *val);
+void gs_flatpak_app_set_object_id (GsApp *app,
+ const gchar *val);
+void gs_flatpak_app_set_repo_gpgkey (GsApp *app,
+ const gchar *val);
+void gs_flatpak_app_set_repo_url (GsApp *app,
+ const gchar *val);
+void gs_flatpak_app_set_file_kind (GsApp *app,
+ GsFlatpakAppFileKind file_kind);
+
+G_END_DECLS
+
+#endif /* __GS_FLATPAK_APP_H */
+
+/* vim: set noexpandtab: */
diff --git a/plugins/flatpak/gs-flatpak-utils.c b/plugins/flatpak/gs-flatpak-utils.c
index 9ea6f1a..f7c5742 100644
--- a/plugins/flatpak/gs-flatpak-utils.c
+++ b/plugins/flatpak/gs-flatpak-utils.c
@@ -21,6 +21,7 @@
#include <config.h>
+#include "gs-flatpak-app.h"
#include "gs-flatpak.h"
#include "gs-flatpak-utils.h"
@@ -71,7 +72,7 @@ gs_flatpak_app_new_from_remote (FlatpakRemote *xremote)
g_autofree gchar *url = NULL;
g_autoptr(GsApp) app = NULL;
- app = gs_app_new (flatpak_remote_get_name (xremote));
+ app = gs_flatpak_app_new (flatpak_remote_get_name (xremote));
gs_app_set_kind (app, AS_APP_KIND_SOURCE);
gs_app_set_state (app, flatpak_remote_get_disabled (xremote) ?
AS_APP_STATE_AVAILABLE : AS_APP_STATE_INSTALLED);
@@ -170,14 +171,14 @@ gs_flatpak_app_new_from_repo_file (GFile *file,
}
/* create source */
- app = gs_app_new (repo_id);
- gs_app_set_flatpak_file_type (app, "flatpakrepo");
+ app = gs_flatpak_app_new (repo_id);
+ gs_flatpak_app_set_file_kind (app, GS_FLATPAK_APP_FILE_KIND_REPO);
gs_app_set_kind (app, AS_APP_KIND_SOURCE);
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
gs_app_set_name (app, GS_APP_QUALITY_NORMAL, repo_title);
- gs_app_set_metadata (app, "flatpak::gpg-key", repo_gpgkey);
- gs_app_set_metadata (app, "flatpak::url", repo_url);
+ gs_flatpak_app_set_repo_gpgkey (app, repo_gpgkey);
+ gs_flatpak_app_set_repo_url (app, repo_url);
gs_app_set_origin_hostname (app, repo_url);
/* optional data */
diff --git a/plugins/flatpak/gs-flatpak-utils.h b/plugins/flatpak/gs-flatpak-utils.h
index fd77ab1..c64aa51 100644
--- a/plugins/flatpak/gs-flatpak-utils.h
+++ b/plugins/flatpak/gs-flatpak-utils.h
@@ -26,23 +26,6 @@ G_BEGIN_DECLS
#include <gnome-software.h>
-/* helpers */
-#define gs_app_get_flatpak_kind_as_str(app) gs_app_get_metadata_item(app,"flatpak::kind")
-#define gs_app_get_flatpak_name(app) gs_app_get_metadata_item(app,"flatpak::name")
-#define gs_app_get_flatpak_arch(app) gs_app_get_metadata_item(app,"flatpak::arch")
-#define gs_app_get_flatpak_branch(app) gs_app_get_metadata_item(app,"flatpak::branch")
-#define gs_app_get_flatpak_commit(app) gs_app_get_metadata_item(app,"flatpak::commit")
-#define gs_app_get_flatpak_file_type(app) gs_app_get_metadata_item(app,"flatpak::file-type")
-#define gs_app_get_flatpak_object_id(app) gs_app_get_metadata_item(app,"flatpak::object-id")
-#define gs_app_get_flatpak_ref_display(app) gs_app_get_metadata_item(app,"flatpak::ref-display")
-#define gs_app_set_flatpak_name(app,val) gs_app_set_metadata(app,"flatpak::name",val)
-#define gs_app_set_flatpak_arch(app,val) gs_app_set_metadata(app,"flatpak::arch",val)
-#define gs_app_set_flatpak_branch(app,val) gs_app_set_metadata(app,"flatpak::branch",val)
-#define gs_app_set_flatpak_commit(app,val) gs_app_set_metadata(app,"flatpak::commit",val)
-#define gs_app_set_flatpak_file_type(app,val) gs_app_set_metadata(app,"flatpak::file-type",val)
-#define gs_app_set_flatpak_object_id(app,val) gs_app_set_metadata(app,"flatpak::object-id",val)
-#define gs_app_set_flatpak_ref_display(app,val) gs_app_set_metadata(app,"flatpak::ref-display",val)
-
void gs_flatpak_error_convert (GError **perror);
GsApp *gs_flatpak_app_new_from_remote (FlatpakRemote *xremote);
GsApp *gs_flatpak_app_new_from_repo_file (GFile *file,
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index f807a06..411de16 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -23,7 +23,6 @@
/* Notes:
*
* All GsApp's created have management-plugin set to flatpak
- * Some GsApp's created have have flatpak::kind of app or runtime
* The GsApp:origin is the remote name, e.g. test-repo
*/
@@ -32,6 +31,7 @@
#include <glib/gi18n.h>
#include "gs-appstream.h"
+#include "gs-flatpak-app.h"
#include "gs-flatpak.h"
#include "gs-flatpak-symlinks.h"
#include "gs-flatpak-utils.h"
@@ -67,17 +67,6 @@ gs_flatpak_build_id (FlatpakRef *xref)
}
static void
-gs_app_set_flatpak_kind (GsApp *app, FlatpakRefKind kind)
-{
- if (kind == FLATPAK_REF_KIND_APP)
- gs_app_set_metadata (app, "flatpak::kind", "app");
- else if (kind == FLATPAK_REF_KIND_RUNTIME)
- gs_app_set_metadata (app, "flatpak::kind", "runtime");
- else
- g_assert_not_reached ();
-}
-
-static void
gs_plugin_refine_item_scope (GsFlatpak *self, GsApp *app)
{
if (gs_app_get_scope (app) == AS_APP_SCOPE_UNKNOWN) {
@@ -98,19 +87,19 @@ gs_flatpak_set_metadata (GsFlatpak *self, GsApp *app, FlatpakRef *xref)
gs_plugin_refine_item_scope (self, app);
/* flatpak specific */
- gs_app_set_flatpak_kind (app, flatpak_ref_get_kind (xref));
- gs_app_set_flatpak_name (app, flatpak_ref_get_name (xref));
- gs_app_set_flatpak_arch (app, flatpak_ref_get_arch (xref));
- gs_app_set_flatpak_branch (app, flatpak_ref_get_branch (xref));
- gs_app_set_flatpak_commit (app, flatpak_ref_get_commit (xref));
+ gs_flatpak_app_set_ref_kind (app, flatpak_ref_get_kind (xref));
+ gs_flatpak_app_set_ref_name (app, flatpak_ref_get_name (xref));
+ gs_flatpak_app_set_ref_arch (app, flatpak_ref_get_arch (xref));
+ gs_flatpak_app_set_ref_branch (app, flatpak_ref_get_branch (xref));
+ gs_flatpak_app_set_commit (app, flatpak_ref_get_commit (xref));
/* ony when we have a non-temp object */
if ((self->flags & GS_FLATPAK_FLAG_IS_TEMPORARY) == 0)
- gs_app_set_flatpak_object_id (app, gs_flatpak_get_id (self));
+ gs_flatpak_app_set_object_id (app, gs_flatpak_get_id (self));
/* do this once for all objects */
ref_display = flatpak_ref_format_ref (xref);
- gs_app_set_flatpak_ref_display (app, ref_display);
+ gs_flatpak_app_set_ref_display (app, ref_display);
/* map the flatpak kind to the gnome-software kind */
if (flatpak_ref_get_kind (xref) == FLATPAK_REF_KIND_APP) {
@@ -141,7 +130,7 @@ gs_flatpak_create_app (GsFlatpak *self, FlatpakRef *xref)
/* create a temp GsApp */
id = gs_flatpak_build_id (xref);
- app = gs_app_new (id);
+ app = gs_plugin_app_new (self->plugin, id);
gs_flatpak_set_metadata (self, app, xref);
/* we already have one, returned the ref'd cached copy */
@@ -969,13 +958,13 @@ gs_flatpak_app_install_source (GsFlatpak *self, GsApp *app,
/* create a new remote */
xremote = flatpak_remote_new (gs_app_get_id (app));
- flatpak_remote_set_url (xremote, gs_app_get_metadata_item (app, "flatpak::url"));
+ flatpak_remote_set_url (xremote, gs_flatpak_app_get_repo_url (app));
flatpak_remote_set_noenumerate (xremote, FALSE);
if (gs_app_get_summary (app) != NULL)
flatpak_remote_set_title (xremote, gs_app_get_summary (app));
/* decode GPG key if set */
- gpg_key = gs_app_get_metadata_item (app, "flatpak::gpg-key");
+ gpg_key = gs_flatpak_app_get_repo_gpgkey (app);
if (gpg_key != NULL && g_strcmp0 (gpg_key, "FOOBAR==") != 0) {
gsize data_len = 0;
g_autofree guchar *data = NULL;
@@ -1253,7 +1242,7 @@ gs_refine_item_metadata (GsFlatpak *self, GsApp *app,
g_autoptr(FlatpakRef) xref = NULL;
/* already set */
- if (gs_app_get_metadata_item (app, "flatpak::kind") != NULL)
+ if (gs_flatpak_app_get_ref_name (app) != NULL)
return TRUE;
/* not a valid type */
@@ -1283,18 +1272,6 @@ gs_refine_item_metadata (GsFlatpak *self, GsApp *app,
return TRUE;
}
-static FlatpakRefKind
-gs_app_get_flatpak_kind (GsApp *app)
-{
- const gchar *kind = gs_app_get_metadata_item (app, "flatpak::kind");
- if (g_strcmp0 (kind, "app") == 0)
- return FLATPAK_REF_KIND_APP;
- if (g_strcmp0 (kind, "runtime") == 0)
- return FLATPAK_REF_KIND_RUNTIME;
- g_warning ("unknown flatpak kind: %s", kind);
- return FLATPAK_REF_KIND_APP;
-}
-
static gboolean
gs_flatpak_refine_origin_from_installation (GsFlatpak *self,
FlatpakInstallation *installation,
@@ -1327,16 +1304,16 @@ gs_flatpak_refine_origin_from_installation (GsFlatpak *self,
g_debug ("looking at remote %s", remote_name);
xref = flatpak_installation_fetch_remote_ref_sync (installation,
remote_name,
- gs_app_get_flatpak_kind (app),
- gs_app_get_flatpak_name (app),
- gs_app_get_flatpak_arch (app),
- gs_app_get_flatpak_branch (app),
+ gs_flatpak_app_get_ref_kind (app),
+ gs_flatpak_app_get_ref_name (app),
+ gs_flatpak_app_get_ref_arch (app),
+ gs_flatpak_app_get_ref_branch (app),
cancellable,
&error_local);
if (xref != NULL) {
g_debug ("found remote %s", remote_name);
gs_app_set_origin (app, remote_name);
- gs_app_set_flatpak_commit (app, flatpak_ref_get_commit (FLATPAK_REF (xref)));
+ gs_flatpak_app_set_commit (app, flatpak_ref_get_commit (FLATPAK_REF (xref)));
return TRUE;
}
g_debug ("failed to find remote %s: %s",
@@ -1391,9 +1368,9 @@ gs_plugin_refine_item_origin (GsFlatpak *self,
/* find list of remotes */
g_debug ("looking for a remote for %s/%s/%s",
- gs_app_get_flatpak_name (app),
- gs_app_get_flatpak_arch (app),
- gs_app_get_flatpak_branch (app));
+ gs_flatpak_app_get_ref_name (app),
+ gs_flatpak_app_get_ref_arch (app),
+ gs_flatpak_app_get_ref_branch (app));
/* first check the plugin's own flatpak installation */
if (!gs_flatpak_refine_origin_from_installation (self,
@@ -1407,7 +1384,7 @@ gs_plugin_refine_item_origin (GsFlatpak *self,
/* check the system installation if we're on a user one */
if (gs_app_get_scope (app) == AS_APP_SCOPE_USER &&
- gs_app_get_flatpak_kind (app) == FLATPAK_REF_KIND_RUNTIME) {
+ gs_flatpak_app_get_ref_kind (app) == FLATPAK_REF_KIND_RUNTIME) {
g_autoptr(GError) error_local = NULL;
g_autoptr(FlatpakInstallation) installation =
gs_flatpak_get_installation_counterpart (self,
@@ -1452,11 +1429,11 @@ gs_flatpak_app_matches_xref (GsFlatpak *self, GsApp *app, FlatpakRef *xref)
return TRUE;
/* do all the metadata items match? */
- if (g_strcmp0 (gs_app_get_flatpak_name (app),
+ if (g_strcmp0 (gs_flatpak_app_get_ref_name (app),
flatpak_ref_get_name (xref)) == 0 &&
- g_strcmp0 (gs_app_get_flatpak_arch (app),
+ g_strcmp0 (gs_flatpak_app_get_ref_arch (app),
flatpak_ref_get_arch (xref)) == 0 &&
- g_strcmp0 (gs_app_get_flatpak_branch (app),
+ g_strcmp0 (gs_flatpak_app_get_ref_branch (app),
flatpak_ref_get_branch (xref)) == 0)
return TRUE;
@@ -1470,10 +1447,10 @@ gs_flatpak_create_fake_ref (GsApp *app, GError **error)
FlatpakRef *xref;
g_autofree gchar *id = NULL;
id = g_strdup_printf ("%s/%s/%s/%s",
- gs_app_get_flatpak_kind_as_str (app),
- gs_app_get_flatpak_name (app),
- gs_app_get_flatpak_arch (app),
- gs_app_get_flatpak_branch (app));
+ gs_flatpak_app_get_ref_kind_as_str (app),
+ gs_flatpak_app_get_ref_name (app),
+ gs_flatpak_app_get_ref_arch (app),
+ gs_flatpak_app_get_ref_branch (app));
xref = flatpak_ref_parse (id, error);
if (xref == NULL) {
gs_flatpak_error_convert (error);
@@ -1532,7 +1509,7 @@ gs_plugin_refine_item_state (GsFlatpak *self,
/* special case: if this is per-user instance and the runtime is
* available system-wide then mark it installed, and vice-versa */
- if (gs_app_get_flatpak_kind (app) == FLATPAK_REF_KIND_RUNTIME &&
+ if (gs_flatpak_app_get_ref_kind (app) == FLATPAK_REF_KIND_RUNTIME &&
gs_app_get_state (app) == AS_APP_STATE_UNKNOWN) {
g_autoptr(GError) error_local = NULL;
g_autoptr(FlatpakInstallation) installation =
@@ -1652,7 +1629,7 @@ gs_flatpak_set_app_metadata (GsFlatpak *self,
gs_flatpak_error_convert (error);
return FALSE;
}
- gs_app_set_flatpak_name (app, name);
+ gs_flatpak_app_set_ref_name (app, name);
runtime = g_key_file_get_string (kf, "Application", "runtime", error);
if (runtime == NULL) {
gs_flatpak_error_convert (error);
@@ -1757,7 +1734,7 @@ gs_plugin_refine_item_metadata (GsFlatpak *self,
/* not applicable */
if (gs_app_get_kind (app) == AS_APP_KIND_SOURCE)
return TRUE;
- if (gs_app_get_flatpak_kind (app) != FLATPAK_REF_KIND_APP)
+ if (gs_flatpak_app_get_ref_kind (app) != FLATPAK_REF_KIND_APP)
return TRUE;
/* already done */
@@ -1768,10 +1745,10 @@ gs_plugin_refine_item_metadata (GsFlatpak *self,
installation_path = flatpak_installation_get_path (self->installation);
installation_path_str = g_file_get_path (installation_path);
install_path = g_build_filename (installation_path_str,
- gs_app_get_flatpak_kind_as_str (app),
- gs_app_get_flatpak_name (app),
- gs_app_get_flatpak_arch (app),
- gs_app_get_flatpak_branch (app),
+ gs_flatpak_app_get_ref_kind_as_str (app),
+ gs_flatpak_app_get_ref_name (app),
+ gs_flatpak_app_get_ref_arch (app),
+ gs_flatpak_app_get_ref_branch (app),
"active",
"metadata",
NULL);
@@ -1801,10 +1778,10 @@ gs_flatpak_get_installed_ref (GsFlatpak *self,
{
FlatpakInstalledRef *ref;
ref = flatpak_installation_get_installed_ref (self->installation,
- gs_app_get_flatpak_kind (app),
- gs_app_get_flatpak_name (app),
- gs_app_get_flatpak_arch (app),
- gs_app_get_flatpak_branch (app),
+ gs_flatpak_app_get_ref_kind (app),
+ gs_flatpak_app_get_ref_name (app),
+ gs_flatpak_app_get_ref_arch (app),
+ gs_flatpak_app_get_ref_branch (app),
cancellable,
error);
if (ref == NULL)
@@ -1846,7 +1823,7 @@ gs_plugin_refine_item_size (GsFlatpak *self,
/* calculate the platform size too if the app is not installed */
if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE &&
- gs_app_get_flatpak_kind (app) == FLATPAK_REF_KIND_APP) {
+ gs_flatpak_app_get_ref_kind (app) == FLATPAK_REF_KIND_APP) {
GsApp *app_runtime;
/* is the app_runtime already installed? */
@@ -2034,7 +2011,7 @@ gs_flatpak_refine_app (GsFlatpak *self,
if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION) {
if (gs_app_get_version (app) == NULL) {
const gchar *branch;
- branch = gs_app_get_flatpak_branch (app);
+ branch = gs_flatpak_app_get_ref_branch (app);
gs_app_set_version (app, branch);
}
}
@@ -2122,7 +2099,7 @@ gs_flatpak_launch (GsFlatpak *self,
GsApp *runtime;
const gchar *branch = NULL;
- branch = gs_app_get_flatpak_branch (app);
+ branch = gs_flatpak_app_get_ref_branch (app);
if (branch == NULL)
branch = "master";
@@ -2144,7 +2121,7 @@ gs_flatpak_launch (GsFlatpak *self,
/* launch the app */
if (!flatpak_installation_launch (self->installation,
- gs_app_get_flatpak_name (app),
+ gs_flatpak_app_get_ref_name (app),
NULL,
branch,
NULL,
@@ -2200,10 +2177,10 @@ gs_flatpak_get_list_for_remove (GsFlatpak *self, GsApp *app,
/* lookup any related refs for this ref */
ref = g_strdup_printf ("%s/%s/%s/%s",
- gs_app_get_flatpak_kind_as_str (app),
- gs_app_get_flatpak_name (app),
- gs_app_get_flatpak_arch (app),
- gs_app_get_flatpak_branch (app));
+ gs_flatpak_app_get_ref_kind_as_str (app),
+ gs_flatpak_app_get_ref_name (app),
+ gs_flatpak_app_get_ref_arch (app),
+ gs_flatpak_app_get_ref_branch (app));
related = flatpak_installation_list_installed_related_refs_sync (self->installation,
gs_app_get_origin (app),
ref, cancellable, error);
@@ -2237,7 +2214,7 @@ gs_flatpak_related_should_download (GsFlatpak *self, GsApp *app, FlatpakRelatedR
const gchar *name = flatpak_ref_get_name (FLATPAK_REF (xref_related));
/* architecture is different */
- if (g_strcmp0 (gs_app_get_flatpak_arch (app),
+ if (g_strcmp0 (gs_flatpak_app_get_ref_arch (app),
flatpak_ref_get_arch (FLATPAK_REF (xref_related))) != 0) {
g_autofree gchar *ref_display = NULL;
ref_display = flatpak_ref_format_ref (FLATPAK_REF (xref_related));
@@ -2299,10 +2276,10 @@ gs_flatpak_get_list_for_install (GsFlatpak *self, GsApp *app,
/* lookup any related refs for this ref */
ref = g_strdup_printf ("%s/%s/%s/%s",
- gs_app_get_flatpak_kind_as_str (app),
- gs_app_get_flatpak_name (app),
- gs_app_get_flatpak_arch (app),
- gs_app_get_flatpak_branch (app));
+ gs_flatpak_app_get_ref_kind_as_str (app),
+ gs_flatpak_app_get_ref_name (app),
+ gs_flatpak_app_get_ref_arch (app),
+ gs_flatpak_app_get_ref_branch (app));
related = flatpak_installation_list_remote_related_refs_sync (self->installation,
gs_app_get_origin (app),
ref, cancellable, error);
@@ -2324,7 +2301,7 @@ gs_flatpak_get_list_for_install (GsFlatpak *self, GsApp *app,
/* already installed? */
app_tmp = gs_flatpak_create_app (self, FLATPAK_REF (xref_related));
- xref_fake_str = gs_app_get_flatpak_ref_display (app_tmp);
+ xref_fake_str = gs_flatpak_app_get_ref_display (app_tmp);
if (g_hash_table_contains (hash_installed, xref_fake_str)) {
g_debug ("not adding related %s as already installed", xref_fake_str);
} else {
@@ -2380,12 +2357,12 @@ gs_flatpak_app_remove (GsFlatpak *self,
phelper->job_max = gs_app_list_length (list);
for (phelper->job_now = 0; phelper->job_now < phelper->job_max; phelper->job_now++) {
GsApp *app_tmp = gs_app_list_index (list, phelper->job_now);
- g_debug ("removing %s", gs_app_get_flatpak_name (app_tmp));
+ g_debug ("removing %s", gs_flatpak_app_get_ref_name (app_tmp));
if (!flatpak_installation_uninstall (self->installation,
- gs_app_get_flatpak_kind (app_tmp),
- gs_app_get_flatpak_name (app_tmp),
- gs_app_get_flatpak_arch (app_tmp),
- gs_app_get_flatpak_branch (app_tmp),
+ gs_flatpak_app_get_ref_kind (app_tmp),
+ gs_flatpak_app_get_ref_name (app_tmp),
+ gs_flatpak_app_get_ref_arch (app_tmp),
+ gs_flatpak_app_get_ref_branch (app_tmp),
gs_flatpak_progress_cb, phelper,
cancellable, error)) {
gs_flatpak_error_convert (error);
@@ -2395,7 +2372,7 @@ gs_flatpak_app_remove (GsFlatpak *self,
}
/* did app also install a noenumerate=True remote */
- remote_name = g_strdup_printf ("%s-origin", gs_app_get_flatpak_name (app));
+ remote_name = g_strdup_printf ("%s-origin", gs_flatpak_app_get_ref_name (app));
xremote = flatpak_installation_get_remote_by_name (self->installation,
remote_name,
cancellable,
@@ -2434,7 +2411,7 @@ install_runtime_for_app (GsFlatpak *self,
GsApp *runtime;
/* only required for ostree-based flatpak apps */
- if (g_strcmp0 (gs_app_get_flatpak_file_type (app), "flatpak") != 0) {
+ if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_BUNDLE) {
gsize len;
const gchar *str;
g_autoptr(GBytes) data = NULL;
@@ -2490,15 +2467,15 @@ install_runtime_for_app (GsFlatpak *self,
g_debug ("%s/%s is not already installed, so installing",
gs_app_get_id (runtime),
- gs_app_get_flatpak_branch (runtime));
+ gs_flatpak_app_get_ref_branch (runtime));
gs_app_set_state (runtime, AS_APP_STATE_INSTALLING);
phelper = gs_flatpak_progress_helper_new (self->plugin, app);
xref = flatpak_installation_install (self->installation,
gs_app_get_origin (runtime),
- gs_app_get_flatpak_kind (runtime),
- gs_app_get_flatpak_name (runtime),
- gs_app_get_flatpak_arch (runtime),
- gs_app_get_flatpak_branch (runtime),
+ gs_flatpak_app_get_ref_kind (runtime),
+ gs_flatpak_app_get_ref_name (runtime),
+ gs_flatpak_app_get_ref_arch (runtime),
+ gs_flatpak_app_get_ref_branch (runtime),
gs_flatpak_progress_cb, phelper,
cancellable, error);
if (xref == NULL) {
@@ -2541,7 +2518,7 @@ gs_flatpak_app_install (GsFlatpak *self,
}
/* flatpakref has to be done in two phases */
- if (g_strcmp0 (gs_app_get_flatpak_file_type (app), "flatpakref") == 0) {
+ if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REF) {
GsApp *runtime;
g_autoptr(FlatpakRemoteRef) xref2 = NULL;
gsize len = 0;
@@ -2612,7 +2589,7 @@ gs_flatpak_app_install (GsFlatpak *self,
cache_fn);
return FALSE;
}
- gs_app_set_flatpak_object_id (app, gs_flatpak_get_id (self));
+ gs_flatpak_app_set_object_id (app, gs_flatpak_get_id (self));
gs_app_set_management_plugin (app, gs_plugin_get_name (self->plugin));
/* install the flatpakrepo */
@@ -2670,7 +2647,7 @@ gs_flatpak_app_install (GsFlatpak *self,
return FALSE;
}
- if (g_strcmp0 (gs_app_get_flatpak_file_type (app), "flatpak") == 0) {
+ if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_BUNDLE) {
g_autoptr(FlatpakInstalledRef) xref = NULL;
g_autoptr(GsFlatpakProgressHelper) phelper = NULL;
if (gs_app_get_local_file (app) == NULL) {
@@ -2721,13 +2698,13 @@ gs_flatpak_app_install (GsFlatpak *self,
for (phelper->job_now = 0; phelper->job_now < phelper->job_max; phelper->job_now++) {
GsApp *app_tmp = gs_app_list_index (list, phelper->job_now);
g_autoptr(FlatpakInstalledRef) xref = NULL;
- g_debug ("installing %s", gs_app_get_flatpak_name (app_tmp));
+ g_debug ("installing %s", gs_flatpak_app_get_ref_name (app_tmp));
xref = flatpak_installation_install (self->installation,
gs_app_get_origin (app_tmp),
- gs_app_get_flatpak_kind (app_tmp),
- gs_app_get_flatpak_name (app_tmp),
- gs_app_get_flatpak_arch (app_tmp),
- gs_app_get_flatpak_branch (app_tmp),
+ gs_flatpak_app_get_ref_kind (app_tmp),
+ gs_flatpak_app_get_ref_name (app_tmp),
+ gs_flatpak_app_get_ref_arch (app_tmp),
+ gs_flatpak_app_get_ref_branch (app_tmp),
gs_flatpak_progress_cb, phelper,
cancellable, error);
if (xref == NULL) {
@@ -2801,25 +2778,25 @@ gs_flatpak_update_app (GsFlatpak *self,
g_autoptr(FlatpakInstalledRef) xref = NULL;
/* either install or update the ref */
- xref_fake_str = gs_app_get_flatpak_ref_display (app_tmp);
+ xref_fake_str = gs_flatpak_app_get_ref_display (app_tmp);
if (!g_hash_table_contains (hash_installed, xref_fake_str)) {
g_debug ("installing %s", xref_fake_str);
xref = flatpak_installation_install (self->installation,
gs_app_get_origin (app_tmp),
- gs_app_get_flatpak_kind (app_tmp),
- gs_app_get_flatpak_name (app_tmp),
- gs_app_get_flatpak_arch (app_tmp),
- gs_app_get_flatpak_branch (app_tmp),
+ gs_flatpak_app_get_ref_kind (app_tmp),
+ gs_flatpak_app_get_ref_name (app_tmp),
+ gs_flatpak_app_get_ref_arch (app_tmp),
+ gs_flatpak_app_get_ref_branch (app_tmp),
gs_flatpak_progress_cb, phelper,
cancellable, error);
} else {
g_debug ("updating %s", xref_fake_str);
xref = flatpak_installation_update (self->installation,
FLATPAK_UPDATE_FLAGS_NONE,
- gs_app_get_flatpak_kind (app_tmp),
- gs_app_get_flatpak_name (app_tmp),
- gs_app_get_flatpak_arch (app_tmp),
- gs_app_get_flatpak_branch (app_tmp),
+ gs_flatpak_app_get_ref_kind (app_tmp),
+ gs_flatpak_app_get_ref_name (app_tmp),
+ gs_flatpak_app_get_ref_arch (app_tmp),
+ gs_flatpak_app_get_ref_branch (app_tmp),
gs_flatpak_progress_cb, phelper,
cancellable, error);
}
@@ -2870,7 +2847,7 @@ gs_flatpak_file_to_app_bundle (GsFlatpak *self,
/* load metadata */
app = gs_flatpak_create_app (self, FLATPAK_REF (xref_bundle));
- gs_app_set_flatpak_file_type (app, "flatpak");
+ gs_flatpak_app_set_file_kind (app, GS_FLATPAK_APP_FILE_KIND_BUNDLE);
gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
gs_app_set_state (app, AS_APP_STATE_AVAILABLE_LOCAL);
gs_app_set_size_installed (app, flatpak_bundle_ref_get_installed_size (xref_bundle));
@@ -2936,7 +2913,7 @@ gs_flatpak_file_to_app_bundle (GsFlatpak *self,
as_store_get_size (store));
/* find app */
- id = g_strdup_printf ("%s.desktop", gs_app_get_flatpak_name (app));
+ id = g_strdup_printf ("%s.desktop", gs_flatpak_app_get_ref_name (app));
item = as_store_get_app_by_id (store, id);
if (item == NULL) {
g_set_error (error,
@@ -2953,7 +2930,7 @@ gs_flatpak_file_to_app_bundle (GsFlatpak *self,
} else {
g_warning ("no appstream metadata in file");
gs_app_set_name (app, GS_APP_QUALITY_LOWEST,
- gs_app_get_flatpak_name (app));
+ gs_flatpak_app_get_ref_name (app));
gs_app_set_summary (app, GS_APP_QUALITY_LOWEST,
"A flatpak application");
}
@@ -3064,7 +3041,7 @@ gs_flatpak_file_to_app_ref (GsFlatpak *self,
/* load metadata */
app = gs_flatpak_create_app (self, FLATPAK_REF (xref));
gs_app_add_quirk (app, AS_APP_QUIRK_HAS_SOURCE);
- gs_app_set_flatpak_file_type (app, "flatpakref");
+ gs_flatpak_app_set_file_kind (app, GS_FLATPAK_APP_FILE_KIND_REF);
gs_app_set_state (app, AS_APP_STATE_AVAILABLE_LOCAL);
gs_flatpak_set_metadata (self, app, FLATPAK_REF (xref));
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 4b5ab9e..b7f3ae2 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -33,6 +33,7 @@
#include <gnome-software.h>
#include "gs-appstream.h"
+#include "gs-flatpak-app.h"
#include "gs-flatpak.h"
#include "gs-flatpak-utils.h"
@@ -75,6 +76,9 @@ gs_plugin_initialize (GsPlugin *plugin)
g_permission_get_can_acquire (permission);
}
+ /* unique to us */
+ gs_plugin_set_app_gtype (plugin, GS_TYPE_FLATPAK_APP);
+
/* used for self tests */
priv->destdir_for_tests = g_getenv ("GS_SELF_TEST_FLATPACK_DATADIR");
}
@@ -284,7 +288,7 @@ gs_plugin_flatpak_get_handler (GsPlugin *plugin, GsApp *app)
}
/* specified an explicit name */
- object_id = gs_app_get_flatpak_object_id (app);
+ object_id = gs_flatpak_app_get_object_id (app);
if (object_id != NULL) {
for (guint i = 0; i < priv->flatpaks->len; i++) {
GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
@@ -430,7 +434,7 @@ gs_plugin_flatpak_file_to_app_repo (GsPlugin *plugin,
for (guint i = 0; i < priv->flatpaks->len; i++) {
GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
if (!gs_flatpak_find_source_by_url (flatpak,
- gs_app_get_metadata_item (app_tmp, "flatpak::url"),
+ gs_flatpak_app_get_repo_url (app_tmp),
list_tmp, cancellable, error))
return FALSE;
}
@@ -509,7 +513,7 @@ gs_plugin_flatpak_file_to_app_bundle (GsPlugin *plugin,
for (guint i = 0; i < priv->flatpaks->len; i++) {
GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
if (!gs_flatpak_find_app_by_ref_display (flatpak,
- gs_app_get_flatpak_ref_display (app_tmp),
+ gs_flatpak_app_get_ref_display (app_tmp),
list_tmp, cancellable, error))
return FALSE;
}
@@ -561,7 +565,7 @@ gs_plugin_flatpak_file_to_app_ref (GsPlugin *plugin,
for (guint i = 0; i < priv->flatpaks->len; i++) {
GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
if (!gs_flatpak_find_app_by_ref_display (flatpak,
- gs_app_get_flatpak_ref_display (app_tmp),
+ gs_flatpak_app_get_ref_display (app_tmp),
list_tmp, cancellable, error))
return FALSE;
}
@@ -589,7 +593,7 @@ gs_plugin_flatpak_file_to_app_ref (GsPlugin *plugin,
if (gs_flatpak_get_scope (flatpak) != AS_APP_SCOPE_SYSTEM)
continue;
if (!gs_flatpak_find_app_by_ref_display (flatpak,
- gs_app_get_flatpak_ref_display (runtime_app),
+ gs_flatpak_app_get_ref_display (runtime_app),
list_system_runtimes,
cancellable, error))
return FALSE;
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index c56f970..40d7c23 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -23,6 +23,8 @@
#include "gnome-software-private.h"
+#include "gs-flatpak-app.h"
+
#include "gs-test.h"
static gboolean
@@ -210,7 +212,7 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
g_assert_cmpint (kf_remote_repo_version, ==, 1);
/* add a remote */
- app_source = gs_app_new ("test");
+ app_source = gs_flatpak_app_new ("test");
testdir = gs_test_get_filename (TESTDATADIR, "app-with-runtime");
if (testdir == NULL)
return;
@@ -218,7 +220,7 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
gs_app_set_kind (app_source, AS_APP_KIND_SOURCE);
gs_app_set_management_plugin (app_source, "flatpak");
gs_app_set_state (app_source, AS_APP_STATE_AVAILABLE);
- gs_app_set_metadata (app_source, "flatpak::url", testdir_repourl);
+ gs_flatpak_app_set_repo_url (app_source, testdir_repourl);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL,
"app", app_source,
NULL);
@@ -458,7 +460,7 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
}
/* add a remote */
- app_source = gs_app_new ("test");
+ app_source = gs_flatpak_app_new ("test");
testdir = gs_test_get_filename (TESTDATADIR, "app-missing-runtime");
if (testdir == NULL)
return;
@@ -466,7 +468,7 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
gs_app_set_kind (app_source, AS_APP_KIND_SOURCE);
gs_app_set_management_plugin (app_source, "flatpak");
gs_app_set_state (app_source, AS_APP_STATE_AVAILABLE);
- gs_app_set_metadata (app_source, "flatpak::url", testdir_repourl);
+ gs_flatpak_app_set_repo_url (app_source, testdir_repourl);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL,
"app", app_source,
NULL);
@@ -741,7 +743,7 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
return;
/* add a remote with only the runtime in */
- app_source = gs_app_new ("test");
+ app_source = gs_flatpak_app_new ("test");
testdir = gs_test_get_filename (TESTDATADIR, "only-runtime");
if (testdir == NULL)
return;
@@ -749,7 +751,7 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
gs_app_set_kind (app_source, AS_APP_KIND_SOURCE);
gs_app_set_management_plugin (app_source, "flatpak");
gs_app_set_state (app_source, AS_APP_STATE_AVAILABLE);
- gs_app_set_metadata (app_source, "flatpak::url", testdir_repourl);
+ gs_flatpak_app_set_repo_url (app_source, testdir_repourl);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL,
"app", app_source,
NULL);
@@ -972,11 +974,11 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
g_assert (symlink (repodir1_fn, "/var/tmp/self-test/repo") == 0);
/* add a remote */
- app_source = gs_app_new ("test");
+ app_source = gs_flatpak_app_new ("test");
gs_app_set_kind (app_source, AS_APP_KIND_SOURCE);
gs_app_set_management_plugin (app_source, "flatpak");
gs_app_set_state (app_source, AS_APP_STATE_AVAILABLE);
- gs_app_set_metadata (app_source, "flatpak::url", "file:///var/tmp/self-test/repo");
+ gs_flatpak_app_set_repo_url (app_source, "file:///var/tmp/self-test/repo");
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL,
"app", app_source,
NULL);
diff --git a/plugins/flatpak/meson.build b/plugins/flatpak/meson.build
index 2b015ec..f26ac7c 100644
--- a/plugins/flatpak/meson.build
+++ b/plugins/flatpak/meson.build
@@ -6,6 +6,7 @@ shared_module(
'gs_plugin_flatpak',
sources : [
'gs-appstream.c',
+ 'gs-flatpak-app.c',
'gs-flatpak.c',
'gs-flatpak-symlinks.c',
'gs-flatpak-utils.c',
@@ -37,6 +38,7 @@ if get_option('enable-tests')
cargs += ['-DTESTDATADIR="' + join_paths(meson.current_build_dir(), 'tests') + '"']
e = executable('gs-self-test-flatpak',
sources : [
+ 'gs-flatpak-app.c',
'gs-self-test.c'
],
include_directories : [
@@ -45,6 +47,7 @@ if get_option('enable-tests')
],
dependencies : [
plugin_libs,
+ flatpak,
],
link_with : [
libgnomesoftware
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]