[evolution-patches] Fix for bug#267402 [HTTPS Calendar Support]



Hi,

Attached patches add support for HTTPS remote calendars. There are 2
patches, one for Evolution 2.5.3 and the other for Evolution-data-server
1.5.3.

Any comments are welcomed.

Cheers,
Tony
--- evolution-data-server-1.5.3/calendar/backends/http/e-cal-backend-http.c-	2005-12-31 08:35:43.000000000 +1100
+++ evolution-data-server-1.5.3/calendar/backends/http/e-cal-backend-http.c	2005-12-31 08:35:50.000000000 +1100
@@ -189,12 +189,18 @@ e_cal_backend_http_get_static_capabiliti
 }
 
 static gchar *
-webcal_to_http_method (const gchar *webcal_str)
+webcal_to_http_method (const gchar *webcal_str, gboolean secure)
 {
+	if (secure && (strncmp ("http://";, webcal_str, sizeof ("http://";) - 1) == 0))
+		return g_strconcat ("https://";, webcal_str + sizeof ("http://";) - 1, NULL);
+
 	if (strncmp ("webcal://", webcal_str, sizeof ("webcal://") - 1))
 		return g_strdup (webcal_str);
 
-	return g_strconcat ("http://";, webcal_str + sizeof ("webcal://") - 1, NULL);
+	if (secure)
+		return g_strconcat ("https://";, webcal_str + sizeof ("webcal://") - 1, NULL);
+	else
+		return g_strconcat ("http://";, webcal_str + sizeof ("webcal://") - 1, NULL);
 }
 
 static gboolean
@@ -240,7 +246,7 @@ retrieval_done (SoupMessage *msg, ECalBa
 		if (newuri) {
 			g_free (priv->uri);
 
-			priv->uri = webcal_to_http_method (newuri);
+			priv->uri = webcal_to_http_method (newuri, FALSE);
 			begin_retrieval_cb (cbhttp);
 		} else {
 			if (!priv->opened) {
@@ -425,8 +431,13 @@ begin_retrieval_cb (ECalBackendHttp *cbh
 		g_object_unref (conf_client);
 	}
 
-	if (priv->uri == NULL)
-		priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)));
+	if (priv->uri == NULL) {
+		ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
+		const char *secure_prop = e_source_get_property (source, "secure");
+		
+		priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
+		                                   (secure_prop && g_str_equal(e_source_get_property (source, "secure"), "1")));
+	}
 
 	/* create message to be sent to server */
 	soup_message = soup_message_new (SOUP_METHOD_GET, priv->uri);
--- /local/devel/evolution-data-server/calendar/backends/http/e-cal-backend-http.c-	2005-12-22 09:40:43.000000000 +1100
+++ e-cal-backend-http.c	2005-12-22 09:46:24.000000000 +1100
@@ -186,12 +186,18 @@ e_cal_backend_http_get_static_capabiliti
 }
 
 static gchar *
-webcal_to_http_method (const gchar *webcal_str)
+webcal_to_http_method (const gchar *webcal_str, gboolean secure)
 {
+	if (secure && (strncmp ("http://";, webcal_str, sizeof ("http://";) - 1) == 0))
+		return g_strconcat ("https://";, webcal_str + sizeof ("http://";) - 1, NULL);
+
 	if (strncmp ("webcal://", webcal_str, sizeof ("webcal://") - 1))
 		return g_strdup (webcal_str);
 
-	return g_strconcat ("http://";, webcal_str + sizeof ("webcal://") - 1, NULL);
+	if (secure)
+		return g_strconcat ("https://";, webcal_str + sizeof ("webcal://") - 1, NULL);
+	else
+		return g_strconcat ("http://";, webcal_str + sizeof ("webcal://") - 1, NULL);
 }
 
 static gboolean
@@ -232,7 +238,7 @@ retrieval_done (SoupMessage *msg, ECalBa
 		if (newuri) {
 			g_free (priv->uri);
 
-			priv->uri = webcal_to_http_method (newuri);
+			priv->uri = webcal_to_http_method (newuri, FALSE);
 			begin_retrieval_cb (cbhttp);
 		} else {
 			if (!priv->opened) {
@@ -417,8 +423,13 @@ begin_retrieval_cb (ECalBackendHttp *cbh
 		g_object_unref (conf_client);
 	}
 
-	if (priv->uri == NULL)
-		priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)));
+	if (priv->uri == NULL) {
+		ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
+		const char *secure_prop = e_source_get_property (source, "secure");
+		
+		priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
+		                                   (secure_prop && g_str_equal(e_source_get_property (source, "secure"), "1")));
+	}
 
 	/* create message to be sent to server */
 	soup_message = soup_message_new (SOUP_METHOD_GET, priv->uri);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]