[Commits] compose.c 1.382.2.597 1.382.2.598 compose.h 1.50.2.64 1.50.2.65 main.c 1.115.2.244 1.115.2.245 mimeview.c 1.83.2.186 1.83.2.187

pawel at claws-mail.org pawel at claws-mail.org
Fri Dec 30 00:16:24 CET 2011


Update of /home/claws-mail/claws/src
In directory claws-mail:/tmp/cvs-serv21538/src

Modified Files:
      Tag: gtk2
	compose.c compose.h main.c mimeview.c 
Log Message:
2011-12-29 [pawel]	3.8.0cvs8

	* src/compose.c
	* src/compose.h
	* src/main.c
	* src/mimeview.c
		Make forwarding selected attachment possible from
		mimeview's context menu
		Fixex bug #2047 'forward attachments'

Index: main.c
===================================================================
RCS file: /home/claws-mail/claws/src/main.c,v
retrieving revision 1.115.2.244
retrieving revision 1.115.2.245
diff -u -d -r1.115.2.244 -r1.115.2.245
--- main.c	1 Nov 2011 20:29:31 -0000	1.115.2.244
+++ main.c	29 Dec 2011 23:16:22 -0000	1.115.2.245
@@ -195,7 +195,7 @@
 	gboolean receive_all;
 	gboolean compose;
 	const gchar *compose_mailto;
-	GPtrArray *attach_files;
+	GList *attach_files;
 	gboolean search;
 	const gchar *search_folder;
 	const gchar *search_type;
@@ -225,7 +225,7 @@
 					 GIOCondition      condition);
 
 static void open_compose_new		(const gchar	*address,
-					 GPtrArray	*attach_files);
+					 GList		*attach_files);
 
 static void send_queue			(void);
 static void initial_processing		(FolderItem *item, gpointer data);
