--- libedataserverui/e-passwords.c.orig	2007-10-19 13:36:01.000000000 -0400
+++ libedataserverui/e-passwords.c	2007-10-19 13:42:50.000000000 -0400
@@ -314,11 +314,8 @@ ep_clear_passwords_keyring(EPassMsg *msg
 
 	result = gnome_keyring_get_default_keyring_sync (&default_keyring);
 	if (!default_keyring) {
-	        if (gnome_keyring_create_sync ("default", NULL) != GNOME_KEYRING_RESULT_OK) {
-				if (!msg->noreply)
-					e_msgport_reply(&msg->msg);
-				return;
-		}
+	        if (gnome_keyring_create_sync ("default", NULL) != GNOME_KEYRING_RESULT_OK)
+			return;
 	        default_keyring = g_strdup ("default");			
 	}
 
@@ -343,12 +340,10 @@ ep_clear_passwords_keyring(EPassMsg *msg
 	}
 	
 	g_free (default_keyring);
-	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
 }
 #endif
 static void
-ep_clear_passwords_file(EPassMsg *msg)
+ep_clear_passwords_keyfile(EPassMsg *msg)
 {
 	gchar *group;
 	GError *error = NULL;
@@ -364,9 +359,22 @@ ep_clear_passwords_file(EPassMsg *msg)
 	}
 
 	g_free (group);
+}
+
+static void
+ep_clear_passwords (EPassMsg *msg)
+{
+#ifdef WITH_GNOME_KEYRING
+	if (gnome_keyring_is_available ())
+		ep_clear_passwords_keyring (msg);
+	else
+		ep_clear_passwords_keyfile (msg);
+#else
+	ep_clear_passwords_keyfile (msg);
+#endif
 
 	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
+		e_msgport_reply (&msg->msg);
 }
 
 static gboolean
@@ -389,11 +397,8 @@ ep_forget_passwords_keyring(EPassMsg *ms
 
 	result = gnome_keyring_get_default_keyring_sync (&default_keyring);
 	if (!default_keyring) {
-	        if (gnome_keyring_create_sync ("default", NULL) != GNOME_KEYRING_RESULT_OK) {
-				if (!msg->noreply)
-					e_msgport_reply(&msg->msg);
-				return;
-		}
+	        if (gnome_keyring_create_sync ("default", NULL) != GNOME_KEYRING_RESULT_OK)
+			return;
 	        default_keyring = g_strdup ("default");			
 	}	
 	d(g_print("Get Default %d\n", result));
@@ -419,14 +424,11 @@ ep_forget_passwords_keyring(EPassMsg *ms
 
 	/* free up the session passwords */
 	g_hash_table_foreach_remove (passwords, free_entry, NULL);
-
-	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
 }
 #endif
 
 static void
-ep_forget_passwords_file(EPassMsg *msg)
+ep_forget_passwords_keyfile(EPassMsg *msg)
 {
 	gchar **groups;
 	gsize length, ii;
@@ -441,9 +443,22 @@ ep_forget_passwords_file(EPassMsg *msg)
 	}
 	ep_key_file_save ();
 	g_strfreev (groups);
+}
+
+static void
+ep_forget_passwords (EPassMsg *msg)
+{
+#ifdef WITH_GNOME_KEYRING
+	if (gnome_keyring_is_available ())
+		ep_forget_passwords_keyring (msg);
+	else
+		ep_forget_passwords_keyfile (msg);
+#else
+	ep_forget_passwords_keyfile (msg);
+#endif
 
 	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
+		e_msgport_reply (&msg->msg);
 }
 
 #ifdef WITH_GNOME_KEYRING
@@ -493,14 +508,11 @@ ep_remember_password_keyring(EPassMsg *m
 		
 		e_uri_free (uri);
 	}
-
-	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
 }
 #endif
 
 static void
