[gnome-builder] flatpak: resolve sdk-extensions in gnome-builder-flatpak
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: resolve sdk-extensions in gnome-builder-flatpak
- Date: Fri, 30 Apr 2021 22:14:17 +0000 (UTC)
commit cd7e379e8d22a966a45026ba74169c15e6305807
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 30 15:14:09 2021 -0700
flatpak: resolve sdk-extensions in gnome-builder-flatpak
This moves the resolution of flatpak extensions into the
gnome-builder-flatpak daemon instead of the gnome-builder UI process.
Eventually, we want to move the rest of libflatpak API calls from the UI
process into this daemon.
.../flatpak/daemon/ipc-flatpak-service-impl.c | 317 +++++++++++++++++++++
src/plugins/flatpak/daemon/meson.build | 5 +
.../daemon/org.gnome.Builder.Flatpak.Service.xml | 14 +
.../flatpak/gbp-flatpak-application-addin.c | 234 ---------------
.../flatpak/gbp-flatpak-application-addin.h | 3 -
src/plugins/flatpak/gbp-flatpak-runtime-provider.c | 23 +-
6 files changed, 352 insertions(+), 244 deletions(-)
---
diff --git a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
index e1921ed66..01f669219 100644
--- a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
+++ b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
@@ -81,6 +81,69 @@ static gboolean runtime_equal (const Runtime
const Runtime *b);
static void is_known_free (IsKnown *state);
+static inline gboolean
+str_equal0 (const char *a,
+ const char *b)
+{
+ return g_strcmp0 (a, b) == 0;
+}
+
+static inline gboolean
+str_empty0 (const char *s)
+{
+ return !s || !*s;
+}
+
+gboolean
+split_id (const gchar *str,
+ gchar **id,
+ gchar **arch,
+ gchar **branch)
+{
+ g_auto(GStrv) parts = g_strsplit (str, "/", 0);
+ guint i = 0;
+
+ if (id)
+ *id = NULL;
+
+ if (arch)
+ *arch = NULL;
+
+ if (branch)
+ *branch = NULL;
+
+ if (parts[i] != NULL)
+ {
+ if (id != NULL)
+ *id = g_strdup (parts[i]);
+ }
+ else
+ {
+ /* we require at least a runtime/app ID */
+ return FALSE;
+ }
+
+ i++;
+
+ if (parts[i] != NULL)
+ {
+ if (arch != NULL)
+ *arch = g_strdup (parts[i]);
+ }
+ else
+ return TRUE;
+
+ i++;
+
+ if (parts[i] != NULL)
+ {
+ if (branch != NULL && !str_empty0 (parts[i]))
+ *branch = g_strdup (parts[i]);
+ }
+
+ return TRUE;
+}
+
static void
is_known_free (IsKnown *state)
{
@@ -495,6 +558,259 @@ ipc_flatpak_service_impl_install (IpcFlatpakService *service,
return TRUE;
}
+typedef struct
+{
+ const gchar *ref;
+ const gchar *extension;
+} ResolveExtension;
+
+G_GNUC_PRINTF (2, 3)
+static const gchar *
+chunk_insert (GStringChunk *strings,
+ const gchar *format,
+ ...)
+{
+ char formatted[256];
+ const gchar *ret = NULL;
+ va_list args;
+
+ va_start (args, format);
+ if (g_vsnprintf (formatted, sizeof formatted, format, args) < sizeof formatted)
+ ret = g_string_chunk_insert_const (strings, formatted);
+ va_end (args);
+
+ return ret;
+}
+
+static gchar *
+resolve_extension (IpcFlatpakServiceImpl *self,
+ const gchar *sdk,
+ const gchar *extension)
+{
+ g_autofree gchar *sdk_id = NULL;
+ g_autofree gchar *sdk_arch = NULL;
+ g_autofree gchar *sdk_branch = NULL;
+ g_autoptr(GArray) maybe_extention_of = NULL;
+ g_autoptr(GArray) runtime_extensions = NULL;
+ g_autoptr(GStringChunk) strings = NULL;
+ GHashTableIter iter;
+ Install *info;
+
+ g_assert (IPC_IS_FLATPAK_SERVICE_IMPL (self));
+ g_assert (sdk != NULL);
+ g_assert (extension != NULL);
+
+ /* It would be very nice to do this asynchronously someday, but we try to
+ * only use cached contents so it's not quite as bad as it could be.
+ */
+
+ if (!split_id (sdk, &sdk_id, &sdk_arch, &sdk_branch))
+ return NULL;
+
+ if (sdk_arch == NULL)
+ sdk_arch = g_strdup (flatpak_get_default_arch ());
+
+ strings = g_string_chunk_new (4096);
+ maybe_extention_of = g_array_new (FALSE, FALSE, sizeof (ResolveExtension));
+ runtime_extensions = g_array_new (FALSE, FALSE, sizeof (ResolveExtension));
+
+ g_hash_table_iter_init (&iter, self->installs);
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&info))
+ {
+ g_autoptr(GPtrArray) remotes = flatpak_installation_list_remotes (info->installation, NULL, NULL);
+
+ if (remotes == NULL)
+ continue;
+
+ for (guint j = 0; j < remotes->len; j++)
+ {
+ FlatpakRemote *remote = g_ptr_array_index (remotes, j);
+ const gchar *name = flatpak_remote_get_name (remote);
+ g_autoptr(GPtrArray) refs = NULL;
+
+ refs = flatpak_installation_list_remote_refs_sync_full (info->installation,
+ name,
+ FLATPAK_QUERY_FLAGS_ONLY_CACHED,
+ NULL,
+ NULL);
+
+ if (refs == NULL)
+ continue;
+
+ for (guint k = 0; k < refs->len; k++)
+ {
+ FlatpakRemoteRef *ref = g_ptr_array_index (refs, k);
+ const char *id = flatpak_ref_get_name (FLATPAK_REF (ref));
+ const char *branch = flatpak_ref_get_branch (FLATPAK_REF (ref));
+ const char *arch = flatpak_ref_get_arch (FLATPAK_REF (ref));
+ g_autoptr(GKeyFile) keyfile = NULL;
+ g_auto(GStrv) groups = NULL;
+ GBytes *bytes;
+
+ if (flatpak_ref_get_kind (FLATPAK_REF (ref)) != FLATPAK_REF_KIND_RUNTIME ||
+ !str_equal0 (arch, sdk_arch) ||
+ !(bytes = flatpak_remote_ref_get_metadata (ref)))
+ continue;
+
+ keyfile = g_key_file_new ();
+ if (!g_key_file_load_from_bytes (keyfile, bytes, 0, NULL))
+ continue;
+
+ groups = g_key_file_get_groups (keyfile, NULL);
+
+ for (guint l = 0; groups[l]; l++)
+ {
+ const gchar *group = groups[l];
+ g_autofree gchar *version = NULL;
+ g_autofree gchar *runtime = NULL;
+ g_autofree gchar *match = NULL;
+ g_autofree gchar *refstr = NULL;
+
+ /* This might be our extension */
+ if (str_equal0 (group, "ExtensionOf") &&
+ str_equal0 (id, extension))
+ {
+ runtime = g_key_file_get_string (keyfile, group, "runtime", NULL);
+ refstr = g_key_file_get_string (keyfile, group, "ref", NULL);
+
+ if (ref != NULL && g_str_has_prefix (refstr, "runtime/"))
+ {
+ g_autofree gchar *ref_id = NULL;
+ g_autofree gchar *ref_arch = NULL;
+ g_autofree gchar *ref_branch = NULL;
+
+ if (split_id (refstr + strlen ("runtime/"), &ref_id, &ref_arch, &ref_branch))
+ {
+ g_clear_pointer (&runtime, g_free);
+
+ /* https://gitlab.gnome.org/GNOME/gnome-builder/issues/1437
+ *
+ * Some extensions report an incorrect ref (or a ref that is
+ * for another architecture than the current). For example,
+ * org.freedesktop.Sdk.Compat.i386/x86_64/19.08 will report
+ * a ref of org.freedesktop.Sdk/i386/19.08.
+ *
+ * To work around this, we can simply swap the arch for the
+ * arch of the runtime extension we're looking at.
+ */
+ runtime = g_strdup_printf ("%s/%s/%s", ref_id, arch, ref_branch);
+ }
+ }
+
+ if (runtime != NULL)
+ {
+ ResolveExtension re = {
+ chunk_insert (strings, "%s/%s/%s", id, arch, branch),
+ g_string_chunk_insert_const (strings, runtime) };
+
+ g_array_append_val (maybe_extention_of, re);
+ }
+ }
+
+ /* This might provide the extension */
+ if (g_str_has_prefix (group, "Extension "))
+ {
+ const gchar *extname = group + strlen ("Extension ");
+
+ /* Only track extensions to the runtime itself unless it is
+ * for our target runtime/SDK.
+ */
+ if (!g_str_has_prefix (extname, id))
+ {
+ if (!str_equal0 (id, sdk_id) ||
+ !str_equal0 (branch, sdk_branch))
+ continue;
+ }
+
+ if (!(version = g_key_file_get_string (keyfile, group, "version", NULL)))
+ version = g_strdup (branch);
+
+ if (version != NULL)
+ {
+ ResolveExtension re = {
+ chunk_insert (strings, "%s/%s/%s", id, arch, branch),
+ chunk_insert (strings, "%s/%s/%s", extname, arch, version) };
+
+ g_array_append_val (runtime_extensions, re);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (guint i = 0; i < maybe_extention_of->len; i++)
+ {
+ const ResolveExtension *maybe = &g_array_index (maybe_extention_of, ResolveExtension, i);
+
+ /* First find any runtime matching the ExtensionOf (such as
+ * ExtensionOf=org.freedesktop.Sdk/x86_64/20.08.
+ */
+
+ for (guint j = 0; j < runtime_extensions->len; j++)
+ {
+ const ResolveExtension *re = &g_array_index (runtime_extensions, ResolveExtension, j);
+ g_autofree gchar *rname = NULL;
+
+ if (!str_equal0 (re->ref, maybe->extension))
+ continue;
+
+ if (!split_id (re->extension, &rname, NULL, NULL))
+ continue;
+
+ /* Now we need to find any runtime that matches the extension
+ * that is in re->extension (such as
+ * org.freedesktop.Sdk.Extension/x86_64/20.08).
+ */
+
+ for (guint k = 0; k < runtime_extensions->len; k++)
+ {
+ const ResolveExtension *target = &g_array_index (runtime_extensions, ResolveExtension, k);
+
+ if (!str_equal0 (re->extension, target->extension))
+ continue;
+
+ if (str_equal0 (target->ref, sdk))
+ {
+ char *ret = g_strdup (maybe->ref);
+ return ret;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+static gboolean
+ipc_flatpak_service_impl_resolve_extension (IpcFlatpakService *service,
+ GDBusMethodInvocation *invocation,
+ const char *sdk,
+ const char *extension)
+{
+ IpcFlatpakServiceImpl *self = (IpcFlatpakServiceImpl *)service;
+ g_autofree char *resolved = NULL;
+
+ g_assert (IPC_IS_FLATPAK_SERVICE_IMPL (self));
+ g_assert (G_IS_DBUS_METHOD_INVOCATION (invocation));
+ g_assert (sdk != NULL);
+ g_assert (extension != NULL);
+
+ resolved = resolve_extension (self, sdk, extension);
+
+ if (resolved == NULL)
+ g_dbus_method_invocation_return_error (g_steal_pointer (&invocation),
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Failed to resolve extension");
+ else
+ ipc_flatpak_service_complete_resolve_extension (service,
+ g_steal_pointer (&invocation),
+ resolved);
+
+ return TRUE;
+}
+
static void
service_iface_init (IpcFlatpakServiceIface *iface)
{
@@ -502,6 +818,7 @@ service_iface_init (IpcFlatpakServiceIface *iface)
iface->handle_list_runtimes = ipc_flatpak_service_impl_list_runtimes;
iface->handle_runtime_is_known = ipc_flatpak_service_impl_runtime_is_known;
iface->handle_install = ipc_flatpak_service_impl_install;
+ iface->handle_resolve_extension = ipc_flatpak_service_impl_resolve_extension;
}
G_DEFINE_TYPE_WITH_CODE (IpcFlatpakServiceImpl, ipc_flatpak_service_impl, IPC_TYPE_FLATPAK_SERVICE_SKELETON,
diff --git a/src/plugins/flatpak/daemon/meson.build b/src/plugins/flatpak/daemon/meson.build
index 506db5eea..49e7217e5 100644
--- a/src/plugins/flatpak/daemon/meson.build
+++ b/src/plugins/flatpak/daemon/meson.build
@@ -36,6 +36,11 @@ test_flatpak_sources = [
ipc_flatpak_transfer_src,
]
+plugins_sources += [
+ ipc_flatpak_service_src,
+ ipc_flatpak_transfer_src,
+]
+
test_flatpak = executable('test-flatpak', 'test-flatpak.c', test_flatpak_sources,
dependencies: [ libgiounix_dep ],
)
diff --git a/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
b/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
index c680e296b..d16a64a72 100644
--- a/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
+++ b/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
@@ -67,5 +67,19 @@
<arg name="full_ref_name" direction="in" type="s"/>
<arg name="transfer" direction="out" type="o"/>
</method>
+ <!--
+ ResolveExtension:
+ @sdk: the primary SDK that is being used
+ @extension: the extension name that is known
+
+ Tries to locate the proper fully qualified name of a SDK extension based
+ on a provided name by locating common parents of @sdk and possible @extension
+ matches.
+ -->
+ <method name="ResolveExtension">
+ <arg name="sdk" type="s" direction="in"/>
+ <arg name="extension" type="s" direction="in"/>
+ <arg name="resolved" type="s" direction="out"/>
+ </method>
</interface>
</node>
diff --git a/src/plugins/flatpak/gbp-flatpak-application-addin.c
b/src/plugins/flatpak/gbp-flatpak-application-addin.c
index deac241ef..1e63a29f0 100644
--- a/src/plugins/flatpak/gbp-flatpak-application-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-application-addin.c
@@ -1497,237 +1497,3 @@ gbp_flatpak_application_addin_find_extension (GbpFlatpakApplicationAddin *self,
return gbp_flatpak_application_addin_find_ref (self, name, NULL, NULL);
}
-
-typedef struct
-{
- const gchar *ref;
- const gchar *extension;
-} ResolveExtension;
-
-G_GNUC_PRINTF (2, 3)
-static const gchar *
-chunk_insert (GStringChunk *strings,
- const gchar *format,
- ...)
-{
- char formatted[256];
- const gchar *ret = NULL;
- va_list args;
-
- va_start (args, format);
- if (g_vsnprintf (formatted, sizeof formatted, format, args) < sizeof formatted)
- ret = g_string_chunk_insert_const (strings, formatted);
- va_end (args);
-
- return ret;
-}
-
-gchar *
-gbp_flatpak_application_addin_resolve_extension (GbpFlatpakApplicationAddin *self,
- const gchar *sdk,
- const gchar *extension)
-{
- g_autoptr(GPtrArray) installations = NULL;
- g_autofree gchar *sdk_id = NULL;
- g_autofree gchar *sdk_arch = NULL;
- g_autofree gchar *sdk_branch = NULL;
- g_autoptr(GArray) maybe_extention_of = NULL;
- g_autoptr(GArray) runtime_extensions = NULL;
- g_autoptr(GStringChunk) strings = NULL;
-
- IDE_ENTRY;
-
- /* XXX: This method is a monstrocity to all main loops. Please make something
- * in libflatpak that we can use instead of this.
- */
-
- g_return_val_if_fail (GBP_IS_FLATPAK_APPLICATION_ADDIN (self), NULL);
- g_return_val_if_fail (sdk != NULL, NULL);
- g_return_val_if_fail (extension != NULL, NULL);
-
- if (self->installations == NULL)
- IDE_RETURN (NULL);
-
- /* It would be very nice to do this asynchronously someday, but we try to
- * only use cached contents so it's not quite as bad as it could be.
- */
-
- if (!gbp_flatpak_split_id (sdk, &sdk_id, &sdk_arch, &sdk_branch))
- IDE_RETURN (NULL);
-
- if (sdk_arch == NULL)
- sdk_arch = g_strdup (flatpak_get_default_arch ());
-
- strings = g_string_chunk_new (4096);
- installations = g_ptr_array_ref (self->installations);
-
- maybe_extention_of = g_array_new (FALSE, FALSE, sizeof (ResolveExtension));
- runtime_extensions = g_array_new (FALSE, FALSE, sizeof (ResolveExtension));
-
- for (guint i = 0; i < installations->len; i++)
- {
- InstallInfo *info = g_ptr_array_index (installations, i);
- g_autoptr(GPtrArray) remotes = flatpak_installation_list_remotes (info->installation, NULL, NULL);
-
- if (remotes == NULL)
- continue;
-
- for (guint j = 0; j < remotes->len; j++)
- {
- FlatpakRemote *remote = g_ptr_array_index (remotes, j);
- const gchar *name = flatpak_remote_get_name (remote);
- g_autoptr(GPtrArray) refs = NULL;
-
- refs = flatpak_installation_list_remote_refs_sync_full (info->installation,
- name,
- FLATPAK_QUERY_FLAGS_ONLY_CACHED,
- NULL,
- NULL);
-
- if (refs == NULL)
- continue;
-
- for (guint k = 0; k < refs->len; k++)
- {
- FlatpakRemoteRef *ref = g_ptr_array_index (refs, k);
- const char *id = flatpak_ref_get_name (FLATPAK_REF (ref));
- const char *branch = flatpak_ref_get_branch (FLATPAK_REF (ref));
- const char *arch = flatpak_ref_get_arch (FLATPAK_REF (ref));
- g_autoptr(GKeyFile) keyfile = NULL;
- g_auto(GStrv) groups = NULL;
- GBytes *bytes;
-
- if (flatpak_ref_get_kind (FLATPAK_REF (ref)) != FLATPAK_REF_KIND_RUNTIME ||
- !ide_str_equal0 (arch, sdk_arch) ||
- !(bytes = flatpak_remote_ref_get_metadata (ref)))
- continue;
-
- keyfile = g_key_file_new ();
- if (!g_key_file_load_from_bytes (keyfile, bytes, 0, NULL))
- continue;
-
- groups = g_key_file_get_groups (keyfile, NULL);
-
- for (guint l = 0; groups[l]; l++)
- {
- const gchar *group = groups[l];
- g_autofree gchar *version = NULL;
- g_autofree gchar *runtime = NULL;
- g_autofree gchar *match = NULL;
- g_autofree gchar *refstr = NULL;
-
- /* This might be our extension */
- if (ide_str_equal0 (group, "ExtensionOf") &&
- ide_str_equal0 (id, extension))
- {
- runtime = g_key_file_get_string (keyfile, group, "runtime", NULL);
- refstr = g_key_file_get_string (keyfile, group, "ref", NULL);
-
- if (ref != NULL && g_str_has_prefix (refstr, "runtime/"))
- {
- g_autofree gchar *ref_id = NULL;
- g_autofree gchar *ref_arch = NULL;
- g_autofree gchar *ref_branch = NULL;
-
- if (gbp_flatpak_split_id (refstr + strlen ("runtime/"), &ref_id, &ref_arch,
&ref_branch))
- {
- g_clear_pointer (&runtime, g_free);
-
- /* https://gitlab.gnome.org/GNOME/gnome-builder/issues/1437
- *
- * Some extensions report an incorrect ref (or a ref that is
- * for another architecture than the current). For example,
- * org.freedesktop.Sdk.Compat.i386/x86_64/19.08 will report
- * a ref of org.freedesktop.Sdk/i386/19.08.
- *
- * To work around this, we can simply swap the arch for the
- * arch of the runtime extension we're looking at.
- */
- runtime = g_strdup_printf ("%s/%s/%s", ref_id, arch, ref_branch);
- }
- }
-
- if (runtime != NULL)
- {
- ResolveExtension re = {
- chunk_insert (strings, "%s/%s/%s", id, arch, branch),
- g_string_chunk_insert_const (strings, runtime) };
-
- g_array_append_val (maybe_extention_of, re);
- }
- }
-
- /* This might provide the extension */
- if (g_str_has_prefix (group, "Extension "))
- {
- const gchar *extname = group + strlen ("Extension ");
-
- /* Only track extensions to the runtime itself unless it is
- * for our target runtime/SDK.
- */
- if (!g_str_has_prefix (extname, id))
- {
- if (!ide_str_equal0 (id, sdk_id) ||
- !ide_str_equal0 (branch, sdk_branch))
- continue;
- }
-
- if (!(version = g_key_file_get_string (keyfile, group, "version", NULL)))
- version = g_strdup (branch);
-
- if (version != NULL)
- {
- ResolveExtension re = {
- chunk_insert (strings, "%s/%s/%s", id, arch, branch),
- chunk_insert (strings, "%s/%s/%s", extname, arch, version) };
-
- g_array_append_val (runtime_extensions, re);
- }
- }
- }
- }
- }
- }
-
- for (guint i = 0; i < maybe_extention_of->len; i++)
- {
- const ResolveExtension *maybe = &g_array_index (maybe_extention_of, ResolveExtension, i);
-
- /* First find any runtime matching the ExtensionOf (such as
- * ExtensionOf=org.freedesktop.Sdk/x86_64/20.08.
- */
-
- for (guint j = 0; j < runtime_extensions->len; j++)
- {
- const ResolveExtension *re = &g_array_index (runtime_extensions, ResolveExtension, j);
- g_autofree gchar *rname = NULL;
-
- if (!ide_str_equal0 (re->ref, maybe->extension))
- continue;
-
- if (!gbp_flatpak_split_id (re->extension, &rname, NULL, NULL))
- continue;
-
- /* Now we need to find any runtime that matches the extension
- * that is in re->extension (such as
- * org.freedesktop.Sdk.Extension/x86_64/20.08).
- */
-
- for (guint k = 0; k < runtime_extensions->len; k++)
- {
- const ResolveExtension *target = &g_array_index (runtime_extensions, ResolveExtension, k);
-
- if (!ide_str_equal0 (re->extension, target->extension))
- continue;
-
- if (ide_str_equal0 (target->ref, sdk))
- {
- char *ret = g_strdup (maybe->ref);
- IDE_RETURN (ret);
- }
- }
- }
- }
-
- IDE_RETURN (NULL);
-}
diff --git a/src/plugins/flatpak/gbp-flatpak-application-addin.h
b/src/plugins/flatpak/gbp-flatpak-application-addin.h
index f99a131a1..4cd344840 100644
--- a/src/plugins/flatpak/gbp-flatpak-application-addin.h
+++ b/src/plugins/flatpak/gbp-flatpak-application-addin.h
@@ -39,9 +39,6 @@ gboolean gbp_flatpak_application_addin_has_runtime
const gchar
*id,
const gchar
*arch,
const gchar
*branch);
-gchar *gbp_flatpak_application_addin_resolve_extension (GbpFlatpakApplicationAddin
*self,
- const gchar
*sdk,
- const gchar
*extension);
void gbp_flatpak_application_addin_check_sysdeps_async (GbpFlatpakApplicationAddin
*self,
GCancellable
*cancellable,
GAsyncReadyCallback
callback,
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
b/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
index 44155cb83..244863401 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
+++ b/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
@@ -29,6 +29,7 @@
#include "ide-gui-private.h"
#include "gbp-flatpak-application-addin.h"
+#include "gbp-flatpak-client.h"
#include "gbp-flatpak-install-dialog.h"
#include "gbp-flatpak-manifest.h"
#include "gbp-flatpak-runtime.h"
@@ -650,23 +651,27 @@ resolve_extension_branch (GbpFlatpakRuntimeProvider *self,
const gchar *sdk,
const gchar *extension)
{
- GbpFlatpakApplicationAddin *addin;
g_autofree gchar *resolved = NULL;
g_autofree gchar *branch = NULL;
+ IdeContext *context;
+ GbpFlatpakClient *client;
+ IpcFlatpakService *service;
IDE_ENTRY;
g_assert (GBP_IS_FLATPAK_RUNTIME_PROVIDER (self));
g_assert (extension != NULL);
- IDE_TRACE_MSG ("Resolving extension %s for SDK %s",
- extension, sdk);
+ IDE_TRACE_MSG ("Resolving extension %s for SDK %s", extension, sdk);
if (extension == NULL)
IDE_RETURN (NULL);
- addin = gbp_flatpak_application_addin_get_default ();
- resolved = gbp_flatpak_application_addin_resolve_extension (addin, sdk, extension);
+ context = ide_object_get_context (IDE_OBJECT (self));
+ client = gbp_flatpak_client_from_context (context);
+ service = gbp_flatpak_client_get_service (client, NULL, NULL);
+
+ ipc_flatpak_service_call_resolve_extension_sync (service, sdk, extension, &resolved, NULL, NULL);
if (resolved == NULL || !gbp_flatpak_split_id (resolved, NULL, NULL, &branch))
IDE_RETURN (NULL);
@@ -767,6 +772,8 @@ gbp_flatpak_runtime_provider_bootstrap_async (IdeRuntimeProvider *provider,
const gchar *build_arch;
IdeContext *context;
IdeConfig *config;
+ GbpFlatpakClient *client;
+ IpcFlatpakService *service;
IDE_ENTRY;
@@ -810,6 +817,8 @@ gbp_flatpak_runtime_provider_bootstrap_async (IdeRuntimeProvider *provider,
ide_task_set_task_data (task, state, bootstrap_state_free);
addin = gbp_flatpak_application_addin_get_default ();
+ client = gbp_flatpak_client_from_context (context);
+ service = gbp_flatpak_client_get_service (client, NULL, NULL);
/* Add all the runtimes the manifest needs */
if (GBP_IS_FLATPAK_MANIFEST (state->config))
@@ -847,9 +856,9 @@ gbp_flatpak_runtime_provider_bootstrap_async (IdeRuntimeProvider *provider,
{
for (guint i = 0; sdk_extensions[i]; i++)
{
- g_autofree char *resolved = gbp_flatpak_application_addin_resolve_extension (addin, sdk_full,
sdk_extensions[i]);
+ g_autofree char *resolved = NULL;
- if (resolved == NULL)
+ if (!ipc_flatpak_service_call_resolve_extension_sync (service, sdk_full, sdk_extensions[i],
&resolved, NULL, NULL))
{
gbp_flatpak_install_dialog_add_runtime (dialog, sdk_extensions[i]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]