@@ -1622,8 +1622,8 @@
 		open_compose_new(cmd.compose_mailto, cmd.attach_files);
 	}
 	if (cmd.attach_files) {
-		ptr_array_free_strings(cmd.attach_files);
-		g_ptr_array_free(cmd.attach_files, TRUE);
+		list_free_strings(cmd.attach_files);
+		g_list_free(cmd.attach_files);
 		cmd.attach_files = NULL;
 	}
 	if (cmd.subscribe) {
@@ -1875,6 +1875,7 @@
 
 static void parse_cmd_opt(int argc, char *argv[])
 {
+	AttachInfo *ainfo;
 	gint i;
 
 	for (i = 1; i < argc; i++) {
@@ -1913,9 +1914,6 @@
 			gchar *file = NULL;
 
 			while (p && *p != '\0' && *p != '-') {
-				if (!cmd.attach_files) {
-					cmd.attach_files = g_ptr_array_new();
-				}
 				if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) {
 					if (!is_file_exist(file)) {
 						g_free(file);
@@ -1929,7 +1927,9 @@
 				} else if (file == NULL) {
 					file = g_strdup(p);
 				}
-				g_ptr_array_add(cmd.attach_files, file);
+				ainfo = g_new0(AttachInfo, 1);
+				ainfo->file = file;
+				cmd.attach_files = g_list_append(cmd.attach_files, ainfo);
 				i++;
 				p = (i+1 < argc)?argv[i+1]:NULL;
 			}
@@ -2249,6 +2249,7 @@
 static gint prohibit_duplicate_launch(void)
 {
 	gint uxsock;
+	GList *curr;
 #ifdef G_OS_UNIX
 	gchar *path;
 
@@ -2291,7 +2292,6 @@
 		fd_write_all(uxsock, "receive\n", 8);
 	} else if (cmd.compose && cmd.attach_files) {
 		gchar *str, *compose_str;
-		gint i;
 
 		if (cmd.compose_mailto) {
 			compose_str = g_strdup_printf("compose_attach %s\n",
@@ -2303,8 +2303,8 @@
 		fd_write_all(uxsock, compose_str, strlen(compose_str));
 		g_free(compose_str);
 
-		for (i = 0; i < cmd.attach_files->len; i++) {
-			str = g_ptr_array_index(cmd.attach_files, i);
+		for (curr = cmd.attach_files; curr != NULL ; curr = curr->next) {
+			str = (gchar *) ((AttachInfo *)curr->data)->file;
 			fd_write_all(uxsock, str, strlen(str));
 			fd_write_all(uxsock, "\n", 1);
 		}
@@ -2468,20 +2468,29 @@
 	} else if (!strncmp(buf, "receive", 7)) {
 		inc_mail(mainwin, prefs_common.newmail_notify_manu);
 	} else if (!strncmp(buf, "compose_attach", 14)) {
-		GPtrArray *files;
+		GList *files = NULL, *curr;
+		AttachInfo *ainfo;
 		gchar *mailto;
 
 		mailto = g_strdup(buf + strlen("compose_attach") + 1);
-		files = g_ptr_array_new();
 		while (fd_gets(sock, buf, sizeof(buf)) > 0) {
 			strretchomp(buf);
 			if (!strcmp2(buf, "."))
 				break;
-			g_ptr_array_add(files, g_strdup(buf));
+				
+			ainfo = g_new0(AttachInfo, 1);
+			ainfo->file = g_strdup(buf);
+			files = g_list_append(files, ainfo);
 		}
 		open_compose_new(mailto, files);
-		ptr_array_free_strings(files);
-		g_ptr_array_free(files, TRUE);
+		
+		curr = g_list_first(files);
+		while (curr != NULL) {
+			ainfo = (AttachInfo *)curr->data;
+			g_free(ainfo->file);
+			g_free(ainfo);
+		}
+		g_list_free(files);
 		g_free(mailto);
 	} else if (!strncmp(buf, "compose", 7)) {
 		open_compose_new(buf + strlen("compose") + 1, NULL);
@@ -2585,7 +2594,7 @@
 
 }
 
-static void open_compose_new(const gchar *address, GPtrArray *attach_files)
+static void open_compose_new(const gchar *address, GList *attach_files)
 {
 	gchar *addr = NULL;
 

Index: mimeview.c
===================================================================
RCS file: /home/claws-mail/claws/src/mimeview.c,v
retrieving revision 1.83.2.186
retrieving revision 1.83.2.187
diff -u -d -r1.83.2.186 -r1.83.2.187
--- mimeview.c	28 Dec 2011 09:47:40 -0000	1.83.2.186
+++ mimeview.c	29 Dec 2011 23:16:22 -0000	1.83.2.187
@@ -121,6 +121,8 @@
 					 MimeInfo	*partinfo,
 					 gboolean	 automatic);
 #endif
+static void mimeview_send_to		(MimeView	*mimeview,
+					 MimeInfo	*partinfo);
 static void mimeview_select_next_part	(MimeView	*mimeview);
 static void mimeview_select_prev_part	(MimeView	*mimeview);
 static void mimeview_view_file		(const gchar	*filename,
@@ -171,6 +173,12 @@
 }
 #endif
 
+static void mimeview_send_to_cb(GtkAction *action, gpointer data)
+{
+	MimeView *mimeview = (MimeView *)data;	
+	mimeview_send_to(mimeview, mimeview_get_part_to_use(mimeview));
+}
+
 static void mimeview_display_as_text_cb(GtkAction *action, gpointer data)
 {
 	mimeview_display_as_text((MimeView *)data);
@@ -202,6 +210,7 @@
 #if (!defined MAEMO && !defined G_OS_WIN32)
 	{ "MimeView/OpenWith", NULL, N_("Open _with (o)..."), NULL, "Open MIME part with...", G_CALLBACK(mimeview_open_with_cb) },
 #endif
+	{ "MimeView/SendTo", NULL, N_("Send to..."), NULL, "Send to", G_CALLBACK(mimeview_send_to_cb) },
 	{ "MimeView/DisplayAsText", NULL, N_("_Display as text (t)"), NULL, "Display as text", G_CALLBACK(mimeview_display_as_text_cb) },
 	{ "MimeView/SaveAs", NULL, N_("_Save as (y)..."), NULL, "Save as", G_CALLBACK(mimeview_save_as_cb) },
 	{ "MimeView/SaveAll", NULL, N_("Save _all..."), NULL, "Save all parts", G_CALLBACK(mimeview_save_all_cb) },
@@ -408,6 +417,9 @@
 			GTK_UI_MANAGER_MENUITEM);
 #endif
 	MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, 
+			"/Menus/MimeView/", "SendTo", "MimeView/SendTo",
+			GTK_UI_MANAGER_MENUITEM);
+	MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, 
 			"/Menus/MimeView/", "DisplayAsText", "MimeView/DisplayAsText",
 			GTK_UI_MANAGER_MENUITEM);
 	MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, 
@@ -2198,6 +2210,44 @@
 }
 #endif
 
+static void mimeview_send_to(MimeView *mimeview, MimeInfo *partinfo)
+{
+	GList *attach_file = NULL;
+	AttachInfo *ainfo = NULL;
+	gchar *filename;
+	gint err;
+
+	if (!mimeview->opened) return;
+	if (!mimeview->file) return;
+
+	cm_return_if_fail(partinfo != NULL);
+
+	filename = procmime_get_tmp_file_name(partinfo);
+
+	if (!(err = procmime_get_part(filename, partinfo))) {
+		ainfo = g_new0(AttachInfo, 1);
+		ainfo->file = filename;
+		ainfo->name = g_strdup(get_part_name(partinfo));
+		ainfo->content_type = procmime_get_content_type_str(
+					partinfo->type, partinfo->subtype);
+		ainfo->charset = g_strdup(procmime_mimeinfo_get_parameter(
+					partinfo, "charset"));
+		attach_file = g_list_append(attach_file, ainfo);
+		
+		compose_new(NULL, NULL, attach_file);
+		
+		g_free(ainfo->name);
+		g_free(ainfo->content_type);
+		g_free(ainfo->charset);
+		g_free(ainfo);
+		g_list_free(attach_file);
+	} else
+		alertpanel_error
+			(_("Couldn't save the part of multipart message: %s"), 
+				strerror(-err));
+	g_free(filename);
+}
+
 static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
 			       const gchar *cmd, MimeView *mimeview)
 {

Index: compose.c
===================================================================
RCS file: /home/claws-mail/claws/src/compose.c,v
retrieving revision 1.382.2.597
retrieving revision 1.382.2.598
diff -u -d -r1.382.2.597 -r1.382.2.598
--- compose.c	8 Dec 2011 09:01:31 -0000	1.382.2.597
+++ compose.c	29 Dec 2011 23:16:21 -0000	1.382.2.598
@@ -180,7 +180,7 @@
 static Compose *compose_generic_new			(PrefsAccount	*account,
 						 const gchar	*to,
 						 FolderItem	*item,
-						 GPtrArray 	*attach_files,
+						 GList		*attach_files,
 						 GList          *listAddress );
 
 static Compose *compose_create			(PrefsAccount	*account,
@@ -891,7 +891,7 @@
 }
 
 Compose *compose_new(PrefsAccount *account, const gchar *mailto,
-		     GPtrArray *attach_files)
+		     GList *attach_files)
 {
 	return compose_generic_new(account, mailto, NULL, attach_files, NULL);
 }
@@ -951,7 +951,7 @@
 }
 
 Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
-			     GPtrArray *attach_files, GList *listAddress )
+			     GList *attach_files, GList *listAddress )
 {
 	Compose *compose;
 	GtkTextView *textview;
@@ -1159,12 +1159,13 @@
 	procmsg_msginfo_free( dummyinfo );
 
 	if (attach_files) {
-		gint i;
-		gchar *file;
+		GList *curr;
+		AttachInfo *ainfo;
 
-		for (i = 0; i < attach_files->len; i++) {
-			file = g_ptr_array_index(attach_files, i);
-			compose_attach_append(compose, file, file, NULL, NULL);
+		for (curr = attach_files ; curr != NULL ; curr = curr->next) {
+			ainfo = (AttachInfo *) curr->data;
+			compose_attach_append(compose, ainfo->file, ainfo->name,
+					ainfo->content_type, ainfo->charset);
 		}
 	}
 

Index: compose.h
===================================================================
RCS file: /home/claws-mail/claws/src/compose.h,v
retrieving revision 1.50.2.64
retrieving revision 1.50.2.65
diff -u -d -r1.50.2.64 -r1.50.2.65
--- compose.h	17 Oct 2011 09:01:27 -0000	1.50.2.64
+++ compose.h	29 Dec 2011 23:16:22 -0000	1.50.2.65
@@ -276,7 +276,7 @@
 /* attache_files will be locale encode */
 Compose *compose_new			(PrefsAccount	*account,
 				 	 const gchar	*mailto,
-				 	 GPtrArray	*attach_files);
+				 	 GList		*attach_files);
 
 Compose *compose_new_with_folderitem	(PrefsAccount	*account,
 					 FolderItem	*item,



More information about the Commits mailing list