[evolution-ews] Addressbook: Re-use authenticated connection for OAB operations
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Addressbook: Re-use authenticated connection for OAB operations
- Date: Wed, 29 Jun 2022 12:44:28 +0000 (UTC)
commit 4ced883dbfd4d8e26a6c0a4bae5dc7982567ca7b
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 29 14:39:52 2022 +0200
Addressbook: Re-use authenticated connection for OAB operations
No need to create a new EEwsConnection when downloading Offline
Address Book files, use the existing (and authenticated) connection
instead. Using a new connection could cause authentication failures
in some cases, due to not doing the necessary round trip
on the SoupSession.
src/EWS/addressbook/e-book-backend-ews.c | 33 +++-----------------------------
src/EWS/common/e-ews-connection.c | 6 ++++--
src/EWS/common/e-ews-connection.h | 16 +++++++++-------
3 files changed, 16 insertions(+), 39 deletions(-)
---
diff --git a/src/EWS/addressbook/e-book-backend-ews.c b/src/EWS/addressbook/e-book-backend-ews.c
index 9bd46e94..03b7804f 100644
--- a/src/EWS/addressbook/e-book-backend-ews.c
+++ b/src/EWS/addressbook/e-book-backend-ews.c
@@ -2615,10 +2615,8 @@ ebb_ews_download_gal_file (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- EEwsConnection *oab_cnc;
gchar *full_url, *oab_url;
gchar *download_path = NULL;
- gchar *password;
CamelEwsSettings *ews_settings;
const gchar *cache_dir;
@@ -2638,25 +2636,13 @@ ebb_ews_download_gal_file (EBookBackendEws *bbews,
cache_dir = e_book_backend_get_cache_dir (E_BOOK_BACKEND (bbews));
download_path = g_build_filename (cache_dir, full->filename, NULL);
- oab_cnc = e_ews_connection_new_for_backend (E_BACKEND (bbews), e_book_backend_get_registry
(E_BOOK_BACKEND (bbews)), full_url, ews_settings);
-
- e_binding_bind_property (
- bbews, "proxy-resolver",
- oab_cnc, "proxy-resolver",
- G_BINDING_SYNC_CREATE);
-
- password = e_ews_connection_dup_password (bbews->priv->cnc);
- e_ews_connection_set_password (oab_cnc, password);
- g_free (password);
-
- if (!e_ews_connection_download_oal_file_sync (oab_cnc, download_path, NULL, NULL, cancellable,
error)) {
+ if (!e_ews_connection_download_oal_file_sync (bbews->priv->cnc, full_url, download_path, NULL, NULL,
cancellable, error)) {
g_free (download_path);
download_path = NULL;
} else {
d (printf ("OAL file downloaded %s\n", download_path));
}
- g_object_unref (oab_cnc);
g_free (oab_url);
g_free (full_url);
@@ -3976,29 +3962,17 @@ ebb_ews_get_changes_sync (EBookMetaBackend *meta_backend,
if (oab_url && *oab_url &&
camel_ews_settings_get_oab_offline (ews_settings)) {
- EEwsConnection *oab_cnc;
GSList *full_l = NULL, *deltas = NULL, *link;
EwsOALDetails *full = NULL;
- gchar *password, *etag = NULL;
+ gchar *etag = NULL;
gint sequence;
sequence = e_cache_get_key_int (E_CACHE (book_cache), "gal-sequence", NULL);
if (sequence == -1)
sequence = 0;
- oab_cnc = e_ews_connection_new_for_backend (E_BACKEND (bbews),
e_book_backend_get_registry (E_BOOK_BACKEND (bbews)), oab_url, ews_settings);
-
- e_binding_bind_property (
- bbews, "proxy-resolver",
- oab_cnc, "proxy-resolver",
- G_BINDING_SYNC_CREATE);
-
- password = e_ews_connection_dup_password (bbews->priv->cnc);
- e_ews_connection_set_password (oab_cnc, password);
- e_util_safe_free_string (password);
-
d (printf ("Ewsgal: Fetching oal full details file\n"));
- if (!e_ews_connection_get_oal_detail_sync (oab_cnc, bbews->priv->folder_id, NULL,
last_sync_tag, &full_l, &etag, cancellable, &local_error)) {
+ if (!e_ews_connection_get_oal_detail_sync (bbews->priv->cnc, oab_url,
bbews->priv->folder_id, NULL, last_sync_tag, &full_l, &etag, cancellable, &local_error)) {
if (g_error_matches (local_error, E_SOUP_SESSION_ERROR,
SOUP_STATUS_NOT_MODIFIED)) {
g_clear_error (&local_error);
} else {
@@ -4076,7 +4050,6 @@ ebb_ews_get_changes_sync (EBookMetaBackend *meta_backend,
g_slist_free_full (full_l, (GDestroyNotify) ews_oal_details_free);
g_slist_free_full (deltas, (GDestroyNotify) ews_oal_details_free);
- g_clear_object (&oab_cnc);
if (success)
*out_new_sync_tag = etag;
diff --git a/src/EWS/common/e-ews-connection.c b/src/EWS/common/e-ews-connection.c
index d2a61a8e..49870fbe 100644
--- a/src/EWS/common/e-ews-connection.c
+++ b/src/EWS/common/e-ews-connection.c
@@ -3211,6 +3211,7 @@ e_ews_connection_get_oal_list_sync (EEwsConnection *cnc,
gboolean
e_ews_connection_get_oal_detail_sync (EEwsConnection *cnc,
+ const gchar *oal_uri,
const gchar *oal_id,
const gchar *oal_element,
const gchar *old_etag,
@@ -3233,7 +3234,7 @@ e_ews_connection_get_oal_detail_sync (EEwsConnection *cnc,
if (out_etag)
*out_etag = NULL;
- request = e_ews_create_request_for_url (cnc->priv->uri, NULL, error);
+ request = e_ews_create_request_for_url (oal_uri, NULL, error);
if (!request)
return FALSE;
@@ -3341,6 +3342,7 @@ e_ews_process_download_oal_file_response (ESoapRequest *request,
gboolean
e_ews_connection_download_oal_file_sync (EEwsConnection *cnc,
+ const gchar *oal_uri,
const gchar *cache_filename,
ESoapResponseProgressFn progress_fn,
gpointer progress_data,
@@ -3354,7 +3356,7 @@ e_ews_connection_download_oal_file_sync (EEwsConnection *cnc,
g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), FALSE);
- request = e_ews_create_request_for_url (cnc->priv->uri, NULL, error);
+ request = e_ews_create_request_for_url (oal_uri, NULL, error);
if (!request)
return FALSE;
diff --git a/src/EWS/common/e-ews-connection.h b/src/EWS/common/e-ews-connection.h
index 183dd66c..f178ce30 100644
--- a/src/EWS/common/e-ews-connection.h
+++ b/src/EWS/common/e-ews-connection.h
@@ -738,6 +738,7 @@ gboolean e_ews_connection_get_oal_list_sync
GError **error);
gboolean e_ews_connection_get_oal_detail_sync
(EEwsConnection *cnc,
+ const gchar *oal_uri,
const gchar *oal_id,
const gchar *oal_element,
const gchar *old_etag,
@@ -745,6 +746,14 @@ gboolean e_ews_connection_get_oal_detail_sync
gchar **out_etag,
GCancellable *cancellable,
GError **error);
+gboolean e_ews_connection_download_oal_file_sync
+ (EEwsConnection *cnc,
+ const gchar *oal_uri,
+ const gchar *cache_filename,
+ ESoapResponseProgressFn progress_fn,
+ gpointer progress_data,
+ GCancellable *cancellable,
+ GError **error);
gboolean e_ews_connection_get_free_busy_sync
(EEwsConnection *cnc,
gint pri,
@@ -753,13 +762,6 @@ gboolean e_ews_connection_get_free_busy_sync
GSList **out_free_busy, /* ICalComponent * */
GCancellable *cancellable,
GError **error);
-gboolean e_ews_connection_download_oal_file_sync
- (EEwsConnection *cnc,
- const gchar *cache_filename,
- ESoapResponseProgressFn progress_fn,
- gpointer progress_data,
- GCancellable *cancellable,
- GError **error);
gboolean e_ews_connection_get_delegate_sync
(EEwsConnection *cnc,
gint pri,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]