evolution r35964 - in trunk/addressbook: . gui/component gui/widgets



Author: mcrha
Date: Tue Aug 12 08:44:09 2008
New Revision: 35964
URL: http://svn.gnome.org/viewvc/evolution?rev=35964&view=rev

Log:
2008-08-12  Milan Crha  <mcrha redhat com>

	** Fix for bug #547308

	* gui/component/addressbook.c: (load_source_auth_cb):
	Do not try to authenticate to the server more than twice when knows
	the password and it didn't fail because of wrong user name/password.
	* gui/widgets/eab-gui-util.c: (const char *status_to_string[]):
	New string for new status code.
	* gui/widgets/eab-gui-util.c: (eab_load_error_dialog):
	Include detailed error in generic failure error, if available and is
	not a repository offline error.



Modified:
   trunk/addressbook/ChangeLog
   trunk/addressbook/gui/component/addressbook.c
   trunk/addressbook/gui/widgets/eab-gui-util.c

Modified: trunk/addressbook/gui/component/addressbook.c
==============================================================================
--- trunk/addressbook/gui/component/addressbook.c	(original)
+++ trunk/addressbook/gui/component/addressbook.c	Tue Aug 12 08:44:09 2008
@@ -73,6 +73,9 @@
 load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
 {
 	LoadSourceData *data = closure;
+	gboolean was_in = g_object_get_data (G_OBJECT (book), "authenticated") != NULL;
+
+	g_object_set_data (G_OBJECT (book), "authenticated", NULL);
 
 	if (data->cancelled) {
 		free_load_source_data (data);
@@ -99,38 +102,42 @@
 						"%s", _("Accessing LDAP Server anonymously"));
 				g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
 				gtk_widget_show (dialog);
-				if (data->cb)
-					data->cb (book, E_BOOK_ERROR_OK, data->closure);
-				free_load_source_data (data);
-				return;
+				status = E_BOOK_ERROR_OK;
+
+				goto done;
 			}
 		} else if (status == E_BOOK_ERROR_INVALID_SERVER_VERSION) {
 			e_error_run (NULL, "addressbook:server-version", NULL);
 			status = E_BOOK_ERROR_OK;
-			if (data->cb)
-				data->cb (book, status, data->closure);
-			free_load_source_data (data);
-			return;
-
+			goto done;
+		} else if (status == E_BOOK_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) {
+			goto done;
 		} else {
-			const gchar *uri = e_book_get_uri (book);
-			gchar *stripped_uri = remove_parameters_from_uri (uri);
-			const gchar *auth_domain = e_source_get_property (data->source, "auth-domain");
-			const gchar *component_name;
+			if (status == E_BOOK_ERROR_AUTHENTICATION_FAILED) {
+				const gchar *uri = e_book_get_uri (book);
+				gchar *stripped_uri = remove_parameters_from_uri (uri);
+				const gchar *auth_domain = e_source_get_property (data->source, "auth-domain");
+				const gchar *component_name;
 
-			component_name = auth_domain ? auth_domain : "Addressbook";
+				component_name = auth_domain ? auth_domain : "Addressbook";
 
-			if (status == E_BOOK_ERROR_AUTHENTICATION_FAILED) {
 				e_passwords_forget_password (component_name, stripped_uri);
+
+				g_free (stripped_uri);
+			} else if (was_in) {
+				/* We already tried to authenticate to the server, and it failed with
+				   other reason than with E_BOOK_ERROR_AUTHENTICATION_FAILED, thus stop
+				   poking with the server and report error to the user. */
+				goto done;
 			}
 
+			g_object_set_data (G_OBJECT (book), "authenticated", GINT_TO_POINTER (1));
 			addressbook_authenticate (book, TRUE, data->source, load_source_auth_cb, closure);
-
-			g_free (stripped_uri);
 			return;
 		}
 	}
 
+done:
 	if (data->cb)
 		data->cb (book, status, data->closure);
 

Modified: trunk/addressbook/gui/widgets/eab-gui-util.c
==============================================================================
--- trunk/addressbook/gui/widgets/eab-gui-util.c	(original)
+++ trunk/addressbook/gui/widgets/eab-gui-util.c	Tue Aug 12 08:44:09 2008
@@ -75,7 +75,8 @@
 	/* E_BOOK_ERROR_NO_SUCH_SOURCE */                       N_("No such source"),
 	/* E_BOOK_ERROR_OFFLINE_UNAVAILABLE */			N_("Not available in offline mode"),
 	/* E_BOOK_ERROR_OTHER_ERROR */                          N_("Other error"),
-	/* E_BOOK_ERROR_INVALID_SERVER_VERSION */		N_("Invalid server version")
+	/* E_BOOK_ERROR_INVALID_SERVER_VERSION */		N_("Invalid server version"),
+	/* E_BOOK_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD */    N_("Unsupported authentication method")
 };
 
 void
@@ -131,6 +132,12 @@
 			_("We were unable to open this addressbook.  This either "
 			  "means you have entered an incorrect URI, or the server "
 			  "is unreachable.");
+
+		/* do not show repository offline message, it's kind of generic error */
+		if (status != E_BOOK_ERROR_REPOSITORY_OFFLINE && status > 0 && status < G_N_ELEMENTS (status_to_string) && status_to_string [status]) {
+			label = g_strconcat (label_string, "\n\n", _("Detailed error:"), " ", _(status_to_string [status]), NULL);
+			label_string = label;
+		}
 	}
 
 	dialog  = e_error_new ((GtkWindow *) parent, "addressbook:load-error", label_string, NULL);



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