Re: [evolution-patches] patch for #65932



On Fri, 2004-09-24 at 17:04 +0200, Rodrigo Moya wrote:
> This should fix the crash specified in the bug.
>
updated patch, which includes making auth_new_cal_from_uri search over
the ESourceList to get the ESource associated with the given URI. This
makes this function actually work for backends that need authentication.
-- 
Rodrigo Moya <rodrigo novell com>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2500.2.15
diff -u -p -r1.2500.2.15 ChangeLog
--- ChangeLog	27 Sep 2004 14:10:11 -0000	1.2500.2.15
+++ ChangeLog	27 Sep 2004 17:40:06 -0000
@@ -1,3 +1,15 @@
+2004-09-27  Rodrigo Moya <rodrigo novell com>
+
+	Fixes #65932
+
+	* common/authentication.c: keep a hash table of all the source lists.
+	(auth_new_cal_from_uri): do a search in the source list for the given URI,
+	and use that ESource if we find it. Also, keep the hash table of source
+	lists up to date.
+
+	* gui/comp-editor-factory.c (cal_opened_cb): don't assert on error
+	cases, just display an error dialog.
+
 2004-09-24  Rodrigo Moya <rodrigo novell com>
 
 	Fixes #65599
Index: common/authentication.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/common/authentication.c,v
retrieving revision 1.7.4.1
diff -u -p -r1.7.4.1 authentication.c
--- common/authentication.c	16 Sep 2004 14:45:53 -0000	1.7.4.1
+++ common/authentication.c	27 Sep 2004 17:40:06 -0000
@@ -30,6 +30,8 @@
 #include "e-util/e-passwords.h"
 #include "authentication.h"
 
+static GHashTable *source_lists_hash = NULL;
+
 static char *
 auth_func_cb (ECal *ecal, const char *prompt, const char *key, gpointer user_data)
 {
@@ -79,24 +81,63 @@ auth_new_cal_from_source (ESource *sourc
 ECal *
 auth_new_cal_from_uri (const char *uri, ECalSourceType type)
 {
-	ESourceGroup *group;
-	ESource *source;
+	ESourceGroup *group = NULL;
+	ESource *source = NULL;
 	ECal *cal;
+	ESourceList *source_list = NULL;
+
+	/* try to find the source in the source list in GConf */
+	source_list = g_hash_table_lookup (source_lists_hash, &type);
+	if (!source_list) {
+		if (e_cal_get_sources (&source_list, type, NULL)) {
+			if (!source_lists_hash)
+				source_lists_hash = g_hash_table_new (g_int_hash, g_int_equal);
+
+			g_hash_table_insert (source_lists_hash, &type, source_list);
+		}
+	}
+
+	if (source_list) {
+		GSList *gl;
+
+		for (gl = e_source_list_peek_groups (source_list); gl != NULL && source == NULL; gl = gl->next) {
+			GSList *sl;
+
+			for (sl = e_source_group_peek_sources (gl->data); sl != NULL; sl = sl->next) {
+				char *source_uri;
+
+				source_uri = e_source_get_uri (sl->data);
+				if (source_uri) {
+					if (!strcmp (source_uri, uri)) {
+						g_free (source_uri);
+						source = g_object_ref (sl->data);
+						break;
+					}
+
+					g_free (source_uri);
+				}
+			}
+		}
+	}
 
-	group = e_source_group_new ("", uri);
-	source = e_source_new ("", "");
-	e_source_set_group (source, group);
-
-	/* we explicitly check for groupwise:// uris, to force authentication on them */
-	if (!strncmp (uri, "groupwise://", strlen ("groupwise://"))) {
-		e_source_set_property (source, "auth", "yes");
-		/* FIXME: need to retrieve the username */
+	if (!source) {
+		group = e_source_group_new ("", uri);
+		source = e_source_new ("", "");
+		e_source_set_group (source, group);
+
+		/* we explicitly check for groupwise:// uris, to force authentication on them */
+		if (!strncmp (uri, "groupwise://", strlen ("groupwise://"))) {
+			e_source_set_property (source, "auth", "1");
+			e_source_set_property (source, "auth-domain", "Groupwise");
+			/* FIXME: need to retrieve the username */
+		}
 	}
 
 	cal = auth_new_cal_from_source (source, type);
 
 	g_object_unref (source);
-	g_object_unref (group);
+	if (group)
+		g_object_unref (group);
 
 	return cal;
 }
Index: gui/comp-editor-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/comp-editor-factory.c,v
retrieving revision 1.37
diff -u -p -r1.37 comp-editor-factory.c
--- gui/comp-editor-factory.c	18 May 2004 14:14:14 -0000	1.37
+++ gui/comp-editor-factory.c	27 Sep 2004 17:40:06 -0000
@@ -410,8 +410,9 @@ cal_opened_cb (ECal *client, ECalendarSt
 		break;
 
 	case E_CALENDAR_STATUS_NO_SUCH_CALENDAR:
-		/* oops - we specified only_if_exists = FALSE */
-		g_assert_not_reached ();
+		dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+						 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+						 _("Calendar not found"));
 		return;
 
 	case E_CALENDAR_STATUS_PROTOCOL_NOT_SUPPORTED:
@@ -425,9 +426,17 @@ cal_opened_cb (ECal *client, ECalendarSt
 						 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
 						 _("Permission denied to open the calendar"));
 		break;
-		
+
+	case E_CALENDAR_STATUS_AUTHENTICATION_FAILED :
+		dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+						 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+						 _("Authentication failed"));
+		break;
+
 	default:
-		g_assert_not_reached ();
+		dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+						 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+						 _("Unknown error"));
 		return;
 	}
 


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