[Commits] [SCM] claws branch, master, updated. 3.16.0-100-g36250f9

wwp at claws-mail.org wwp at claws-mail.org
Wed Mar 28 23:08:22 CEST 2018


The branch, master has been updated
       via  36250f91fd2aed984e71f1ad21439592523518dd (commit)
      from  07b12c904194d30be8138ed4a1c975aba7d0aa44 (commit)

Summary of changes:
 src/plugins/att_remover/att_remover.c |   37 ++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit 36250f91fd2aed984e71f1ad21439592523518dd
Author: wwp <wwp at free.fr>
Date:   Wed Mar 28 23:06:15 2018 +0200

    Attachment remover: notify the user about what has been done when processing
    multiple selections.

diff --git a/src/plugins/att_remover/att_remover.c b/src/plugins/att_remover/att_remover.c
index 4684a29..ad4cf8f 100644
--- a/src/plugins/att_remover/att_remover.c
+++ b/src/plugins/att_remover/att_remover.c
@@ -418,6 +418,8 @@ static void remove_attachments(GSList *msglist)
 	SummaryView *summaryview = mainwin->summaryview;
 	GSList *cur;
 	gint msgnum = -1;
+	gint stripped_msgs = 0;
+	gint total_msgs = 0;
 	
 	if (alertpanel_full(_("Destroy attachments"),
                   _("Do you really want to remove all attachments from "
@@ -437,10 +439,12 @@ static void remove_attachments(GSList *msglist)
 		MsgInfo *newmsg = NULL;
 		MimeInfo *info = NULL;
 		MimeInfo *partinfo = NULL;
+		MimeInfo *nextpartinfo = NULL;
 
 		if (!msginfo)
 			continue;
-		
+		total_msgs++;			/* count all processed messages */
+
 		newmsg = procmsg_msginfo_copy(msginfo);
 		info = procmime_scan_message(newmsg);
 	
@@ -448,12 +452,27 @@ static void remove_attachments(GSList *msglist)
 			procmsg_msginfo_free(&newmsg);
 			continue;
 		}
-		partinfo->node->next = NULL;
-		partinfo->node->children = NULL;
-		info->node->children->data = partinfo;
+		/* only strip attachments where there is at least one */
+		nextpartinfo = procmime_mimeinfo_next(partinfo);
+		if (nextpartinfo) {
+			partinfo->node->next = NULL;
+			partinfo->node->children = NULL;
+			info->node->children->data = partinfo;
+
+			msgnum = save_new_message(msginfo, newmsg, info, FALSE);
 
-		msgnum = save_new_message(msginfo, newmsg, info, FALSE);		
+			stripped_msgs++;	/* count messages with removed attachment(s) */
+		}
 	}
+	if (stripped_msgs == 0) {
+		alertpanel_notice(_("The selected messages don't have any attachments."));
+	} else {
+		if (stripped_msgs != total_msgs)
+			alertpanel_notice(_("Attachments removed from %d of the %d selected messages."),
+							stripped_msgs, total_msgs);
+		else
+			alertpanel_notice(_("Attachments removed from all %d selected messages."), total_msgs);
+	}	
 
 	inc_unlock();
 	folder_item_update_thaw();
@@ -482,12 +501,10 @@ static void remove_attachments_ui(GtkAction *action, gpointer data)
 		
 		if (!partinfo) {
 			alertpanel_notice(_("This message doesn't have any attachments."));
-			g_slist_free(msglist);
-			return;
+		} else {
+			AttRemoverData.msginfo = msglist->data;
+			remove_attachments_dialog(&AttRemoverData);
 		}
-		
-		AttRemoverData.msginfo = msglist->data;
-		remove_attachments_dialog(&AttRemoverData);
 	} else
 		remove_attachments(msglist);
 

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list