summaryrefslogtreecommitdiffstats
path: root/meta-gnome/recipes-gnome/gnome-online-accounts/files
diff options
context:
space:
mode:
Diffstat (limited to 'meta-gnome/recipes-gnome/gnome-online-accounts/files')
-rw-r--r--meta-gnome/recipes-gnome/gnome-online-accounts/files/0001-Use-GUri-instead-of-SoupURI.patch351
-rw-r--r--meta-gnome/recipes-gnome/gnome-online-accounts/files/0002-Port-to-libsoup3.patch841
2 files changed, 1192 insertions, 0 deletions
diff --git a/meta-gnome/recipes-gnome/gnome-online-accounts/files/0001-Use-GUri-instead-of-SoupURI.patch b/meta-gnome/recipes-gnome/gnome-online-accounts/files/0001-Use-GUri-instead-of-SoupURI.patch
new file mode 100644
index 000000000..11fc96bc2
--- /dev/null
+++ b/meta-gnome/recipes-gnome/gnome-online-accounts/files/0001-Use-GUri-instead-of-SoupURI.patch
@@ -0,0 +1,351 @@
1From 5a5abbedb171986dbf6f5a37577ec6afa892b66b Mon Sep 17 00:00:00 2001
2From: Carlos Garcia Campos <cgarcia@igalia.com>
3Date: Mon, 7 Jun 2021 16:31:18 +0200
4Subject: [PATCH 1/2] Use GUri instead of SoupURI
5
6In preparation for libsoup3 where SoupURI has been removed in favor of
7GUri.
8
9Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/gnome-online-accounts/-/merge_requests/73]
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 configure.ac | 2 +-
13 src/goabackend/goaoauth2provider.c | 11 +--
14 src/goabackend/goaoauthprovider.c | 8 +-
15 src/goabackend/goaowncloudprovider.c | 107 ++++++++++++++++-----------
16 src/goabackend/goawebview.c | 9 +--
17 5 files changed, 80 insertions(+), 57 deletions(-)
18
19diff --git a/configure.ac b/configure.ac
20index 1f88bbd..7c0b39d 100644
21--- a/configure.ac
22+++ b/configure.ac
23@@ -90,7 +90,7 @@ GTK_DOC_CHECK([1.3])
24 # Libraries
25 #
26
27-PKG_CHECK_MODULES(GLIB, [glib-2.0 gio-2.0 gio-unix-2.0 >= 2.52])
28+PKG_CHECK_MODULES(GLIB, [glib-2.0 gio-2.0 gio-unix-2.0 >= 2.67.4])
29 AC_SUBST(GLIB_CFLAGS)
30 AC_SUBST(GLIB_LIBS)
31
32diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
33index 3715431..2757838 100644
34--- a/src/goabackend/goaoauth2provider.c
35+++ b/src/goabackend/goaoauth2provider.c
36@@ -763,7 +763,7 @@ on_web_view_decide_policy (WebKitWebView *web_view,
37 GHashTable *key_value_pairs;
38 WebKitNavigationAction *action;
39 WebKitURIRequest *request;
40- SoupURI *uri;
41+ GUri *uri;
42 const gchar *fragment;
43 const gchar *oauth2_error;
44 const gchar *query;
45@@ -793,9 +793,9 @@ on_web_view_decide_policy (WebKitWebView *web_view,
46 if (!g_str_has_prefix (requested_uri, redirect_uri))
47 goto default_behaviour;
48
49- uri = soup_uri_new (requested_uri);
50- fragment = soup_uri_get_fragment (uri);
51- query = soup_uri_get_query (uri);
52+ uri = g_uri_parse (requested_uri, G_URI_FLAGS_ENCODED, NULL);
53+ fragment = g_uri_get_fragment (uri);
54+ query = g_uri_get_query (uri);
55
56 /* Three cases:
57 * 1) we can either have the backend handle the URI for us, or
58@@ -808,7 +808,7 @@ on_web_view_decide_policy (WebKitWebView *web_view,
59 {
60 gchar *url;
61
62- url = soup_uri_to_string (uri, FALSE);
63+ url = g_uri_to_string (uri);
64 if (!goa_oauth2_provider_process_redirect_url (self, url, &priv->access_token, &priv->error))
65 {
66 g_prefix_error (&priv->error, _("Authorization response: "));
67@@ -889,6 +889,7 @@ on_web_view_decide_policy (WebKitWebView *web_view,
68 goto ignore_request;
69
70 ignore_request:
71+ g_uri_unref (uri);
72 g_assert (response_id != GTK_RESPONSE_NONE);
73 if (response_id < 0)
74 gtk_dialog_response (priv->dialog, response_id);
75diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c
76index 0bfab6b..ff0927e 100644
77--- a/src/goabackend/goaoauthprovider.c
78+++ b/src/goabackend/goaoauthprovider.c
79@@ -643,7 +643,7 @@ on_web_view_decide_policy (WebKitWebView *web_view,
80 {
81 GHashTable *key_value_pairs;
82 IdentifyData *data = user_data;
83- SoupURI *uri;
84+ GUri *uri;
85 WebKitNavigationAction *action;
86 WebKitURIRequest *request;
87 const gchar *query;
88@@ -664,8 +664,8 @@ on_web_view_decide_policy (WebKitWebView *web_view,
89 if (!g_str_has_prefix (requested_uri, redirect_uri))
90 goto default_behaviour;
91
92- uri = soup_uri_new (requested_uri);
93- query = soup_uri_get_query (uri);
94+ uri = g_uri_parse (requested_uri, G_URI_FLAGS_ENCODED, NULL);
95+ query = g_uri_get_query (uri);
96
97 if (query != NULL)
98 {
99@@ -678,6 +678,8 @@ on_web_view_decide_policy (WebKitWebView *web_view,
100 g_hash_table_unref (key_value_pairs);
101 }
102
103+ g_uri_unref (uri);
104+
105 if (data->oauth_verifier != NULL)
106 goto ignore_request;
107
108diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
109index d142966..10734be 100644
110--- a/src/goabackend/goaowncloudprovider.c
111+++ b/src/goabackend/goaowncloudprovider.c
112@@ -22,8 +22,6 @@
113
114 #include <glib/gi18n-lib.h>
115
116-#include <libsoup/soup.h>
117-
118 #include "goahttpclient.h"
119 #include "goaprovider.h"
120 #include "goaowncloudprovider.h"
121@@ -78,45 +76,42 @@ get_provider_features (GoaProvider *provider)
122 /* ---------------------------------------------------------------------------------------------------- */
123
124 static char *
125-uri_to_string_with_path (SoupURI *soup_uri, const gchar *path)
126+uri_to_string_with_path (GUri *uri, const gchar *path)
127 {
128 gchar *uri_string;
129 gchar *uri_tmp;
130
131- if (soup_uri == NULL)
132+ if (uri == NULL)
133 return NULL;
134
135- uri_tmp = soup_uri_to_string (soup_uri, FALSE);
136+ uri_tmp = g_uri_to_string (uri);
137 uri_string = g_strconcat (uri_tmp, path, NULL);
138 g_free (uri_tmp);
139
140 return uri_string;
141 }
142
143-static char *get_webdav_uri (SoupURI *soup_uri)
144+static char *get_webdav_uri (GUri *uri)
145 {
146- SoupURI *uri_tmp;
147+ GUri *uri_tmp;
148 gchar *uri_webdav;
149 const gchar *scheme;
150- guint port;
151
152- if (soup_uri == NULL)
153+ if (uri == NULL)
154 return NULL;
155
156- scheme = soup_uri_get_scheme (soup_uri);
157- port = soup_uri_get_port (soup_uri);
158- uri_tmp = soup_uri_copy (soup_uri);
159-
160- if (g_strcmp0 (scheme, SOUP_URI_SCHEME_HTTPS) == 0)
161- soup_uri_set_scheme (uri_tmp, "davs");
162- else
163- soup_uri_set_scheme (uri_tmp, "dav");
164-
165- if (!soup_uri_uses_default_port (soup_uri))
166- soup_uri_set_port (uri_tmp, port);
167+ scheme = g_uri_get_scheme (uri);
168+ uri_tmp = g_uri_build (g_uri_get_flags (uri),
169+ g_strcmp0 (scheme, "https") == 0 ? "davs" : "dav",
170+ g_uri_get_userinfo (uri),
171+ g_uri_get_host (uri),
172+ g_uri_get_port (uri),
173+ g_uri_get_path (uri),
174+ g_uri_get_query (uri),
175+ g_uri_get_fragment (uri));
176
177 uri_webdav = uri_to_string_with_path (uri_tmp, WEBDAV_ENDPOINT);
178- soup_uri_free (uri_tmp);
179+ g_uri_unref (uri_tmp);
180
181 return uri_webdav;
182 }
183@@ -140,7 +135,7 @@ build_object (GoaProvider *provider,
184 gchar *uri_carddav;
185 gchar *uri_webdav;
186 GoaPasswordBased *password_based = NULL;
187- SoupURI *uri = NULL;
188+ GUri *uri = NULL;
189 gboolean accept_ssl_errors;
190 gboolean calendar_enabled;
191 gboolean contacts_enabled;
192@@ -176,9 +171,24 @@ build_object (GoaProvider *provider,
193 account = goa_object_get_account (GOA_OBJECT (object));
194 identity = goa_account_get_identity (account);
195 uri_string = g_key_file_get_string (key_file, group, "Uri", NULL);
196- uri = soup_uri_new (uri_string);
197+ uri = g_uri_parse (uri_string, G_URI_FLAGS_ENCODED, NULL);
198 if (uri != NULL)
199- soup_uri_set_user (uri, identity);
200+ {
201+ GUri *tmp_uri;
202+
203+ tmp_uri = g_uri_build_with_user (g_uri_get_flags (uri),
204+ g_uri_get_scheme (uri),
205+ identity,
206+ g_uri_get_password (uri),
207+ g_uri_get_auth_params (uri),
208+ g_uri_get_host (uri),
209+ g_uri_get_port (uri),
210+ g_uri_get_path (uri),
211+ g_uri_get_query (uri),
212+ g_uri_get_fragment (uri));
213+ g_uri_unref (uri);
214+ uri = tmp_uri;
215+ }
216
217 accept_ssl_errors = g_key_file_get_boolean (key_file, group, "AcceptSslErrors", NULL);
218
219@@ -224,7 +234,7 @@ build_object (GoaProvider *provider,
220
221 out:
222 g_clear_object (&password_based);
223- g_clear_pointer (&uri, soup_uri_free);
224+ g_clear_pointer (&uri, g_uri_unref);
225 g_free (uri_string);
226 return ret;
227 }
228@@ -354,8 +364,11 @@ add_entry (GtkWidget *grid,
229 static gchar *
230 normalize_uri (const gchar *address, gchar **server)
231 {
232- SoupURI *uri = NULL;
233+ GUri *uri = NULL;
234+ GUri *uri_tmp = NULL;
235 const gchar *path;
236+ const gchar *new_scheme;
237+ gchar *new_path = NULL;
238 gchar *ret = NULL;
239 gchar *scheme = NULL;
240 gchar *uri_string = NULL;
241@@ -384,48 +397,56 @@ normalize_uri (const gchar *address, gchar **server)
242 else
243 goto out;
244
245- uri = soup_uri_new (uri_string);
246+ uri = g_uri_parse (uri_string, G_URI_FLAGS_ENCODED, NULL);
247 if (uri == NULL)
248 goto out;
249
250 if (g_strcmp0 (scheme, "dav") == 0)
251- soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP);
252+ new_scheme = "http";
253 else if (g_strcmp0 (scheme, "davs") == 0)
254- soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTPS);
255+ new_scheme = "https";
256+ else
257+ new_scheme = g_uri_get_scheme (uri);
258
259- path = soup_uri_get_path (uri);
260+ path = g_uri_get_path (uri);
261 if (!g_str_has_suffix (path, "/"))
262- {
263- gchar *new_path;
264-
265 new_path = g_strconcat (path, "/", NULL);
266- soup_uri_set_path (uri, new_path);
267- path = soup_uri_get_path (uri);
268- g_free (new_path);
269- }
270+
271+ uri_tmp = g_uri_build (g_uri_get_flags (uri),
272+ new_scheme,
273+ g_uri_get_userinfo (uri),
274+ g_uri_get_host (uri),
275+ g_uri_get_port (uri),
276+ new_path ? new_path : path,
277+ g_uri_get_query (uri),
278+ g_uri_get_fragment (uri));
279+ g_free (new_path);
280+ g_uri_unref (uri);
281+ uri = uri_tmp;
282+ path = g_uri_get_path (uri);
283
284 if (server != NULL)
285 {
286 gchar *port_string;
287 gchar *pretty_path;
288- guint port;
289+ gint port;
290
291- port = soup_uri_get_port (uri);
292- port_string = g_strdup_printf (":%u", port);
293+ port = g_uri_get_port (uri);
294+ port_string = g_strdup_printf (":%d", port);
295
296 pretty_path = g_strdup (path);
297 pretty_path[strlen(pretty_path) - 1] = '\0';
298
299- *server = g_strconcat (soup_uri_get_host (uri), (port == std_port) ? "" : port_string, pretty_path, NULL);
300+ *server = g_strconcat (g_uri_get_host (uri), (port == std_port || port == -1) ? "" : port_string, pretty_path, NULL);
301
302 g_free (port_string);
303 g_free (pretty_path);
304 }
305
306- ret = soup_uri_to_string (uri, FALSE);
307+ ret = g_uri_to_string (uri);
308
309 out:
310- g_clear_pointer (&uri, soup_uri_free);
311+ g_clear_pointer (&uri, g_uri_unref);
312 g_free (scheme);
313 g_free (uri_string);
314 return ret;
315diff --git a/src/goabackend/goawebview.c b/src/goabackend/goawebview.c
316index 2438e0c..3df600e 100644
317--- a/src/goabackend/goawebview.c
318+++ b/src/goabackend/goawebview.c
319@@ -25,7 +25,6 @@
320 #include <glib.h>
321 #include <glib/gi18n-lib.h>
322 #include <jsc/jsc.h>
323-#include <libsoup/soup.h>
324 #include <webkit2/webkit2.h>
325
326 #include "goawebview.h"
327@@ -77,17 +76,17 @@ web_view_clear_notify_progress_cb (gpointer user_data)
328 static char *
329 web_view_create_loading_title (const gchar *url)
330 {
331- SoupURI *uri;
332+ GUri *uri;
333 const gchar *hostname;
334 gchar *title;
335
336 g_return_val_if_fail (url != NULL && url[0] != '\0', NULL);
337
338- uri = soup_uri_new (url);
339- hostname = soup_uri_get_host (uri);
340+ uri = g_uri_parse (url, G_URI_FLAGS_NONE, NULL);
341+ hostname = g_uri_get_host (uri);
342 /* translators: %s here is the address of the web page */
343 title = g_strdup_printf (_("Loading “%s”…"), hostname);
344- soup_uri_free (uri);
345+ g_uri_unref (uri);
346
347 return title;
348 }
349--
3502.33.1
351
diff --git a/meta-gnome/recipes-gnome/gnome-online-accounts/files/0002-Port-to-libsoup3.patch b/meta-gnome/recipes-gnome/gnome-online-accounts/files/0002-Port-to-libsoup3.patch
new file mode 100644
index 000000000..0f959084a
--- /dev/null
+++ b/meta-gnome/recipes-gnome/gnome-online-accounts/files/0002-Port-to-libsoup3.patch
@@ -0,0 +1,841 @@
1From 7d8c5208d095ce8e7123935263ef7a02f0381ae5 Mon Sep 17 00:00:00 2001
2From: Carlos Garcia Campos <cgarcia@igalia.com>
3Date: Mon, 7 Jun 2021 18:28:42 +0200
4Subject: [PATCH 2/2] Port to libsoup3
5
6Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/gnome-online-accounts/-/merge_requests/73]
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 configure.ac | 8 +-
10 src/daemon/goadaemon.c | 2 +-
11 src/goabackend/goaewsclient.c | 178 +++++++++++++++--------------
12 src/goabackend/goahttpclient.c | 72 +++++++-----
13 src/goabackend/goalastfmprovider.c | 24 ++--
14 src/goabackend/goaoauth2provider.c | 6 +-
15 src/goabackend/goaoauthprovider.c | 23 ++--
16 src/goabackend/goarestproxy.h | 2 -
17 src/goabackend/goasouplogger.c | 33 ++----
18 src/goabackend/goasouplogger.h | 3 -
19 src/goabackend/goautils.c | 27 ++---
20 11 files changed, 199 insertions(+), 179 deletions(-)
21
22--- a/configure.ac
23+++ b/configure.ac
24@@ -113,15 +113,15 @@ if test "$enable_backend" != "no"; then
25 AC_SUBST(GTK_CFLAGS)
26 AC_SUBST(GTK_LIBS)
27
28- PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, [javascriptcoregtk-4.0 >= 2.12.0])
29+ PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, [javascriptcoregtk-4.1 >= 2.33.1])
30 AC_SUBST(JAVASCRIPT_CORE_GTK_CFLAGS)
31 AC_SUBST(JAVASCRIPT_CORE_GTK_LIBS)
32
33- PKG_CHECK_MODULES(WEBKIT_GTK, [webkit2gtk-4.0 >= 2.26.0])
34+ PKG_CHECK_MODULES(WEBKIT_GTK, [webkit2gtk-4.1 >= 2.33.1])
35 AC_SUBST(WEBKIT_GTK_CFLAGS)
36 AC_SUBST(WEBKIT_GTK_LIBS)
37
38- PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.42])
39+ PKG_CHECK_MODULES(LIBSOUP, [libsoup-3.0 >= 2.99.8])
40 AC_SUBST(LIBSOUP_CFLAGS)
41 AC_SUBST(LIBSOUP_LIBS)
42
43@@ -129,7 +129,7 @@ if test "$enable_backend" != "no"; then
44 AC_SUBST(JSON_GLIB_CFLAGS)
45 AC_SUBST(JSON_GLIB_LIBS)
46
47- PKG_CHECK_MODULES(REST, [rest-0.7])
48+ PKG_CHECK_MODULES(REST, [rest-1.0])
49 AC_SUBST(REST_CFLAGS)
50 AC_SUBST(REST_LIBS)
51
52--- a/src/daemon/goadaemon.c
53+++ b/src/daemon/goadaemon.c
54@@ -1496,7 +1496,7 @@ is_authorization_error (GError *error)
55 g_return_val_if_fail (error != NULL, FALSE);
56
57 ret = FALSE;
58- if (error->domain == REST_PROXY_ERROR || error->domain == SOUP_HTTP_ERROR)
59+ if (error->domain == REST_PROXY_ERROR)
60 {
61 if (SOUP_STATUS_IS_CLIENT_ERROR (error->code))
62 ret = TRUE;
63--- a/src/goabackend/goaewsclient.c
64+++ b/src/goabackend/goaewsclient.c
65@@ -63,6 +63,12 @@ goa_ews_client_new (void)
66
67 typedef struct
68 {
69+ gchar *password;
70+ gchar *username;
71+} AutodiscoverAuthData;
72+
73+typedef struct
74+{
75 GCancellable *cancellable;
76 GError *error;
77 SoupMessage *msgs[2];
78@@ -71,13 +77,16 @@ typedef struct
79 guint pending;
80 gulong cancellable_id;
81 xmlOutputBuffer *buf;
82+ AutodiscoverAuthData *auth;
83 } AutodiscoverData;
84
85-typedef struct
86+static void
87+ews_client_autodiscover_auth_data_free (AutodiscoverAuthData *auth)
88 {
89- gchar *password;
90- gchar *username;
91-} AutodiscoverAuthData;
92+ g_free (auth->password);
93+ g_free (auth->username);
94+ g_slice_free (AutodiscoverAuthData, auth);
95+}
96
97 static void
98 ews_client_autodiscover_data_free (gpointer user_data)
99@@ -92,22 +101,12 @@ ews_client_autodiscover_data_free (gpoin
100
101 g_clear_error (&data->error);
102
103- /* soup_session_queue_message stole the references to data->msgs */
104 xmlOutputBufferClose (data->buf);
105+ g_clear_pointer (&data->auth, ews_client_autodiscover_auth_data_free);
106 g_object_unref (data->session);
107 g_slice_free (AutodiscoverData, data);
108 }
109
110-static void
111-ews_client_autodiscover_auth_data_free (gpointer data, GClosure *closure)
112-{
113- AutodiscoverAuthData *auth = data;
114-
115- g_free (auth->password);
116- g_free (auth->username);
117- g_slice_free (AutodiscoverAuthData, auth);
118-}
119-
120 static gboolean
121 ews_client_check_node (const xmlNode *node, const gchar *name)
122 {
123@@ -115,9 +114,8 @@ ews_client_check_node (const xmlNode *no
124 return node->type == XML_ELEMENT_NODE && !g_strcmp0 ((gchar *) node->name, name);
125 }
126
127-static void
128-ews_client_authenticate (SoupSession *session,
129- SoupMessage *msg,
130+static gboolean
131+ews_client_authenticate (SoupMessage *msg,
132 SoupAuth *auth,
133 gboolean retrying,
134 gpointer user_data)
135@@ -125,26 +123,26 @@ ews_client_authenticate (SoupSession *se
136 AutodiscoverAuthData *data = user_data;
137
138 if (retrying)
139- return;
140+ return FALSE;
141
142 soup_auth_authenticate (auth, data->username, data->password);
143+ return TRUE;
144 }
145
146-static void
147-ews_client_request_started (SoupSession *session, SoupMessage *msg, SoupSocket *socket, gpointer user_data)
148+static gboolean
149+ews_client_accept_certificate (SoupMessage *msg, GTlsCertificate *cert, GTlsCertificateFlags cert_flags, gpointer user_data)
150 {
151 AutodiscoverData *data;
152 GTask *task = G_TASK (user_data);
153- GTlsCertificateFlags cert_flags;
154
155- g_debug ("goa_ews_client_autodiscover(): request started (%p)", msg);
156+ g_debug ("goa_ews_client_autodiscover(): accept certificate for request (%p)", msg);
157
158 data = (AutodiscoverData *) g_task_get_task_data (task);
159
160- if (!data->accept_ssl_errors
161- && soup_message_get_https_status (msg, NULL, &cert_flags)
162- && cert_flags != 0
163- && data->error == NULL)
164+ if (data->accept_ssl_errors || cert_flags == 0)
165+ return TRUE;
166+
167+ if (data->error == NULL)
168 {
169 goa_utils_set_error_ssl (&data->error, cert_flags);
170
171@@ -153,6 +151,8 @@ ews_client_request_started (SoupSession
172 */
173 soup_session_abort (data->session);
174 }
175+
176+ return FALSE;
177 }
178
179 static void
180@@ -192,8 +192,10 @@ ews_client_autodiscover_parse_protocol (
181 }
182
183 static void
184-ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
185+ews_client_autodiscover_response_cb (SoupSession *session, GAsyncResult *result, gpointer user_data)
186 {
187+ SoupMessage *msg;
188+ GBytes *body;
189 GError *error = NULL;
190 AutodiscoverData *data;
191 GTask *task = G_TASK (user_data);
192@@ -204,7 +206,11 @@ ews_client_autodiscover_response_cb (Sou
193 xmlDoc *doc;
194 xmlNode *node;
195
196- g_debug ("goa_ews_client_autodiscover(): response (%p, %u)", msg, msg->status_code);
197+ msg = soup_session_get_async_result_message (session, result);
198+
199+ g_debug ("goa_ews_client_autodiscover(): response (%p, %u)", msg, soup_message_get_status (msg));
200+
201+ body = soup_session_send_and_read_finish (session, result, &error);
202
203 data = (AutodiscoverData *) g_task_get_task_data (task);
204 size = sizeof (data->msgs) / sizeof (data->msgs[0]);
205@@ -215,16 +221,19 @@ ews_client_autodiscover_response_cb (Sou
206 break;
207 }
208 if (idx == size || data->pending == 0)
209- return;
210+ {
211+ g_bytes_unref (body);
212+ g_clear_object (&error);
213+ g_object_unref (msg);
214+ return;
215+ }
216
217 data->msgs[idx] = NULL;
218- status = msg->status_code;
219-
220- /* status == SOUP_STATUS_CANCELLED, if we are being aborted by the
221+ /* G_IO_ERROR_CANCELLED, if we are being aborted by the
222 * GCancellable, an SSL error or another message that was
223 * successful.
224 */
225- if (status == SOUP_STATUS_CANCELLED)
226+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
227 {
228 /* If we are being aborted by the GCancellable, then the
229 * GTask is responsible for setting the GError automatically.
230@@ -235,21 +244,23 @@ ews_client_autodiscover_response_cb (Sou
231 */
232 goto out;
233 }
234- else if (status != SOUP_STATUS_OK)
235+
236+ status = soup_message_get_status (msg);
237+ if (status != SOUP_STATUS_OK || error)
238 {
239- g_warning ("goa_ews_client_autodiscover() failed: %u — %s", msg->status_code, msg->reason_phrase);
240+ g_warning ("goa_ews_client_autodiscover() failed: %u — %s", status, soup_message_get_reason_phrase (msg));
241 g_return_if_fail (data->error == NULL);
242
243- goa_utils_set_error_soup (&error, msg);
244+ if (!error)
245+ goa_utils_set_error_soup (&error, msg);
246 goto out;
247 }
248
249- soup_buffer_free (soup_message_body_flatten (SOUP_MESSAGE (msg)->response_body));
250 g_debug ("The response headers");
251 g_debug ("===================");
252- g_debug ("%s", SOUP_MESSAGE (msg)->response_body->data);
253+ g_debug ("%s", (char *)g_bytes_get_data (body, NULL));
254
255- doc = xmlReadMemory (msg->response_body->data, msg->response_body->length, "autodiscover.xml", NULL, 0);
256+ doc = xmlReadMemory (g_bytes_get_data (body, NULL), g_bytes_get_size (body), "autodiscover.xml", NULL, 0);
257 if (doc == NULL)
258 {
259 g_set_error (&error,
260@@ -333,7 +344,7 @@ ews_client_autodiscover_response_cb (Sou
261 /* The callback (ie. this function) will be invoked after we
262 * have returned to the main loop.
263 */
264- soup_session_cancel_message (data->session, data->msgs[idx], SOUP_STATUS_CANCELLED);
265+ g_cancellable_cancel (data->cancellable);
266 }
267 }
268
269@@ -368,6 +379,7 @@ ews_client_autodiscover_response_cb (Sou
270
271 g_clear_error (&error);
272 g_object_unref (task);
273+ g_object_unref (msg);
274 }
275
276 static xmlDoc *
277@@ -399,52 +411,54 @@ static void
278 ews_client_post_restarted_cb (SoupMessage *msg, gpointer data)
279 {
280 xmlOutputBuffer *buf = data;
281+ GBytes *body;
282
283 /* In violation of RFC2616, libsoup will change a POST request to
284 * a GET on receiving a 302 redirect.
285 */
286 g_debug ("Working around libsoup bug with redirect");
287- g_object_set (msg, SOUP_MESSAGE_METHOD, "POST", NULL);
288+ g_object_set (msg, "method", "POST", NULL);
289
290- soup_message_set_request(msg,
291- "text/xml; charset=utf-8",
292- SOUP_MEMORY_COPY,
293 #ifdef LIBXML2_NEW_BUFFER
294- (gchar *) xmlOutputBufferGetContent(buf),
295- xmlOutputBufferGetSize(buf));
296+ body = g_bytes_new (xmlOutputBufferGetContent (buf), xmlOutputBufferGetSize (buf));
297 #else
298- (gchar *) buf->buffer->content,
299- buf->buffer->use);
300+ body = g_bytes_new (buf->buffer->content, buf->buffer->use);
301 #endif
302+ soup_message_set_request_body_from_bytes (msg, "text/xml; charset=utf-8", body);
303+ g_bytes_unref (body);
304 }
305
306 static SoupMessage *
307-ews_client_create_msg_for_url (const gchar *url, xmlOutputBuffer *buf)
308+ews_client_create_msg_for_url (const gchar *url, xmlOutputBuffer *buf, AutodiscoverAuthData *auth, GTask *task)
309 {
310 SoupMessage *msg;
311+ GBytes *body = NULL;
312
313 msg = soup_message_new (buf != NULL ? "POST" : "GET", url);
314- soup_message_headers_append (msg->request_headers, "User-Agent", "libews/0.1");
315+ soup_message_headers_append (soup_message_get_request_headers (msg),
316+ "User-Agent", "libews/0.1");
317+
318+ g_signal_connect (msg, "authenticate",
319+ G_CALLBACK (ews_client_authenticate),
320+ auth);
321+ g_signal_connect (msg, "accept-certificate",
322+ G_CALLBACK (ews_client_accept_certificate),
323+ task);
324
325 if (buf != NULL)
326 {
327- soup_message_set_request (msg,
328- "text/xml; charset=utf-8",
329- SOUP_MEMORY_COPY,
330 #ifdef LIBXML2_NEW_BUFFER
331- (gchar *) xmlOutputBufferGetContent(buf),
332- xmlOutputBufferGetSize(buf));
333+ body = g_bytes_new (xmlOutputBufferGetContent (buf), xmlOutputBufferGetSize (buf));
334 #else
335- (gchar *) buf->buffer->content,
336- buf->buffer->use);
337+ body = g_bytes_new (buf->buffer->content, buf->buffer->use);
338 #endif
339+ soup_message_set_request_body_from_bytes (msg, "text/xml; charset=utf-8", body);
340 g_signal_connect (msg, "restarted", G_CALLBACK (ews_client_post_restarted_cb), buf);
341 }
342
343- soup_buffer_free (soup_message_body_flatten (SOUP_MESSAGE (msg)->request_body));
344 g_debug ("The request headers");
345 g_debug ("===================");
346- g_debug ("%s", SOUP_MESSAGE (msg)->request_body->data);
347+ g_debug ("%s", body ? (char *)g_bytes_get_data (body, NULL) : "");
348
349 return msg;
350 }
351@@ -497,12 +511,15 @@ goa_ews_client_autodiscover (GoaEwsClien
352 * (successful) one win.
353 */
354
355+ auth = g_slice_new0 (AutodiscoverAuthData);
356+ auth->username = g_strdup (username);
357+ auth->password = g_strdup (password);
358+ data->auth = auth;
359 data->buf = buf;
360- data->msgs[0] = ews_client_create_msg_for_url (url1, buf);
361- data->msgs[1] = ews_client_create_msg_for_url (url2, buf);
362+ data->msgs[0] = ews_client_create_msg_for_url (url1, buf, auth, task);
363+ data->msgs[1] = ews_client_create_msg_for_url (url2, buf, auth, task);
364 data->pending = sizeof (data->msgs) / sizeof (data->msgs[0]);
365- data->session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, FALSE,
366- NULL);
367+ data->session = soup_session_new ();
368 soup_session_add_feature_by_type (data->session, SOUP_TYPE_AUTH_NTLM);
369 data->accept_ssl_errors = accept_ssl_errors;
370
371@@ -515,26 +532,19 @@ goa_ews_client_autodiscover (GoaEwsClien
372 NULL);
373 }
374
375- auth = g_slice_new0 (AutodiscoverAuthData);
376- auth->username = g_strdup (username);
377- auth->password = g_strdup (password);
378- g_signal_connect_data (data->session,
379- "authenticate",
380- G_CALLBACK (ews_client_authenticate),
381- auth,
382- ews_client_autodiscover_auth_data_free,
383- 0);
384-
385- g_signal_connect (data->session, "request-started", G_CALLBACK (ews_client_request_started), task);
386-
387- soup_session_queue_message (data->session,
388- data->msgs[0],
389- ews_client_autodiscover_response_cb,
390- g_object_ref (task));
391- soup_session_queue_message (data->session,
392- data->msgs[1],
393- ews_client_autodiscover_response_cb,
394- g_object_ref (task));
395+
396+ soup_session_send_and_read_async (data->session,
397+ data->msgs[0],
398+ G_PRIORITY_DEFAULT,
399+ data->cancellable,
400+ (GAsyncReadyCallback)ews_client_autodiscover_response_cb,
401+ g_object_ref (task));
402+ soup_session_send_and_read_async (data->session,
403+ data->msgs[1],
404+ G_PRIORITY_DEFAULT,
405+ data->cancellable,
406+ (GAsyncReadyCallback)ews_client_autodiscover_response_cb,
407+ g_object_ref (task));
408
409 g_free (url2);
410 g_free (url1);
411--- a/src/goabackend/goahttpclient.c
412+++ b/src/goabackend/goahttpclient.c
413@@ -82,7 +82,7 @@ http_client_check_data_free (gpointer us
414
415 g_clear_error (&data->error);
416
417- /* soup_session_queue_message stole the references to data->msg */
418+ g_object_unref (data->msg);
419 g_object_unref (data->session);
420 g_slice_free (CheckData, data);
421 }
422@@ -97,9 +97,8 @@ http_client_check_auth_data_free (gpoint
423 g_slice_free (CheckAuthData, auth);
424 }
425
426-static void
427-http_client_authenticate (SoupSession *session,
428- SoupMessage *msg,
429+static gboolean
430+http_client_authenticate (SoupMessage *msg,
431 SoupAuth *auth,
432 gboolean retrying,
433 gpointer user_data)
434@@ -107,26 +106,26 @@ http_client_authenticate (SoupSession *s
435 CheckAuthData *data = user_data;
436
437 if (retrying)
438- return;
439+ return FALSE;
440
441 soup_auth_authenticate (auth, data->username, data->password);
442+ return TRUE;
443 }
444
445-static void
446-http_client_request_started (SoupSession *session, SoupMessage *msg, SoupSocket *socket, gpointer user_data)
447+static gboolean
448+http_client_accept_certificate (SoupMessage *msg, GTlsCertificate *cert, GTlsCertificateFlags cert_flags, gpointer user_data)
449 {
450 CheckData *data;
451 GTask *task = G_TASK (user_data);
452- GTlsCertificateFlags cert_flags;
453
454 g_debug ("goa_http_client_check(): request started (%p)", msg);
455
456 data = (CheckData *) g_task_get_task_data (task);
457
458- if (!data->accept_ssl_errors
459- && soup_message_get_https_status (msg, NULL, &cert_flags)
460- && cert_flags != 0
461- && data->error == NULL)
462+ if (data->accept_ssl_errors || cert_flags == 0)
463+ return TRUE;
464+
465+ if (data->error == NULL)
466 {
467 goa_utils_set_error_ssl (&data->error, cert_flags);
468
469@@ -135,6 +134,8 @@ http_client_request_started (SoupSession
470 */
471 soup_session_abort (data->session);
472 }
473+
474+ return FALSE;
475 }
476
477 static void
478@@ -154,21 +155,27 @@ http_client_check_cancelled_cb (GCancell
479 }
480
481 static void
482-http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
483+http_client_check_response_cb (SoupSession *session, GAsyncResult *result, gpointer user_data)
484 {
485+ SoupMessage *msg;
486 CheckData *data;
487- GCancellable *cancellable;
488 GTask *task = G_TASK (user_data);
489+ guint status;
490+ GBytes *body;
491+ GError *error = NULL;
492
493- g_debug ("goa_http_client_check(): response (%p, %u)", msg, msg->status_code);
494+ msg = soup_session_get_async_result_message (session, result);
495+
496+ g_debug ("goa_http_client_check(): response (%p, %u)", msg, soup_message_get_status (msg));
497+
498+ body = soup_session_send_and_read_finish (session, result, &error);
499
500 data = (CheckData *) g_task_get_task_data (task);
501- cancellable = g_task_get_cancellable (task);
502
503- /* status == SOUP_STATUS_CANCELLED, if we are being aborted by the
504+ /* G_IO_ERROR_CANCELLED, if we are being aborted by the
505 * GCancellable or due to an SSL error.
506 */
507- if (msg->status_code == SOUP_STATUS_CANCELLED)
508+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
509 {
510 /* If we are being aborted by the GCancellable then there might
511 * or might not be an error. The GCancellable can be triggered
512@@ -176,20 +183,27 @@ http_client_check_response_cb (SoupSessi
513 * of events across threads.
514 */
515 if (data->error == NULL)
516- g_cancellable_set_error_if_cancelled (cancellable, &data->error);
517+ g_propagate_error (&data->error, g_steal_pointer (&error));
518
519 goto out;
520 }
521- else if (msg->status_code != SOUP_STATUS_OK)
522+
523+ status = soup_message_get_status (msg);
524+ if (status != SOUP_STATUS_OK || error)
525 {
526- g_warning ("goa_http_client_check() failed: %u — %s", msg->status_code, msg->reason_phrase);
527+ g_warning ("goa_http_client_check() failed: %u — %s", status, soup_message_get_reason_phrase (msg));
528 g_return_if_fail (data->error == NULL);
529
530- goa_utils_set_error_soup (&data->error, msg);
531+ if (error)
532+ g_propagate_error (&data->error, g_steal_pointer (&error));
533+ else
534+ goa_utils_set_error_soup (&data->error, msg);
535 goto out;
536 }
537
538 out:
539+ g_clear_error (&error);
540+ g_clear_pointer (&body, g_bytes_unref);
541 if (data->error != NULL)
542 g_task_return_error (task, g_steal_pointer (&data->error));
543 else
544@@ -225,7 +239,7 @@ goa_http_client_check (GoaHttpClient
545 data = g_slice_new0 (CheckData);
546 g_task_set_task_data (task, data, http_client_check_data_free);
547
548- data->session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, FALSE, NULL);
549+ data->session = soup_session_new ();
550
551 logger = goa_soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
552 soup_session_add_feature (data->session, SOUP_SESSION_FEATURE (logger));
553@@ -246,15 +260,21 @@ goa_http_client_check (GoaHttpClient
554 auth = g_slice_new0 (CheckAuthData);
555 auth->username = g_strdup (username);
556 auth->password = g_strdup (password);
557- g_signal_connect_data (data->session,
558+ g_signal_connect_data (data->msg,
559 "authenticate",
560 G_CALLBACK (http_client_authenticate),
561 auth,
562 http_client_check_auth_data_free,
563 0);
564
565- g_signal_connect (data->session, "request-started", G_CALLBACK (http_client_request_started), task);
566- soup_session_queue_message (data->session, data->msg, http_client_check_response_cb, g_object_ref (task));
567+ g_signal_connect (data->msg, "accept-certificate", G_CALLBACK (http_client_accept_certificate), task);
568+
569+ soup_session_send_and_read_async (data->session,
570+ data->msg,
571+ G_PRIORITY_DEFAULT,
572+ data->cancellable,
573+ (GAsyncReadyCallback)http_client_check_response_cb,
574+ g_object_ref (task));
575
576 g_object_unref (task);
577 }
578--- a/src/goabackend/goalastfmprovider.c
579+++ b/src/goabackend/goalastfmprovider.c
580@@ -483,8 +483,7 @@ add_account_cb (GoaManager *manager, GAs
581
582 static void
583 check_cb (RestProxyCall *call,
584- const GError *error,
585- GObject *weak_object,
586+ GAsyncResult *result,
587 gpointer user_data)
588 {
589 AddAccountData *data = user_data;
590@@ -494,6 +493,9 @@ check_cb (RestProxyCall *call,
591 JsonObject *session_obj;
592 const gchar *payload;
593
594+ if (!rest_proxy_call_invoke_finish (call, result, &data->error))
595+ goto out;
596+
597 parser = NULL;
598
599 parser = json_parser_new ();
600@@ -562,12 +564,12 @@ on_rest_proxy_call_cancelled_cb (GCancel
601 }
602
603 static void
604-lastfm_login (GoaProvider *provider,
605- const gchar *username,
606- const gchar *password,
607- GCancellable *cancellable,
608- RestProxyCallAsyncCallback callback,
609- gpointer user_data)
610+lastfm_login (GoaProvider *provider,
611+ const gchar *username,
612+ const gchar *password,
613+ GCancellable *cancellable,
614+ GAsyncReadyCallback callback,
615+ gpointer user_data)
616 {
617 AddAccountData *data = user_data;
618 RestProxyCall *call;
619@@ -598,7 +600,7 @@ lastfm_login (GoaProvider
620 rest_proxy_call_add_param (call, "api_sig", sig_md5);
621 rest_proxy_call_add_param (call, "format", "json");
622
623- rest_proxy_call_async (call, callback, NULL, data, &data->error);
624+ rest_proxy_call_invoke_async (call, NULL, callback, data);
625
626 g_signal_connect (cancellable, "cancelled", G_CALLBACK (on_rest_proxy_call_cancelled_cb), call);
627
628@@ -665,7 +667,7 @@ add_account (GoaProvider *provider,
629 username,
630 password,
631 data.cancellable,
632- (RestProxyCallAsyncCallback) check_cb,
633+ (GAsyncReadyCallback) check_cb,
634 &data);
635
636 gtk_widget_set_sensitive (data.connect_button, FALSE);
637@@ -819,7 +821,7 @@ refresh_account (GoaProvider *provide
638 username,
639 password,
640 data.cancellable,
641- (RestProxyCallAsyncCallback) check_cb,
642+ (GAsyncReadyCallback) check_cb,
643 &data);
644 gtk_widget_set_sensitive (data.connect_button, FALSE);
645 gtk_widget_show (data.progress_grid);
646--- a/src/goabackend/goaoauth2provider.c
647+++ b/src/goabackend/goaoauth2provider.c
648@@ -95,11 +95,15 @@ is_authorization_error (GError *error)
649 g_return_val_if_fail (error != NULL, FALSE);
650
651 ret = FALSE;
652- if (error->domain == REST_PROXY_ERROR || error->domain == SOUP_HTTP_ERROR)
653+ if (error->domain == REST_PROXY_ERROR)
654 {
655 if (SOUP_STATUS_IS_CLIENT_ERROR (error->code))
656 ret = TRUE;
657 }
658+ else if (g_error_matches (error, GOA_ERROR, GOA_ERROR_NOT_AUTHORIZED))
659+ {
660+ ret = TRUE;
661+ }
662 return ret;
663 }
664
665--- a/src/goabackend/goaoauthprovider.c
666+++ b/src/goabackend/goaoauthprovider.c
667@@ -77,11 +77,15 @@ is_authorization_error (GError *error)
668 g_return_val_if_fail (error != NULL, FALSE);
669
670 ret = FALSE;
671- if (error->domain == REST_PROXY_ERROR || error->domain == SOUP_HTTP_ERROR)
672+ if (error->domain == REST_PROXY_ERROR)
673 {
674 if (SOUP_STATUS_IS_CLIENT_ERROR (error->code))
675 ret = TRUE;
676 }
677+ else if (g_error_matches (error, GOA_ERROR, GOA_ERROR_NOT_AUTHORIZED))
678+ {
679+ ret = TRUE;
680+ }
681 return ret;
682 }
683
684@@ -701,9 +705,15 @@ on_web_view_decide_policy (WebKitWebView
685 }
686
687 static void
688-rest_proxy_call_cb (RestProxyCall *call, const GError *error, GObject *weak_object, gpointer user_data)
689+rest_proxy_call_cb (GObject *source, GAsyncResult *result, gpointer user_data)
690 {
691+ RestProxyCall *call = REST_PROXY_CALL (source);
692 IdentifyData *data = user_data;
693+
694+ if (!rest_proxy_call_invoke_finish (call, result, &data->error))
695+ {
696+ g_prefix_error (&data->error, _("Error getting a Request Token: "));
697+ }
698 g_main_loop_quit (data->loop);
699 }
700
701@@ -770,11 +780,7 @@ get_tokens_and_identity (GoaOAuthProvide
702 for (n = 0; request_params[n] != NULL; n += 2)
703 rest_proxy_call_add_param (call, request_params[n], request_params[n+1]);
704 }
705- if (!rest_proxy_call_async (call, rest_proxy_call_cb, NULL, &data, &data.error))
706- {
707- g_prefix_error (&data.error, _("Error getting a Request Token: "));
708- goto out;
709- }
710+ rest_proxy_call_invoke_async (call, NULL, rest_proxy_call_cb, &data);
711
712 goa_utils_set_dialog_title (GOA_PROVIDER (provider), dialog, add_account);
713
714@@ -796,6 +802,9 @@ get_tokens_and_identity (GoaOAuthProvide
715 g_main_loop_run (data.loop);
716 gtk_container_remove (GTK_CONTAINER (grid), spinner);
717
718+ if (data.error)
719+ goto out;
720+
721 if (rest_proxy_call_get_status_code (call) != 200)
722 {
723 gchar *msg;
724--- a/src/goabackend/goarestproxy.h
725+++ b/src/goabackend/goarestproxy.h
726@@ -27,8 +27,6 @@
727
728 G_BEGIN_DECLS
729
730-G_DEFINE_AUTOPTR_CLEANUP_FUNC (RestProxy, g_object_unref);
731-
732 #define GOA_TYPE_REST_PROXY (goa_rest_proxy_get_type ())
733 G_DECLARE_FINAL_TYPE (GoaRestProxy, goa_rest_proxy, GOA, REST_PROXY, RestProxy);
734
735--- a/src/goabackend/goasouplogger.c
736+++ b/src/goabackend/goasouplogger.c
737@@ -22,15 +22,6 @@
738
739 #include "goasouplogger.h"
740
741-struct _GoaSoupLogger
742-{
743- SoupLogger parent_instance;
744-};
745-
746-G_DEFINE_TYPE (GoaSoupLogger, goa_soup_logger, SOUP_TYPE_LOGGER);
747-
748-/* ---------------------------------------------------------------------------------------------------- */
749-
750 static void
751 goa_soup_logger_printer (SoupLogger *logger,
752 SoupLoggerLogLevel level,
753@@ -45,24 +36,16 @@ goa_soup_logger_printer (SoupLogger
754 g_free (message);
755 }
756
757-/* ---------------------------------------------------------------------------------------------------- */
758-
759-static void
760-goa_soup_logger_init (GoaSoupLogger *self)
761-{
762- soup_logger_set_printer (SOUP_LOGGER (self), goa_soup_logger_printer, NULL, NULL);
763-}
764-
765-static void
766-goa_soup_logger_class_init (GoaSoupLoggerClass *klass)
767-{
768-}
769-
770-/* ---------------------------------------------------------------------------------------------------- */
771-
772 SoupLogger *
773 goa_soup_logger_new (SoupLoggerLogLevel level,
774 gint max_body_size)
775 {
776- return g_object_new (GOA_TYPE_SOUP_LOGGER, "level", level, "max-body-size", max_body_size, NULL);
777+ SoupLogger *logger;
778+
779+ logger = soup_logger_new (level);
780+ if (max_body_size != -1)
781+ soup_logger_set_max_body_size (logger, max_body_size);
782+ soup_logger_set_printer (logger, goa_soup_logger_printer, NULL, NULL);
783+
784+ return logger;
785 }
786--- a/src/goabackend/goasouplogger.h
787+++ b/src/goabackend/goasouplogger.h
788@@ -27,9 +27,6 @@
789
790 G_BEGIN_DECLS
791
792-#define GOA_TYPE_SOUP_LOGGER (goa_soup_logger_get_type ())
793-G_DECLARE_FINAL_TYPE (GoaSoupLogger, goa_soup_logger, GOA, SOUP_LOGGER, SoupLogger);
794-
795 SoupLogger *goa_soup_logger_new (SoupLoggerLogLevel level,
796 gint max_body_size);
797
798--- a/src/goabackend/goautils.c
799+++ b/src/goabackend/goautils.c
800@@ -841,29 +841,26 @@ goa_utils_set_error_soup (GError **err,
801 {
802 gchar *error_msg = NULL;
803 gint error_code = GOA_ERROR_FAILED; /* TODO: more specific */
804+ guint status_code;
805
806- switch (msg->status_code)
807+ status_code = soup_message_get_status (msg);
808+ switch (status_code)
809 {
810- case SOUP_STATUS_CANT_RESOLVE:
811- error_msg = g_strdup (_("Cannot resolve hostname"));
812- break;
813-
814- case SOUP_STATUS_CANT_RESOLVE_PROXY:
815- error_msg = g_strdup (_("Cannot resolve proxy hostname"));
816- break;
817-
818 case SOUP_STATUS_INTERNAL_SERVER_ERROR:
819 case SOUP_STATUS_NOT_FOUND:
820 error_msg = g_strdup (_("Cannot find WebDAV endpoint"));
821 break;
822
823- case SOUP_STATUS_UNAUTHORIZED:
824- error_msg = g_strdup (_("Authentication failed"));
825- error_code = GOA_ERROR_NOT_AUTHORIZED;
826- break;
827-
828 default:
829- error_msg = g_strdup_printf (_("Code: %u — Unexpected response from server"), msg->status_code);
830+ if (SOUP_STATUS_IS_CLIENT_ERROR (status_code))
831+ {
832+ error_msg = g_strdup (_("Authentication failed"));
833+ error_code = GOA_ERROR_NOT_AUTHORIZED;
834+ }
835+ else
836+ {
837+ error_msg = g_strdup_printf (_("Code: %u — Unexpected response from server"), status_code);
838+ }
839 break;
840 }
841