-ep_remember_password_file(EPassMsg *msg)
+ep_remember_password_keyfile(EPassMsg *msg)
 {
 	gchar *group, *key, *password;
 
@@ -521,9 +533,22 @@ ep_remember_password_file(EPassMsg *msg)
 	g_free (group);
 	g_free (key);
 	g_free (password);
+}
+
+static void
+ep_remember_password (EPassMsg *msg)
+{
+#ifdef WITH_GNOME_KEYRING
+	if (gnome_keyring_is_available ())
+		ep_remember_password_keyring (msg);
+	else
+		ep_remember_password_keyfile (msg);
+#else
+	ep_remember_password_keyfile (msg);
+#endif
 
 	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
+		e_msgport_reply (&msg->msg);
 }
 
 #ifdef WITH_GNOME_KEYRING
@@ -606,15 +631,12 @@ ep_forget_password_keyring (EPassMsg *ms
 	g_free (default_keyring);
 
 exit:
-	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
-
 	e_uri_free(uri);
 }
 #endif
 
 static void
-ep_forget_password_file (EPassMsg *msg)
+ep_forget_password_keyfile (EPassMsg *msg)
 {
 	gchar *group, *key;
 	GError *error = NULL;
@@ -634,12 +656,24 @@ ep_forget_password_file (EPassMsg *msg)
 
 	g_free (group);
 	g_free (key);
+}
+
+static void
+ep_forget_password (EPassMsg *msg)
+{
+#ifdef WITH_GNOME_KEYRING
+	if (gnome_keyring_is_available ())
+		ep_forget_password_keyring (msg);
+	else
+		ep_forget_password_keyfile (msg);
+#else
+	ep_forget_password_keyfile (msg);
+#endif
 
 	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
+		e_msgport_reply (&msg->msg);
 }
 
-
 #ifdef WITH_GNOME_KEYRING
 static void
 ep_get_password_keyring (EPassMsg *msg)
@@ -715,14 +749,11 @@ ep_get_password_keyring (EPassMsg *msg)
 		
 		e_uri_free (uri);
 	}
-
-	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
 }	
 #endif
 
 static void
-ep_get_password_file (EPassMsg *msg)
+ep_get_password_keyfile (EPassMsg *msg)
 {
 	gchar *group, *key, *password;
 	GError *error = NULL;
@@ -747,9 +778,22 @@ ep_get_password_file (EPassMsg *msg)
 
 	g_free (group);
 	g_free (key);
+}
+
+static void
+ep_get_password (EPassMsg *msg)
+{
+#ifdef WITH_GNOME_KEYRING
+	if (gnome_keyring_is_available ())
+		ep_get_password_keyring (msg);
+	else
+		ep_get_password_keyfile (msg);
+#else
+	ep_get_password_keyfile (msg);
+#endif
 
 	if (!msg->noreply)
-		e_msgport_reply(&msg->msg);
+		e_msgport_reply (&msg->msg);
 }
 
 static void
@@ -785,17 +829,8 @@ pass_response(GtkDialog *dialog, int res
 				msg->oldpass = msg->password;
 				ep_add_password(msg);
 			}
-#ifdef WITH_GNOME_KEYRING
-			if (*msg->remember && type == E_PASSWORDS_REMEMBER_FOREVER) {
-				if (gnome_keyring_is_available())
-					ep_remember_password_keyring(msg);
-				else
-					ep_remember_password_file(msg);
-			}
-#else
 			if (*msg->remember && type == E_PASSWORDS_REMEMBER_FOREVER)
-				ep_remember_password_file(msg);				    
-#endif				    
+				ep_remember_password(msg);				    
 
 			msg->noreply = noreply;
 		}
