diff options
-rw-r--r-- | common/flatpak-auth-private.h | 2 | ||||
-rw-r--r-- | common/flatpak-auth.c | 2 | ||||
-rw-r--r-- | common/flatpak-transaction.c | 19 | ||||
-rw-r--r-- | data/org.freedesktop.Flatpak.xml | 3 | ||||
-rw-r--r-- | tests/test-authenticator.c | 17 |
5 files changed, 31 insertions, 12 deletions
diff --git a/common/flatpak-auth-private.h b/common/flatpak-auth-private.h index c92494e7..4f5476c6 100644 --- a/common/flatpak-auth-private.h +++ b/common/flatpak-auth-private.h @@ -52,7 +52,7 @@ FlatpakAuthenticatorRequest *flatpak_auth_create_request (FlatpakAuth gboolean flatpak_auth_request_ref_tokens (FlatpakAuthenticator *authenticator, FlatpakAuthenticatorRequest *request, const char *remote, - const char **refs, + GVariant *refs, GCancellable *cancellable, GError **error); char * flatpak_auth_create_request_path (const char *peer, diff --git a/common/flatpak-auth.c b/common/flatpak-auth.c index ca892e4d..d8b93bcb 100644 --- a/common/flatpak-auth.c +++ b/common/flatpak-auth.c @@ -130,7 +130,7 @@ gboolean flatpak_auth_request_ref_tokens (FlatpakAuthenticator *authenticator, FlatpakAuthenticatorRequest *request, const char *remote, - const char **refs, + GVariant *refs, GCancellable *cancellable, GError **error) { diff --git a/common/flatpak-transaction.c b/common/flatpak-transaction.c index 39985487..ba43438a 100644 --- a/common/flatpak-transaction.c +++ b/common/flatpak-transaction.c @@ -2773,25 +2773,30 @@ request_tokens_for_remote (FlatpakTransaction *self, GError **error) { FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (self); - g_autofree char *refs_as_str = NULL; + g_autoptr(GString) refs_as_str = g_string_new (""); GList *l; - g_autoptr(GPtrArray) refs = g_ptr_array_new (); g_autoptr(AutoFlatpakAuthenticatorRequest) request = NULL; g_autoptr(AutoFlatpakAuthenticator) authenticator = NULL; g_autoptr(GMainContextPopDefault) context = NULL; RequestData data = { self, remote }; g_autoptr(GVariant) tokens = NULL; g_autoptr(GVariant) results = NULL; + g_autoptr(GVariant) refs = NULL; + GVariantBuilder refs_builder; + + g_variant_builder_init (&refs_builder, G_VARIANT_TYPE ("a(si)")); for (l = ops; l != NULL; l = l->next) { FlatpakTransactionOperation *op = l->data; - g_ptr_array_add (refs, op->ref); + g_variant_builder_add (&refs_builder, "(si)", op->ref, (gint32)op->token_type); + g_string_append_printf (refs_as_str, "(%s, %d)", op->ref, op->token_type); + if (l->next != NULL) + g_string_append (refs_as_str, ", "); } - g_ptr_array_add (refs, NULL); - refs_as_str = g_strjoinv (", ", (char **)refs->pdata); - g_debug ("Requesting tokens for remote %s, refs: %s", remote, refs_as_str); + g_debug ("Requesting tokens for remote %s: %s", remote, refs_as_str->str); + refs = g_variant_ref_sink (g_variant_builder_end (&refs_builder)); context = flatpak_main_context_new_default (); @@ -2810,7 +2815,7 @@ request_tokens_for_remote (FlatpakTransaction *self, priv->active_webflow = &data; data.request = request; - if (!flatpak_auth_request_ref_tokens (authenticator, request, remote, (const char **)refs->pdata, cancellable, error)) + if (!flatpak_auth_request_ref_tokens (authenticator, request, remote, refs, cancellable, error)) return FALSE; while (!data.done) diff --git a/data/org.freedesktop.Flatpak.xml b/data/org.freedesktop.Flatpak.xml index 50769257..6ec7f8de 100644 --- a/data/org.freedesktop.Flatpak.xml +++ b/data/org.freedesktop.Flatpak.xml @@ -176,7 +176,8 @@ <arg type='s' name='handle_token' direction='in'/> <arg type='a{sv}' name='authenticator_options' direction='in'/> <arg type='s' name='remote' direction='in'/> - <arg type='as' name='refs' direction='in'/> + <!-- This is the ref and its token-type --> + <arg type='a(si)' name='refs' direction='in'/> <arg type='o' name='handle' direction='out'/> </method> </interface> diff --git a/tests/test-authenticator.c b/tests/test-authenticator.c index ed0e1ef6..f6dc0a0a 100644 --- a/tests/test-authenticator.c +++ b/tests/test-authenticator.c @@ -173,7 +173,7 @@ handle_request_ref_tokens (FlatpakAuthenticator *authenticator, const gchar *arg_handle_token, GVariant *arg_authenticator_option, const gchar *arg_remote, - const gchar *const *arg_refs) + GVariant *arg_refs) { g_autoptr(GError) error = NULL; g_autoptr(GSocketService) server = NULL; @@ -182,6 +182,8 @@ handle_request_ref_tokens (FlatpakAuthenticator *authenticator, g_autofree char *request_path = NULL; guint16 port; TokenRequestData *data; + g_autoptr(GPtrArray) refs = NULL; + gsize n_refs, i; g_debug ("handling RequestRefTokens"); @@ -213,7 +215,18 @@ handle_request_ref_tokens (FlatpakAuthenticator *authenticator, return TRUE; } - data = token_request_data_new (invocation, request, server, arg_refs); + refs = g_ptr_array_new_with_free_func (g_free); + n_refs = g_variant_n_children (arg_refs); + for (i = 0; i < n_refs; i++) + { + const char *ref; + gint32 token_type; + g_variant_get_child (arg_refs, i, "(&si)", &ref, &token_type); + g_ptr_array_add (refs, g_strdup (ref)); + } + g_ptr_array_add (refs, NULL); + + data = token_request_data_new (invocation, request, server, (const char *const*)refs->pdata); g_signal_connect (server, "incoming", (GCallback)http_incoming, data); g_signal_connect (request, "handle-close", G_CALLBACK (handle_request_close), data); |