[Commits] [SCM] claws branch, master, updated. 3.15.0-137-g9b17603

Colin colin at claws-mail.org
Fri Sep 15 15:46:19 CEST 2017


The branch, master has been updated
       via  9b17603ded77a56d10e56e80b9647487e25546da (commit)
      from  c3167bf1a4bf76a75813856d48e9d3c00f6c3849 (commit)

Summary of changes:
 src/compose.c |    5 ++++-
 src/compose.h |    1 +
 src/main.c    |   17 ++++++++++++++---
 3 files changed, 19 insertions(+), 4 deletions(-)


- Log -----------------------------------------------------------------
commit 9b17603ded77a56d10e56e80b9647487e25546da
Author: Colin Leroy <colin at colino.net>
Date:   Fri Sep 15 15:45:46 2017 +0200

    CLI: Add a --insert option to --compose, allowing to insert files.

diff --git a/src/compose.c b/src/compose.c
index eef03d5..5aad277 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -1226,7 +1226,10 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
 		for (curr = attach_files ; curr != NULL ; curr = curr->next) {
 			ainfo = (AttachInfo *) curr->data;
-			compose_attach_append(compose, ainfo->file, ainfo->file,
+			if (ainfo->insert)
+				compose_insert_file(compose, ainfo->file);
+			else
+				compose_attach_append(compose, ainfo->file, ainfo->file,
 					ainfo->content_type, ainfo->charset);
 		}
 	}
diff --git a/src/compose.h b/src/compose.h
index ddfc63f..5fe65a3 100644
--- a/src/compose.h
+++ b/src/compose.h
@@ -262,6 +262,7 @@ struct _AttachInfo
 	gchar *name;
 	goffset size;
 	gchar *charset;
+	gboolean insert;
 };
 
 typedef enum
diff --git a/src/main.c b/src/main.c
index 0c5c907..3945401 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1868,9 +1868,10 @@ static void parse_cmd_opt(int argc, char *argv[])
 				cmd.subscribe = TRUE;
 				cmd.subscribe_uri = p;
 			}
-		} else if (!strncmp(argv[i], "--attach", 8)) {
+		} else if (!strncmp(argv[i], "--attach", 8) || !strncmp(argv[i], "--insert", 8)) {
 			const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
 			gchar *file = NULL;
+			gboolean insert = !strncmp(argv[i], "--insert", 8);
 
 			while (p && *p != '\0' && *p != '-') {
 				if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) {
@@ -1886,8 +1887,10 @@ static void parse_cmd_opt(int argc, char *argv[])
 				} else if (file == NULL) {
 					file = g_strdup(p);
 				}
+
 				ainfo = g_new0(AttachInfo, 1);
 				ainfo->file = file;
+				ainfo->insert = insert;
 				cmd.attach_files = g_list_append(cmd.attach_files, ainfo);
 				i++;
 				p = (i+1 < argc)?argv[i+1]:NULL;
@@ -1964,6 +1967,9 @@ static void parse_cmd_opt(int argc, char *argv[])
 			g_print("%s\n", _("  --attach file1 [file2]...\n"
 					  "                         open composition window with specified files\n"
 					  "                         attached"));
+			g_print("%s\n", _("  --insert file1 [file2]...\n"
+					  "                         open composition window with specified files\n"
+					  "                         inserted"));
 			g_print("%s\n", _("  --receive              receive new messages"));
 			g_print("%s\n", _("  --receive-all          receive new messages of all accounts"));
 			g_print("%s\n", _("  --cancel-receiving     cancel receiving of messages"));
@@ -2346,6 +2352,10 @@ static gint prohibit_duplicate_launch(void)
 
 		for (curr = cmd.attach_files; curr != NULL ; curr = curr->next) {
 			str = (gchar *) ((AttachInfo *)curr->data)->file;
+			if (((AttachInfo *)curr->data)->insert)
+				fd_write_all(uxsock, "insert ", strlen("insert "));
+			else
+				fd_write_all(uxsock, "attach ", strlen("attach "));
 			fd_write_all(uxsock, str, strlen(str));
 			fd_write_all(uxsock, "\n", 1);
 		}
@@ -2546,9 +2556,10 @@ static void lock_socket_input_cb(gpointer data,
 			strretchomp(buf);
 			if (!strcmp2(buf, "."))
 				break;
-				
+
 			ainfo = g_new0(AttachInfo, 1);
-			ainfo->file = g_strdup(buf);
+			ainfo->file = g_strdup(strstr(buf, " ") + 1);
+			ainfo->insert = !strncmp(buf, "insert ", 7);
 			files = g_list_append(files, ainfo);
 		}
 		open_compose_new(mailto, files);

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list