From 644adb37ddbad2363bbe2d98f28de1caefa499c9 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 7 Jun 2021 16:31:18 +0200 Subject: [PATCH 01/11] Use GUri instead of SoupURI In preparation for libsoup3 where SoupURI has been removed in favor of GUri. --- configure.ac | 2 +- meson.build | 2 +- src/goabackend/goaoauth2provider.c | 11 +-- src/goabackend/goaoauthprovider.c | 8 +- src/goabackend/goaowncloudprovider.c | 107 ++++++++++++++++----------- src/goabackend/goawebview.c | 9 +-- 6 files changed, 81 insertions(+), 58 deletions(-) diff --git a/configure.ac b/configure.ac index 3bf9374a..1bde1392 100644 --- a/configure.ac +++ b/configure.ac @@ -90,7 +90,7 @@ GTK_DOC_CHECK([1.3]) # Libraries # -PKG_CHECK_MODULES(GLIB, [glib-2.0 gio-2.0 gio-unix-2.0 >= 2.52]) +PKG_CHECK_MODULES(GLIB, [glib-2.0 gio-2.0 gio-unix-2.0 >= 2.67.4]) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) diff --git a/meson.build b/meson.build index b048f663..c9f8c848 100644 --- a/meson.build +++ b/meson.build @@ -76,7 +76,7 @@ endif add_project_arguments(compiler_flags, language: 'c') -glib_req_version = '>= 2.52' +glib_req_version = '>= 2.67.4' gio_dep = dependency('gio-2.0', version: glib_req_version) gio_unix_dep = dependency('gio-unix-2.0', version: glib_req_version) diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c index 3715431d..2757838b 100644 --- a/src/goabackend/goaoauth2provider.c +++ b/src/goabackend/goaoauth2provider.c @@ -763,7 +763,7 @@ on_web_view_decide_policy (WebKitWebView *web_view, GHashTable *key_value_pairs; WebKitNavigationAction *action; WebKitURIRequest *request; - SoupURI *uri; + GUri *uri; const gchar *fragment; const gchar *oauth2_error; const gchar *query; @@ -793,9 +793,9 @@ on_web_view_decide_policy (WebKitWebView *web_view, if (!g_str_has_prefix (requested_uri, redirect_uri)) goto default_behaviour; - uri = soup_uri_new (requested_uri); - fragment = soup_uri_get_fragment (uri); - query = soup_uri_get_query (uri); + uri = g_uri_parse (requested_uri, G_URI_FLAGS_ENCODED, NULL); + fragment = g_uri_get_fragment (uri); + query = g_uri_get_query (uri); /* Three cases: * 1) we can either have the backend handle the URI for us, or @@ -808,7 +808,7 @@ on_web_view_decide_policy (WebKitWebView *web_view, { gchar *url; - url = soup_uri_to_string (uri, FALSE); + url = g_uri_to_string (uri); if (!goa_oauth2_provider_process_redirect_url (self, url, &priv->access_token, &priv->error)) { g_prefix_error (&priv->error, _("Authorization response: ")); @@ -889,6 +889,7 @@ on_web_view_decide_policy (WebKitWebView *web_view, goto ignore_request; ignore_request: + g_uri_unref (uri); g_assert (response_id != GTK_RESPONSE_NONE); if (response_id < 0) gtk_dialog_response (priv->dialog, response_id); diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c index 0bfab6b1..ff0927ef 100644 --- a/src/goabackend/goaoauthprovider.c +++ b/src/goabackend/goaoauthprovider.c @@ -643,7 +643,7 @@ on_web_view_decide_policy (WebKitWebView *web_view, { GHashTable *key_value_pairs; IdentifyData *data = user_data; - SoupURI *uri; + GUri *uri; WebKitNavigationAction *action; WebKitURIRequest *request; const gchar *query; @@ -664,8 +664,8 @@ on_web_view_decide_policy (WebKitWebView *web_view, if (!g_str_has_prefix (requested_uri, redirect_uri)) goto default_behaviour; - uri = soup_uri_new (requested_uri); - query = soup_uri_get_query (uri); + uri = g_uri_parse (requested_uri, G_URI_FLAGS_ENCODED, NULL); + query = g_uri_get_query (uri); if (query != NULL) { @@ -678,6 +678,8 @@ on_web_view_decide_policy (WebKitWebView *web_view, g_hash_table_unref (key_value_pairs); } + g_uri_unref (uri); + if (data->oauth_verifier != NULL) goto ignore_request; diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c index d1429661..10734beb 100644 --- a/src/goabackend/goaowncloudprovider.c +++ b/src/goabackend/goaowncloudprovider.c @@ -22,8 +22,6 @@ #include -#include - #include "goahttpclient.h" #include "goaprovider.h" #include "goaowncloudprovider.h" @@ -78,45 +76,42 @@ get_provider_features (GoaProvider *provider) /* ---------------------------------------------------------------------------------------------------- */ static char * -uri_to_string_with_path (SoupURI *soup_uri, const gchar *path) +uri_to_string_with_path (GUri *uri, const gchar *path) { gchar *uri_string; gchar *uri_tmp; - if (soup_uri == NULL) + if (uri == NULL) return NULL; - uri_tmp = soup_uri_to_string (soup_uri, FALSE); + uri_tmp = g_uri_to_string (uri); uri_string = g_strconcat (uri_tmp, path, NULL); g_free (uri_tmp); return uri_string; } -static char *get_webdav_uri (SoupURI *soup_uri) +static char *get_webdav_uri (GUri *uri) { - SoupURI *uri_tmp; + GUri *uri_tmp; gchar *uri_webdav; const gchar *scheme; - guint port; - if (soup_uri == NULL) + if (uri == NULL) return NULL; - scheme = soup_uri_get_scheme (soup_uri); - port = soup_uri_get_port (soup_uri); - uri_tmp = soup_uri_copy (soup_uri); - - if (g_strcmp0 (scheme, SOUP_URI_SCHEME_HTTPS) == 0) - soup_uri_set_scheme (uri_tmp, "davs"); - else - soup_uri_set_scheme (uri_tmp, "dav"); - - if (!soup_uri_uses_default_port (soup_uri)) - soup_uri_set_port (uri_tmp, port); + scheme = g_uri_get_scheme (uri); + uri_tmp = g_uri_build (g_uri_get_flags (uri), + g_strcmp0 (scheme, "https") == 0 ? "davs" : "dav", + g_uri_get_userinfo (uri), + g_uri_get_host (uri), + g_uri_get_port (uri), + g_uri_get_path (uri), + g_uri_get_query (uri), + g_uri_get_fragment (uri)); uri_webdav = uri_to_string_with_path (uri_tmp, WEBDAV_ENDPOINT); - soup_uri_free (uri_tmp); + g_uri_unref (uri_tmp); return uri_webdav; } @@ -140,7 +135,7 @@ build_object (GoaProvider *provider, gchar *uri_carddav; gchar *uri_webdav; GoaPasswordBased *password_based = NULL; - SoupURI *uri = NULL; + GUri *uri = NULL; gboolean accept_ssl_errors; gboolean calendar_enabled; gboolean contacts_enabled; @@ -176,9 +171,24 @@ build_object (GoaProvider *provider, account = goa_object_get_account (GOA_OBJECT (object)); identity = goa_account_get_identity (account); uri_string = g_key_file_get_string (key_file, group, "Uri", NULL); - uri = soup_uri_new (uri_string); + uri = g_uri_parse (uri_string, G_URI_FLAGS_ENCODED, NULL); if (uri != NULL) - soup_uri_set_user (uri, identity); + { + GUri *tmp_uri; + + tmp_uri = g_uri_build_with_user (g_uri_get_flags (uri), + g_uri_get_scheme (uri), + identity, + g_uri_get_password (uri), + g_uri_get_auth_params (uri), + g_uri_get_host (uri), + g_uri_get_port (uri), + g_uri_get_path (uri), + g_uri_get_query (uri), + g_uri_get_fragment (uri)); + g_uri_unref (uri); + uri = tmp_uri; + } accept_ssl_errors = g_key_file_get_boolean (key_file, group, "AcceptSslErrors", NULL); @@ -224,7 +234,7 @@ build_object (GoaProvider *provider, out: g_clear_object (&password_based); - g_clear_pointer (&uri, soup_uri_free); + g_clear_pointer (&uri, g_uri_unref); g_free (uri_string); return ret; } @@ -354,8 +364,11 @@ add_entry (GtkWidget *grid, static gchar * normalize_uri (const gchar *address, gchar **server) { - SoupURI *uri = NULL; + GUri *uri = NULL; + GUri *uri_tmp = NULL; const gchar *path; + const gchar *new_scheme; + gchar *new_path = NULL; gchar *ret = NULL; gchar *scheme = NULL; gchar *uri_string = NULL; @@ -384,48 +397,56 @@ normalize_uri (const gchar *address, gchar **server) else goto out; - uri = soup_uri_new (uri_string); + uri = g_uri_parse (uri_string, G_URI_FLAGS_ENCODED, NULL); if (uri == NULL) goto out; if (g_strcmp0 (scheme, "dav") == 0) - soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP); + new_scheme = "http"; else if (g_strcmp0 (scheme, "davs") == 0) - soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTPS); + new_scheme = "https"; + else + new_scheme = g_uri_get_scheme (uri); - path = soup_uri_get_path (uri); + path = g_uri_get_path (uri); if (!g_str_has_suffix (path, "/")) - { - gchar *new_path; - new_path = g_strconcat (path, "/", NULL); - soup_uri_set_path (uri, new_path); - path = soup_uri_get_path (uri); - g_free (new_path); - } + + uri_tmp = g_uri_build (g_uri_get_flags (uri), + new_scheme, + g_uri_get_userinfo (uri), + g_uri_get_host (uri), + g_uri_get_port (uri), + new_path ? new_path : path, + g_uri_get_query (uri), + g_uri_get_fragment (uri)); + g_free (new_path); + g_uri_unref (uri); + uri = uri_tmp; + path = g_uri_get_path (uri); if (server != NULL) { gchar *port_string; gchar *pretty_path; - guint port; + gint port; - port = soup_uri_get_port (uri); - port_string = g_strdup_printf (":%u", port); + port = g_uri_get_port (uri); + port_string = g_strdup_printf (":%d", port); pretty_path = g_strdup (path); pretty_path[strlen(pretty_path) - 1] = '\0'; - *server = g_strconcat (soup_uri_get_host (uri), (port == std_port) ? "" : port_string, pretty_path, NULL); + *server = g_strconcat (g_uri_get_host (uri), (port == std_port || port == -1) ? "" : port_string, pretty_path, NULL); g_free (port_string); g_free (pretty_path); } - ret = soup_uri_to_string (uri, FALSE); + ret = g_uri_to_string (uri); out: - g_clear_pointer (&uri, soup_uri_free); + g_clear_pointer (&uri, g_uri_unref); g_free (scheme); g_free (uri_string); return ret; diff --git a/src/goabackend/goawebview.c b/src/goabackend/goawebview.c index 2438e0cd..3df600ea 100644 --- a/src/goabackend/goawebview.c +++ b/src/goabackend/goawebview.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "goawebview.h" @@ -77,17 +76,17 @@ web_view_clear_notify_progress_cb (gpointer user_data) static char * web_view_create_loading_title (const gchar *url) { - SoupURI *uri; + GUri *uri; const gchar *hostname; gchar *title; g_return_val_if_fail (url != NULL && url[0] != '\0', NULL); - uri = soup_uri_new (url); - hostname = soup_uri_get_host (uri); + uri = g_uri_parse (url, G_URI_FLAGS_NONE, NULL); + hostname = g_uri_get_host (uri); /* translators: %s here is the address of the web page */ title = g_strdup_printf (_("Loading “%s”…"), hostname); - soup_uri_free (uri); + g_uri_unref (uri); return title; } -- GitLab From 93e05eae7d0cab8829d489587ad807c8bdb7a194 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 7 Jun 2021 18:28:42 +0200 Subject: [PATCH 02/11] Port to libsoup3 The port requires multiple version bumps: - WebKitGTK 4.1 - librest 1.0 It also requires a comprehensive set of changes to adjust to changes in the API of multiple projects. Original commit by: Carlos Garcia Campos Additional work by: Michael Catanzaro Additional work by: Milan Crha --- configure.ac | 8 +- meson.build | 8 +- src/daemon/goadaemon.c | 2 +- src/examples/lastfm-shout.c | 3 +- src/goabackend/goaewsclient.c | 200 +++++++++++++----------- src/goabackend/goaflickrprovider.c | 2 +- src/goabackend/goagoogleprovider.c | 2 +- src/goabackend/goahttpclient.c | 72 ++++++--- src/goabackend/goalastfmprovider.c | 28 ++-- src/goabackend/goaoauth2provider.c | 13 +- src/goabackend/goaoauthprovider.c | 25 ++- src/goabackend/goaoauthprovider.h | 2 +- src/goabackend/goarestproxy.h | 4 +- src/goabackend/goasouplogger.c | 33 +--- src/goabackend/goasouplogger.h | 3 - src/goabackend/goautils.c | 27 ++-- src/goabackend/goawindowsliveprovider.c | 2 +- 17 files changed, 233 insertions(+), 201 deletions(-) diff --git a/configure.ac b/configure.ac index 1bde1392..4e1fc3c3 100644 --- a/configure.ac +++ b/configure.ac @@ -113,15 +113,15 @@ if test "$enable_backend" != "no"; then AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) - PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, [javascriptcoregtk-4.0 >= 2.12.0]) + PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, [javascriptcoregtk-4.1 >= 2.33.1]) AC_SUBST(JAVASCRIPT_CORE_GTK_CFLAGS) AC_SUBST(JAVASCRIPT_CORE_GTK_LIBS) - PKG_CHECK_MODULES(WEBKIT_GTK, [webkit2gtk-4.0 >= 2.26.0]) + PKG_CHECK_MODULES(WEBKIT_GTK, [webkit2gtk-4.1 >= 2.33.1]) AC_SUBST(WEBKIT_GTK_CFLAGS) AC_SUBST(WEBKIT_GTK_LIBS) - PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.42]) + PKG_CHECK_MODULES(LIBSOUP, [libsoup-3.0 >= 2.99.8]) AC_SUBST(LIBSOUP_CFLAGS) AC_SUBST(LIBSOUP_LIBS) @@ -129,7 +129,7 @@ if test "$enable_backend" != "no"; then AC_SUBST(JSON_GLIB_CFLAGS) AC_SUBST(JSON_GLIB_LIBS) - PKG_CHECK_MODULES(REST, [rest-0.7]) + PKG_CHECK_MODULES(REST, [rest-1.0]) AC_SUBST(REST_CFLAGS) AC_SUBST(REST_LIBS) diff --git a/meson.build b/meson.build index c9f8c848..53edb13b 100644 --- a/meson.build +++ b/meson.build @@ -97,13 +97,13 @@ endif enable_goabackend = get_option('goabackend') if enable_goabackend gtk_dep = dependency('gtk+-3.0', version: '>= 3.19.12') - javascript_core_gtk_dep = dependency('javascriptcoregtk-4.0', version: '>= 2.12.0') + javascript_core_gtk_dep = dependency('javascriptcoregtk-4.1', version: '>= 2.33.1') json_glib_dep = dependency('json-glib-1.0') libsecret_dep = dependency('libsecret-1') - libsoup_dep = dependency('libsoup-2.4', version: '>= 2.42') + libsoup_dep = dependency('libsoup-3.0', version: '>= 2.99.8') libxml_dep = dependency('libxml-2.0') - rest_dep = dependency('rest-0.7') - webkit_gtk_dep = dependency('webkit2gtk-4.0', version: '>= 2.26.0') + rest_dep = dependency('rest-1.0') + webkit_gtk_dep = dependency('webkit2gtk-4.1', version: '>= 2.33.1') endif config_h.set('GOA_BACKEND_ENABLED', enable_goabackend) diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c index 564973e1..e04e0847 100644 --- a/src/daemon/goadaemon.c +++ b/src/daemon/goadaemon.c @@ -1494,7 +1494,7 @@ is_authorization_error (GError *error) g_return_val_if_fail (error != NULL, FALSE); ret = FALSE; - if (error->domain == REST_PROXY_ERROR || error->domain == SOUP_HTTP_ERROR) + if (error->domain == REST_PROXY_ERROR) { if (SOUP_STATUS_IS_CLIENT_ERROR (error->code)) ret = TRUE; diff --git a/src/examples/lastfm-shout.c b/src/examples/lastfm-shout.c index 7b50743a..08cdbfc0 100644 --- a/src/examples/lastfm-shout.c +++ b/src/examples/lastfm-shout.c @@ -22,8 +22,7 @@ #include #include -#include -#include +#include int main (int argc, char **argv) diff --git a/src/goabackend/goaewsclient.c b/src/goabackend/goaewsclient.c index 4d1330f5..4cb23581 100644 --- a/src/goabackend/goaewsclient.c +++ b/src/goabackend/goaewsclient.c @@ -61,6 +61,12 @@ goa_ews_client_new (void) /* ---------------------------------------------------------------------------------------------------- */ +typedef struct +{ + gchar *password; + gchar *username; +} AutodiscoverAuthData; + typedef struct { GCancellable *cancellable; @@ -71,13 +77,16 @@ typedef struct guint pending; gulong cancellable_id; xmlOutputBuffer *buf; + AutodiscoverAuthData *auth; } AutodiscoverData; -typedef struct +static void +ews_client_autodiscover_auth_data_free (AutodiscoverAuthData *auth) { - gchar *password; - gchar *username; -} AutodiscoverAuthData; + g_free (auth->password); + g_free (auth->username); + g_slice_free (AutodiscoverAuthData, auth); +} static void ews_client_autodiscover_data_free (gpointer user_data) @@ -92,22 +101,12 @@ ews_client_autodiscover_data_free (gpointer user_data) g_clear_error (&data->error); - /* soup_session_queue_message stole the references to data->msgs */ xmlOutputBufferClose (data->buf); + g_clear_pointer (&data->auth, ews_client_autodiscover_auth_data_free); g_object_unref (data->session); g_slice_free (AutodiscoverData, data); } -static void -ews_client_autodiscover_auth_data_free (gpointer data, GClosure *closure) -{ - AutodiscoverAuthData *auth = data; - - g_free (auth->password); - g_free (auth->username); - g_slice_free (AutodiscoverAuthData, auth); -} - static gboolean ews_client_check_node (const xmlNode *node, const gchar *name) { @@ -115,9 +114,8 @@ ews_client_check_node (const xmlNode *node, const gchar *name) return node->type == XML_ELEMENT_NODE && !g_strcmp0 ((gchar *) node->name, name); } -static void -ews_client_authenticate (SoupSession *session, - SoupMessage *msg, +static gboolean +ews_client_authenticate (SoupMessage *msg, SoupAuth *auth, gboolean retrying, gpointer user_data) @@ -125,26 +123,26 @@ ews_client_authenticate (SoupSession *session, AutodiscoverAuthData *data = user_data; if (retrying) - return; + return FALSE; soup_auth_authenticate (auth, data->username, data->password); + return TRUE; } -static void -ews_client_request_started (SoupSession *session, SoupMessage *msg, SoupSocket *socket, gpointer user_data) +static gboolean +ews_client_accept_certificate (SoupMessage *msg, GTlsCertificate *cert, GTlsCertificateFlags cert_flags, gpointer user_data) { AutodiscoverData *data; GTask *task = G_TASK (user_data); - GTlsCertificateFlags cert_flags; - g_debug ("goa_ews_client_autodiscover(): request started (%p)", msg); + g_debug ("goa_ews_client_autodiscover(): accept certificate for request (%p)", msg); data = (AutodiscoverData *) g_task_get_task_data (task); - if (!data->accept_ssl_errors - && soup_message_get_https_status (msg, NULL, &cert_flags) - && cert_flags != 0 - && data->error == NULL) + if (data->accept_ssl_errors || cert_flags == 0) + return TRUE; + + if (data->error == NULL) { goa_utils_set_error_ssl (&data->error, cert_flags); @@ -153,6 +151,8 @@ ews_client_request_started (SoupSession *session, SoupMessage *msg, SoupSocket * */ soup_session_abort (data->session); } + + return FALSE; } static void @@ -191,9 +191,25 @@ ews_client_autodiscover_parse_protocol (xmlNode *node) return as_url && oab_url; } +static gboolean +ews_client_autodiscover_complete_idle_cb (gpointer user_data) +{ + GTask *task = user_data; + AutodiscoverData *data = g_task_get_task_data (task); + + if (data->error != NULL) + g_task_return_error (task, g_steal_pointer (&data->error)); + else + g_task_return_boolean (task, TRUE); + + return G_SOURCE_REMOVE; +} + static void -ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) +ews_client_autodiscover_response_cb (SoupSession *session, GAsyncResult *result, gpointer user_data) { + SoupMessage *msg; + GBytes *body; GError *error = NULL; AutodiscoverData *data; GTask *task = G_TASK (user_data); @@ -204,7 +220,11 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo xmlDoc *doc; xmlNode *node; - g_debug ("goa_ews_client_autodiscover(): response (%p, %u)", msg, msg->status_code); + msg = soup_session_get_async_result_message (session, result); + + g_debug ("goa_ews_client_autodiscover(): response (%p, %u)", msg, soup_message_get_status (msg)); + + body = soup_session_send_and_read_finish (session, result, &error); data = (AutodiscoverData *) g_task_get_task_data (task); size = sizeof (data->msgs) / sizeof (data->msgs[0]); @@ -215,16 +235,19 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo break; } if (idx == size || data->pending == 0) - return; + { + g_bytes_unref (body); + g_clear_object (&error); + g_object_unref (task); + return; + } data->msgs[idx] = NULL; - status = msg->status_code; - - /* status == SOUP_STATUS_CANCELLED, if we are being aborted by the + /* G_IO_ERROR_CANCELLED, if we are being aborted by the * GCancellable, an SSL error or another message that was * successful. */ - if (status == SOUP_STATUS_CANCELLED) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { /* If we are being aborted by the GCancellable, then the * GTask is responsible for setting the GError automatically. @@ -235,21 +258,23 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo */ goto out; } - else if (status != SOUP_STATUS_OK) + + status = soup_message_get_status (msg); + if (status != SOUP_STATUS_OK || error) { - g_warning ("goa_ews_client_autodiscover() failed: %u — %s", msg->status_code, msg->reason_phrase); + g_warning ("goa_ews_client_autodiscover() failed: %u — %s", status, soup_message_get_reason_phrase (msg)); g_return_if_fail (data->error == NULL); - goa_utils_set_error_soup (&error, msg); + if (!error) + goa_utils_set_error_soup (&error, msg); goto out; } - soup_buffer_free (soup_message_body_flatten (SOUP_MESSAGE (msg)->response_body)); g_debug ("The response headers"); g_debug ("==================="); - g_debug ("%s", SOUP_MESSAGE (msg)->response_body->data); + g_debug ("%s", (char *)g_bytes_get_data (body, NULL)); - doc = xmlReadMemory (msg->response_body->data, msg->response_body->length, "autodiscover.xml", NULL, 0); + doc = xmlReadMemory (g_bytes_get_data (body, NULL), g_bytes_get_size (body), "autodiscover.xml", NULL, 0); if (doc == NULL) { g_set_error (&error, @@ -333,7 +358,7 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo /* The callback (ie. this function) will be invoked after we * have returned to the main loop. */ - soup_session_cancel_message (data->session, data->msgs[idx], SOUP_STATUS_CANCELLED); + g_cancellable_cancel (data->cancellable); } } @@ -360,10 +385,10 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo data->pending--; if (data->pending == 0) { - if (data->error != NULL) - g_task_return_error (task, g_steal_pointer (&data->error)); - else - g_task_return_boolean (task, TRUE); + /* This is required, to not free the SoupSession under its hands (as this callback is called under it) */ + GSource *idle_source = g_idle_source_new (); + g_source_set_callback (idle_source, ews_client_autodiscover_complete_idle_cb, g_object_ref (task), g_object_unref); + g_source_attach (idle_source, g_task_get_context (task)); } g_clear_error (&error); @@ -399,52 +424,56 @@ static void ews_client_post_restarted_cb (SoupMessage *msg, gpointer data) { xmlOutputBuffer *buf = data; + GBytes *body; /* In violation of RFC2616, libsoup will change a POST request to * a GET on receiving a 302 redirect. */ g_debug ("Working around libsoup bug with redirect"); - g_object_set (msg, SOUP_MESSAGE_METHOD, "POST", NULL); + g_object_set (msg, "method", "POST", NULL); - soup_message_set_request(msg, - "text/xml; charset=utf-8", - SOUP_MEMORY_COPY, #ifdef LIBXML2_NEW_BUFFER - (gchar *) xmlOutputBufferGetContent(buf), - xmlOutputBufferGetSize(buf)); + body = g_bytes_new (xmlOutputBufferGetContent (buf), xmlOutputBufferGetSize (buf)); #else - (gchar *) buf->buffer->content, - buf->buffer->use); + body = g_bytes_new (buf->buffer->content, buf->buffer->use); #endif + soup_message_set_request_body_from_bytes (msg, "text/xml; charset=utf-8", body); + g_bytes_unref (body); } static SoupMessage * -ews_client_create_msg_for_url (const gchar *url, xmlOutputBuffer *buf) +ews_client_create_msg_for_url (const gchar *url, xmlOutputBuffer *buf, AutodiscoverAuthData *auth, GTask *task) { SoupMessage *msg; + GBytes *body = NULL; msg = soup_message_new (buf != NULL ? "POST" : "GET", url); - soup_message_headers_append (msg->request_headers, "User-Agent", "libews/0.1"); + soup_message_headers_append (soup_message_get_request_headers (msg), + "User-Agent", "libews/0.1"); + + g_signal_connect (msg, "authenticate", + G_CALLBACK (ews_client_authenticate), + auth); + g_signal_connect (msg, "accept-certificate", + G_CALLBACK (ews_client_accept_certificate), + task); if (buf != NULL) { - soup_message_set_request (msg, - "text/xml; charset=utf-8", - SOUP_MEMORY_COPY, #ifdef LIBXML2_NEW_BUFFER - (gchar *) xmlOutputBufferGetContent(buf), - xmlOutputBufferGetSize(buf)); + body = g_bytes_new (xmlOutputBufferGetContent (buf), xmlOutputBufferGetSize (buf)); #else - (gchar *) buf->buffer->content, - buf->buffer->use); + body = g_bytes_new (buf->buffer->content, buf->buffer->use); #endif + soup_message_set_request_body_from_bytes (msg, "text/xml; charset=utf-8", body); g_signal_connect (msg, "restarted", G_CALLBACK (ews_client_post_restarted_cb), buf); } - soup_buffer_free (soup_message_body_flatten (SOUP_MESSAGE (msg)->request_body)); g_debug ("The request headers"); g_debug ("==================="); - g_debug ("%s", SOUP_MESSAGE (msg)->request_body->data); + g_debug ("%*.s", body ? (int) g_bytes_get_size (body) : 0, body ? (char *)g_bytes_get_data (body, NULL) : ""); + if (body) + g_bytes_unref (body); return msg; } @@ -497,12 +526,15 @@ goa_ews_client_autodiscover (GoaEwsClient *self, * (successful) one win. */ + auth = g_slice_new0 (AutodiscoverAuthData); + auth->username = g_strdup (username); + auth->password = g_strdup (password); + data->auth = auth; data->buf = buf; - data->msgs[0] = ews_client_create_msg_for_url (url1, buf); - data->msgs[1] = ews_client_create_msg_for_url (url2, buf); + data->msgs[0] = ews_client_create_msg_for_url (url1, buf, auth, task); + data->msgs[1] = ews_client_create_msg_for_url (url2, buf, auth, task); data->pending = sizeof (data->msgs) / sizeof (data->msgs[0]); - data->session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, FALSE, - NULL); + data->session = soup_session_new (); soup_session_add_feature_by_type (data->session, SOUP_TYPE_AUTH_NTLM); data->accept_ssl_errors = accept_ssl_errors; @@ -515,26 +547,18 @@ goa_ews_client_autodiscover (GoaEwsClient *self, NULL); } - auth = g_slice_new0 (AutodiscoverAuthData); - auth->username = g_strdup (username); - auth->password = g_strdup (password); - g_signal_connect_data (data->session, - "authenticate", - G_CALLBACK (ews_client_authenticate), - auth, - ews_client_autodiscover_auth_data_free, - 0); - - g_signal_connect (data->session, "request-started", G_CALLBACK (ews_client_request_started), task); - - soup_session_queue_message (data->session, - data->msgs[0], - ews_client_autodiscover_response_cb, - g_object_ref (task)); - soup_session_queue_message (data->session, - data->msgs[1], - ews_client_autodiscover_response_cb, - g_object_ref (task)); + soup_session_send_and_read_async (data->session, + data->msgs[0], + G_PRIORITY_DEFAULT, + data->cancellable, + (GAsyncReadyCallback)ews_client_autodiscover_response_cb, + g_object_ref (task)); + soup_session_send_and_read_async (data->session, + data->msgs[1], + G_PRIORITY_DEFAULT, + data->cancellable, + (GAsyncReadyCallback)ews_client_autodiscover_response_cb, + g_object_ref (task)); g_free (url2); g_free (url1); diff --git a/src/goabackend/goaflickrprovider.c b/src/goabackend/goaflickrprovider.c index 702ed1ea..4eb8c115 100644 --- a/src/goabackend/goaflickrprovider.c +++ b/src/goabackend/goaflickrprovider.c @@ -20,7 +20,7 @@ #include "config.h" #include -#include +#include #include #include "goaprovider.h" diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c index d8abf1c8..7d4cd306 100644 --- a/src/goabackend/goagoogleprovider.c +++ b/src/goabackend/goagoogleprovider.c @@ -19,7 +19,7 @@ #include "config.h" #include -#include +#include #include #include "goaprovider.h" diff --git a/src/goabackend/goahttpclient.c b/src/goabackend/goahttpclient.c index 81aa52d0..3b6857d0 100644 --- a/src/goabackend/goahttpclient.c +++ b/src/goabackend/goahttpclient.c @@ -82,7 +82,7 @@ http_client_check_data_free (gpointer user_data) g_clear_error (&data->error); - /* soup_session_queue_message stole the references to data->msg */ + g_object_unref (data->msg); g_object_unref (data->session); g_slice_free (CheckData, data); } @@ -97,9 +97,8 @@ http_client_check_auth_data_free (gpointer data, GClosure *closure) g_slice_free (CheckAuthData, auth); } -static void -http_client_authenticate (SoupSession *session, - SoupMessage *msg, +static gboolean +http_client_authenticate (SoupMessage *msg, SoupAuth *auth, gboolean retrying, gpointer user_data) @@ -107,26 +106,26 @@ http_client_authenticate (SoupSession *session, CheckAuthData *data = user_data; if (retrying) - return; + return FALSE; soup_auth_authenticate (auth, data->username, data->password); + return TRUE; } -static void -http_client_request_started (SoupSession *session, SoupMessage *msg, SoupSocket *socket, gpointer user_data) +static gboolean +http_client_accept_certificate (SoupMessage *msg, GTlsCertificate *cert, GTlsCertificateFlags cert_flags, gpointer user_data) { CheckData *data; GTask *task = G_TASK (user_data); - GTlsCertificateFlags cert_flags; g_debug ("goa_http_client_check(): request started (%p)", msg); data = (CheckData *) g_task_get_task_data (task); - if (!data->accept_ssl_errors - && soup_message_get_https_status (msg, NULL, &cert_flags) - && cert_flags != 0 - && data->error == NULL) + if (data->accept_ssl_errors || cert_flags == 0) + return TRUE; + + if (data->error == NULL) { goa_utils_set_error_ssl (&data->error, cert_flags); @@ -135,6 +134,8 @@ http_client_request_started (SoupSession *session, SoupMessage *msg, SoupSocket */ soup_session_abort (data->session); } + + return FALSE; } static void @@ -154,21 +155,27 @@ http_client_check_cancelled_cb (GCancellable *cancellable, gpointer user_data) } static void -http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) +http_client_check_response_cb (SoupSession *session, GAsyncResult *result, gpointer user_data) { + SoupMessage *msg; CheckData *data; - GCancellable *cancellable; GTask *task = G_TASK (user_data); + guint status; + GBytes *body; + GError *error = NULL; + + msg = soup_session_get_async_result_message (session, result); + + g_debug ("goa_http_client_check(): response (%p, %u)", msg, soup_message_get_status (msg)); - g_debug ("goa_http_client_check(): response (%p, %u)", msg, msg->status_code); + body = soup_session_send_and_read_finish (session, result, &error); data = (CheckData *) g_task_get_task_data (task); - cancellable = g_task_get_cancellable (task); - /* status == SOUP_STATUS_CANCELLED, if we are being aborted by the + /* G_IO_ERROR_CANCELLED, if we are being aborted by the * GCancellable or due to an SSL error. */ - if (msg->status_code == SOUP_STATUS_CANCELLED) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { /* If we are being aborted by the GCancellable then there might * or might not be an error. The GCancellable can be triggered @@ -176,20 +183,27 @@ http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer * of events across threads. */ if (data->error == NULL) - g_cancellable_set_error_if_cancelled (cancellable, &data->error); + g_propagate_error (&data->error, g_steal_pointer (&error)); goto out; } - else if (msg->status_code != SOUP_STATUS_OK) + + status = soup_message_get_status (msg); + if (status != SOUP_STATUS_OK || error) { - g_warning ("goa_http_client_check() failed: %u — %s", msg->status_code, msg->reason_phrase); + g_warning ("goa_http_client_check() failed: %u — %s", status, soup_message_get_reason_phrase (msg)); g_return_if_fail (data->error == NULL); - goa_utils_set_error_soup (&data->error, msg); + if (error) + g_propagate_error (&data->error, g_steal_pointer (&error)); + else + goa_utils_set_error_soup (&data->error, msg); goto out; } out: + g_clear_error (&error); + g_clear_pointer (&body, g_bytes_unref); if (data->error != NULL) g_task_return_error (task, g_steal_pointer (&data->error)); else @@ -225,7 +239,7 @@ goa_http_client_check (GoaHttpClient *self, data = g_slice_new0 (CheckData); g_task_set_task_data (task, data, http_client_check_data_free); - data->session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, FALSE, NULL); + data->session = soup_session_new (); logger = goa_soup_logger_new (SOUP_LOGGER_LOG_BODY, -1); soup_session_add_feature (data->session, SOUP_SESSION_FEATURE (logger)); @@ -246,15 +260,21 @@ goa_http_client_check (GoaHttpClient *self, auth = g_slice_new0 (CheckAuthData); auth->username = g_strdup (username); auth->password = g_strdup (password); - g_signal_connect_data (data->session, + g_signal_connect_data (data->msg, "authenticate", G_CALLBACK (http_client_authenticate), auth, http_client_check_auth_data_free, 0); - g_signal_connect (data->session, "request-started", G_CALLBACK (http_client_request_started), task); - soup_session_queue_message (data->session, data->msg, http_client_check_response_cb, g_object_ref (task)); + g_signal_connect (data->msg, "accept-certificate", G_CALLBACK (http_client_accept_certificate), task); + + soup_session_send_and_read_async (data->session, + data->msg, + G_PRIORITY_DEFAULT, + data->cancellable, + (GAsyncReadyCallback)http_client_check_response_cb, + g_object_ref (task)); g_object_unref (task); } diff --git a/src/goabackend/goalastfmprovider.c b/src/goabackend/goalastfmprovider.c index cb9a6f26..15a2d745 100644 --- a/src/goabackend/goalastfmprovider.c +++ b/src/goabackend/goalastfmprovider.c @@ -19,7 +19,7 @@ #include "config.h" #include -#include +#include #include #include "goahttpclient.h" @@ -483,18 +483,18 @@ add_account_cb (GoaManager *manager, GAsyncResult *res, gpointer user_data) static void check_cb (RestProxyCall *call, - const GError *error, - GObject *weak_object, + GAsyncResult *result, gpointer user_data) { AddAccountData *data = user_data; JsonNode *session; - JsonParser *parser; + JsonParser *parser = NULL; JsonObject *json_obj; JsonObject *session_obj; const gchar *payload; - parser = NULL; + if (!rest_proxy_call_invoke_finish (call, result, &data->error)) + goto out; parser = json_parser_new (); payload = rest_proxy_call_get_payload (call); @@ -562,12 +562,12 @@ on_rest_proxy_call_cancelled_cb (GCancellable *cancellable, RestProxyCall *call) } static void -lastfm_login (GoaProvider *provider, - const gchar *username, - const gchar *password, - GCancellable *cancellable, - RestProxyCallAsyncCallback callback, - gpointer user_data) +lastfm_login (GoaProvider *provider, + const gchar *username, + const gchar *password, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { AddAccountData *data = user_data; RestProxyCall *call; @@ -598,7 +598,7 @@ lastfm_login (GoaProvider *provider, rest_proxy_call_add_param (call, "api_sig", sig_md5); rest_proxy_call_add_param (call, "format", "json"); - rest_proxy_call_async (call, callback, NULL, data, &data->error); + rest_proxy_call_invoke_async (call, NULL, callback, data); g_signal_connect (cancellable, "cancelled", G_CALLBACK (on_rest_proxy_call_cancelled_cb), call); @@ -665,7 +665,7 @@ add_account (GoaProvider *provider, username, password, data.cancellable, - (RestProxyCallAsyncCallback) check_cb, + (GAsyncReadyCallback) check_cb, &data); gtk_widget_set_sensitive (data.connect_button, FALSE); @@ -819,7 +819,7 @@ refresh_account (GoaProvider *provider, username, password, data.cancellable, - (RestProxyCallAsyncCallback) check_cb, + (GAsyncReadyCallback) check_cb, &data); gtk_widget_set_sensitive (data.connect_button, FALSE); gtk_widget_show (data.progress_grid); diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c index 2757838b..5b8d43de 100644 --- a/src/goabackend/goaoauth2provider.c +++ b/src/goabackend/goaoauth2provider.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -95,11 +95,15 @@ is_authorization_error (GError *error) g_return_val_if_fail (error != NULL, FALSE); ret = FALSE; - if (error->domain == REST_PROXY_ERROR || error->domain == SOUP_HTTP_ERROR) + if (error->domain == REST_PROXY_ERROR) { if (SOUP_STATUS_IS_CLIENT_ERROR (error->code)) ret = TRUE; } + else if (g_error_matches (error, GOA_ERROR, GOA_ERROR_NOT_AUTHORIZED)) + { + ret = TRUE; + } return ret; } @@ -763,7 +767,7 @@ on_web_view_decide_policy (WebKitWebView *web_view, GHashTable *key_value_pairs; WebKitNavigationAction *action; WebKitURIRequest *request; - GUri *uri; + GUri *uri = NULL; const gchar *fragment; const gchar *oauth2_error; const gchar *query; @@ -889,7 +893,8 @@ on_web_view_decide_policy (WebKitWebView *web_view, goto ignore_request; ignore_request: - g_uri_unref (uri); + if (uri) + g_uri_unref (uri); g_assert (response_id != GTK_RESPONSE_NONE); if (response_id < 0) gtk_dialog_response (priv->dialog, response_id); diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c index ff0927ef..8c2e0f27 100644 --- a/src/goabackend/goaoauthprovider.c +++ b/src/goabackend/goaoauthprovider.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -77,11 +77,15 @@ is_authorization_error (GError *error) g_return_val_if_fail (error != NULL, FALSE); ret = FALSE; - if (error->domain == REST_PROXY_ERROR || error->domain == SOUP_HTTP_ERROR) + if (error->domain == REST_PROXY_ERROR) { if (SOUP_STATUS_IS_CLIENT_ERROR (error->code)) ret = TRUE; } + else if (g_error_matches (error, GOA_ERROR, GOA_ERROR_NOT_AUTHORIZED)) + { + ret = TRUE; + } return ret; } @@ -701,9 +705,15 @@ on_web_view_decide_policy (WebKitWebView *web_view, } static void -rest_proxy_call_cb (RestProxyCall *call, const GError *error, GObject *weak_object, gpointer user_data) +rest_proxy_call_cb (GObject *source, GAsyncResult *result, gpointer user_data) { + RestProxyCall *call = REST_PROXY_CALL (source); IdentifyData *data = user_data; + + if (!rest_proxy_call_invoke_finish (call, result, &data->error)) + { + g_prefix_error (&data->error, _("Error getting a Request Token: ")); + } g_main_loop_quit (data->loop); } @@ -770,11 +780,7 @@ get_tokens_and_identity (GoaOAuthProvider *provider, for (n = 0; request_params[n] != NULL; n += 2) rest_proxy_call_add_param (call, request_params[n], request_params[n+1]); } - if (!rest_proxy_call_async (call, rest_proxy_call_cb, NULL, &data, &data.error)) - { - g_prefix_error (&data.error, _("Error getting a Request Token: ")); - goto out; - } + rest_proxy_call_invoke_async (call, NULL, rest_proxy_call_cb, &data); goa_utils_set_dialog_title (GOA_PROVIDER (provider), dialog, add_account); @@ -796,6 +802,9 @@ get_tokens_and_identity (GoaOAuthProvider *provider, g_main_loop_run (data.loop); gtk_container_remove (GTK_CONTAINER (grid), spinner); + if (data.error) + goto out; + if (rest_proxy_call_get_status_code (call) != 200) { gchar *msg; diff --git a/src/goabackend/goaoauthprovider.h b/src/goabackend/goaoauthprovider.h index d4ffa3cd..e42f7a5e 100644 --- a/src/goabackend/goaoauthprovider.h +++ b/src/goabackend/goaoauthprovider.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include G_BEGIN_DECLS diff --git a/src/goabackend/goarestproxy.h b/src/goabackend/goarestproxy.h index 09fb0762..0241e65e 100644 --- a/src/goabackend/goarestproxy.h +++ b/src/goabackend/goarestproxy.h @@ -23,12 +23,10 @@ #ifndef __GOA_REST_PROXY_H__ #define __GOA_REST_PROXY_H__ -#include +#include G_BEGIN_DECLS -G_DEFINE_AUTOPTR_CLEANUP_FUNC (RestProxy, g_object_unref); - #define GOA_TYPE_REST_PROXY (goa_rest_proxy_get_type ()) G_DECLARE_FINAL_TYPE (GoaRestProxy, goa_rest_proxy, GOA, REST_PROXY, RestProxy); diff --git a/src/goabackend/goasouplogger.c b/src/goabackend/goasouplogger.c index 9b0a53d1..330b6a90 100644 --- a/src/goabackend/goasouplogger.c +++ b/src/goabackend/goasouplogger.c @@ -22,15 +22,6 @@ #include "goasouplogger.h" -struct _GoaSoupLogger -{ - SoupLogger parent_instance; -}; - -G_DEFINE_TYPE (GoaSoupLogger, goa_soup_logger, SOUP_TYPE_LOGGER); - -/* ---------------------------------------------------------------------------------------------------- */ - static void goa_soup_logger_printer (SoupLogger *logger, SoupLoggerLogLevel level, @@ -45,24 +36,16 @@ goa_soup_logger_printer (SoupLogger *logger, g_free (message); } -/* ---------------------------------------------------------------------------------------------------- */ - -static void -goa_soup_logger_init (GoaSoupLogger *self) -{ - soup_logger_set_printer (SOUP_LOGGER (self), goa_soup_logger_printer, NULL, NULL); -} - -static void -goa_soup_logger_class_init (GoaSoupLoggerClass *klass) -{ -} - -/* ---------------------------------------------------------------------------------------------------- */ - SoupLogger * goa_soup_logger_new (SoupLoggerLogLevel level, gint max_body_size) { - return g_object_new (GOA_TYPE_SOUP_LOGGER, "level", level, "max-body-size", max_body_size, NULL); + SoupLogger *logger; + + logger = soup_logger_new (level); + if (max_body_size != -1) + soup_logger_set_max_body_size (logger, max_body_size); + soup_logger_set_printer (logger, goa_soup_logger_printer, NULL, NULL); + + return logger; } diff --git a/src/goabackend/goasouplogger.h b/src/goabackend/goasouplogger.h index 4a997854..6929dc07 100644 --- a/src/goabackend/goasouplogger.h +++ b/src/goabackend/goasouplogger.h @@ -27,9 +27,6 @@ G_BEGIN_DECLS -#define GOA_TYPE_SOUP_LOGGER (goa_soup_logger_get_type ()) -G_DECLARE_FINAL_TYPE (GoaSoupLogger, goa_soup_logger, GOA, SOUP_LOGGER, SoupLogger); - SoupLogger *goa_soup_logger_new (SoupLoggerLogLevel level, gint max_body_size); diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c index b23a2585..70d66a6e 100644 --- a/src/goabackend/goautils.c +++ b/src/goabackend/goautils.c @@ -841,29 +841,26 @@ goa_utils_set_error_soup (GError **err, SoupMessage *msg) { gchar *error_msg = NULL; gint error_code = GOA_ERROR_FAILED; /* TODO: more specific */ + guint status_code; - switch (msg->status_code) + status_code = soup_message_get_status (msg); + switch (status_code) { - case SOUP_STATUS_CANT_RESOLVE: - error_msg = g_strdup (_("Cannot resolve hostname")); - break; - - case SOUP_STATUS_CANT_RESOLVE_PROXY: - error_msg = g_strdup (_("Cannot resolve proxy hostname")); - break; - case SOUP_STATUS_INTERNAL_SERVER_ERROR: case SOUP_STATUS_NOT_FOUND: error_msg = g_strdup (_("Cannot find WebDAV endpoint")); break; - case SOUP_STATUS_UNAUTHORIZED: - error_msg = g_strdup (_("Authentication failed")); - error_code = GOA_ERROR_NOT_AUTHORIZED; - break; - default: - error_msg = g_strdup_printf (_("Code: %u — Unexpected response from server"), msg->status_code); + if (SOUP_STATUS_IS_CLIENT_ERROR (status_code)) + { + error_msg = g_strdup (_("Authentication failed")); + error_code = GOA_ERROR_NOT_AUTHORIZED; + } + else + { + error_msg = g_strdup_printf (_("Code: %u — Unexpected response from server"), status_code); + } break; } diff --git a/src/goabackend/goawindowsliveprovider.c b/src/goabackend/goawindowsliveprovider.c index be357465..608767a3 100644 --- a/src/goabackend/goawindowsliveprovider.c +++ b/src/goabackend/goawindowsliveprovider.c @@ -20,7 +20,7 @@ #include "config.h" #include -#include +#include #include #include "goaprovider.h" -- GitLab From 2a04648e7e9df543d21d3340316511f8320be23a Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Tue, 19 Apr 2022 11:43:24 -0500 Subject: [PATCH 03/11] ci: use Arch Linux This provides webkit2gtk3-4.1, which is not available from Fedora. I tried using Ubuntu first, but that's missing the latest librest. Arch has them both already. Good job, Arch! --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2510a3e1..c83d7857 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,14 +2,14 @@ stages: - build build-meson: - image: fedora:latest + image: archlinux:latest stage: build before_script: - - dnf update -y - - dnf -y install - meson gcc dbus-devel gcr-devel glib2-devel gobject-introspection-devel - gtk-doc gtk3-devel json-glib-devel krb5-devel libsecret-devel - libsoup-devel rest-devel vala webkit2gtk3-devel + - pacman -Syu --noconfirm + - pacman -S --noconfirm + meson gcc dbus gcr glib2 gobject-introspection + gtk-doc gtk3 json-glib krb5 libsecret + libsoup3 librest vala webkit2gtk-4.1 script: - meson setup -Dgtk_doc=true _build - meson compile -C _build -- GitLab From 0fce48da91c52cdcda22d329427173f8fbd97ae0 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 11:40:55 +0100 Subject: [PATCH 04/11] Update the required version of Meson Meson 0.50 is positively ancient, and we're getting deprecation warnings when building with reasonably more recent versions. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 53edb13b..3c199ce0 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( version: '3.45.1', license: 'LGPL2+', default_options: 'buildtype=debugoptimized', - meson_version: '>= 0.50.0' + meson_version: '>= 0.56.0' ) goa_name = 'goa' -- GitLab From 2ac5dec3e847387dde7c09f118dcfbc8b30df5d7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 11:45:51 +0100 Subject: [PATCH 05/11] build: Replace deprecated get_pkgconfig_variable method Use the generic get_variable() method instead. --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 3c199ce0..80a17d8d 100644 --- a/meson.build +++ b/meson.build @@ -83,8 +83,8 @@ gio_unix_dep = dependency('gio-unix-2.0', version: glib_req_version) glib_dep = dependency('glib-2.0', version: glib_req_version) dbus_dep = dependency('dbus-1') -dbus_service_dir = dbus_dep.get_pkgconfig_variable('session_bus_services_dir', - define_variable: ['datadir', goa_datadir]) +dbus_service_dir = dbus_dep.get_variable(pkgconfig: 'session_bus_services_dir', + pkgconfig_define: ['datadir', goa_datadir]) # Libraries # introspection support -- GitLab From 7d5b523c18f4ca7a488f3d46b1492dc2966dc5d3 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 12:46:03 +0100 Subject: [PATCH 06/11] Add libsoup3 and librest-1.0 as subprojects This avoids issues like depending on distribution quirks. --- meson.build | 8 ++++++-- subprojects/.gitignore | 2 ++ subprojects/librest.wrap | 4 ++++ subprojects/libsoup.wrap | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 subprojects/.gitignore create mode 100644 subprojects/librest.wrap create mode 100644 subprojects/libsoup.wrap diff --git a/meson.build b/meson.build index 80a17d8d..791c3d4e 100644 --- a/meson.build +++ b/meson.build @@ -100,9 +100,13 @@ if enable_goabackend javascript_core_gtk_dep = dependency('javascriptcoregtk-4.1', version: '>= 2.33.1') json_glib_dep = dependency('json-glib-1.0') libsecret_dep = dependency('libsecret-1') - libsoup_dep = dependency('libsoup-3.0', version: '>= 2.99.8') + libsoup_dep = dependency('libsoup-3.0', version: '>= 3.0', fallback: ['libsoup']) libxml_dep = dependency('libxml-2.0') - rest_dep = dependency('rest-1.0') + rest_dep = dependency('rest-1.0', + version: '>= 0.9.0', + fallback: ['librest', 'librest_dep'], + default_options: ['soup2=false'], + ) webkit_gtk_dep = dependency('webkit2gtk-4.1', version: '>= 2.33.1') endif config_h.set('GOA_BACKEND_ENABLED', enable_goabackend) diff --git a/subprojects/.gitignore b/subprojects/.gitignore new file mode 100644 index 00000000..feddb5df --- /dev/null +++ b/subprojects/.gitignore @@ -0,0 +1,2 @@ +librest/ +libsoup/ diff --git a/subprojects/librest.wrap b/subprojects/librest.wrap new file mode 100644 index 00000000..d5219a00 --- /dev/null +++ b/subprojects/librest.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory=librest +url=https://gitlab.gnome.org/gnome/librest.git +revision=master diff --git a/subprojects/libsoup.wrap b/subprojects/libsoup.wrap new file mode 100644 index 00000000..812076d1 --- /dev/null +++ b/subprojects/libsoup.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory=libsoup +url=https://gitlab.gnome.org/gnome/libsoup.git +revision=master -- GitLab From 153f3ab5eb629aa5dae212a642d0ee772ea3664a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 12:47:06 +0100 Subject: [PATCH 07/11] ci: Force building librest as a subproject We need the latest version from the Git repository, as the packaged snapshot is not enough. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c83d7857..71067558 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ build-meson: - pacman -S --noconfirm meson gcc dbus gcr glib2 gobject-introspection gtk-doc gtk3 json-glib krb5 libsecret - libsoup3 librest vala webkit2gtk-4.1 + libsoup3 vala webkit2gtk-4.1 script: - meson setup -Dgtk_doc=true _build - meson compile -C _build -- GitLab From 5da0c7688e3ba85dbd3628ebef661c78d907fad7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 12:50:57 +0100 Subject: [PATCH 08/11] ci: Add git to the installed packages --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71067558..eec22f4a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ build-meson: before_script: - pacman -Syu --noconfirm - pacman -S --noconfirm - meson gcc dbus gcr glib2 gobject-introspection + meson git gcc dbus gcr glib2 gobject-introspection gtk-doc gtk3 json-glib krb5 libsecret libsoup3 vala webkit2gtk-4.1 script: -- GitLab From ed05825b0ee3907cb4b462400988024a05d82bb2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 12:56:48 +0100 Subject: [PATCH 09/11] build: Disable librest examples When building as a subproject we don't need examples, especially examples that depend on libadwaita. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 791c3d4e..ecdb4eeb 100644 --- a/meson.build +++ b/meson.build @@ -105,7 +105,7 @@ if enable_goabackend rest_dep = dependency('rest-1.0', version: '>= 0.9.0', fallback: ['librest', 'librest_dep'], - default_options: ['soup2=false'], + default_options: ['soup2=false', 'examples=false'], ) webkit_gtk_dep = dependency('webkit2gtk-4.1', version: '>= 2.33.1') endif -- GitLab From 4a631c6a361dca393000cebf92cd132aa715d1b3 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 13:00:28 +0100 Subject: [PATCH 10/11] build: Disable librest docs --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ecdb4eeb..1a939445 100644 --- a/meson.build +++ b/meson.build @@ -105,7 +105,7 @@ if enable_goabackend rest_dep = dependency('rest-1.0', version: '>= 0.9.0', fallback: ['librest', 'librest_dep'], - default_options: ['soup2=false', 'examples=false'], + default_options: ['soup2=false', 'examples=false', 'gtk_doc=false'], ) webkit_gtk_dep = dependency('webkit2gtk-4.1', version: '>= 2.33.1') endif -- GitLab From 3842d29fa402925a56a13e3b2f5d969d19b60e1b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Jun 2022 21:09:41 +0100 Subject: [PATCH 11/11] build: Disable librest tests We assume librest is going to be tested. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 1a939445..72ad8ba3 100644 --- a/meson.build +++ b/meson.build @@ -105,7 +105,7 @@ if enable_goabackend rest_dep = dependency('rest-1.0', version: '>= 0.9.0', fallback: ['librest', 'librest_dep'], - default_options: ['soup2=false', 'examples=false', 'gtk_doc=false'], + default_options: ['soup2=false', 'examples=false', 'tests=false', 'gtk_doc=false'], ) webkit_gtk_dep = dependency('webkit2gtk-4.1', version: '>= 2.33.1') endif -- GitLab