evolution-data-server r8390 - in trunk: . camel camel/providers/groupwise camel/providers/imap camel/providers/imap4 camel/providers/imapp camel/providers/nntp camel/providers/pop3 camel/providers/smtp docs/reference/camel



Author: mbarnes
Date: Thu Jan 17 21:00:56 2008
New Revision: 8390
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8390&view=rev

Log:
2008-01-17  Matthew Barnes  <mbarnes redhat com>

	** Fixes bug #506250

	* docs/reference/camel/camel-sections.txt:
	Add camel_session_build_password_prompt.

	* camel/camel-session.c (camel_session_build_password_prompt):
	New function constructs a password prompt markup string from the
	given account type, user name, and host name.  The prompt string
	is suitable for use in a password prompt dialog.

	* camel/providers/nntp/camel-nntp-auth.c
        (camel_nntp_auth_authenticate):
	* camel/providers/nntp/camel-nntp-store.c
        (camel_nntp_try_authenticate):
	* camel/providers/pop3/camel-pop3-store.c (pop3_try_authenticate):
	* camel/providers/camel-smtp-transport.c (smtp_connect):
	* camel/providers/camel-groupwise-store.c (groupwise_auth_loop):
	* camel/providers/imap/camel-imap-store.c (imap_auth_loop):
	* camel/providers/imapp/camel-imapp-store.c (store_get_pass):
	* camel/providers/imap4/camel-imap4-store.c (imap4_try_authenticate):
	Use a consistently worded password prompt message by calling
	camel_session_build_password_prompt().



Modified:
   trunk/ChangeLog
   trunk/camel/ChangeLog
   trunk/camel/camel-session.c
   trunk/camel/camel-session.h
   trunk/camel/providers/groupwise/ChangeLog
   trunk/camel/providers/groupwise/camel-groupwise-store.c
   trunk/camel/providers/imap/ChangeLog
   trunk/camel/providers/imap/camel-imap-store.c
   trunk/camel/providers/imap4/ChangeLog
   trunk/camel/providers/imap4/camel-imap4-store.c
   trunk/camel/providers/imapp/ChangeLog
   trunk/camel/providers/imapp/camel-imapp-store.c
   trunk/camel/providers/nntp/ChangeLog
   trunk/camel/providers/nntp/camel-nntp-auth.c
   trunk/camel/providers/nntp/camel-nntp-store.c
   trunk/camel/providers/pop3/ChangeLog
   trunk/camel/providers/pop3/camel-pop3-store.c
   trunk/camel/providers/smtp/ChangeLog
   trunk/camel/providers/smtp/camel-smtp-transport.c
   trunk/docs/reference/camel/camel-sections.txt

Modified: trunk/camel/camel-session.c
==============================================================================
--- trunk/camel/camel-session.c	(original)
+++ trunk/camel/camel-session.c	Thu Jan 17 21:00:56 2008
@@ -428,6 +428,49 @@
 	return CS_CLASS (session)->alert_user (session, type, prompt, cancel);
 }
 
