[Commits] [SCM] claws branch, master, updated. 3.16.0-224-gc927230

claws at claws-mail.org claws at claws-mail.org
Fri Jun 29 13:51:27 CEST 2018


The branch, master has been updated
       via  c927230cdcc4fbff1c75d148028a1949f43a4722 (commit)
      from  bc4d3678036bc6b6fe3c54e19f5f075559d08706 (commit)

Summary of changes:
 src/account.c     |   15 +++++++++-
 src/account.h     |    1 +
 src/messageview.c |   85 ++++++++++++++++++++++++++++++-----------------------
 3 files changed, 63 insertions(+), 38 deletions(-)


- Log -----------------------------------------------------------------
commit c927230cdcc4fbff1c75d148028a1949f43a4722
Author: Paul <paul at claws-mail.org>
Date:   Fri Jun 29 12:51:24 2018 +0100

    when a return-receipt request is sent to an unknown addr, make the user choose which acc to send from

diff --git a/src/account.c b/src/account.c
index b51e7b8..af3383f 100644
--- a/src/account.c
+++ b/src/account.c
@@ -276,7 +276,20 @@ GList *account_find_all_from_address(GList *ac_list, const gchar *address)
 	}
 	return ac_list;
 }
-	
+
+GList *account_find_all(void)
+{
+	GList *cur;
+	PrefsAccount *ac;
+	GList *ac_list = NULL;
+
+	for (cur = account_list; cur != NULL; cur = cur->next) {
+		ac = (PrefsAccount *)cur->data;
+		ac_list = g_list_append(ac_list, ac);
+	}
+	return ac_list;
+}
+
 PrefsAccount *account_find_from_smtp_server(const gchar *address,
 					    const gchar *smtp_server)
 {
diff --git a/src/account.h b/src/account.h
index 649366b..6d9319a 100644
--- a/src/account.h
+++ b/src/account.h
@@ -48,6 +48,7 @@ void	      account_write_config_all	(void);
 
 GList        *account_find_all_from_address	(GList		*ac_list,
 						 const gchar	*address);
+GList	     *account_find_all		(void);
 PrefsAccount *account_find_from_smtp_server	(const gchar	*address,
 						 const gchar	*smtp_server);
 PrefsAccount *account_find_from_address		(const gchar	*address, gboolean newsgroups_ok);
diff --git a/src/messageview.c b/src/messageview.c
index 652d06f..38a08eb 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -167,7 +167,8 @@ static void reply_cb			(GtkAction	*action,
 					 gpointer	 data);
 
 static PrefsAccount *select_account_from_list
-					(GList		*ac_list);
+					(GList		*ac_list,
+					 gboolean	 has_accounts);
 static void addressbook_open_cb		(GtkAction	*action,
 					 gpointer	 data);
 static void add_address_cb		(GtkAction	*action,
@@ -868,32 +869,13 @@ static gint disposition_notification_send(MsgInfo *msginfo)
 	ac_list = account_find_all_from_address(ac_list, msginfo->cc);
 
 	if (ac_list == NULL) {
-		AlertValue val;
-		gchar *tr;
-		gchar *text;
-		tr = g_strdup(C_("'%s' stands for 'To' then 'Cc'",
-		    "This message is asking for a return receipt notification\n"
-		    "but according to its '%s' and '%s' headers it was not\n"
-		    "officially addressed to you.\n"
-		    "It is advised to not send the return receipt."));
-		text = g_strdup_printf(tr,
-		  prefs_common_translated_header_name("To"),
-		  prefs_common_translated_header_name("Cc"));
-		val = alertpanel_full(_("Warning"),
-		  text,
-		  _("_Don't Send"), _("_Send"), NULL, ALERTFOCUS_FIRST, FALSE,
-		  NULL, ALERT_WARNING);
-		g_free(text);
-		g_free(tr);
-		if (val != G_ALERTALTERNATE)
+		ac_list = account_find_all();
+		if ((account = select_account_from_list(ac_list,0)) == NULL)
 			return -1;
-	}
-
-	if (g_list_length(ac_list) > 1) {
-		if ((account = select_account_from_list(ac_list)) == NULL)
+	} else if (g_list_length(ac_list) > 1) {
+		if ((account = select_account_from_list(ac_list,1)) == NULL)
 			return -1;
-	}
-	else if (ac_list != NULL)
+	} else if (ac_list != NULL)
 		account = (PrefsAccount *) ac_list->data;
 	g_list_free(ac_list);
 
@@ -970,7 +952,17 @@ static gint disposition_notification_send(MsgInfo *msginfo)
 		goto FILE_ERROR;
 
 	/* From */
-	if (fprintf(fp, "From: %s\n", msginfo->to) < 0)
+	if (account->name && *account->name) {
+		notification_convert_header(&buf, account->name, strlen("From: "));
+		if (buf == NULL)
+			goto FILE_ERROR;
+		if (fprintf(fp, "From: %s <%s>\n", buf, account->address) < 0) {
+			g_free(buf);
+			goto FILE_ERROR;
+		}
+		g_free(buf);
+		buf = NULL;
+	} else
 		goto FILE_ERROR;
 
 	if (fprintf(fp, "To: %s\n", to) < 0)
@@ -2080,30 +2072,49 @@ static void select_account_cb(GtkWidget *w, gpointer data)
 	*(gint*)data = combobox_get_active_data(GTK_COMBO_BOX(w));
 }
 
-static PrefsAccount *select_account_from_list(GList *ac_list)
+static PrefsAccount *select_account_from_list(GList *ac_list, gboolean has_accounts)
 {
 	GtkWidget *optmenu;
 	gint account_id;
+	AlertValue val;
+	gchar *text;
 
 	cm_return_val_if_fail(ac_list != NULL, NULL);
 	cm_return_val_if_fail(ac_list->data != NULL, NULL);
-	
+
 	optmenu = gtkut_account_menu_new(ac_list,
 			G_CALLBACK(select_account_cb),
 			&account_id);
 	if (!optmenu)
 		return NULL;
 	account_id = ((PrefsAccount *) ac_list->data)->account_id;
-	if (alertpanel_with_widget(
-				_("Return Receipt Notification"),
-				_("More than one of your accounts uses the "
-				  "address that this message was sent to.\n"
-				  "Please choose which account you want to "
-				  "use for sending the receipt notification:"),
-			        _("_Cancel"), _("_Send Notification"), NULL, ALERTFOCUS_FIRST,
-			        FALSE, optmenu) != G_ALERTALTERNATE)
+	if (has_accounts == FALSE) {
+		gchar *tr;
+		tr = g_strdup(C_("'%s' stands for 'To' then 'Cc'",
+		    "This message is asking for a return receipt notification\n"
+		    "but according to its '%s' and '%s' headers it was not\n"
+		    "officially addressed to you.\n"
+		    "It is advised to not send the return receipt."));
+		text = g_strdup_printf(tr,
+		  prefs_common_translated_header_name("To"),
+		  prefs_common_translated_header_name("Cc"));
+		g_free(tr);
+	} else
+		text = _("More than one of your accounts uses the "
+			 "address that this message was sent to.\n"
+			 "Please choose which account you want to "
+			 "use for sending the receipt notification:");
+
+	val = alertpanel_with_widget(
+			_("Return Receipt Notification"),
+			text,
+			_("_Cancel"), _("_Send Notification"), NULL, ALERTFOCUS_FIRST,
+			FALSE, optmenu);
+	
+	if (val != G_ALERTALTERNATE)
 		return NULL;
-	return account_find_from_id(account_id);
+	else
+		return account_find_from_id(account_id);
 }
 
 /* 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list