@@ -812,16 +847,8 @@ pass_response(GtkDialog *dialog, int res
 	mw = (EPassMsg *)request_list.head;
 	mn = (EPassMsg *)mw->msg.ln.next;
 	while (mn) {
-#ifdef WITH_GNOME_KEYRING		
-		if ((mw->dispatch == (gnome_keyring_is_available() ? ep_forget_password_keyring : ep_forget_password_file)
-#else
-		if ((mw->dispatch == ep_forget_password_file		     
-#endif
-#ifdef WITH_GNOME_KEYRING				     
-		     || mw->dispatch == (gnome_keyring_is_available() ? ep_get_password_keyring : ep_get_password_file)
-#else
-		     || mw->dispatch == ep_get_password_file		     
-#endif
+		if ((mw->dispatch == ep_forget_password
+		     || mw->dispatch == ep_get_password
 		     || mw->dispatch == ep_ask_password)		    
 		    && (strcmp(mw->component, msg->component) == 0
 			&& strcmp(mw->key, msg->key) == 0)) {
@@ -880,14 +907,7 @@ ep_ask_password(EPassMsg *msg)
 	gtk_widget_grab_focus (msg->entry);
 	
 	if ((msg->flags & E_PASSWORDS_REPROMPT)) {
-#ifdef WITH_GNOME_KEYRING
-		if (gnome_keyring_is_available())
-			ep_get_password_keyring(msg);
-		else
-			ep_get_password_file(msg);			
-#else
-		ep_get_password_file(msg);
-#endif
+		ep_get_password(msg);
 		if (msg->password) {
 			gtk_entry_set_text ((GtkEntry *) msg->entry, msg->password);
 			g_free (msg->password);
@@ -1031,11 +1051,7 @@ e_passwords_set_online(int state)
 void
 e_passwords_forget_passwords (void)
 {
-#ifdef WITH_GNOME_KEYRING	
-	EPassMsg *msg = ep_msg_new(gnome_keyring_is_available() ? ep_forget_passwords_keyring : ep_forget_passwords_file);
-#else
-	EPassMsg *msg = ep_msg_new(ep_forget_passwords_file);
-#endif
+	EPassMsg *msg = ep_msg_new(ep_forget_passwords);
 	
 	ep_msg_send(msg);
 	ep_msg_free(msg);
@@ -1049,11 +1065,7 @@ e_passwords_forget_passwords (void)
 void
 e_passwords_clear_passwords (const char *component_name)
 {
-#ifdef WITH_GNOME_KEYRING	
-	EPassMsg *msg = ep_msg_new(gnome_keyring_is_available() ? ep_clear_passwords_keyring : ep_clear_passwords_file);
-#else
-	EPassMsg *msg = ep_msg_new(ep_clear_passwords_file);		
-#endif
+	EPassMsg *msg = ep_msg_new(ep_clear_passwords);		
 
 	msg->component = component_name;
 	ep_msg_send(msg);
@@ -1074,11 +1086,7 @@ e_passwords_remember_password (const cha
 	g_return_if_fail(component_name != NULL);
 	g_return_if_fail(key != NULL);
 
-#ifdef WITH_GNOME_KEYRING
-	msg = ep_msg_new(gnome_keyring_is_available() ? ep_remember_password_keyring : ep_remember_password_file);
-#else
-	msg = ep_msg_new(ep_remember_password_file);
-#endif	
+	msg = ep_msg_new(ep_remember_password);
 	msg->component = component_name;
 	msg->key = key;
 
@@ -1100,11 +1108,7 @@ e_passwords_forget_password (const char 
 	g_return_if_fail(component_name != NULL);
 	g_return_if_fail(key != NULL);
 
-#ifdef WITH_GNOME_KEYRING	
-	msg = ep_msg_new(gnome_keyring_is_available() ? ep_forget_password_keyring : ep_forget_password_file);
-#else	
-	msg = ep_msg_new(ep_forget_password_file);
-#endif	
+	msg = ep_msg_new(ep_forget_password);
 	msg->component = component_name;
 	msg->key = key;
 
@@ -1128,12 +1132,7 @@ e_passwords_get_password (const char *co
 	g_return_val_if_fail(component_name != NULL, NULL);
 	g_return_val_if_fail(key != NULL, NULL);
 
-#ifdef WITH_GNOME_KEYRING	
-	msg = ep_msg_new(gnome_keyring_is_available() ? ep_get_password_keyring : ep_get_password_file);
-#else
-	msg = ep_msg_new(ep_get_password_file);
-#endif	
-
+	msg = ep_msg_new(ep_get_password);
 	msg->component = component_name;
 	msg->key = key;
 
