[evolution-data-server/gnome-3-26] Bug 790759 - Proxies are ignored in EWebDAVDiscover and Google OAuth2 token refresh
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-26] Bug 790759 - Proxies are ignored in EWebDAVDiscover and Google OAuth2 token refresh
- Date: Thu, 23 Nov 2017 16:00:41 +0000 (UTC)
commit 3e4618c35409b938c54c12770470c9609af01b9b
Author: Eloi Vanderbeken <eloi vanderbeken+gnome_bugzilla gmail com>
Date: Thu Nov 23 16:57:53 2017 +0100
Bug 790759 - Proxies are ignored in EWebDAVDiscover and Google OAuth2 token refresh
.../e-source-credentials-provider-impl-google.c | 70 ++++++++++++++++---
src/libedataserver/e-webdav-discover.c | 58 ++++++++++++++++
2 files changed, 117 insertions(+), 11 deletions(-)
---
diff --git a/src/libedataserver/e-source-credentials-provider-impl-google.c
b/src/libedataserver/e-source-credentials-provider-impl-google.c
index 9424620..f17f0a4 100644
--- a/src/libedataserver/e-source-credentials-provider-impl-google.c
+++ b/src/libedataserver/e-source-credentials-provider-impl-google.c
@@ -337,10 +337,55 @@ cpi_google_abort_session_cb (GCancellable *cancellable,
soup_session_abort (session);
}
+static gboolean
+cpi_google_setup_proxy_resolver (SoupSession *session,
+ ESource *cred_source,
+ GCancellable *cancellable)
+{
+ ESourceAuthentication *auth_extension;
+ ESource *source = NULL;
+ gchar *uid;
+ gboolean success = TRUE;
+
+ g_return_val_if_fail (SOUP_IS_SESSION (session), FALSE);
+ g_return_val_if_fail (G_IS_CANCELLABLE (cancellable), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE (cred_source), FALSE);
+
+ if (!e_source_has_extension (cred_source, E_SOURCE_EXTENSION_AUTHENTICATION))
+ return TRUE;
+
+ auth_extension = e_source_get_extension (cred_source, E_SOURCE_EXTENSION_AUTHENTICATION);
+ uid = e_source_authentication_dup_proxy_uid (auth_extension);
+
+ if (uid != NULL) {
+ ESourceRegistry *registry;
+
+ registry = e_source_registry_new_sync (cancellable, NULL);
+ if (!registry)
+ success = FALSE;
+ else
+ source = e_source_registry_ref_source (registry, uid);
+
+ g_clear_object (®istry);
+ g_free (uid);
+ }
+
+ if (source != NULL) {
+ GProxyResolver *proxy_resolver;
+
+ proxy_resolver = G_PROXY_RESOLVER (source);
+ if (g_proxy_resolver_is_supported (proxy_resolver))
+ g_object_set (session, SOUP_SESSION_PROXY_RESOLVER, proxy_resolver, NULL);
+
+ g_object_unref (source);
+ }
+
+ return success;
+}
+
static guint
cpi_google_post_data_sync (const gchar *uri,
const gchar *post_data,
- /* ESourceRegistry *registry, */
ESource *cred_source,
GCancellable *cancellable,
gchar **out_response_data)
@@ -357,14 +402,6 @@ cpi_google_post_data_sync (const gchar *uri,
*out_response_data = NULL;
- message = soup_message_new (SOUP_METHOD_POST, uri);
- g_return_val_if_fail (message != NULL, SOUP_STATUS_MALFORMED);
-
- soup_message_set_request (message, "application/x-www-form-urlencoded",
- SOUP_MEMORY_TEMPORARY, post_data, strlen (post_data));
-
- e_soup_ssl_trust_connect (message, cred_source);
-
session = soup_session_new ();
g_object_set (
session,
@@ -374,8 +411,19 @@ cpi_google_post_data_sync (const gchar *uri,
SOUP_SESSION_ACCEPT_LANGUAGE_AUTO, TRUE,
NULL);
- /* Oops, doesn't honor proxy settings (neither EWebDAVDiscover) */
- /* cpi_google_setup_proxy_resolver (session, registry, cred_source); */
+ if (!cpi_google_setup_proxy_resolver (session, cred_source, cancellable)) {
+ g_object_unref (session);
+
+ return SOUP_STATUS_CANT_RESOLVE_PROXY;
+ }
+
+ message = soup_message_new (SOUP_METHOD_POST, uri);
+ g_return_val_if_fail (message != NULL, SOUP_STATUS_MALFORMED);
+
+ soup_message_set_request (message, "application/x-www-form-urlencoded",
+ SOUP_MEMORY_TEMPORARY, post_data, strlen (post_data));
+
+ e_soup_ssl_trust_connect (message, cred_source);
soup_message_headers_append (message->request_headers, "Connection", "close");
diff --git a/src/libedataserver/e-webdav-discover.c b/src/libedataserver/e-webdav-discover.c
index d2ff7b3..eb8addd 100644
--- a/src/libedataserver/e-webdav-discover.c
+++ b/src/libedataserver/e-webdav-discover.c
@@ -21,6 +21,8 @@
#include <libsoup/soup.h>
+#include "e-source-authentication.h"
+#include "e-source-registry.h"
#include "e-source-webdav.h"
#include "e-webdav-session.h"
#include "e-xml-utils.h"
@@ -404,6 +406,54 @@ e_webdav_discover_sources_thread (GTask *task,
}
}
+static gboolean
+e_webdav_discover_setup_proxy_resolver (EWebDAVSession *webdav,
+ ESource *cred_source,
+ GCancellable *cancellable,
+ GError **error)
+{
+ ESourceAuthentication *auth_extension;
+ ESource *source = NULL;
+ gchar *uid;
+ gboolean success = TRUE;
+
+ g_return_val_if_fail (E_IS_WEBDAV_SESSION (webdav), FALSE);
+ g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE (cred_source), FALSE);
+
+ if (!e_source_has_extension (cred_source, E_SOURCE_EXTENSION_AUTHENTICATION))
+ return TRUE;
+
+ auth_extension = e_source_get_extension (cred_source, E_SOURCE_EXTENSION_AUTHENTICATION);
+ uid = e_source_authentication_dup_proxy_uid (auth_extension);
+
+ if (uid != NULL) {
+ ESourceRegistry * registry;
+
+ registry = e_source_registry_new_sync (cancellable, error);
+ if (!registry) {
+ success = FALSE;
+ } else {
+ source = e_source_registry_ref_source (registry, uid);
+ g_object_unref (registry);
+ }
+
+ g_free (uid);
+ }
+
+ if (source != NULL) {
+ GProxyResolver *proxy_resolver;
+
+ proxy_resolver = G_PROXY_RESOLVER (source);
+ if (g_proxy_resolver_is_supported (proxy_resolver))
+ g_object_set (E_SOUP_SESSION (webdav), SOUP_SESSION_PROXY_RESOLVER, proxy_resolver,
NULL);
+
+ g_object_unref (source);
+ }
+
+ return success;
+}
+
/**
* e_webdav_discover_sources:
* @source: an #ESource from which to take connection details
@@ -630,6 +680,14 @@ e_webdav_discover_sources_sync (ESource *source,
}
webdav = e_webdav_session_new (source);
+
+ if (!e_webdav_discover_setup_proxy_resolver (webdav, source, cancellable, error)) {
+ soup_uri_free (soup_uri);
+ g_object_unref (webdav);
+
+ return FALSE;
+ }
+
e_soup_session_setup_logging (E_SOUP_SESSION (webdav), g_getenv ("WEBDAV_DEBUG"));
e_soup_session_set_credentials (E_SOUP_SESSION (webdav), credentials);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]