+/**
+ * camel_session_build_password_prompt:
+ * @type: account type (e.g. "IMAP")
+ * @user: user name for the account
+ * @host: host name for the account
+ *
+ * Constructs a localized password prompt from @type, @user and @host,
+ * suitable for passing to camel_session_get_password().  The resulting
+ * string contains markup tags.  Use g_free() to free it.
+ *
+ * Returns: a newly-allocated password prompt string
+ **/
+char *
+camel_session_build_password_prompt (const char *type,
+                                     const char *user,
+                                     const char *host)
+{
+	char *user_markup;
+	char *host_markup;
+	char *prompt;
+
+	g_return_val_if_fail (type != NULL, NULL);
+	g_return_val_if_fail (user != NULL, NULL);
+	g_return_val_if_fail (host != NULL, NULL);
+
+	/* Add bold tags to the "user" and "host" strings.  We use
+	 * separate strings here to avoid putting markup tags in the
+	 * translatable string below. */
+	user_markup = g_strdup_printf ("<b>%s</b>", user);
+	host_markup = g_strdup_printf ("<b>%s</b>", host);
+
+	/* Translators: The first argument is the account type
+	 * (e.g. "IMAP"), the second is the user name, and the
+	 * third is the host name. */
+	prompt = g_strdup_printf (
+		_("Please enter the %s password for %s on host %s."),
+		type, user_markup, host_markup);
+
+	g_free (user_markup);
+	g_free (host_markup);
+
+	return prompt;
+}
 
 /**
  * camel_session_is_online:

Modified: trunk/camel/camel-session.h
==============================================================================
--- trunk/camel/camel-session.h	(original)
+++ trunk/camel/camel-session.h	Thu Jan 17 21:00:56 2008
@@ -155,6 +155,11 @@
 						     const char *prompt,
 						     gboolean cancel);
 
+char *		   camel_session_build_password_prompt
+						    (const char *type,
+						     const char *user,
+						     const char *host);
+
 gboolean           camel_session_is_online          (CamelSession *session);
 void               camel_session_set_online         (CamelSession *session,
 						     gboolean online);

Modified: trunk/camel/providers/groupwise/camel-groupwise-store.c
==============================================================================
--- trunk/camel/providers/groupwise/camel-groupwise-store.c	(original)
+++ trunk/camel/providers/groupwise/camel-groupwise-store.c	Thu Jan 17 21:00:56 2008
@@ -194,10 +194,8 @@
 		if (!service->url->passwd && !(store->flags & CAMEL_STORE_PROXY)) {
 			char *prompt;
 
-			prompt = g_strdup_printf (_("Please enter the GroupWise "
-						    "password for %s %s"),
-						  service->url->user,
-						  service->url->host);
+			prompt = camel_session_build_password_prompt (
+				"GroupWise", service->url->user, service->url->host);
 			service->url->passwd =
 				camel_session_get_password (session, service, "Groupwise",
 							    prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);

Modified: trunk/camel/providers/imap/camel-imap-store.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-store.c	(original)
+++ trunk/camel/providers/imap/camel-imap-store.c	Thu Jan 17 21:00:56 2008
@@ -1368,18 +1368,23 @@
 		}
 
 		if (!service->url->passwd) {
-			char *prompt;
+			char *base_prompt;
+			char *full_prompt;
 
-			prompt = g_strdup_printf (_("%sPlease enter the IMAP "
-				"password for %s %s"),
-				errbuf ? errbuf : "",
-				service->url->user,
-				service->url->host);
-
-			service->url->passwd =
-				camel_session_get_password (session, service, auth_domain,
-					prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
-			g_free (prompt);
+			base_prompt = camel_session_build_password_prompt (
+				"IMAP", service->url->user, service->url->host);
+
+			if (errbuf != NULL)
+				full_prompt = g_strconcat (errbuf, base_prompt, NULL);
+			else
+				full_prompt = g_strdup (base_prompt);
+
+			service->url->passwd = camel_session_get_password (
+				session, service, auth_domain, full_prompt,
+				"password", CAMEL_SESSION_PASSWORD_SECRET, ex);
+
+			g_free (base_prompt);
+			g_free (full_prompt);
 			g_free (errbuf);
 			errbuf = NULL;
 

Modified: trunk/camel/providers/imap4/camel-imap4-store.c
==============================================================================
--- trunk/camel/providers/imap4/camel-imap4-store.c	(original)
+++ trunk/camel/providers/imap4/camel-imap4-store.c	Thu Jan 17 21:00:56 2008
@@ -453,19 +453,26 @@
 
 	if ((!mech || (mech && mech->need_password)) && !service->url->passwd) {
 		guint32 flags = CAMEL_SESSION_PASSWORD_SECRET;
-		char *prompt;
+		char *base_prompt;
+		char *full_prompt;
 
 		if (reprompt)
 			flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
 
-		prompt = g_strdup_printf (_("%sPlease enter the IMAP password for %s on host %s"),
-					  errmsg ? errmsg : "",
-					  service->url->user,
-					  service->url->host);
+		base_prompt = camel_session_build_password_prompt (
+			"IMAP", service->url->user, service->url->host);
 
-		service->url->passwd = camel_session_get_password (session, service, NULL, prompt, "password", flags, ex);
+		if (errmsg != NULL)
+			full_prompt = g_strconcat (errmsg, base_prompt, NULL);
+		else
+			full_prompt = g_strdup (full_prompt);
+
+		service->url->passwd = camel_session_get_password (
+			session, service, NULL, full_prompt,
+			"password", flags, ex);
 
-		g_free (prompt);
+		g_free (base_prompt);
+		g_free (full_prompt);
 
 		if (!service->url->passwd)
 			return FALSE;

Modified: trunk/camel/providers/imapp/camel-imapp-store.c
==============================================================================
--- trunk/camel/providers/imapp/camel-imapp-store.c	(original)
+++ trunk/camel/providers/imapp/camel-imapp-store.c	Thu Jan 17 21:00:56 2008
@@ -357,19 +357,28 @@
 store_get_pass(CamelIMAPPStore *store)
 {
 	if (((CamelService *)store)->url->passwd == NULL) {
-		char *prompt;
+		char *base_prompt;
+		char *full_prompt;
 		CamelException ex;
 
 		camel_exception_init(&ex);
 
-		prompt = g_strdup_printf (_("%sPlease enter the IMAP password for %s %s"),
-					  store->login_error?store->login_error:"",
-					  ((CamelService *)store)->url->user,
-					  ((CamelService *)store)->url->host);
-		((CamelService *)store)->url->passwd = camel_session_get_password(camel_service_get_session((CamelService *)store),
-										  (CamelService *)store, NULL,
-										  prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, &ex);
-		g_free (prompt);
+		base_prompt = camel_session_build_password_prompt (
+			"IMAP", ((CamelService *) store)->url->user,
+			((CamelService *) store)->url->host);
+
+		if (store->login_error != NULL)
+			full_prompt = g_strconcat (store->login_error, base_prompt, NULL);
+		else
+			full_prompt = g_strdup (base_prompt);
+
+		((CamelService *)store)->url->passwd = camel_session_get_password (
+			camel_service_get_session ((CamelService *) store),
+			(CamelService *) store, NULL, full_prompt, "password",
+			CAMEL_SESSION_PASSWORD_SECRET, &ex);
+
+		g_free (base_prompt);
+		g_free (full_prompt);
 		if (camel_exception_is_set(&ex))
 			camel_exception_throw_ex(&ex);
 	}

Modified: trunk/camel/providers/nntp/camel-nntp-auth.c
==============================================================================
--- trunk/camel/providers/nntp/camel-nntp-auth.c	(original)
+++ trunk/camel/providers/nntp/camel-nntp-auth.c	Thu Jan 17 21:00:56 2008
@@ -43,11 +43,12 @@
 	if (!service->url->authmech && !service->url->passwd) {
 		gchar *prompt;
 
-		prompt = g_strdup_printf (_("Please enter the NNTP password for %s %s"),
-					  service->url->user, service->url->host);
-		service->url->passwd =
-			camel_session_get_password (session, prompt,
-						    TRUE, service, "password", ex);
+		prompt = camel_session_build_password_prompt (
+			"NNTP", service->url->user, service->url->host);
+
+		service->url->passwd = camel_session_get_password (
+			session, prompt, TRUE, service, "password", ex);
+
 		g_free (prompt);
 
 		if (!service->url->passwd) {

Modified: trunk/camel/providers/nntp/camel-nntp-store.c
==============================================================================
--- trunk/camel/providers/nntp/camel-nntp-store.c	(original)
+++ trunk/camel/providers/nntp/camel-nntp-store.c	Thu Jan 17 21:00:56 2008
@@ -1159,9 +1159,8 @@
 	if (!service->url->passwd) {
 		char *prompt, *base;
 	retry:
-		base = g_strdup_printf (_("Please enter the NNTP password for %s %s"),
-					service->url->user,
-					service->url->host);
+		base = camel_session_build_password_prompt (
+			"NNTP", service->url->user, service->url->host);
 		if (line) {
 			char *top = g_strdup_printf(_("Cannot authenticate to server: %s"), line);
 

Modified: trunk/camel/providers/pop3/camel-pop3-store.c
==============================================================================
--- trunk/camel/providers/pop3/camel-pop3-store.c	(original)
+++ trunk/camel/providers/pop3/camel-pop3-store.c	Thu Jan 17 21:00:56 2008
@@ -469,19 +469,27 @@
 	service->url->authmech = g_strdup("LOGIN");*/
 
 	if (!service->url->passwd) {
-		char *prompt;
+		char *base_prompt;
+		char *full_prompt;
 		guint32 flags = CAMEL_SESSION_PASSWORD_SECRET;
 
 		if (reprompt)
 			flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
 
-		prompt = g_strdup_printf (_("%sPlease enter the POP password for %s on host %s"),
-					  errmsg ? errmsg : "",
-					  service->url->user,
-					  service->url->host);
-		service->url->passwd = camel_session_get_password (camel_service_get_session (service), service, NULL,
-								   prompt, "password", flags, ex);
-		g_free (prompt);
+		base_prompt = camel_session_build_password_prompt (
+			"POP", service->url->user, service->url->host);
+
+		if (errmsg != NULL)
+			full_prompt = g_strconcat (errmsg, base_prompt, NULL);
+		else
+			full_prompt = g_strdup (base_prompt);
+
+		service->url->passwd = camel_session_get_password (
+			camel_service_get_session (service), service,
+			NULL, full_prompt, "password", flags, ex);
+
+		g_free (base_prompt);
+		g_free (full_prompt);
 		if (!service->url->passwd)
 			return FALSE;
 	}

