[evolution-data-server/account-mgmt: 13/33] Adapt calendar backends to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/account-mgmt: 13/33] Adapt calendar backends to the new ESource API.
- Date: Wed, 7 Sep 2011 16:08:11 +0000 (UTC)
commit fbe38d0d407bc16c2fb75fb29f6c853cf24e3049
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Nov 22 23:04:56 2010 -0500
Adapt calendar backends to the new ESource API.
calendar/backends/http/e-cal-backend-http.c | 104 ++++++++++++++++++++++-----
1 files changed, 86 insertions(+), 18 deletions(-)
---
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index d40bdd3..8f041e2 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -28,6 +28,10 @@
#include <glib/gi18n-lib.h>
#include "libedataserver/e-xml-hash-utils.h"
#include "libedataserver/e-proxy.h"
+#include "libedataserver/e-source-authentication.h"
+#include "libedataserver/e-source-refresh.h"
+#include "libedataserver/e-source-security.h"
+#include "libedataserver/e-source-webdav.h"
#include <libecal/e-cal-recur.h>
#include <libecal/e-cal-util.h>
#include <libecal/e-cal-time-util.h>
@@ -557,13 +561,24 @@ soup_authenticate (SoupSession *session,
gpointer data)
{
ECalBackendHttpPrivate *priv;
- ECalBackendHttp *cbhttp;
+ ECalBackendHttp *cbhttp;
+ ESourceAuthentication *auth_extension;
+ ESource *source;
+ const gchar *extension_name;
+ const gchar *user;
cbhttp = E_CAL_BACKEND_HTTP (data);
priv = cbhttp->priv;
- if (!retrying && priv->credentials && e_credentials_has_key (priv->credentials, E_CREDENTIALS_KEY_USERNAME)) {
- soup_auth_authenticate (auth, e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_USERNAME), e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_PASSWORD));
+ source = e_cal_backend_get_source (E_CAL_BACKEND (data));
+ extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
+ auth_extension = e_source_get_extension (source, extension_name);
+ user = e_source_authentication_get_user (auth_extension);
+
+ if (!retrying && priv->credentials) {
+ soup_auth_authenticate (
+ auth, user, e_credentials_peek (
+ priv->credentials, E_CREDENTIALS_KEY_PASSWORD));
e_credentials_clear_peek (priv->credentials);
}
}
@@ -592,11 +607,34 @@ begin_retrieval_cb (ECalBackendHttp *cbhttp)
priv->is_loading = TRUE;
if (priv->uri == NULL) {
- ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
- const gchar *secure_prop = e_source_get_property (source, "use_ssl");
+ ESource *source;
+ ESourceSecurity *security_extension;
+ ESourceWebdav *webdav_extension;
+ SoupURI *soup_uri;
+ gboolean secure_connection;
+ const gchar *extension_name;
+ const gchar *method;
+ gchar *uri_string;
+
+ source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
+
+ extension_name = E_SOURCE_EXTENSION_SECURITY;
+ security_extension = e_source_get_extension (source, extension_name);
+
+ extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
+ webdav_extension = e_source_get_extension (source, extension_name);
+
+ method = e_source_security_get_method (security_extension);
+ secure_connection = (g_strcmp0 (method, "none") != 0);
- priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
- (secure_prop && g_str_equal(secure_prop, "1")));
+ soup_uri = e_source_webdav_get_soup_uri (webdav_extension);
+ uri_string = soup_uri_to_string (soup_uri, FALSE);
+ soup_uri_free (soup_uri);
+
+ priv->uri = webcal_to_http_method (
+ uri_string, secure_connection);
+
+ g_free (uri_string);
}
/* create the Soup session if not already created */
@@ -676,7 +714,9 @@ maybe_start_reload_timeout (ECalBackendHttp *cbhttp)
{
ECalBackendHttpPrivate *priv;
ESource *source;
- const gchar *refresh_str;
+ ESourceRefresh *refresh_extension;
+ const gchar *extension_name;
+ guint interval_in_minutes;
priv = cbhttp->priv;
@@ -691,10 +731,14 @@ maybe_start_reload_timeout (ECalBackendHttp *cbhttp)
return;
}
- refresh_str = e_source_get_property (source, "refresh");
+ extension_name = E_SOURCE_EXTENSION_REFRESH;
+ refresh_extension = e_source_get_extension (source, extension_name);
+
+ interval_in_minutes =
+ e_source_refresh_get_interval_minutes (refresh_extension);
- priv->reload_timeout_id = g_timeout_add ((refresh_str ? atoi (refresh_str) : 30) * 60000,
- (GSourceFunc) reload_cb, cbhttp);
+ priv->reload_timeout_id = g_timeout_add_seconds (
+ interval_in_minutes * 60, (GSourceFunc) reload_cb, cbhttp);
}
static void
@@ -710,15 +754,34 @@ source_changed_cb (ESource *source,
if (priv->uri) {
ESource *source;
- const gchar *secure_prop;
+ ESourceSecurity *security_extension;
+ ESourceWebdav *webdav_extension;
+ SoupURI *soup_uri;
+ gboolean secure_connection;
+ const gchar *extension_name;
+ const gchar *method;
+ gchar *uri_string;
gchar *new_uri;
source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
- secure_prop = e_source_get_property (source, "use_ssl");
+
+ extension_name = E_SOURCE_EXTENSION_SECURITY;
+ security_extension = e_source_get_extension (source, extension_name);
+
+ extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
+ webdav_extension = e_source_get_extension (source, extension_name);
+
+ method = e_source_security_get_method (security_extension);
+ secure_connection = (g_strcmp0 (method, "none") != 0);
+
+ soup_uri = e_source_webdav_get_soup_uri (webdav_extension);
+ uri_string = soup_uri_to_string (soup_uri, FALSE);
+ soup_uri_free (soup_uri);
new_uri = webcal_to_http_method (
- e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
- (secure_prop && g_str_equal(secure_prop, "1")));
+ uri_string, secure_connection);
+
+ g_free (uri_string);
if (new_uri && !g_str_equal (priv->uri, new_uri)) {
/* uri changed, do reload some time soon */
@@ -744,6 +807,8 @@ e_cal_backend_http_open (ECalBackendSync *backend,
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
ESource *source;
+ ESourceAuthentication *auth_extension;
+ const gchar *extension_name;
gchar *tmp;
cbhttp = E_CAL_BACKEND_HTTP (backend);
@@ -757,6 +822,9 @@ e_cal_backend_http_open (ECalBackendSync *backend,
source = e_cal_backend_get_source (E_CAL_BACKEND (backend));
+ extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
+ auth_extension = e_source_get_extension (source, extension_name);
+
if (priv->source_changed_id == 0) {
priv->source_changed_id = g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), cbhttp);
}
@@ -787,7 +855,7 @@ e_cal_backend_http_open (ECalBackendSync *backend,
e_cal_backend_notify_online (E_CAL_BACKEND (backend), priv->is_online);
if (priv->is_online) {
- if (e_source_get_property (source, "auth")) {
+ if (e_source_authentication_required (auth_extension)) {
e_cal_backend_notify_auth_required (E_CAL_BACKEND (cbhttp), TRUE, priv->credentials);
} else if (priv->requires_auth && perror && !*perror) {
g_propagate_error (perror, EDC_ERROR (AuthenticationRequired));
@@ -813,7 +881,7 @@ e_cal_backend_http_authenticate_user (ECalBackendSync *backend,
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- if (priv->credentials && credentials && e_credentials_equal_keys (priv->credentials, credentials, E_CREDENTIALS_KEY_USERNAME, E_CREDENTIALS_KEY_PASSWORD, NULL)) {
+ if (priv->credentials && credentials && e_credentials_equal_keys (priv->credentials, credentials, E_CREDENTIALS_KEY_PASSWORD, NULL)) {
g_propagate_error (error, EDC_ERROR (AuthenticationRequired));
return;
}
@@ -821,7 +889,7 @@ e_cal_backend_http_authenticate_user (ECalBackendSync *backend,
e_credentials_free (priv->credentials);
priv->credentials = NULL;
- if (!credentials || !e_credentials_has_key (credentials, E_CREDENTIALS_KEY_USERNAME)) {
+ if (!credentials) {
g_propagate_error (error, EDC_ERROR (AuthenticationRequired));
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]