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



On Mon, 2006-01-02 at 13:38 +0530, chen wrote:
> Please attach the patch for evolution-2.5.3. Both patches attached here
> are for EDS.
> 
> 
Opps! Sorry, here is the evolution patch.

Tony

> thanks, Chenthill.
> 
> On Sat, 2005-12-31 at 09:00 +1100, Tony Tsui wrote:
> > 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-patches mailing list
> > Evolution-patches gnome org
> > http://mail.gnome.org/mailman/listinfo/evolution-patches
> 
--- evolution-2.5.3/plugins/calendar-http/calendar-http.c-	2004-12-28 23:10:46.000000000 +1100
+++ evolution-2.5.3/plugins/calendar-http/calendar-http.c	2005-12-31 08:36:25.000000000 +1100
@@ -2,6 +2,7 @@
  *
  *
  * Copyright (C) 2004 David Trowbridge
+ * Copyright (C) 2005 Tony Tsui
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -19,6 +20,7 @@
  *
  */
 
+#include <glib-object.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkentry.h>
 #include <gtk/gtktable.h>
@@ -27,6 +29,7 @@
 #include <gtk/gtkmenu.h>
 #include <gtk/gtkmenuitem.h>
 #include <gtk/gtkhbox.h>
+#include <gtk/gtkcheckbutton.h>
 #include <e-util/e-config.h>
 #include <calendar/gui/e-cal-config.h>
 #include <libedataserver/e-source.h>
@@ -80,6 +83,16 @@ url_changed (GtkEntry *entry, ESource *s
 	char *relative_uri;
 
 	uri = e_uri_new (gtk_entry_get_text (GTK_ENTRY (entry)));
+
+	if (strncmp (uri->protocol, "https", sizeof ("https") - 1) == 0) {
+		gpointer secure_checkbox;
+
+		secure_checkbox = g_object_get_data (G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (entry))),
+		                                     "secure_checkbox");
+                 
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (secure_checkbox), TRUE);
+	}
+
 	relative_uri = print_uri_noproto (uri);
 	e_source_set_relative_uri (source, relative_uri);
 	g_free (relative_uri);
@@ -212,6 +225,15 @@ option_changed (GtkOptionMenu *option, E
 	g_free (refresh_str);
 }
 
+static void 
+secure_setting_changed (GtkWidget *widget, ESource *source)
+{
+	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+		e_source_set_property (source, "secure", "1");
+	else 
+		e_source_set_property (source, "secure", "0");
+}
+
 GtkWidget *
 e_calendar_http_refresh (EPlugin *epl, EConfigHookItemFactoryData *data)
 {
@@ -284,6 +306,34 @@ e_calendar_http_refresh (EPlugin *epl, E
 	return hbox;
 }
 
+GtkWidget *
+e_calendar_http_secure (EPlugin *epl, EConfigHookItemFactoryData *data)
+{
+	ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
+	GtkWidget *secure_setting, *parent;
+	const char *secure_prop;
+	int row;
+
+	parent = data->parent;
+
+	row = ((GtkTable*)parent)->nrows;
+
+	secure_setting = gtk_check_button_new_with_label (_("Secure connection"));
+
+	secure_prop = e_source_get_property (t->source, "secure");
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (secure_setting), (secure_prop && g_str_equal (secure_prop, "1"))  ? TRUE : FALSE);
+  
+	g_signal_connect (secure_setting, "toggled", G_CALLBACK (secure_setting_changed), t->source);
+
+	gtk_widget_show (secure_setting);
+	gtk_table_attach (GTK_TABLE (parent), secure_setting, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+
+	/* Store pointer to secure checkbox so we can retrieve it in url_changed() */
+	g_object_set_data (G_OBJECT (parent), "secure_checkbox", (gpointer)secure_setting);
+	
+	return secure_setting;
+}
+
 gboolean
 e_calendar_http_check (EPlugin *epl, EConfigHookPageCheckData *data)
 {
@@ -292,23 +342,24 @@ e_calendar_http_check (EPlugin *epl, ECo
 	EUri *uri;
 	gboolean ok = FALSE;
 	ESourceGroup *group = e_source_peek_group (t->source);
-        char *uri_text;
+	char *uri_text;
 
 	if (strncmp (e_source_group_peek_base_uri (group), "webcal", 6))
 		return TRUE;
 
-        uri_text = e_source_get_uri (t->source);
-        if (!strncmp (uri_text, "file:", 5)) {
-                g_free (uri_text);
-                return FALSE;
-        }
+	uri_text = e_source_get_uri (t->source);
+	if (!strncmp (uri_text, "file:", 5)) {
+		g_free (uri_text);
+		return FALSE;
+	}
 
 	uri = e_uri_new (uri_text);
 	ok = ((!strcmp (uri->protocol, "webcal")) ||
-              (!strcmp (uri->protocol, "http")) ||
-              (!strcmp (uri->protocol, "file")) );
+	      (!strcmp (uri->protocol, "http")) ||
+	      (!strcmp (uri->protocol, "https")) ||
+	      (!strcmp (uri->protocol, "file")) );
 	e_uri_free (uri);
-        g_free (uri_text);
+	g_free (uri_text);
 
 	return ok;
 }
--- evolution-2.5.3/plugins/calendar-http/org-gnome-calendar-http.eplug.xml-	2005-06-18 21:39:18.000000000 +1000
+++ evolution-2.5.3/plugins/calendar-http/org-gnome-calendar-http.eplug.xml	2005-12-31 08:36:25.000000000 +1100
@@ -16,9 +16,13 @@
 		 type="item_table"
 		 path="00.general/00.source/40.url"
 		 factory="e_calendar_http_url"/>
+                <item
+		 type="item_table"
+		 path="00.general/00.source/50.secure"
+		 factory="e_calendar_http_secure"/>
 		<item
 		 type="item_table"
-		 path="00.general/00.source/50.refresh"
+		 path="00.general/00.source/60.refresh"
 		 factory="e_calendar_http_refresh"/>
             </group>
         </hook>


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