Modified: trunk/camel/providers/smtp/camel-smtp-transport.c
==============================================================================
--- trunk/camel/providers/smtp/camel-smtp-transport.c	(original)
+++ trunk/camel/providers/smtp/camel-smtp-transport.c	Thu Jan 17 21:00:56 2008
@@ -527,16 +527,23 @@
 			}
 
 			if (!service->url->passwd) {
-				char *prompt;
+				char *base_prompt;
+				char *full_prompt;
 
-				prompt = g_strdup_printf (_("%sPlease enter the SMTP password for %s on host %s"),
-							  errbuf ? errbuf : "", service->url->user,
-							  service->url->host);
+				base_prompt = camel_session_build_password_prompt (
+					"SMTP", service->url->user, service->url->host);
 
-				service->url->passwd = camel_session_get_password (session, service, NULL,
-						prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
+				if (errbuf != NULL)
+					full_prompt = g_strconcat (errbuf, base_prompt, NULL);
+				else
+					full_prompt = g_strdup (base_prompt);
+
+				service->url->passwd = camel_session_get_password (
+					session, service, NULL, full_prompt,
+					"password", CAMEL_SESSION_PASSWORD_SECRET, ex);
 
-				g_free (prompt);
+				g_free (base_prompt);
+				g_free (full_prompt);
 				g_free (errbuf);
 				errbuf = NULL;
 

Modified: trunk/docs/reference/camel/camel-sections.txt
==============================================================================
--- trunk/docs/reference/camel/camel-sections.txt	(original)
+++ trunk/docs/reference/camel/camel-sections.txt	Thu Jan 17 21:00:56 2008
@@ -1531,6 +1531,7 @@
 camel_session_get_password
 camel_session_forget_password
 camel_session_alert_user
+camel_session_build_password_prompt
 camel_session_is_online
 camel_session_set_online
 camel_session_get_filter_driver



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