From: Paul Mangan Date: Mon, 11 Feb 2002 13:43:37 +0000 (+0000) Subject: sync with sylpheed 0.7.1 release X-Git-Tag: rel_0_7_1~23 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=027dce92c31fbe8051c7f86248ec91db8a380caa sync with sylpheed 0.7.1 release --- diff --git a/ChangeLog b/ChangeLog index 719dde878..049b309e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2002-02-11 + + * version 0.7.1 + +2002-02-11 + + * src/compose.[ch] + src/gtkutils.[ch] + src/prefs_template.c + src/quote_fmt.h + src/quote_fmt_parse.y + src/summaryview.c + src/utils.[ch]: if the part of the message text is selected, use + it for quoted text instead of the entire message body (thanks to + Darko Koruga). + src/utils.[ch]: str_open_as_stream(): new. It returns an + temporary stream for the given string. + * src/main.c: added "--send" command line option. + * src/compose.c: compose_reply_set_entry(): add From address to + Cc if Reply-To and to_all are both specified. + * Makefile.am: correct the Source: line in the RPM spec file in + .tar.bz2 package. + 2002-02-07 * src/procmsg.c: procmsg_open_message(): fetch message if the cache diff --git a/ChangeLog.claws b/ChangeLog.claws index bc984cac4..f26c3af2f 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,8 @@ +2002-02-11 [paul] 0.7.0claws58 + + * sync with sylpheed 0.7.1 release + see ChangeLog entries 2002-02-11 + 2002-02-08 [paul] 0.7.0claws57 * sync with sylpheed 0.7.0cvs39 diff --git a/ChangeLog.jp b/ChangeLog.jp index 259e206ef..788e754d3 100644 --- a/ChangeLog.jp +++ b/ChangeLog.jp @@ -1,3 +1,26 @@ +2002-02-11 + + * version 0.7.1 + +2002-02-11 + + * src/compose.[ch] + src/gtkutils.[ch] + src/prefs_template.c + src/quote_fmt.h + src/quote_fmt_parse.y + src/summaryview.c + src/utils.[ch]: ¥á¥Ã¥»¡¼¥¸¥Æ¥­¥¹¥È¤ÎÉôʬ¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢ + ¥á¥Ã¥»¡¼¥¸ËÜʸÁ´ÂΤÎÂå¤ï¤ê¤Ë¤½¤ì¤ò°úÍÑʸ¤È¤·¤Æ»È¤¦¤è¤¦¤Ë¤·¤¿ + (Darko Koruga ¤µ¤ó thanks)¡£ + src/utils.[ch]: str_open_as_stream(): ¿·µ¬¡£Í¿¤¨¤é¤ì¤¿Ê¸»úÎó + ¤ËÂФ·¤Æ°ì»þŪ¤Ê¥¹¥È¥ê¡¼¥à¤òÊÖ¤¹¡£ + * src/main.c: "--send" ¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤òÄɲᣠ+ * src/compose.c: compose_reply_set_entry(): Reply-To ¤È to_all ¤¬ + ξÊý»ØÄꤵ¤ì¤Æ¤¤¤ì¤Ð From ¤Î¥¢¥É¥ì¥¹¤ò Cc ¤ËÄɲᣠ+ * Makefile.am: .tar.bz2 ¥Ñ¥Ã¥±¡¼¥¸Ãæ¤Î RPM spec ¥Õ¥¡¥¤¥ë¤Î Source: + ¹Ô¤ò½¤Àµ¡£ + 2002-02-07 * src/procmsg.c: procmsg_open_message(): ¥­¥ã¥Ã¥·¥å¤¬Â¸ºß¤·¤Ê¤¤ diff --git a/Makefile.am b/Makefile.am index 862fd7895..381af96d8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,11 +6,11 @@ EXTRA_DIST = \ README.jp \ README.claws \ TODO.jp \ + sylpheed.desktop \ sylpheed.spec \ sylpheed.spec.in \ autogen.sh \ sylpheed.png \ - sylpheed.desktop \ ChangeLog.claws if SYLPHEED_GNOME @@ -30,5 +30,8 @@ BZIP2_ENV = release: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + rm -f $(distdir)/sylpheed.spec + sed '/^Source:/s/\.tar\.gz$$/\.tar\.bz2/' sylpheed.spec \ + > $(distdir)/sylpheed.spec BZIP2=$(BZIP2_ENV) $(TAR) --bzip2 -chof $(distdir).tar.bz2 $(distdir) -rm -rf $(distdir) diff --git a/NEWS b/NEWS index ab962534c..64309a5ad 100644 --- a/NEWS +++ b/NEWS @@ -12,10 +12,16 @@ Changes of Sylpheed * "Show all header" now displays the headers in the current message view. * File save dialog has been improved. + * '--send' option has been added. + * Quoted part of message text on reply or forward is specifiable by + selecting it. + * From address is now added to Cc entry when 'Reply to all' is used + on the messages which have Reply-To header. * Mac OS X (Darwin) has been supported. * Ctrl-Enter now works on the composition window. + * It now compiles with C compilers other than gcc. * Crash in mark processing on 64bit architecture has been fixed. - * Crash when some fonts couldn't be loaded has been fixed. + * Crash on font load failure has been fixed. * Some address completion bugs have been fixed. * Some many other bugs have been fixed. diff --git a/TODO.jp b/TODO.jp index b56f7c723..b027a502a 100644 --- a/TODO.jp +++ b/TODO.jp @@ -7,11 +7,9 @@ o POP before SMTP o ¥ª¥ê¥¸¥Ê¥ë¤Î¥¢¥¤¥³¥ó¤È¥í¥´ o ¼«Æ°Êݸµ¡Ç½ o ¿¶¤êʬ¤±½èÍý¤Î¶¯²½ -o ¿¶¤êʬ¤±¤ÇÀµµ¬É½¸½¤ËÂбþ¤¹¤ë -o MH, mbox °Ê³°¤Î·Á¼°¤Ø¤ÎÂбþ(Maildir Åù) +o MH, mbox °Ê³°¤Î·Á¼°¤Ø¤ÎÂбþ (Maildir Åù) o ½ÅÍ×ÅÙ (Priority:, X-Priority:, X-MSMail-Priority:) o ¼õ¿®³Îǧ (Disposition-Notification-To:) -o ¥­¡¼¥Ð¥¤¥ó¥É¤Î¥«¥¹¥¿¥Þ¥¤¥º o ¥Ä¡¼¥ë¥Ð¡¼¤Î¥«¥¹¥¿¥Þ¥¤¥º o ¥Õ¥©¥ë¥ÀËè¤ÎÀßÄê o RFC 2231 (MIME ¥Õ¥¡¥¤¥ë̾¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°) Âбþ @@ -38,6 +36,7 @@ o . HTML¥á¡¼¥ë¤Îɽ¼¨ (HTML¥á¡¼¥ë¤ÎºîÀ®¤ÏͽÄê¤Ê¤·:-P) . »þ´Ö¤¬³Ý¤«¤ë½èÍý¤Î¿ÊĽ¾õ¶·É½¼¨ . Á÷¼õ¿®¤È¤½¤ì°Ê³°¤È¤ÎʹԽèÍý +. ¥­¡¼¥Ð¥¤¥ó¥É¤Î¥«¥¹¥¿¥Þ¥¤¥º ¼ÂÁõºÑ¤Îµ¡Ç½ ============ @@ -69,3 +68,4 @@ o * LDAPÂбþ * ¥á¥Ã¥»¡¼¥¸¤ÎÁ´Ê¸¸¡º÷ (¥Ù¥¿) * ¥Æ¥ó¥×¥ì¡¼¥Èµ¡Ç½ +* ¿¶¤êʬ¤±¤ÇÀµµ¬É½¸½¤ËÂбþ¤¹¤ë diff --git a/configure.in b/configure.in index ebc048df0..ff251b283 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ MINOR_VERSION=7 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws57 +EXTRA_VERSION=claws58 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/compose.c b/src/compose.c index a466ad37c..97618a2ac 100644 --- a/src/compose.c +++ b/src/compose.c @@ -173,7 +173,7 @@ static gchar *compose_quote_fmt (Compose *compose, MsgInfo *msginfo, const gchar *fmt, const gchar *qmark, - const gchar *seltext); + const gchar *body); static void compose_reply_set_entry (Compose *compose, MsgInfo *msginfo, @@ -443,7 +443,7 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all, gboolean ignore_replyto, gboolean followup_and_reply_to, - const gchar *seltext); + const gchar *body); void compose_headerentry_changed_cb (GtkWidget *entry, ComposeHeaderEntry *headerentry); @@ -799,26 +799,26 @@ Compose *compose_new_followup_and_replyto(PrefsAccount *account, */ void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all, - gboolean ignore_replyto, const gchar *seltext) + gboolean ignore_replyto, const gchar *body) { compose_generic_reply(msginfo, quote, to_all, ignore_replyto, FALSE, - seltext); + body); } void compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote, gboolean to_all, gboolean ignore_replyto, - const gchar *seltext) + const gchar *body) { compose_generic_reply(msginfo, quote, to_all, ignore_replyto, TRUE, - seltext); + body); } static void compose_generic_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all, gboolean ignore_replyto, gboolean followup_and_reply_to, - const gchar *seltext) + const gchar *body) { Compose *compose; PrefsAccount *account; @@ -925,7 +925,7 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote, quote_str = compose_quote_fmt(compose, msginfo, prefs_common.quotefmt, - qmark, seltext); + qmark, body); } if (prefs_common.auto_sig) @@ -1166,7 +1166,7 @@ if (msginfo->var && *msginfo->var) { \ } Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo, - gboolean as_attach, const gchar *seltext) + gboolean as_attach, const gchar *body) { Compose *compose; /* PrefsAccount *account; */ @@ -1239,7 +1239,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo, quote_str = compose_quote_fmt(compose, msginfo, prefs_common.fw_quotefmt, qmark, - seltext); + body); compose_attach_parts(compose, msginfo); } @@ -1710,7 +1710,7 @@ static gchar *compose_parse_references(const gchar *ref, const gchar *msgid) static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, const gchar *fmt, const gchar *qmark, - const gchar *seltext) + const gchar *body) { GtkSText *text = GTK_STEXT(compose->text); gchar *quote_str = NULL; @@ -1731,7 +1731,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, } if (fmt && *fmt != '\0') { - quote_fmt_init(msginfo, quote_str, seltext); + quote_fmt_init(msginfo, quote_str, body); quote_fmt_scan_string(fmt); quote_fmt_parse(); @@ -1764,9 +1764,10 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo, gboolean to_all, gboolean ignore_replyto, gboolean followup_and_reply_to) { - GSList *cc_list; + GSList *cc_list = NULL; GSList *cur; - gchar *from; + gchar *from = NULL; + gchar *replyto = NULL; GHashTable *to_table; g_return_if_fail(compose->account != NULL); @@ -1781,11 +1782,6 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo, : msginfo->from ? msginfo->from : ""), COMPOSE_TO); - if (compose->replyto && to_all) - compose_entry_append - (compose, compose->replyto, COMPOSE_CC); - - if (compose->account->protocol == A_NNTP) { if (ignore_replyto) compose_entry_append @@ -1819,15 +1815,30 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo, if (!to_all || compose->account->protocol == A_NNTP) return; - from = g_strdup(compose->replyto ? compose->replyto : - msginfo->from ? msginfo->from : ""); - extract_address(from); + if (compose->replyto) { + Xstrdup_a(replyto, compose->replyto, return); + extract_address(replyto); + } + if (msginfo->from) { + Xstrdup_a(from, msginfo->from, return); + extract_address(from); + } + + if (compose->mailinglist && from) { + cc_list = address_list_append(cc_list, from); + } + + if (replyto && from) + cc_list = address_list_append(cc_list, from); + + if (!compose->mailinglist) + cc_list = address_list_append(cc_list, msginfo->to); - cc_list = address_list_append(NULL, msginfo->to); cc_list = address_list_append(cc_list, compose->cc); to_table = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_insert(to_table, from, GINT_TO_POINTER(1)); + if (replyto) + g_hash_table_insert(to_table, replyto, GINT_TO_POINTER(1)); if (compose->account) g_hash_table_insert(to_table, compose->account->address, GINT_TO_POINTER(1)); @@ -1844,7 +1855,6 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo, cur = next; } g_hash_table_destroy(to_table); - g_free(from); if (cc_list) { for (cur = cc_list; cur != NULL; cur = cur->next) diff --git a/src/compose.h b/src/compose.h index 169a3e4a3..84b196a5d 100644 --- a/src/compose.h +++ b/src/compose.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2001 Hiroyuki Yamamoto + * Copyright (C) 1999-2002 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -220,16 +220,16 @@ void compose_followup_and_reply_to (MsgInfo *msginfo, gboolean quote, gboolean to_all, gboolean ignore_replyto, - const gchar *seltext); + const gchar *body); void compose_reply (MsgInfo *msginfo, gboolean quote, gboolean to_all, gboolean ignore_replyto, - const gchar *seltext); + const gchar *body); Compose *compose_forward (PrefsAccount *account, MsgInfo *msginfo, gboolean as_attach, - const gchar *seltext); + const gchar *body); Compose *compose_forward_multiple (PrefsAccount *account, GSList *msginfo_list); Compose *compose_bounce (PrefsAccount *account, diff --git a/src/gtkutils.c b/src/gtkutils.c index aef3a4586..180953fec 100644 --- a/src/gtkutils.c +++ b/src/gtkutils.c @@ -248,6 +248,25 @@ void gtkut_combo_set_items(GtkCombo *combo, const gchar *str1, ...) g_list_free(combo_items); } +gchar *gtkut_editable_get_selection(GtkEditable *editable) +{ + guint start_pos, end_pos; + + g_return_if_fail(editable != NULL); + + if (!editable->has_selection) return NULL; + + if (editable->selection_start_pos < editable->selection_end_pos) { + start_pos = editable->selection_start_pos; + end_pos = editable->selection_end_pos; + } else { + start_pos = editable->selection_end_pos; + end_pos = editable->selection_start_pos; + } + + return gtk_editable_get_chars(editable, start_pos, end_pos); +} + /* * Walk through the widget tree and disclaim the selection from all currently * realized GtkEditable widgets. @@ -485,25 +504,3 @@ void gtkut_widget_set_composer_icon(GtkWidget *widget) } gdk_window_set_icon(widget->window, NULL, xpm, bmp); } - -gchar *gtkut_get_selection(GtkWidget *widget) -{ - gchar *seltext = NULL; - guint start_pos, end_pos; - GtkEditable *editable = (GtkEditable *) widget; - - if (editable->has_selection) { - if (editable->selection_start_pos < editable->selection_end_pos) { - start_pos = editable->selection_start_pos; - end_pos = editable->selection_end_pos; - } - else { - start_pos = editable->selection_end_pos; - end_pos = editable->selection_start_pos; - } - - seltext = gtk_editable_get_chars(editable, start_pos, end_pos); - } - - return seltext; -} diff --git a/src/gtkutils.h b/src/gtkutils.h index 0ede718c2..dd9f691ac 100644 --- a/src/gtkutils.h +++ b/src/gtkutils.h @@ -102,6 +102,8 @@ void gtkut_clist_set_focus_row (GtkCList *clist, void gtkut_combo_set_items (GtkCombo *combo, const gchar *str1, ...); +gchar *gtkut_editable_get_selection (GtkEditable *editable); + void gtkut_container_remove (GtkContainer *container, GtkWidget *widget); @@ -133,6 +135,4 @@ void gtkut_widget_init (void); void gtkut_widget_set_app_icon (GtkWidget *widget); void gtkut_widget_set_composer_icon (GtkWidget *widget); - -gchar *gtkut_get_selection (GtkWidget *widget); #endif /* __GTKUTILS_H__ */ diff --git a/src/main.c b/src/main.c index 2a2a94d41..eff3ed34d 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2001 Hiroyuki Yamamoto + * Copyright (C) 1999-2002 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,6 +65,7 @@ #include "import.h" #include "manage_window.h" #include "alertpanel.h" +#include "statusbar.h" #include "addressbook.h" #include "compose.h" #include "folder.h" @@ -111,6 +112,8 @@ static gchar *get_socket_name (void); static void open_compose_new_with_recipient (const gchar *address); +static void send_queue (void); + #if 0 /* for gettext */ _("File `%s' already exists.\n" @@ -302,6 +305,9 @@ int main(int argc, char *argv[]) inc_autocheck_timer_init(mainwin); + /* ignore SIGPIPE signal for preventing sudden death of program */ + signal(SIGPIPE, SIG_IGN); + if (cmd.receive_all || prefs_common.chk_on_startup) inc_all_account_mail(mainwin); else if (cmd.receive) @@ -311,14 +317,8 @@ int main(int argc, char *argv[]) if (cmd.compose) open_compose_new_with_recipient(cmd.compose_mailto); - - if (cmd.send) { - if (procmsg_send_queue() < 0) - alertpanel_error(_("Some errors occurred while sending queued messages.")); - } - - /* ignore SIGPIPE signal for preventing sudden death of program */ - signal(SIGPIPE, SIG_IGN); + if (cmd.send) + send_queue(); gtk_main(); @@ -352,13 +352,13 @@ static void parse_cmd_opt(int argc, char *argv[]) cmd.compose_mailto = p; i++; } + } else if (!strncmp(argv[i], "--send", 6)) { + cmd.send = TRUE; } else if (!strncmp(argv[i], "--version", 9)) { puts("Sylpheed version " VERSION); exit(0); } else if (!strncmp(argv[i], "--status", 8)) { cmd.status = TRUE; - } else if (!strncmp(argv[i], "--send", 6)) { - cmd.send = TRUE; } else if (!strncmp(argv[i], "--help", 6)) { g_print(_("Usage: %s [OPTION]...\n"), g_basename(argv[0])); @@ -366,7 +366,7 @@ static void parse_cmd_opt(int argc, char *argv[]) puts(_(" --compose [address] open composition window")); puts(_(" --receive receive new messages")); puts(_(" --receive-all receive new messages of all accounts")); - puts(_(" --send send all queued messages")); + puts(_(" --send send all queued messages")); puts(_(" --status show the total number of messages")); puts(_(" --debug debug mode")); puts(_(" --help display this help and exit")); @@ -488,13 +488,6 @@ static gint prohibit_duplicate_launch(void) fd_write(uxsock, "receive_all\n", 12); else if (cmd.receive) fd_write(uxsock, "receive\n", 8); - else if (cmd.send) { - gchar buf[BUFFSIZE]; - - fd_write(uxsock, "send\n", 5); - fd_gets(uxsock, buf, sizeof(buf)); - fputs(buf, stdout); - } else if (cmd.compose) { gchar *compose_str; @@ -505,6 +498,8 @@ static gint prohibit_duplicate_launch(void) fd_write(uxsock, compose_str, strlen(compose_str)); g_free(compose_str); + } else if (cmd.send) { + fd_write(uxsock, "send\n", 5); } else if (cmd.status) { gchar buf[BUFFSIZE]; @@ -537,23 +532,10 @@ static void lock_socket_input_cb(gpointer data, } else if (!strncmp(buf, "receive", 7)){ main_window_popup(mainwin); inc_mail(mainwin); - } else if (!strncmp(buf, "send", 4)) { - gint queued = get_queued_message_num(); - - if (queued > 0) { - if (procmsg_send_queue() < 0) - g_snprintf(buf, sizeof(buf), - "%s\n", /* avoids adding another translatable */ - _("Some errors occurred while sending queued messages.")); - else /* queue sent ok */ - g_snprintf(buf, sizeof(buf), _("\%d queued message(s) sent\n"), queued); - } - else { - g_snprintf(buf, sizeof(buf), "%s\n", _("No queued messages found.")); - } - fd_write(sock, buf, strlen(buf)); } else if (!strncmp(buf, "compose", 7)) { open_compose_new_with_recipient(buf + strlen("compose") + 1); + } else if (!strncmp(buf, "send", 4)) { + send_queue(); } else if (!strncmp(buf, "status", 6)) { guint new, unread, total; @@ -568,7 +550,7 @@ static void lock_socket_input_cb(gpointer data, static void open_compose_new_with_recipient(const gchar *address) { gchar *addr = NULL; - + if (address) { Xstrdup_a(addr, address, return); g_strstrip(addr); @@ -579,3 +561,23 @@ static void open_compose_new_with_recipient(const gchar *address) else compose_new(NULL); } + +static void send_queue(void) +{ + GList *list; + + if (procmsg_send_queue() < 0) + alertpanel_error(_("Some errors occurred while sending queued messages.")); + + statusbar_pop_all(); + + for (list = folder_get_list(); list != NULL; list = list->next) { + Folder *folder; + + folder = list->data; + if (folder->queue) { + folder_item_scan(folder->queue); + folderview_update_item(folder->queue, TRUE); + } + } +} diff --git a/src/quote_fmt.h b/src/quote_fmt.h index 0e18f4340..c9c4c004f 100644 --- a/src/quote_fmt.h +++ b/src/quote_fmt.h @@ -5,7 +5,8 @@ #define quote_fmt_parse quote_fmtparse gchar *quote_fmt_get_buffer(void); -void quote_fmt_init(MsgInfo *info, gchar *my_quote_str, const gchar *seltext); +void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, + const gchar *my_body); gint quote_fmtparse(void); void quote_fmt_scan_string(const gchar *str); diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y index 6125d336b..66ee7f5be 100644 --- a/src/quote_fmt_parse.y +++ b/src/quote_fmt_parse.y @@ -23,14 +23,14 @@ int yylex(void); static MsgInfo *msginfo = NULL; static gboolean *visible = NULL; -static gchar *seltext = NULL; static gint maxsize = 0; static gint stacksize = 0; static gchar *buffer = NULL; static gint bufmax = 0; static gint bufsize = 0; -static gchar *quote_str = NULL; +static const gchar *quote_str = NULL; +static const gchar *body = NULL; static gint error = 0; static void add_visibility(gboolean val) @@ -51,7 +51,7 @@ static void remove_visibility(void) stacksize--; } -static void add_buffer(gchar *s) +static void add_buffer(const gchar *s) { gint len; @@ -94,12 +94,12 @@ gchar *quote_fmt_get_buffer(void) add_buffer(tmp); \ } -void quote_fmt_init(MsgInfo *info, gchar *my_quote_str, - const gchar *selectiontext) +void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, + const gchar *my_body) { quote_str = my_quote_str; + body = my_body; msginfo = info; - seltext = (gchar *) selectiontext; stacksize = 0; add_visibility(TRUE); if (buffer != NULL) @@ -264,15 +264,16 @@ special: } | SHOW_MESSAGE { - if (seltext) { - INSERT(seltext); - } - else if (msginfo->folder) { + if (msginfo->folder) { gchar buf[BUFFSIZE]; FILE *fp; - if ((fp = procmime_get_first_text_content(msginfo)) - == NULL) + if (body) + fp = str_open_as_stream(body); + else + fp = procmime_get_first_text_content(msginfo); + + if (fp == NULL) g_warning(_("Can't get text part\n")); else { while (fgets(buf, sizeof(buf), fp) != NULL) { @@ -285,18 +286,12 @@ special: } | SHOW_QUOTED_MESSAGE { - gchar *tmp_file = NULL; - - if (seltext) - tmp_file = write_buffer_to_file(seltext, - strlen(seltext)); - - if (msginfo->folder || tmp_file) { + if (msginfo->folder) { gchar buf[BUFFSIZE]; FILE *fp; - if (tmp_file) - fp = fopen(tmp_file, "r"); + if (body) + fp = str_open_as_stream(body); else fp = procmime_get_first_text_content(msginfo); @@ -312,24 +307,15 @@ special: fclose(fp); } } - - if (tmp_file) - unlink(tmp_file); } | SHOW_MESSAGE_NO_SIGNATURE { - gchar *tmp_file = NULL; - - if (seltext) - tmp_file = write_buffer_to_file(seltext, - strlen(seltext)); - if (msginfo->folder) { gchar buf[BUFFSIZE]; FILE *fp; - if (tmp_file) - fp = fopen(tmp_file, "r"); + if (body) + fp = str_open_as_stream(body); else fp = procmime_get_first_text_content(msginfo); @@ -345,24 +331,15 @@ special: fclose(fp); } } - - if (tmp_file) - unlink(tmp_file); } | SHOW_QUOTED_MESSAGE_NO_SIGNATURE { - gchar *tmp_file = NULL; - - if (seltext) - tmp_file = write_buffer_to_file(seltext, - strlen(seltext)); - - if (msginfo->folder || tmp_file) { + if (msginfo->folder) { gchar buf[BUFFSIZE]; FILE *fp; - if (tmp_file) - fp = fopen(tmp_file, "r"); + if (body) + fp = str_open_as_stream(body); else fp = procmime_get_first_text_content(msginfo); @@ -380,9 +357,6 @@ special: fclose(fp); } } - - if (tmp_file) - unlink(tmp_file); } | SHOW_BACKSLASH { diff --git a/src/summaryview.c b/src/summaryview.c index a3ccc2cf9..9a1e217a5 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -3968,55 +3968,52 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type) void summary_reply(SummaryView *summaryview, ComposeMode mode) { GtkWidget *widget; + GList *sel = GTK_CLIST(summaryview->ctree)->selection; MsgInfo *msginfo; - GList *sel = GTK_CLIST(summaryview->ctree)->selection; - gchar *seltext = NULL; + gchar *text; msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree), summaryview->selected); if (!msginfo) return; - if (summaryview && summaryview->messageview && - summaryview->messageview->textview && - summaryview->messageview->textview->text) - seltext = gtkut_get_selection( - summaryview->messageview->textview->text); + text = gtkut_editable_get_selection + (GTK_EDITABLE(summaryview->messageview->textview->text)); switch (mode) { case COMPOSE_REPLY: compose_reply(msginfo, prefs_common.reply_with_quote, - FALSE, FALSE, seltext); + FALSE, FALSE, text); break; case COMPOSE_REPLY_WITH_QUOTE: - compose_reply(msginfo, TRUE, FALSE, FALSE, seltext); + compose_reply(msginfo, TRUE, FALSE, FALSE, text); break; case COMPOSE_REPLY_WITHOUT_QUOTE: - compose_reply(msginfo, FALSE, FALSE, FALSE, seltext); + compose_reply(msginfo, FALSE, FALSE, FALSE, NULL); break; case COMPOSE_REPLY_TO_SENDER: compose_reply(msginfo, prefs_common.reply_with_quote, - FALSE, TRUE, seltext); + FALSE, TRUE, text); break; case COMPOSE_FOLLOWUP_AND_REPLY_TO: compose_followup_and_reply_to(msginfo, prefs_common.reply_with_quote, - FALSE, TRUE, seltext); + FALSE, TRUE, text); break; case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE: - compose_reply(msginfo, TRUE, FALSE, TRUE, seltext); + compose_reply(msginfo, TRUE, FALSE, TRUE, text); break; case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE: - compose_reply(msginfo, FALSE, FALSE, TRUE, seltext); + compose_reply(msginfo, FALSE, FALSE, TRUE, NULL); break; case COMPOSE_REPLY_TO_ALL: compose_reply(msginfo, prefs_common.reply_with_quote, - TRUE, TRUE, seltext); + TRUE, FALSE, text); break; case COMPOSE_REPLY_TO_ALL_WITH_QUOTE: - compose_reply(msginfo, TRUE, TRUE, TRUE, seltext); + compose_reply(msginfo, TRUE, TRUE, FALSE, text); break; case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE: - compose_reply(msginfo, FALSE, TRUE, TRUE, seltext); + compose_reply(msginfo, FALSE, TRUE, FALSE, NULL); break; case COMPOSE_FORWARD: if (prefs_common.forward_as_attachment) { @@ -4029,7 +4026,7 @@ void summary_reply(SummaryView *summaryview, ComposeMode mode) break; case COMPOSE_FORWARD_INLINE: if (!sel->next) { - compose_forward(NULL, msginfo, FALSE, seltext); + compose_forward(NULL, msginfo, FALSE, text); break; } /* if (sel->next) FALL THROUGH */ @@ -4052,9 +4049,7 @@ void summary_reply(SummaryView *summaryview, ComposeMode mode) } summary_set_marks_selected(summaryview); - - if (seltext) - g_free((gchar *) seltext); + g_free(text); } /* color label */ diff --git a/src/utils.c b/src/utils.c index 67df6503f..24fa9fbd0 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1842,20 +1842,28 @@ FILE *my_tmpfile(void) return tmpfile(); } -gchar *write_buffer_to_file(const gchar *buf, guint bufsize) +FILE *str_open_as_stream(const gchar *str) { FILE *fp; - gchar *tmp_file = NULL; + size_t len; + + g_return_val_if_fail(str != NULL, NULL); + + fp = my_tmpfile(); + if (!fp) { + FILE_OP_ERROR("str_open_as_stream", "my_tmpfile"); + return NULL; + } - tmp_file = get_tmp_file(); - fp = fopen(tmp_file, "w"); - if (fp) { - fwrite(buf, 1, bufsize, fp); + len = strlen(str); + if (fwrite(str, len, 1, fp) != 1) { + FILE_OP_ERROR("str_open_as_stream", "fwrite"); fclose(fp); + return NULL; } - else tmp_file = NULL; - return tmp_file; + rewind(fp); + return fp; } gint execute_async(gchar *const argv[]) diff --git a/src/utils.h b/src/utils.h index e8ce4ce13..a1150dedd 100644 --- a/src/utils.h +++ b/src/utils.h @@ -313,8 +313,7 @@ gint move_file (const gchar *src, gint change_file_mode_rw (FILE *fp, const gchar *file); FILE *my_tmpfile (void); -gchar *write_buffer_to_file (const gchar *buf, - guint bufsize); +FILE *str_open_as_stream (const gchar *str); #define is_file_exist(file) file_exist(file, FALSE) #define is_file_or_fifo_exist(file) file_exist(file, TRUE)