From 7cc11916c2c87fb93a1ef39204751c96659d9c60 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 5 Apr 2013 02:43:19 +0000 Subject: print all texts in messages with print command. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3250 ee746299-78ed-0310-b773-934348b2243d --- libsylph/procmsg.c | 43 ++++++------------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) (limited to 'libsylph/procmsg.c') diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c index dd880a15..869c59de 100644 --- a/libsylph/procmsg.c +++ b/libsylph/procmsg.c @@ -1720,7 +1720,8 @@ static gint print_command_exec(const gchar *file, const gchar *cmdline) if (buf[strlen(buf) - 1] != '&') strcat(buf, "&"); - system(buf); + if (system(buf) != 0) + return -1; return 0; } @@ -1792,49 +1793,17 @@ void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline, gboolean all_headers) { gchar *prtmp; - FILE *msgfp, *tmpfp, *prfp; - gchar buf[BUFFSIZE]; g_return_if_fail(msginfo != NULL); - if ((tmpfp = procmime_get_first_text_content - (msginfo, conv_get_locale_charset_str())) == NULL) { - g_warning("Can't get text part\n"); - return; - } - prtmp = g_strdup_printf("%s%cprinttmp-%08x.txt", get_mime_tmp_dir(), G_DIR_SEPARATOR, print_id++); - if ((prfp = g_fopen(prtmp, "w")) == NULL) { - FILE_OP_ERROR(prtmp, "procmsg_print_message: fopen"); - g_free(prtmp); - fclose(tmpfp); - return; - } - - if ((msgfp = procmsg_open_message(msginfo)) == NULL) { - fclose(prfp); - g_free(prtmp); - fclose(tmpfp); - return; - } - - procmsg_write_headers(msginfo, NULL, msgfp, prfp, - conv_get_locale_charset_str(), all_headers); - - fclose(msgfp); - - fputc('\n', prfp); - - while (fgets(buf, sizeof(buf), tmpfp) != NULL) - fputs(buf, prfp); - - fclose(prfp); - fclose(tmpfp); - - print_command_exec(prtmp, cmdline); + if (procmsg_save_message_as_text(msginfo, prtmp, + conv_get_locale_charset_str(), + all_headers) == 0) + print_command_exec(prtmp, cmdline); g_free(prtmp); } -- cgit v1.2.3