2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include <gdk/gdkkeysyms.h>
28 #include <gtk/gtkmain.h>
29 #include <gtk/gtkmenu.h>
30 #include <gtk/gtkmenuitem.h>
31 #include <gtk/gtkitemfactory.h>
32 #include <gtk/gtkcheckmenuitem.h>
33 #include <gtk/gtkoptionmenu.h>
34 #include <gtk/gtkwidget.h>
35 #include <gtk/gtkclist.h>
36 #include <gtk/gtkctree.h>
37 #include <gtk/gtkvpaned.h>
38 #include <gtk/gtkentry.h>
39 #include <gtk/gtkeditable.h>
40 #include <gtk/gtkwindow.h>
41 #include <gtk/gtksignal.h>
42 #include <gtk/gtkvbox.h>
43 #include <gtk/gtkcontainer.h>
44 #include <gtk/gtkhandlebox.h>
45 #include <gtk/gtktoolbar.h>
46 #include <gtk/gtktable.h>
47 #include <gtk/gtkhbox.h>
48 #include <gtk/gtklabel.h>
49 #include <gtk/gtkscrolledwindow.h>
50 #include <gtk/gtkthemes.h>
51 #include <gtk/gtkdnd.h>
56 #include <sys/types.h>
60 /* #include <sys/utsname.h> */
66 #if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
73 #include "mainwindow.h"
76 #include "addressbook.h"
77 #include "folderview.h"
80 #include "stock_pixmap.h"
81 #include "send_message.h"
84 #include "customheader.h"
85 #include "prefs_common.h"
86 #include "prefs_account.h"
90 #include "procheader.h"
92 #include "statusbar.h"
95 #include "quoted-printable.h"
100 #include "alertpanel.h"
101 #include "manage_window.h"
102 #include "gtkshruler.h"
104 #include "addr_compl.h"
105 #include "quote_fmt.h"
106 #include "template.h"
108 #include "foldersel.h"
112 # include "rfc2015.h"
122 #define N_ATTACH_COLS 3
126 COMPOSE_CALL_GTK_STEXT_MOVE_BEGINNING_OF_LINE,
127 COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_CHARACTER,
128 COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_CHARACTER,
129 COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_WORD,
130 COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_WORD,
131 COMPOSE_CALL_GTK_STEXT_MOVE_END_OF_LINE,
132 COMPOSE_CALL_GTK_STEXT_MOVE_NEXT_LINE,
133 COMPOSE_CALL_GTK_STEXT_MOVE_PREVIOUS_LINE,
134 COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_CHARACTER,
135 COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_CHARACTER,
136 COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_WORD,
137 COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_WORD,
138 COMPOSE_CALL_GTK_STEXT_DELETE_LINE,
139 COMPOSE_CALL_GTK_STEXT_DELETE_LINE_N,
140 COMPOSE_CALL_GTK_STEXT_DELETE_TO_LINE_END
141 } ComposeCallGtkSTextAction;
145 PRIORITY_HIGHEST = 1,
152 #define B64_LINE_SIZE 57
153 #define B64_BUFFSIZE 77
155 #define MAX_REFERENCES_LEN 999
157 static GdkColor quote_color = {0, 0, 0, 0xbfff};
159 static GList *compose_list = NULL;
161 Compose *compose_generic_new (PrefsAccount *account,
164 GPtrArray *attach_files);
166 static Compose *compose_create (PrefsAccount *account,
169 static GtkWidget *compose_account_option_menu_create
171 static void compose_set_template_menu (Compose *compose);
172 static void compose_template_apply (Compose *compose,
175 static void compose_destroy (Compose *compose);
177 static void compose_entries_set (Compose *compose,
178 const gchar *mailto);
179 static gint compose_parse_header (Compose *compose,
181 static gchar *compose_parse_references (const gchar *ref,
184 static gchar *compose_quote_fmt (Compose *compose,
190 static void compose_reply_set_entry (Compose *compose,
196 followup_and_reply_to);
197 static void compose_reedit_set_entry (Compose *compose,
199 static void compose_insert_sig (Compose *compose,
201 static gchar *compose_get_signature_str (Compose *compose);
202 static void compose_insert_file (Compose *compose,
204 static void compose_attach_append (Compose *compose,
207 const gchar *content_type);
208 static void compose_attach_parts (Compose *compose,
210 static void compose_wrap_line (Compose *compose);
211 static void compose_wrap_line_all (Compose *compose);
212 static void compose_wrap_line_all_full (Compose *compose,
214 static void compose_set_title (Compose *compose);
215 static void compose_select_account (Compose *compose,
216 PrefsAccount *account,
219 static PrefsAccount *compose_current_mail_account(void);
220 /* static gint compose_send (Compose *compose); */
221 static gboolean compose_check_for_valid_recipient
223 static gboolean compose_check_entries (Compose *compose,
224 gboolean check_subject);
225 static gint compose_write_to_file (Compose *compose,
228 static gint compose_write_body_to_file (Compose *compose,
230 static gint compose_remove_reedit_target (Compose *compose);
231 void compose_remove_draft (Compose *compose);
232 static gint compose_queue (Compose *compose,
235 static gint compose_queue_sub (Compose *compose,
238 gboolean check_subject);
239 static void compose_write_attach (Compose *compose,
241 static gint compose_write_headers (Compose *compose,
243 const gchar *charset,
244 EncodingType encoding,
247 static void compose_convert_header (gchar *dest,
251 gboolean addr_field);
252 static void compose_generate_msgid (Compose *compose,
256 static void compose_attach_info_free (AttachInfo *ainfo);
257 static void compose_attach_remove_selected (Compose *compose);
259 static void compose_attach_property (Compose *compose);
260 static void compose_attach_property_create (gboolean *cancelled);
261 static void attach_property_ok (GtkWidget *widget,
262 gboolean *cancelled);
263 static void attach_property_cancel (GtkWidget *widget,
264 gboolean *cancelled);
265 static gint attach_property_delete_event (GtkWidget *widget,
267 gboolean *cancelled);
268 static void attach_property_key_pressed (GtkWidget *widget,
270 gboolean *cancelled);
272 static void compose_exec_ext_editor (Compose *compose);
273 static gint compose_exec_ext_editor_real (const gchar *file);
274 static gboolean compose_ext_editor_kill (Compose *compose);
275 static void compose_input_cb (gpointer data,
277 GdkInputCondition condition);
278 static void compose_set_ext_editor_sensitive (Compose *compose,
281 static void compose_undo_state_changed (UndoMain *undostruct,
286 static gint calc_cursor_xpos (GtkSText *text,
290 static void compose_create_header_entry (Compose *compose);
291 static void compose_add_header_entry (Compose *compose, gchar *header, gchar *text);
292 static void compose_update_priority_menu_item(Compose * compose);
294 /* callback functions */
296 static gboolean compose_edit_size_alloc (GtkEditable *widget,
297 GtkAllocation *allocation,
298 GtkSHRuler *shruler);
299 static void account_activated (GtkMenuItem *menuitem,
301 static void attach_selected (GtkCList *clist,
306 static void attach_button_pressed (GtkWidget *widget,
307 GdkEventButton *event,
309 static void attach_key_pressed (GtkWidget *widget,
313 static void compose_send_cb (gpointer data,
316 static void compose_send_later_cb (gpointer data,
320 static void compose_draft_cb (gpointer data,
324 static void compose_attach_cb (gpointer data,
327 static void compose_insert_file_cb (gpointer data,
330 static void compose_insert_sig_cb (gpointer data,
334 static void compose_close_cb (gpointer data,
338 static void compose_address_cb (gpointer data,
341 static void compose_template_activate_cb(GtkWidget *widget,
344 static void compose_ext_editor_cb (gpointer data,
348 static gint compose_delete_cb (GtkWidget *widget,
351 static void compose_destroy_cb (GtkWidget *widget,
354 static void compose_undo_cb (Compose *compose);
355 static void compose_redo_cb (Compose *compose);
356 static void compose_cut_cb (Compose *compose);
357 static void compose_copy_cb (Compose *compose);
358 static void compose_paste_cb (Compose *compose);
359 static void compose_paste_as_quote_cb (Compose *compose);
360 static void compose_allsel_cb (Compose *compose);
362 static void compose_gtk_stext_action_cb (Compose *compose,
363 ComposeCallGtkSTextAction action);
365 static void compose_grab_focus_cb (GtkWidget *widget,
368 static void compose_changed_cb (GtkEditable *editable,
370 static void compose_button_press_cb (GtkWidget *widget,
371 GdkEventButton *event,
374 static void compose_key_press_cb (GtkWidget *widget,
380 static void compose_toggle_to_cb (gpointer data,
383 static void compose_toggle_cc_cb (gpointer data,
386 static void compose_toggle_bcc_cb (gpointer data,
389 static void compose_toggle_replyto_cb (gpointer data,
392 static void compose_toggle_followupto_cb(gpointer data,
395 static void compose_toggle_attach_cb (gpointer data,
399 static void compose_toggle_ruler_cb (gpointer data,
403 static void compose_toggle_sign_cb (gpointer data,
406 static void compose_toggle_encrypt_cb (gpointer data,
409 static void compose_set_gnupg_mode_cb (gpointer data,
412 static void compose_update_gnupg_mode_menu_item(Compose * compose);
413 static void activate_gnupg_mode (Compose *compose,
414 PrefsAccount *account);
416 static void compose_toggle_return_receipt_cb(gpointer data, guint action,
418 static void compose_toggle_remove_refs_cb(gpointer data, guint action,
420 static void compose_set_priority_cb (gpointer data,
424 static void compose_attach_drag_received_cb (GtkWidget *widget,
425 GdkDragContext *drag_context,
428 GtkSelectionData *data,
432 static void compose_insert_drag_received_cb (GtkWidget *widget,
433 GdkDragContext *drag_context,
436 GtkSelectionData *data,
442 static void to_activated (GtkWidget *widget,
444 static void newsgroups_activated (GtkWidget *widget,
446 static void cc_activated (GtkWidget *widget,
448 static void bcc_activated (GtkWidget *widget,
450 static void replyto_activated (GtkWidget *widget,
452 static void followupto_activated (GtkWidget *widget,
454 static void subject_activated (GtkWidget *widget,
458 static void text_activated (GtkWidget *widget,
460 static void text_inserted (GtkWidget *widget,
465 static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
466 gboolean to_all, gboolean to_ml,
468 gboolean followup_and_reply_to,
471 void compose_headerentry_changed_cb (GtkWidget *entry,
472 ComposeHeaderEntry *headerentry);
473 void compose_headerentry_key_press_event_cb(GtkWidget *entry,
475 ComposeHeaderEntry *headerentry);
477 static void compose_show_first_last_header (Compose *compose, gboolean show_first);
480 static void compose_check_all (Compose *compose);
481 static void compose_highlight_all (Compose *compose);
482 static void compose_check_backwards (Compose *compose);
483 static void compose_check_forwards_go (Compose *compose);
486 static gboolean compose_send_control_enter (Compose *compose);
487 static gint compose_defer_auto_save_draft (Compose *compose);
489 static GtkItemFactoryEntry compose_popup_entries[] =
491 {N_("/_Add..."), NULL, compose_attach_cb, 0, NULL},
492 {N_("/_Remove"), NULL, compose_attach_remove_selected, 0, NULL},
493 {N_("/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_Properties..."), NULL, compose_attach_property, 0, NULL}
497 static GtkItemFactoryEntry compose_entries[] =
499 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_File/_Attach file"), "<control>M", compose_attach_cb, 0, NULL},
501 {N_("/_File/_Insert file"), "<control>I", compose_insert_file_cb, 0, NULL},
502 {N_("/_File/Insert si_gnature"), "<control>G", compose_insert_sig_cb, 0, NULL},
503 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_File/_Close"), "<control>W", compose_close_cb, 0, NULL},
506 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
507 {N_("/_Edit/_Undo"), "<control>Z", compose_undo_cb, 0, NULL},
508 {N_("/_Edit/_Redo"), "<control>Y", compose_redo_cb, 0, NULL},
509 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_Edit/Cu_t"), "<control>X", compose_cut_cb, 0, NULL},
511 {N_("/_Edit/_Copy"), "<control>C", compose_copy_cb, 0, NULL},
512 {N_("/_Edit/_Paste"), "<control>V", compose_paste_cb, 0, NULL},
513 {N_("/_Edit/Paste as _quotation"),
514 NULL, compose_paste_as_quote_cb, 0, NULL},
515 {N_("/_Edit/Select _all"), "<control>A", compose_allsel_cb, 0, NULL},
516 {N_("/_Edit/A_dvanced"), NULL, NULL, 0, "<Branch>"},
517 {N_("/_Edit/A_dvanced/Move a character backward"),
519 compose_gtk_stext_action_cb,
520 COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_CHARACTER,
522 {N_("/_Edit/A_dvanced/Move a character forward"),
524 compose_gtk_stext_action_cb,
525 COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_CHARACTER,
527 {N_("/_Edit/A_dvanced/Move a word backward"),
529 compose_gtk_stext_action_cb,
530 COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_WORD,
532 {N_("/_Edit/A_dvanced/Move a word forward"),
534 compose_gtk_stext_action_cb,
535 COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_WORD,
537 {N_("/_Edit/A_dvanced/Move to beginning of line"),
538 NULL, /* "<control>A" */
539 compose_gtk_stext_action_cb,
540 COMPOSE_CALL_GTK_STEXT_MOVE_BEGINNING_OF_LINE,
542 {N_("/_Edit/A_dvanced/Move to end of line"),
544 compose_gtk_stext_action_cb,
545 COMPOSE_CALL_GTK_STEXT_MOVE_END_OF_LINE,
547 {N_("/_Edit/A_dvanced/Move to previous line"),
549 compose_gtk_stext_action_cb,
550 COMPOSE_CALL_GTK_STEXT_MOVE_PREVIOUS_LINE,
552 {N_("/_Edit/A_dvanced/Move to next line"),
554 compose_gtk_stext_action_cb,
555 COMPOSE_CALL_GTK_STEXT_MOVE_NEXT_LINE,
557 {N_("/_Edit/A_dvanced/Delete a character backward"),
559 compose_gtk_stext_action_cb,
560 COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_CHARACTER,
562 {N_("/_Edit/A_dvanced/Delete a character forward"),
564 compose_gtk_stext_action_cb,
565 COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_CHARACTER,
567 {N_("/_Edit/A_dvanced/Delete a word backward"),
568 NULL, /* "<control>W" */
569 compose_gtk_stext_action_cb,
570 COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_WORD,
572 {N_("/_Edit/A_dvanced/Delete a word forward"),
573 NULL, /* "<alt>D", */
574 compose_gtk_stext_action_cb,
575 COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_WORD,
577 {N_("/_Edit/A_dvanced/Delete line"),
579 compose_gtk_stext_action_cb,
580 COMPOSE_CALL_GTK_STEXT_DELETE_LINE,
582 {N_("/_Edit/A_dvanced/Delete entire line"),
584 compose_gtk_stext_action_cb,
585 COMPOSE_CALL_GTK_STEXT_DELETE_LINE_N,
587 {N_("/_Edit/A_dvanced/Delete to end of line"),
589 compose_gtk_stext_action_cb,
590 COMPOSE_CALL_GTK_STEXT_DELETE_TO_LINE_END,
592 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
593 {N_("/_Edit/_Wrap current paragraph"),
594 "<control>L", compose_wrap_line, 0, NULL},
595 {N_("/_Edit/Wrap all long _lines"),
596 "<control><alt>L", compose_wrap_line_all, 0, NULL},
597 {N_("/_Edit/Edit with e_xternal editor"),
598 "<shift><control>X", compose_ext_editor_cb, 0, NULL},
600 {N_("/_Spelling"), NULL, NULL, 0, "<Branch>"},
601 {N_("/_Spelling/_Check all or check selection"),
602 NULL, compose_check_all, 0, NULL},
603 {N_("/_Spelling/_Highlight all misspelled words"),
604 NULL, compose_highlight_all, 0, NULL},
605 {N_("/_Spelling/Check _backwards misspelled word"),
606 NULL, compose_check_backwards , 0, NULL},
607 {N_("/_Spelling/_Forward to next misspelled word"),
608 NULL, compose_check_forwards_go, 0, NULL},
609 {N_("/_Spelling/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_Spelling/_Spelling Configuration"),
611 NULL, NULL, 0, "<Branch>"},
613 #if 0 /* NEW COMPOSE GUI */
614 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
615 {N_("/_View/_To"), NULL, compose_toggle_to_cb , 0, "<ToggleItem>"},
616 {N_("/_View/_Cc"), NULL, compose_toggle_cc_cb , 0, "<ToggleItem>"},
617 {N_("/_View/_Bcc"), NULL, compose_toggle_bcc_cb , 0, "<ToggleItem>"},
618 {N_("/_View/_Reply to"), NULL, compose_toggle_replyto_cb, 0, "<ToggleItem>"},
619 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Followup to"), NULL, compose_toggle_followupto_cb, 0, "<ToggleItem>"},
621 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_View/R_uler"), NULL, compose_toggle_ruler_cb, 0, "<ToggleItem>"},
623 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_View/_Attachment"), NULL, compose_toggle_attach_cb, 0, "<ToggleItem>"},
626 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
627 {N_("/_Message/_Send"), "<control>Return",
628 compose_send_cb, 0, NULL},
629 {N_("/_Message/Send _later"), "<shift><control>S",
630 compose_send_later_cb, 0, NULL},
631 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
632 {N_("/_Message/Save to _draft folder"),
633 "<shift><control>D", compose_draft_cb, 0, NULL},
634 {N_("/_Message/Save and _keep editing"),
635 "<control>S", compose_draft_cb, 1, NULL},
636 #if 0 /* NEW COMPOSE GUI */
637 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_Message/_To"), NULL, compose_toggle_to_cb , 0, "<ToggleItem>"},
639 {N_("/_Message/_Cc"), NULL, compose_toggle_cc_cb , 0, "<ToggleItem>"},
640 {N_("/_Message/_Bcc"), NULL, compose_toggle_bcc_cb , 0, "<ToggleItem>"},
641 {N_("/_Message/_Reply to"), NULL, compose_toggle_replyto_cb, 0, "<ToggleItem>"},
642 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
643 {N_("/_Message/_Followup to"), NULL, compose_toggle_followupto_cb, 0, "<ToggleItem>"},
644 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_Message/_Attach"), NULL, compose_toggle_attach_cb, 0, "<ToggleItem>"},
648 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
649 {N_("/_Message/Si_gn"), NULL, compose_toggle_sign_cb , 0, "<ToggleItem>"},
650 {N_("/_Message/_Encrypt"), NULL, compose_toggle_encrypt_cb, 0, "<ToggleItem>"},
651 {N_("/_Message/Mode/MIME"), NULL, compose_set_gnupg_mode_cb, GNUPG_MODE_DETACH, "<RadioItem>"},
652 {N_("/_Message/Mode/Inline"), NULL, compose_set_gnupg_mode_cb, GNUPG_MODE_INLINE, "/Message/Mode/MIME"},
653 #endif /* USE_GPGME */
654 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
655 {N_("/_Message/_Priority"), NULL, NULL, 0, "<Branch>"},
656 {N_("/_Message/Priority/_Highest"), NULL, compose_set_priority_cb, PRIORITY_HIGHEST, "<RadioItem>"},
657 {N_("/_Message/Priority/Hi_gh"), NULL, compose_set_priority_cb, PRIORITY_HIGH, "/Message/Priority/Highest"},
658 {N_("/_Message/Priority/_Normal"), NULL, compose_set_priority_cb, PRIORITY_NORMAL, "/Message/Priority/Highest"},
659 {N_("/_Message/Priority/Lo_w"), NULL, compose_set_priority_cb, PRIORITY_LOW, "/Message/Priority/Highest"},
660 {N_("/_Message/Priority/_Lowest"), NULL, compose_set_priority_cb, PRIORITY_LOWEST, "/Message/Priority/Highest"},
661 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Message/_Request Return Receipt"), NULL, compose_toggle_return_receipt_cb, 0, "<ToggleItem>"},
663 {N_("/_Message/Remo_ve references"), NULL, compose_toggle_remove_refs_cb, 0, "<ToggleItem>"},
664 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
665 {N_("/_Tools/Show _ruler"), NULL, compose_toggle_ruler_cb, 0, "<ToggleItem>"},
666 {N_("/_Tools/_Address book"), "<shift><control>A", compose_address_cb , 0, NULL},
667 {N_("/_Tools/_Template"), NULL, NULL, 0, "<Branch>"},
668 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
669 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
673 static GtkTargetEntry compose_mime_types[] =
675 {"text/uri-list", 0, 0}
678 Compose *compose_new(PrefsAccount *account, const gchar *mailto,
679 GPtrArray *attach_files)
681 return compose_generic_new(account, mailto, NULL, attach_files);
684 Compose *compose_new_with_folderitem(PrefsAccount *account, FolderItem *item)
686 return compose_generic_new(account, NULL, item, NULL);
689 Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
690 GPtrArray *attach_files)
694 GtkItemFactory *ifactory;
695 gboolean grab_focus_on_last = TRUE;
697 if (item && item->prefs && item->prefs->enable_default_account)
698 account = account_find_from_id(item->prefs->default_account);
700 if (!account) account = cur_account;
701 g_return_val_if_fail(account != NULL, NULL);
703 compose = compose_create(account, COMPOSE_NEW);
704 ifactory = gtk_item_factory_from_widget(compose->menubar);
706 compose->replyinfo = NULL;
707 compose->fwdinfo = NULL;
709 text = GTK_STEXT(compose->text);
710 gtk_stext_freeze(text);
713 if (item && item->prefs && item->prefs->enable_default_dictionary &&
715 gtkaspell_change_dict(compose->gtkaspell,
716 item->prefs->default_dictionary);
719 if (account->auto_sig)
720 compose_insert_sig(compose, FALSE);
721 gtk_editable_set_position(GTK_EDITABLE(text), 0);
722 gtk_stext_set_point(text, 0);
724 gtk_stext_thaw(text);
726 if (account->protocol != A_NNTP) {
727 if (mailto && *mailto != '\0') {
728 compose_entries_set(compose, mailto);
730 } else if (item && item->prefs->enable_default_to) {
731 compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
732 compose_entry_select(compose, item->prefs->default_to);
733 grab_focus_on_last = FALSE;
735 if (item && item->ret_rcpt) {
736 menu_set_toggle(ifactory, "/Message/Request Return Receipt", TRUE);
740 compose_entry_append(compose, mailto, COMPOSE_NEWSGROUPS);
743 * CLAWS: just don't allow return receipt request, even if the user
744 * may want to send an email. simple but foolproof.
746 menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
753 for (i = 0; i < attach_files->len; i++) {
754 file = g_ptr_array_index(attach_files, i);
755 compose_attach_append(compose, file, file, NULL);
759 compose_show_first_last_header(compose, TRUE);
761 /* Set save folder */
762 if (item && item->prefs && item->prefs->save_copy_to_folder) {
763 gchar *folderidentifier;
765 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), prefs_common.savemsg);
766 folderidentifier = folder_item_get_identifier(item);
767 gtk_entry_set_text(GTK_ENTRY(compose->savemsg_entry), folderidentifier);
768 g_free(folderidentifier);
771 /* Grab focus on last header only if no default_to was set */
772 if (grab_focus_on_last)
773 gtk_widget_grab_focus(compose->header_last->entry);
775 if (prefs_common.auto_exteditor)
776 compose_exec_ext_editor(compose);
782 Compose *compose_new_followup_and_replyto(PrefsAccount *account,
783 const gchar *followupto, gchar * to)
787 if (!account) account = cur_account;
788 g_return_val_if_fail(account != NULL, NULL);
789 g_return_val_if_fail(account->protocol != A_NNTP, NULL);
791 compose = compose_create(account, COMPOSE_NEW);
793 if (prefs_common.auto_sig)
794 compose_insert_sig(compose);
795 gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
796 gtk_stext_set_point(GTK_STEXT(compose->text), 0);
798 compose_entry_append(compose, to, COMPOSE_TO);
799 compose_entry_append(compose, followupto, COMPOSE_NEWSGROUPS);
800 gtk_widget_grab_focus(compose->subject_entry);
806 void compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
811 g_return_if_fail(msginfo_list != NULL);
813 msginfo = (MsgInfo*)g_slist_nth_data(msginfo_list, 0);
814 g_return_if_fail(msginfo != NULL);
816 list_len = g_slist_length(msginfo_list);
820 compose_reply(msginfo, prefs_common.reply_with_quote,
821 FALSE, prefs_common.default_reply_list, FALSE, body);
823 case COMPOSE_REPLY_WITH_QUOTE:
824 compose_reply(msginfo, TRUE, FALSE, prefs_common.default_reply_list, FALSE, body);
826 case COMPOSE_REPLY_WITHOUT_QUOTE:
827 compose_reply(msginfo, FALSE, FALSE, prefs_common.default_reply_list, FALSE, NULL);
829 case COMPOSE_REPLY_TO_SENDER:
830 compose_reply(msginfo, prefs_common.reply_with_quote,
831 FALSE, FALSE, TRUE, body);
833 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
834 compose_followup_and_reply_to(msginfo,
835 prefs_common.reply_with_quote,
838 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
839 compose_reply(msginfo, TRUE, FALSE, FALSE, TRUE, body);
841 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
842 compose_reply(msginfo, FALSE, FALSE, FALSE, TRUE, NULL);
844 case COMPOSE_REPLY_TO_ALL:
845 compose_reply(msginfo, prefs_common.reply_with_quote,
846 TRUE, FALSE, FALSE, body);
848 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
849 compose_reply(msginfo, TRUE, TRUE, FALSE, FALSE, body);
851 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
852 compose_reply(msginfo, FALSE, TRUE, FALSE, FALSE, NULL);
854 case COMPOSE_REPLY_TO_LIST:
855 compose_reply(msginfo, prefs_common.reply_with_quote,
856 FALSE, TRUE, FALSE, body);
858 case COMPOSE_REPLY_TO_LIST_WITH_QUOTE:
859 compose_reply(msginfo, TRUE, FALSE, TRUE, FALSE, body);
861 case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE:
862 compose_reply(msginfo, FALSE, FALSE, TRUE, FALSE, NULL);
864 case COMPOSE_FORWARD:
865 if (prefs_common.forward_as_attachment) {
866 compose_reply_mode(COMPOSE_FORWARD_AS_ATTACH, msginfo_list, body);
869 compose_reply_mode(COMPOSE_FORWARD_INLINE, msginfo_list, body);
873 case COMPOSE_FORWARD_INLINE:
874 /* check if we reply to more than one Message */
876 compose_forward(NULL, msginfo, FALSE, body);
879 /* more messages FALL THROUGH */
880 case COMPOSE_FORWARD_AS_ATTACH:
881 compose_forward_multiple(NULL, msginfo_list);
883 case COMPOSE_REDIRECT:
884 compose_redirect(NULL, msginfo);
887 g_warning("compose_reply(): invalid Compose Mode: %d\n", mode);
891 void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
892 gboolean to_ml, gboolean to_sender,
895 compose_generic_reply(msginfo, quote, to_all, to_ml,
896 to_sender, FALSE, body);
899 void compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
904 compose_generic_reply(msginfo, quote, to_all, FALSE,
905 to_sender, TRUE, body);
908 static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
909 gboolean to_all, gboolean to_ml,
911 gboolean followup_and_reply_to,
914 GtkItemFactory *ifactory;
916 PrefsAccount *account = NULL;
917 PrefsAccount *reply_account;
920 g_return_if_fail(msginfo != NULL);
921 g_return_if_fail(msginfo->folder != NULL);
923 account = account_get_reply_account(msginfo, prefs_common.reply_account_autosel);
925 g_return_if_fail(account != NULL);
927 if (to_sender && account->protocol == A_NNTP &&
928 !followup_and_reply_to) {
930 account_find_from_address(account->address);
932 reply_account = compose_current_mail_account();
936 reply_account = account;
938 compose = compose_create(account, COMPOSE_REPLY);
939 ifactory = gtk_item_factory_from_widget(compose->menubar);
941 menu_set_toggle(ifactory, "/Message/Remove references", FALSE);
942 menu_set_sensitive(ifactory, "/Message/Remove references", TRUE);
944 compose->replyinfo = procmsg_msginfo_get_full_info(msginfo);
945 if (!compose->replyinfo)
946 compose->replyinfo = procmsg_msginfo_copy(msginfo);
948 if (msginfo->folder && msginfo->folder->ret_rcpt)
949 menu_set_toggle(ifactory, "/Message/Request Return Receipt", TRUE);
951 /* Set save folder */
952 if (msginfo->folder && msginfo->folder->prefs && msginfo->folder->prefs->save_copy_to_folder) {
953 gchar *folderidentifier;
955 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
956 folderidentifier = folder_item_get_identifier(msginfo->folder);
957 gtk_entry_set_text(GTK_ENTRY(compose->savemsg_entry), folderidentifier);
958 g_free(folderidentifier);
961 if (compose_parse_header(compose, msginfo) < 0) return;
962 compose_reply_set_entry(compose, msginfo, to_all, to_ml,
963 to_sender, followup_and_reply_to);
964 compose_show_first_last_header(compose, TRUE);
966 text = GTK_STEXT(compose->text);
967 gtk_stext_freeze(text);
970 if (msginfo->folder && msginfo->folder->prefs &&
971 msginfo->folder->prefs &&
972 msginfo->folder->prefs->enable_default_dictionary &&
974 gtkaspell_change_dict(compose->gtkaspell,
975 msginfo->folder->prefs->default_dictionary);
981 if (prefs_common.quotemark && *prefs_common.quotemark)
982 qmark = prefs_common.quotemark;
986 compose_quote_fmt(compose, compose->replyinfo,
987 prefs_common.quotefmt,
991 if (account->auto_sig)
992 compose_insert_sig(compose, FALSE);
994 if (quote && prefs_common.linewrap_quote)
995 compose_wrap_line_all(compose);
997 gtk_editable_set_position(GTK_EDITABLE(text), 0);
998 gtk_stext_set_point(text, 0);
1000 gtk_stext_thaw(text);
1001 gtk_widget_grab_focus(compose->text);
1003 if (prefs_common.auto_exteditor)
1004 compose_exec_ext_editor(compose);
1007 #define INSERT_FW_HEADER(var, hdr) \
1008 if (msginfo->var && *msginfo->var) { \
1009 gtk_stext_insert(text, NULL, NULL, NULL, hdr, -1); \
1010 gtk_stext_insert(text, NULL, NULL, NULL, msginfo->var, -1); \
1011 gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1); \
1014 Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
1015 gboolean as_attach, const gchar *body)
1020 g_return_val_if_fail(msginfo != NULL, NULL);
1021 g_return_val_if_fail(msginfo->folder != NULL, NULL);
1023 if (msginfo->folder->prefs->enable_default_account)
1024 account = account_find_from_id(msginfo->folder->prefs->default_account);
1026 account = msginfo->folder->folder->account;
1027 if (!account && msginfo->to && prefs_common.forward_account_autosel) {
1029 Xstrdup_a(to, msginfo->to, return NULL);
1030 extract_address(to);
1031 account = account_find_from_address(to);
1034 if (!account && prefs_common.forward_account_autosel) {
1036 if (!get_header_from_msginfo(msginfo,cc,sizeof(cc),"CC:")){ /* Found a CC header */
1037 extract_address(cc);
1038 account = account_find_from_address(cc);
1042 if (account == NULL) {
1043 account = cur_account;
1045 account = msginfo->folder->folder->account;
1046 if (!account) account = cur_account;
1049 g_return_val_if_fail(account != NULL, NULL);
1051 compose = compose_create(account, COMPOSE_FORWARD);
1053 compose->fwdinfo = procmsg_msginfo_get_full_info(msginfo);
1054 if (!compose->fwdinfo)
1055 compose->fwdinfo = procmsg_msginfo_copy(msginfo);
1057 if (msginfo->subject && *msginfo->subject) {
1058 gchar *buf, *buf2, *p;
1060 buf = p = g_strdup(msginfo->subject);
1061 p += subject_get_prefix_length(p);
1062 memmove(buf, p, strlen(p) + 1);
1064 buf2 = g_strdup_printf("Fw: %s", buf);
1065 gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf2);
1071 text = GTK_STEXT(compose->text);
1072 gtk_stext_freeze(text);
1077 msgfile = procmsg_get_message_file_path(msginfo);
1078 if (!is_file_exist(msgfile))
1079 g_warning("%s: file not exist\n", msgfile);
1081 compose_attach_append(compose, msgfile, msgfile,
1087 MsgInfo *full_msginfo;
1089 full_msginfo = procmsg_msginfo_get_full_info(msginfo);
1091 full_msginfo = procmsg_msginfo_copy(msginfo);
1093 if (prefs_common.fw_quotemark &&
1094 *prefs_common.fw_quotemark)
1095 qmark = prefs_common.fw_quotemark;
1099 compose_quote_fmt(compose, full_msginfo,
1100 prefs_common.fw_quotefmt,
1102 compose_attach_parts(compose, msginfo);
1104 procmsg_msginfo_free(full_msginfo);
1107 if (account->auto_sig)
1108 compose_insert_sig(compose, FALSE);
1110 if (prefs_common.linewrap_quote)
1111 compose_wrap_line_all(compose);
1113 gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
1114 gtk_stext_set_point(GTK_STEXT(compose->text), 0);
1116 gtk_stext_thaw(text);
1117 #if 0 /* NEW COMPOSE GUI */
1118 if (account->protocol != A_NNTP)
1119 gtk_widget_grab_focus(compose->to_entry);
1121 gtk_widget_grab_focus(compose->newsgroups_entry);
1123 gtk_widget_grab_focus(compose->header_last->entry);
1125 if (prefs_common.auto_exteditor)
1126 compose_exec_ext_editor(compose);
1129 if (msginfo->folder && msginfo->folder->prefs && msginfo->folder->prefs->save_copy_to_folder) {
1130 gchar *folderidentifier;
1132 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
1133 folderidentifier = folder_item_get_identifier(msginfo->folder);
1134 gtk_entry_set_text(GTK_ENTRY(compose->savemsg_entry), folderidentifier);
1135 g_free(folderidentifier);
1141 #undef INSERT_FW_HEADER
1143 Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list)
1150 g_return_val_if_fail(msginfo_list != NULL, NULL);
1152 for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
1153 if ( ((MsgInfo *)msginfo->data)->folder == NULL )
1157 if (account == NULL) {
1158 account = cur_account;
1160 account = msginfo->folder->folder->account;
1161 if (!account) account = cur_account;
1164 g_return_val_if_fail(account != NULL, NULL);
1166 for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
1167 MSG_UNSET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_REPLIED);
1168 MSG_SET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_FORWARDED);
1171 compose = compose_create(account, COMPOSE_FORWARD);
1173 text = GTK_STEXT(compose->text);
1174 gtk_stext_freeze(text);
1176 for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
1177 msgfile = procmsg_get_message_file_path((MsgInfo *)msginfo->data);
1178 if (!is_file_exist(msgfile))
1179 g_warning("%s: file not exist\n", msgfile);
1181 compose_attach_append(compose, msgfile, msgfile,
1186 if (account->auto_sig)
1187 compose_insert_sig(compose, FALSE);
1189 if (prefs_common.linewrap_quote)
1190 compose_wrap_line_all(compose);
1192 gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
1193 gtk_stext_set_point(GTK_STEXT(compose->text), 0);
1195 gtk_stext_thaw(text);
1196 gtk_widget_grab_focus(compose->header_last->entry);
1198 #if 0 /* NEW COMPOSE GUI */
1199 if (account->protocol != A_NNTP)
1200 gtk_widget_grab_focus(compose->to_entry);
1202 gtk_widget_grab_focus(compose->newsgroups_entry);
1208 void compose_reedit(MsgInfo *msginfo)
1211 PrefsAccount *account = NULL;
1214 gchar buf[BUFFSIZE];
1216 g_return_if_fail(msginfo != NULL);
1217 g_return_if_fail(msginfo->folder != NULL);
1219 if (msginfo->folder->stype == F_QUEUE || msginfo->folder->stype == F_DRAFT) {
1220 gchar queueheader_buf[BUFFSIZE];
1223 /* Select Account from queue headers */
1224 if (!get_header_from_msginfo(msginfo, queueheader_buf,
1225 sizeof(queueheader_buf), "X-Sylpheed-Account-Id:")) {
1226 id = atoi(&queueheader_buf[22]);
1227 account = account_find_from_id(id);
1229 if (!account && !get_header_from_msginfo(msginfo, queueheader_buf,
1230 sizeof(queueheader_buf), "NAID:")) {
1231 id = atoi(&queueheader_buf[5]);
1232 account = account_find_from_id(id);
1234 if (!account && !get_header_from_msginfo(msginfo, queueheader_buf,
1235 sizeof(queueheader_buf), "MAID:")) {
1236 id = atoi(&queueheader_buf[5]);
1237 account = account_find_from_id(id);
1239 if (!account && !get_header_from_msginfo(msginfo, queueheader_buf,
1240 sizeof(queueheader_buf), "S:")) {
1241 account = account_find_from_address(queueheader_buf);
1244 account = msginfo->folder->folder->account;
1246 if (!account && prefs_common.reedit_account_autosel) {
1247 gchar from[BUFFSIZE];
1248 if (!get_header_from_msginfo(msginfo, from, sizeof(from), "FROM:")){
1249 extract_address(from);
1250 account = account_find_from_address(from);
1253 if (!account) account = cur_account;
1254 g_return_if_fail(account != NULL);
1256 compose = compose_create(account, COMPOSE_REEDIT);
1257 compose->targetinfo = procmsg_msginfo_copy(msginfo);
1259 if (msginfo->folder->stype == F_QUEUE
1260 || msginfo->folder->stype == F_DRAFT) {
1261 gchar queueheader_buf[BUFFSIZE];
1263 /* Set message save folder */
1264 if (!get_header_from_msginfo(msginfo, queueheader_buf, sizeof(queueheader_buf), "SCF:")) {
1267 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
1268 gtk_editable_delete_text(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
1269 gtk_editable_insert_text(GTK_EDITABLE(compose->savemsg_entry), &queueheader_buf[4], strlen(&queueheader_buf[4]), &startpos);
1273 if (compose_parse_header(compose, msginfo) < 0) return;
1274 compose_reedit_set_entry(compose, msginfo);
1276 text = GTK_STEXT(compose->text);
1277 gtk_stext_freeze(text);
1279 if ((fp = procmime_get_first_text_content(msginfo)) == NULL)
1280 g_warning("Can't get text part\n");
1282 while (fgets(buf, sizeof(buf), fp) != NULL) {
1284 gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
1288 compose_attach_parts(compose, msginfo);
1290 gtk_stext_thaw(text);
1291 gtk_widget_grab_focus(compose->text);
1293 if (prefs_common.auto_exteditor)
1294 compose_exec_ext_editor(compose);
1297 Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
1301 GtkItemFactory *ifactory;
1303 g_return_val_if_fail(msginfo != NULL, NULL);
1306 account = account_get_reply_account(msginfo,
1307 prefs_common.reply_account_autosel);
1308 g_return_val_if_fail(account != NULL, NULL);
1310 compose = compose_create(account, COMPOSE_REDIRECT);
1311 ifactory = gtk_item_factory_from_widget(compose->menubar);
1313 compose->replyinfo = NULL;
1314 compose->fwdinfo = NULL;
1316 compose_show_first_last_header(compose, TRUE);
1318 gtk_widget_grab_focus(compose->header_last->entry);
1320 filename = procmsg_get_message_file(msginfo);
1321 if (filename == NULL)
1324 compose->redirect_filename = filename;
1326 compose_attach_parts(compose, msginfo);
1328 if (msginfo->subject)
1329 gtk_entry_set_text(GTK_ENTRY(compose->subject_entry),
1331 gtk_editable_set_editable(GTK_EDITABLE(compose->subject_entry), FALSE);
1333 gtk_stext_freeze(GTK_STEXT(compose->text));
1334 compose_quote_fmt(compose, msginfo, "%M", NULL, NULL);
1335 gtk_editable_set_editable(GTK_EDITABLE(compose->text), FALSE);
1336 gtk_stext_thaw(GTK_STEXT(compose->text));
1338 ifactory = gtk_item_factory_from_widget(compose->popupmenu);
1339 menu_set_sensitive(ifactory, "/Add...", FALSE);
1340 menu_set_sensitive(ifactory, "/Remove", FALSE);
1341 menu_set_sensitive(ifactory, "/Property...", FALSE);
1343 ifactory = gtk_item_factory_from_widget(compose->menubar);
1344 menu_set_sensitive(ifactory, "/File/Insert file", FALSE);
1345 menu_set_sensitive(ifactory, "/File/Attach file", FALSE);
1346 menu_set_sensitive(ifactory, "/File/Insert signature", FALSE);
1347 menu_set_sensitive(ifactory, "/Edit", FALSE);
1348 menu_set_sensitive(ifactory, "/Message/Save to draft folder", FALSE);
1349 menu_set_sensitive(ifactory, "/Message/Save and keep editing", FALSE);
1351 menu_set_sensitive(ifactory, "/Message/Sign", FALSE);
1352 menu_set_sensitive(ifactory, "/Message/Encrypt", FALSE);
1353 menu_set_sensitive(ifactory, "/Message/Mode/MIME", FALSE);
1354 menu_set_sensitive(ifactory, "/Message/Mode/Inline", FALSE);
1356 menu_set_sensitive(ifactory, "/Message/Priority", FALSE);
1357 menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
1358 menu_set_sensitive(ifactory, "/Tools/Show ruler", FALSE);
1359 menu_set_sensitive(ifactory, "/Tools/Actions", FALSE);
1361 gtk_widget_set_sensitive(compose->toolbar->draft_btn, FALSE);
1362 gtk_widget_set_sensitive(compose->toolbar->insert_btn, FALSE);
1363 gtk_widget_set_sensitive(compose->toolbar->attach_btn, FALSE);
1364 gtk_widget_set_sensitive(compose->toolbar->sig_btn, FALSE);
1365 gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, FALSE);
1366 gtk_widget_set_sensitive(compose->toolbar->linewrap_btn, FALSE);
1371 GList *compose_get_compose_list(void)
1373 return compose_list;
1376 void compose_entry_append(Compose *compose, const gchar *address,
1377 ComposeEntryType type)
1381 if (!address || *address == '\0') return;
1383 #if 0 /* NEW COMPOSE GUI */
1386 entry = GTK_ENTRY(compose->cc_entry);
1389 entry = GTK_ENTRY(compose->bcc_entry);
1391 case COMPOSE_NEWSGROUPS:
1392 entry = GTK_ENTRY(compose->newsgroups_entry);
1396 entry = GTK_ENTRY(compose->to_entry);
1400 text = gtk_entry_get_text(entry);
1402 gtk_entry_append_text(entry, ", ");
1403 gtk_entry_append_text(entry, address);
1411 header = N_("Bcc:");
1413 case COMPOSE_REPLYTO:
1414 header = N_("Reply-To:");
1416 case COMPOSE_NEWSGROUPS:
1417 header = N_("Newsgroups:");
1419 case COMPOSE_FOLLOWUPTO:
1420 header = N_( "Followup-To:");
1427 header = prefs_common.trans_hdr ? gettext(header) : header;
1429 compose_add_header_entry(compose, header, (gchar *)address);
1432 void compose_entry_select (Compose *compose, const gchar *mailto)
1434 GSList *header_list;
1436 for (header_list = compose->header_list; header_list != NULL; header_list = header_list->next) {
1437 GtkEntry * entry = GTK_ENTRY(((ComposeHeaderEntry *)header_list->data)->entry);
1439 if (gtk_entry_get_text(entry) && !g_strcasecmp(gtk_entry_get_text(entry), mailto)) {
1440 gtk_entry_select_region(entry, 0, -1);
1441 gtk_widget_grab_focus(GTK_WIDGET(entry));
1446 void compose_toolbar_cb(gint action, gpointer data)
1448 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1449 Compose *compose = (Compose*)toolbar_item->parent;
1451 g_return_if_fail(compose != NULL);
1455 compose_send_cb(compose, 0, NULL);
1458 compose_send_later_cb(compose, 0, NULL);
1461 compose_draft_cb(compose, 0, NULL);
1464 compose_insert_file_cb(compose, 0, NULL);
1467 compose_attach_cb(compose, 0, NULL);
1470 compose_insert_sig(compose, FALSE);
1473 compose_ext_editor_cb(compose, 0, NULL);
1476 compose_wrap_line(compose);
1479 compose_address_cb(compose, 0, NULL);
1486 static void compose_entries_set(Compose *compose, const gchar *mailto)
1491 gchar *subject = NULL;
1494 scan_mailto_url(mailto, &to, &cc, &bcc, &subject, &body);
1497 compose_entry_append(compose, to, COMPOSE_TO);
1499 compose_entry_append(compose, cc, COMPOSE_CC);
1501 compose_entry_append(compose, bcc, COMPOSE_BCC);
1503 gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
1505 gtk_stext_insert(GTK_STEXT(compose->text),
1506 NULL, NULL, NULL, body, -1);
1507 gtk_stext_insert(GTK_STEXT(compose->text),
1508 NULL, NULL, NULL, "\n", 1);
1518 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
1520 static HeaderEntry hentry[] = {{"Reply-To:", NULL, TRUE},
1521 {"Cc:", NULL, TRUE},
1522 {"References:", NULL, FALSE},
1523 {"Bcc:", NULL, TRUE},
1524 {"Newsgroups:", NULL, TRUE},
1525 {"Followup-To:", NULL, TRUE},
1526 {"List-Post:", NULL, FALSE},
1527 {"X-Priority:", NULL, FALSE},
1528 {NULL, NULL, FALSE}};
1544 g_return_val_if_fail(msginfo != NULL, -1);
1546 if ((fp = procmsg_open_message(msginfo)) == NULL) return -1;
1547 procheader_get_header_fields(fp, hentry);
1550 if (hentry[H_REPLY_TO].body != NULL) {
1551 conv_unmime_header_overwrite(hentry[H_REPLY_TO].body);
1552 compose->replyto = hentry[H_REPLY_TO].body;
1553 hentry[H_REPLY_TO].body = NULL;
1555 if (hentry[H_CC].body != NULL) {
1556 conv_unmime_header_overwrite(hentry[H_CC].body);
1557 compose->cc = hentry[H_CC].body;
1558 hentry[H_CC].body = NULL;
1560 if (hentry[H_REFERENCES].body != NULL) {
1561 if (compose->mode == COMPOSE_REEDIT)
1562 compose->references = hentry[H_REFERENCES].body;
1564 compose->references = compose_parse_references
1565 (hentry[H_REFERENCES].body, msginfo->msgid);
1566 g_free(hentry[H_REFERENCES].body);
1568 hentry[H_REFERENCES].body = NULL;
1570 if (hentry[H_BCC].body != NULL) {
1571 if (compose->mode == COMPOSE_REEDIT) {
1572 conv_unmime_header_overwrite(hentry[H_BCC].body);
1573 compose->bcc = hentry[H_BCC].body;
1575 g_free(hentry[H_BCC].body);
1576 hentry[H_BCC].body = NULL;
1578 if (hentry[H_NEWSGROUPS].body != NULL) {
1579 conv_unmime_header_overwrite(hentry[H_NEWSGROUPS].body);
1580 compose->newsgroups = hentry[H_NEWSGROUPS].body;
1581 hentry[H_NEWSGROUPS].body = NULL;
1583 if (hentry[H_FOLLOWUP_TO].body != NULL) {
1584 conv_unmime_header_overwrite(hentry[H_FOLLOWUP_TO].body);
1585 compose->followup_to = hentry[H_FOLLOWUP_TO].body;
1586 hentry[H_FOLLOWUP_TO].body = NULL;
1588 if (hentry[H_LIST_POST].body != NULL) {
1591 extract_address(hentry[H_LIST_POST].body);
1592 if (hentry[H_LIST_POST].body[0] != '\0') {
1593 scan_mailto_url(hentry[H_LIST_POST].body,
1594 &to, NULL, NULL, NULL, NULL);
1596 g_free(compose->ml_post);
1597 compose->ml_post = to;
1600 g_free(hentry[H_LIST_POST].body);
1601 hentry[H_LIST_POST].body = NULL;
1604 /* CLAWS - X-Priority */
1605 if (compose->mode == COMPOSE_REEDIT)
1606 if (hentry[H_X_PRIORITY].body != NULL) {
1609 priority = atoi(hentry[H_X_PRIORITY].body);
1610 g_free(hentry[H_X_PRIORITY].body);
1612 hentry[H_X_PRIORITY].body = NULL;
1614 if (priority < PRIORITY_HIGHEST ||
1615 priority > PRIORITY_LOWEST)
1616 priority = PRIORITY_NORMAL;
1618 compose->priority = priority;
1621 if (compose->mode == COMPOSE_REEDIT && msginfo->inreplyto)
1622 compose->inreplyto = g_strdup(msginfo->inreplyto);
1623 else if (compose->mode != COMPOSE_REEDIT &&
1624 msginfo->msgid && *msginfo->msgid) {
1625 compose->inreplyto = g_strdup(msginfo->msgid);
1627 if (!compose->references) {
1628 if (msginfo->inreplyto && *msginfo->inreplyto)
1629 compose->references =
1630 g_strdup_printf("<%s>\n\t<%s>",
1634 compose->references =
1635 g_strconcat("<", msginfo->msgid, ">",
1643 static gchar *compose_parse_references(const gchar *ref, const gchar *msgid)
1645 GSList *ref_id_list, *cur;
1649 ref_id_list = references_list_append(NULL, ref);
1650 if (!ref_id_list) return NULL;
1651 if (msgid && *msgid)
1652 ref_id_list = g_slist_append(ref_id_list, g_strdup(msgid));
1657 for (cur = ref_id_list; cur != NULL; cur = cur->next)
1658 /* "<" + Message-ID + ">" + CR+LF+TAB */
1659 len += strlen((gchar *)cur->data) + 5;
1661 if (len > MAX_REFERENCES_LEN) {
1662 /* remove second message-ID */
1663 if (ref_id_list && ref_id_list->next &&
1664 ref_id_list->next->next) {
1665 g_free(ref_id_list->next->data);
1666 ref_id_list = g_slist_remove
1667 (ref_id_list, ref_id_list->next->data);
1669 slist_free_strings(ref_id_list);
1670 g_slist_free(ref_id_list);
1677 new_ref = g_string_new("");
1678 for (cur = ref_id_list; cur != NULL; cur = cur->next) {
1679 if (new_ref->len > 0)
1680 g_string_append(new_ref, "\n\t");
1681 g_string_sprintfa(new_ref, "<%s>", (gchar *)cur->data);
1684 slist_free_strings(ref_id_list);
1685 g_slist_free(ref_id_list);
1687 new_ref_str = new_ref->str;
1688 g_string_free(new_ref, FALSE);
1693 static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
1694 const gchar *fmt, const gchar *qmark,
1697 GtkSText *text = GTK_STEXT(compose->text);
1698 static MsgInfo dummyinfo;
1699 gchar *quote_str = NULL;
1703 const gchar *trimmed_body = body;
1706 msginfo = &dummyinfo;
1708 if (qmark != NULL) {
1709 quote_fmt_init(msginfo, NULL, NULL);
1710 quote_fmt_scan_string(qmark);
1713 buf = quote_fmt_get_buffer();
1715 alertpanel_error(_("Quote mark format error."));
1717 Xstrdup_a(quote_str, buf, return NULL)
1720 if (fmt && *fmt != '\0') {
1721 while (trimmed_body && strlen(trimmed_body) > 1
1722 && trimmed_body[0]=='\n')
1725 quote_fmt_init(msginfo, quote_str, trimmed_body);
1726 quote_fmt_scan_string(fmt);
1729 buf = quote_fmt_get_buffer();
1731 alertpanel_error(_("Message reply/forward format error."));
1737 gtk_stext_freeze(text);
1739 for (p = buf; *p != '\0'; ) {
1740 lastp = strchr(p, '\n');
1741 len = lastp ? lastp - p + 1 : -1;
1742 gtk_stext_insert(text, NULL, NULL, NULL, p, len);
1749 gtk_stext_thaw(text);
1754 static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
1755 gboolean to_all, gboolean to_ml,
1757 gboolean followup_and_reply_to)
1759 GSList *cc_list = NULL;
1762 gchar *replyto = NULL;
1763 GHashTable *to_table;
1765 g_return_if_fail(compose->account != NULL);
1766 g_return_if_fail(msginfo != NULL);
1768 if (compose->account->protocol != A_NNTP) {
1769 if (!compose->replyto && to_ml && compose->ml_post
1770 && !(msginfo->folder && msginfo->folder->prefs->enable_default_reply_to))
1771 compose_entry_append(compose,
1774 else if (!(to_all || to_sender)
1776 && msginfo->folder->prefs->enable_default_reply_to) {
1777 compose_entry_append(compose,
1778 msginfo->folder->prefs->default_reply_to,
1781 compose_entry_append(compose,
1782 (compose->replyto && !to_sender)
1783 ? compose->replyto :
1784 msginfo->from ? msginfo->from : "",
1787 if (to_sender || (compose->followup_to &&
1788 !strncmp(compose->followup_to, "poster", 6)))
1789 compose_entry_append
1791 (compose->replyto ? compose->replyto :
1792 msginfo->from ? msginfo->from : ""),
1795 else if (followup_and_reply_to || to_all) {
1796 compose_entry_append
1798 (compose->replyto ? compose->replyto :
1799 msginfo->from ? msginfo->from : ""),
1802 compose_entry_append
1804 compose->followup_to ? compose->followup_to :
1805 compose->newsgroups ? compose->newsgroups : "",
1806 COMPOSE_NEWSGROUPS);
1809 compose_entry_append
1811 compose->followup_to ? compose->followup_to :
1812 compose->newsgroups ? compose->newsgroups : "",
1813 COMPOSE_NEWSGROUPS);
1816 if (msginfo->subject && *msginfo->subject) {
1817 gchar *buf, *buf2, *p;
1819 buf = p = g_strdup(msginfo->subject);
1820 p += subject_get_prefix_length(p);
1821 memmove(buf, p, strlen(p) + 1);
1823 buf2 = g_strdup_printf("Re: %s", buf);
1824 gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf2);
1829 gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), "Re: ");
1831 if (to_ml && compose->ml_post) return;
1832 if (!to_all || compose->account->protocol == A_NNTP) return;
1834 if (compose->replyto) {
1835 Xstrdup_a(replyto, compose->replyto, return);
1836 extract_address(replyto);
1838 if (msginfo->from) {
1839 Xstrdup_a(from, msginfo->from, return);
1840 extract_address(from);
1843 if (replyto && from)
1844 cc_list = address_list_append_with_comments(cc_list, from);
1845 cc_list = address_list_append_with_comments(cc_list, msginfo->to);
1846 cc_list = address_list_append_with_comments(cc_list, compose->cc);
1848 to_table = g_hash_table_new(g_str_hash, g_str_equal);
1850 g_hash_table_insert(to_table, g_strdup(replyto), GINT_TO_POINTER(1));
1851 if (compose->account)
1852 g_hash_table_insert(to_table, g_strdup(compose->account->address),
1853 GINT_TO_POINTER(1));
1855 /* remove address on To: and that of current account */
1856 for (cur = cc_list; cur != NULL; ) {
1857 GSList *next = cur->next;
1860 addr = g_strdup(cur->data);
1861 extract_address(addr);
1863 if (GPOINTER_TO_INT(g_hash_table_lookup(to_table, addr)) == 1)
1864 cc_list = g_slist_remove(cc_list, cur->data);
1866 g_hash_table_insert(to_table, addr, GINT_TO_POINTER(1));
1870 hash_free_strings(to_table);
1871 g_hash_table_destroy(to_table);
1874 for (cur = cc_list; cur != NULL; cur = cur->next)
1875 compose_entry_append(compose, (gchar *)cur->data,
1877 slist_free_strings(cc_list);
1878 g_slist_free(cc_list);
1883 #define SET_ENTRY(entry, str) \
1886 gtk_entry_set_text(GTK_ENTRY(compose->entry), str); \
1889 #define SET_ADDRESS(type, str) \
1892 compose_entry_append(compose, str, type); \
1895 static void compose_reedit_set_entry(Compose *compose, MsgInfo *msginfo)
1897 g_return_if_fail(msginfo != NULL);
1899 SET_ENTRY(subject_entry, msginfo->subject);
1900 SET_ADDRESS(COMPOSE_TO, msginfo->to);
1901 SET_ADDRESS(COMPOSE_CC, compose->cc);
1902 SET_ADDRESS(COMPOSE_BCC, compose->bcc);
1903 SET_ADDRESS(COMPOSE_REPLYTO, compose->replyto);
1904 SET_ADDRESS(COMPOSE_NEWSGROUPS, compose->newsgroups);
1905 SET_ADDRESS(COMPOSE_FOLLOWUPTO, compose->followup_to);
1907 compose_update_priority_menu_item(compose);
1909 compose_update_gnupg_mode_menu_item(compose);
1911 compose_show_first_last_header(compose, TRUE);
1918 static void compose_insert_sig(Compose *compose, gboolean replace)
1920 GtkSText *text = GTK_STEXT(compose->text);
1924 g_return_if_fail(compose->account != NULL);
1926 cur_pos = gtk_editable_get_position(GTK_EDITABLE(text));
1928 gtk_stext_freeze(text);
1930 len = gtk_stext_get_length(text);
1931 gtk_stext_set_point(text, len);
1933 if (replace && compose->sig_str) {
1936 if (compose->sig_str[0] == '\0')
1939 pos = gtkut_stext_find(text, 0, compose->sig_str, TRUE);
1942 len = get_mbs_len(compose->sig_str);
1944 gtk_stext_set_point(text, pos);
1945 gtk_stext_forward_delete(text, len);
1950 g_free(compose->sig_str);
1951 compose->sig_str = compose_get_signature_str(compose);
1952 if (!compose->sig_str || (replace && !compose->account->auto_sig))
1953 compose->sig_str = g_strdup("");
1955 gtk_stext_insert(text, NULL, NULL, NULL, compose->sig_str, -1);
1957 gtk_stext_thaw(text);
1959 if (cur_pos > gtk_stext_get_length(text))
1960 cur_pos = gtk_stext_get_length(text);
1962 gtk_editable_set_position(GTK_EDITABLE(text), cur_pos);
1963 gtk_stext_set_point(text, cur_pos);
1966 static gchar *compose_get_signature_str(Compose *compose)
1968 gchar *sig_body = NULL;
1969 gchar *sig_str = NULL;
1971 g_return_val_if_fail(compose->account != NULL, NULL);
1973 if (!compose->account->sig_path)
1976 if (compose->account->sig_type == SIG_FILE) {
1977 if (!is_file_or_fifo_exist(compose->account->sig_path)) {
1978 g_warning("can't open signature file: %s\n",
1979 compose->account->sig_path);
1984 if (compose->account->sig_type == SIG_COMMAND)
1985 sig_body = get_command_output(compose->account->sig_path);
1989 tmp = file_read_to_str(compose->account->sig_path);
1992 sig_body = normalize_newlines(tmp);
1996 if (compose->account->sig_sep)
1997 sig_str = g_strconcat("\n\n", compose->account->sig_sep, "\n", sig_body,
2000 sig_str = g_strconcat("\n\n", sig_body, NULL);
2007 static void compose_insert_file(Compose *compose, const gchar *file)
2009 GtkSText *text = GTK_STEXT(compose->text);
2010 gchar buf[BUFFSIZE];
2014 g_return_if_fail(file != NULL);
2016 if ((fp = fopen(file, "rb")) == NULL) {
2017 FILE_OP_ERROR(file, "fopen");
2021 gtk_stext_freeze(text);
2023 while (fgets(buf, sizeof(buf), fp) != NULL) {
2024 /* strip <CR> if DOS/Windows file,
2025 replace <CR> with <LF> if Macintosh file. */
2028 if (len > 0 && buf[len - 1] != '\n') {
2030 if (buf[len] == '\r') buf[len] = '\n';
2032 gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
2035 gtk_stext_thaw(text);
2040 static void compose_attach_append(Compose *compose, const gchar *file,
2041 const gchar *filename,
2042 const gchar *content_type)
2045 gchar *text[N_ATTACH_COLS];
2050 if (!is_file_exist(file)) {
2051 g_warning("File %s doesn't exist\n", file);
2054 if ((size = get_file_size(file)) < 0) {
2055 g_warning("Can't get file size of %s\n", file);
2059 alertpanel_notice(_("File %s is empty."), file);
2062 if ((fp = fopen(file, "rb")) == NULL) {
2063 alertpanel_error(_("Can't read %s."), file);
2068 #if 0 /* NEW COMPOSE GUI */
2069 if (!compose->use_attach) {
2070 GtkItemFactory *ifactory;
2071 GtkWidget *menuitem;
2073 ifactory = gtk_item_factory_from_widget(compose->menubar);
2074 menuitem = gtk_item_factory_get_item(ifactory,
2075 "/View/Attachment");
2076 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2080 ainfo = g_new0(AttachInfo, 1);
2081 ainfo->file = g_strdup(file);
2084 ainfo->content_type = g_strdup(content_type);
2085 if (!strcasecmp(content_type, "message/rfc822")) {
2087 MsgFlags flags = {0, 0};
2090 if (procmime_get_encoding_for_file(file) == ENC_7BIT)
2091 ainfo->encoding = ENC_7BIT;
2093 ainfo->encoding = ENC_8BIT;
2095 msginfo = procheader_parse_file(file, flags, FALSE, FALSE);
2096 if (msginfo && msginfo->subject)
2097 name = msginfo->subject;
2099 name = g_basename(filename ? filename : file);
2101 ainfo->name = g_strdup_printf(_("Message: %s"), name);
2103 procmsg_msginfo_free(msginfo);
2105 if (!g_strncasecmp(content_type, "text", 4))
2107 procmime_get_encoding_for_file(file);
2109 ainfo->encoding = ENC_BASE64;
2110 ainfo->name = g_strdup
2111 (g_basename(filename ? filename : file));
2114 ainfo->content_type = procmime_get_mime_type(file);
2115 if (!ainfo->content_type) {
2116 ainfo->content_type =
2117 g_strdup("application/octet-stream");
2118 ainfo->encoding = ENC_BASE64;
2119 } else if (!g_strncasecmp(ainfo->content_type, "text", 4))
2120 ainfo->encoding = procmime_get_encoding_for_file(file);
2122 ainfo->encoding = ENC_BASE64;
2123 ainfo->name = g_strdup(g_basename(filename ? filename : file));
2127 text[COL_MIMETYPE] = ainfo->content_type;
2128 text[COL_SIZE] = to_human_readable(size);
2129 text[COL_NAME] = ainfo->name;
2131 row = gtk_clist_append(GTK_CLIST(compose->attach_clist), text);
2132 gtk_clist_set_row_data(GTK_CLIST(compose->attach_clist), row, ainfo);
2135 #define IS_FIRST_PART_TEXT(info) \
2136 ((info->mime_type == MIME_TEXT || info->mime_type == MIME_TEXT_HTML || \
2137 info->mime_type == MIME_TEXT_ENRICHED) || \
2138 (info->mime_type == MIME_MULTIPART && info->content_type && \
2139 !strcasecmp(info->content_type, "multipart/alternative") && \
2140 (info->children && \
2141 (info->children->mime_type == MIME_TEXT || \
2142 info->children->mime_type == MIME_TEXT_HTML || \
2143 info->children->mime_type == MIME_TEXT_ENRICHED))))
2145 static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
2152 mimeinfo = procmime_scan_message(msginfo);
2153 if (!mimeinfo) return;
2155 /* skip first text (presumably message body) */
2156 child = mimeinfo->children;
2157 if (!child || IS_FIRST_PART_TEXT(mimeinfo)) {
2158 procmime_mimeinfo_free_all(mimeinfo);
2162 if (IS_FIRST_PART_TEXT(child))
2163 child = child->next;
2165 infile = procmsg_get_message_file_path(msginfo);
2167 while (child != NULL) {
2168 if (child->children || child->mime_type == MIME_MULTIPART) {
2169 child = procmime_mimeinfo_next(child);
2172 if (child->parent && child->parent->parent
2173 && !strcasecmp(child->parent->parent->content_type, "multipart/signed")
2174 && child->mime_type == MIME_TEXT) {
2175 /* this is the main text part of a signed message */
2176 child = procmime_mimeinfo_next(child);
2179 outfile = procmime_get_tmp_file_name(child);
2180 if (procmime_get_part(outfile, infile, child) < 0)
2181 g_warning("Can't get the part of multipart message.");
2182 else if (compose->mode != COMPOSE_REEDIT || strcmp(child->content_type, "application/pgp-signature"))
2183 compose_attach_append
2185 child->filename ? child->filename : child->name,
2186 child->content_type);
2188 child = child->next;
2192 procmime_mimeinfo_free_all(mimeinfo);
2195 #undef IS_FIRST_PART_TEXT
2197 #define GET_CHAR(pos, buf, len) \
2199 if (text->use_wchar) \
2200 len = wctomb(buf, (wchar_t)GTK_STEXT_INDEX(text, (pos))); \
2202 buf[0] = GTK_STEXT_INDEX(text, (pos)); \
2207 #define DISP_WIDTH(len) \
2208 ((len > 2 && conv_get_current_charset() == C_UTF_8) ? 2 : \
2209 (len == 2 && conv_get_current_charset() == C_UTF_8) ? 1 : len)
2211 #define INDENT_CHARS ">|#"
2212 #define SPACE_CHARS " \t"
2214 static void compose_wrap_line(Compose *compose)
2216 GtkSText *text = GTK_STEXT(compose->text);
2217 gint ch_len, last_ch_len;
2218 gchar cbuf[MB_LEN_MAX], last_ch;
2222 gint p_start, p_end;
2223 gint line_pos, cur_pos;
2224 gint line_len, cur_len;
2226 gtk_stext_freeze(text);
2228 text_len = gtk_stext_get_length(text);
2230 /* check to see if the point is on the paragraph mark (empty line). */
2231 cur_pos = gtk_stext_get_point(text);
2232 GET_CHAR(cur_pos, cbuf, ch_len);
2233 if ((ch_len == 1 && *cbuf == '\n') || cur_pos == text_len) {
2235 goto compose_end; /* on the paragraph mark */
2236 GET_CHAR(cur_pos - 1, cbuf, ch_len);
2237 if (ch_len == 1 && *cbuf == '\n')
2238 goto compose_end; /* on the paragraph mark */
2241 /* find paragraph start. */
2242 line_end = quoted = 0;
2243 for (p_start = cur_pos; p_start >= 0; --p_start) {
2244 GET_CHAR(p_start, cbuf, ch_len);
2245 if (ch_len == 1 && *cbuf == '\n') {
2247 goto compose_end; /* quoted part */
2255 && strchr(prefs_common.quote_chars, *cbuf))
2257 else if (ch_len != 1 || !isspace(*cbuf))
2266 /* find paragraph end. */
2268 for (p_end = cur_pos; p_end < text_len; p_end++) {
2269 GET_CHAR(p_end, cbuf, ch_len);
2270 if (ch_len == 1 && *cbuf == '\n') {
2277 if (line_end && ch_len == 1 &&
2278 strchr(prefs_common.quote_chars, *cbuf))
2279 goto compose_end; /* quoted part */
2284 if (p_end >= text_len)
2287 if (p_start >= p_end)
2290 line_len = cur_len = 0;
2294 for (cur_pos = p_start; cur_pos < p_end; cur_pos++) {
2297 GET_CHAR(cur_pos, cbuf, ch_len);
2304 if (ch_len == 1 && isspace(*cbuf))
2307 if (ch_len == 1 && *cbuf == '\n') {
2309 if (last_ch_len == 1 && !isspace(last_ch)) {
2310 if (cur_pos + 1 < p_end) {
2311 GET_CHAR(cur_pos + 1, cbuf, ch_len);
2312 if (ch_len == 1 && !isspace(*cbuf))
2316 gtk_stext_set_point(text, cur_pos + 1);
2317 gtk_stext_backward_delete(text, 1);
2319 gtk_stext_set_point(text, cur_pos);
2320 gtk_stext_insert(text, NULL, NULL, NULL, " ", 1);
2330 last_ch_len = ch_len;
2334 line_pos = cur_pos + 1;
2335 line_len = cur_len + ch_len;
2338 if (cur_len + DISP_WIDTH(ch_len) > prefs_common.linewrap_len &&
2342 GET_CHAR(line_pos - 1, cbuf, ch_len);
2343 if (ch_len == 1 && isspace(*cbuf)) {
2344 gtk_stext_set_point(text, line_pos);
2345 gtk_stext_backward_delete(text, 1);
2354 gtk_stext_set_point(text, line_pos);
2355 gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
2359 cur_len = cur_len - line_len + DISP_WIDTH(ch_len);
2365 line_pos = cur_pos + 1;
2366 line_len = cur_len + DISP_WIDTH(ch_len);
2368 cur_len += DISP_WIDTH(ch_len);
2372 gtk_stext_thaw(text);
2377 /* Darko: used when I debug wrapping */
2378 void dump_text(GtkSText *text, int pos, int tlen, int breakoncr)
2381 gchar cbuf[MB_LEN_MAX];
2383 printf("%d [", pos);
2384 for (i = pos; i < tlen; i++) {
2385 GET_CHAR(i, cbuf, clen);
2386 if (clen < 0) break;
2387 if (breakoncr && clen == 1 && cbuf[0] == '\n')
2389 fwrite(cbuf, clen, 1, stdout);
2397 WAIT_FOR_INDENT_CHAR,
2398 WAIT_FOR_INDENT_CHAR_OR_SPACE
2401 /* return indent length, we allow:
2402 > followed by spaces/tabs
2403 | followed by spaces/tabs
2404 uppercase characters immediately followed by >,
2405 and the repeating sequences of the above */
2406 /* return indent length */
2407 static guint get_indent_length(GtkSText *text, guint start_pos, guint text_len)
2410 guint i, ch_len, alnum_cnt = 0;
2411 IndentState state = WAIT_FOR_INDENT_CHAR;
2412 gchar cbuf[MB_LEN_MAX];
2416 if (prefs_common.quote_chars == NULL) {
2420 for (i = start_pos; i < text_len; i++) {
2421 GET_CHAR(i, cbuf, ch_len);
2425 if (cbuf[0] == '\n')
2428 is_indent = strchr(prefs_common.quote_chars, cbuf[0]) ? TRUE : FALSE;
2429 is_space = strchr(SPACE_CHARS, cbuf[0]) ? TRUE : FALSE;
2432 case WAIT_FOR_SPACE:
2433 if (is_space == FALSE)
2435 state = WAIT_FOR_INDENT_CHAR_OR_SPACE;
2437 case WAIT_FOR_INDENT_CHAR_OR_SPACE:
2438 if (is_indent == FALSE && is_space == FALSE &&
2441 if (is_space == TRUE) {
2443 state = WAIT_FOR_INDENT_CHAR_OR_SPACE;
2444 } else if (is_indent == TRUE) {
2446 state = WAIT_FOR_SPACE;
2449 state = WAIT_FOR_INDENT_CHAR;
2452 case WAIT_FOR_INDENT_CHAR:
2453 if (is_indent == FALSE && !isupper(cbuf[0]))
2455 if (is_indent == TRUE) {
2457 && !strchr(prefs_common.quote_chars, cbuf[0]))
2460 state = WAIT_FOR_SPACE;
2471 if ((i_len > 0) && (state == WAIT_FOR_INDENT_CHAR))
2477 /* insert quotation string when line was wrapped */
2478 static guint ins_quote(GtkSText *text, guint indent_len,
2479 guint prev_line_pos, guint text_len,
2482 guint i, ins_len = 0;
2486 for (i = 0; i < indent_len; i++) {
2487 ch = GTK_STEXT_INDEX(text, prev_line_pos + i);
2488 gtk_stext_insert(text, NULL, NULL, NULL, &ch, 1);
2490 ins_len = indent_len;
2496 /* check if we should join the next line */
2497 static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
2498 guint prev_ilen, gboolean autowrap)
2500 guint indent_len, ch_len;
2501 gboolean do_join = FALSE;
2502 gchar cbuf[MB_LEN_MAX];
2504 indent_len = get_indent_length(text, start_pos, tlen);
2506 if ((autowrap || indent_len > 0) && indent_len == prev_ilen) {
2507 GET_CHAR(start_pos + indent_len, cbuf, ch_len);
2508 if (ch_len > 0 && (cbuf[0] != '\n'))
2515 static void compose_wrap_line_all(Compose *compose)
2517 compose_wrap_line_all_full(compose, FALSE);
2520 #define STEXT_FREEZE() \
2521 if (!frozen) { gtk_stext_freeze(text); frozen = TRUE; }
2523 static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
2525 GtkSText *text = GTK_STEXT(compose->text);
2527 guint line_pos = 0, cur_pos = 0, p_pos = 0;
2528 gint line_len = 0, cur_len = 0;
2530 gboolean is_new_line = TRUE, do_delete = FALSE;
2532 gboolean linewrap_quote = TRUE;
2533 gboolean set_editable_pos = FALSE;
2534 gint editable_pos = 0;
2535 gboolean frozen = FALSE;
2536 guint linewrap_len = prefs_common.linewrap_len;
2537 gchar *qfmt = prefs_common.quotemark;
2538 gchar cbuf[MB_LEN_MAX];
2540 tlen = gtk_stext_get_length(text);
2542 for (; cur_pos < tlen; cur_pos++) {
2543 /* mark position of new line - needed for quotation wrap */
2546 i_len = get_indent_length(text, cur_pos, tlen);
2548 is_new_line = FALSE;
2551 g_print("new line i_len=%d p_pos=", i_len);
2552 dump_text(text, p_pos, tlen, 1);
2556 GET_CHAR(cur_pos, cbuf, ch_len);
2558 /* fix line length for tabs */
2559 if (ch_len == 1 && *cbuf == '\t') {
2560 guint tab_width = text->default_tab_width;
2561 guint tab_offset = line_len % tab_width;
2564 g_print("found tab at pos=%d line_len=%d ", cur_pos,
2568 line_len += tab_width - tab_offset - 1;
2572 printf("new_len=%d\n", line_len);
2576 /* we have encountered line break */
2577 if (ch_len == 1 && *cbuf == '\n') {
2579 gchar cb[MB_LEN_MAX];
2581 /* should we join the next line */
2582 if ((autowrap || i_len != cur_len) && do_delete &&
2584 (text, cur_pos + 1, tlen, i_len, autowrap))
2590 g_print("found CR at %d do_del is %d next line is ",
2591 cur_pos, do_delete);
2592 dump_text(text, cur_pos + 1, tlen, 1);
2595 /* skip delete if it is continuous URL */
2596 if (do_delete && (line_pos - p_pos <= i_len) &&
2597 gtk_stext_is_uri_string(text, line_pos, tlen))
2601 g_print("l_len=%d wrap_len=%d do_del=%d\n",
2602 line_len, linewrap_len, do_delete);
2604 /* should we delete to perform smart wrapping */
2605 if (line_len < linewrap_len && do_delete) {
2607 /* get rid of newline */
2608 gtk_stext_set_point(text, cur_pos);
2609 gtk_stext_forward_delete(text, 1);
2612 /* if text starts with quote fmt or with
2613 indent string, delete them */
2616 ilen = gtk_stext_str_compare_n
2617 (text, cur_pos, p_pos, i_len,
2620 gtk_stext_forward_delete
2626 GET_CHAR(cur_pos, cb, clen);
2628 /* insert space if it's alphanumeric */
2629 if ((cur_pos != line_pos) &&
2630 ((clen > 1) || isalnum(cb[0]))) {
2631 gtk_stext_insert(text, NULL, NULL,
2636 /* and start over with current line */
2637 cur_pos = p_pos - 1;
2639 line_len = cur_len = 0;
2643 g_print("after delete l_pos=");
2644 dump_text(text, line_pos, tlen, 1);
2646 /* move beginning of line if we are on LF */
2647 GET_CHAR(line_pos, cb, clen);
2648 if (clen == 1 && *cb == '\n')
2651 g_print("new line_pos=%d\n", line_pos);
2657 /* mark new line beginning */
2658 line_pos = cur_pos + 1;
2659 line_len = cur_len = 0;
2670 /* possible line break */
2671 if (ch_len == 1 && isspace(*cbuf)) {
2672 line_pos = cur_pos + 1;
2673 line_len = cur_len + ch_len;
2676 /* are we over wrapping length set in preferences ? */
2677 if (cur_len + DISP_WIDTH(ch_len) > linewrap_len) {
2681 g_print("should wrap cur_pos=%d ", cur_pos);
2682 dump_text(text, p_pos, tlen, 1);
2683 dump_text(text, line_pos, tlen, 1);
2685 /* force wrapping if it is one long word but not URL */
2686 if (line_pos - p_pos <= i_len)
2687 if (!gtk_stext_is_uri_string
2688 (text, line_pos, tlen))
2689 line_pos = cur_pos - 1;
2691 g_print("new line_pos=%d\n", line_pos);
2694 GET_CHAR(line_pos - 1, cbuf, clen);
2696 /* if next character is space delete it */
2697 if (clen == 1 && isspace(*cbuf)) {
2698 if (p_pos + i_len != line_pos ||
2699 !gtk_stext_is_uri_string
2700 (text, line_pos, tlen)) {
2702 /* workaround for correct cursor
2704 if (set_editable_pos == FALSE) {
2705 editable_pos = gtk_editable_get_position(GTK_EDITABLE(text));
2706 if (editable_pos == line_pos)
2707 set_editable_pos = TRUE;
2709 gtk_stext_set_point(text, line_pos);
2710 gtk_stext_backward_delete(text, 1);
2719 /* if it is URL at beginning of line don't wrap */
2720 if (p_pos + i_len == line_pos &&
2721 gtk_stext_is_uri_string(text, line_pos, tlen)) {
2723 g_print("found URL at ");
2724 dump_text(text, line_pos, tlen, 1);
2731 gtk_stext_set_point(text, line_pos);
2732 gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
2733 gtk_stext_compact_buffer(text);
2736 /* for loop will increase it */
2737 cur_pos = line_pos - 1;
2738 /* start over with current line */
2740 line_len = cur_len = 0;
2741 if (autowrap || i_len > 0)
2746 g_print("after CR insert ");
2747 dump_text(text, line_pos, tlen, 1);
2748 dump_text(text, cur_pos, tlen, 1);
2751 /* should we insert quotation ? */
2752 if (linewrap_quote && i_len) {
2753 /* only if line is not already quoted */
2754 if (!gtk_stext_str_compare
2755 (text, line_pos, tlen, qfmt)) {
2758 if (line_pos - p_pos > i_len) {
2760 (text, i_len, p_pos,
2765 g_print("after quote insert ");
2766 dump_text(text, line_pos, tlen, 1);
2774 line_pos = cur_pos + 1;
2775 line_len = cur_len + DISP_WIDTH(ch_len);
2777 /* advance to next character in buffer */
2778 cur_len += DISP_WIDTH(ch_len);
2782 gtk_stext_thaw(text);
2784 if (set_editable_pos && editable_pos <= tlen)
2785 gtk_editable_set_position(GTK_EDITABLE(text), editable_pos);
2791 static void compose_set_title(Compose *compose)
2796 edited = compose->modified ? _(" [Edited]") : "";
2797 if (compose->account && compose->account->address)
2798 str = g_strdup_printf(_("%s - Compose message%s"),
2799 compose->account->address, edited);
2801 str = g_strdup_printf(_("Compose message%s"), edited);
2802 gtk_window_set_title(GTK_WINDOW(compose->window), str);
2807 * compose_current_mail_account:
2809 * Find a current mail account (the currently selected account, or the
2810 * default account, if a news account is currently selected). If a
2811 * mail account cannot be found, display an error message.
2813 * Return value: Mail account, or NULL if not found.
2815 static PrefsAccount *
2816 compose_current_mail_account(void)
2820 if (cur_account && cur_account->protocol != A_NNTP)
2823 ac = account_get_default();
2824 if (!ac || ac->protocol == A_NNTP) {
2825 alertpanel_error(_("Account for sending mail is not specified.\n"
2826 "Please select a mail account before sending."));
2833 static void compose_select_account(Compose *compose, PrefsAccount *account,
2836 GtkWidget *menuitem;
2837 GtkItemFactory *ifactory;
2839 g_return_if_fail(account != NULL);
2841 compose->account = account;
2843 compose_set_title(compose);
2845 ifactory = gtk_item_factory_from_widget(compose->menubar);
2847 if (account->protocol == A_NNTP) {
2848 gtk_widget_show(compose->newsgroups_hbox);
2849 gtk_widget_show(compose->newsgroups_entry);
2850 gtk_table_set_row_spacing(GTK_TABLE(compose->table), 2, 4);
2851 compose->use_newsgroups = TRUE;
2853 menuitem = gtk_item_factory_get_item(ifactory, "/View/To");
2854 gtk_check_menu_item_set_active
2855 (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2856 gtk_widget_set_sensitive(menuitem, TRUE);
2857 menuitem = gtk_item_factory_get_item(ifactory, "/View/Cc");
2858 gtk_check_menu_item_set_active
2859 (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2860 gtk_widget_set_sensitive(menuitem, TRUE);
2862 menu_set_sensitive(ifactory, "/View/Followup to", TRUE);
2864 gtk_widget_hide(compose->newsgroups_hbox);
2865 gtk_widget_hide(compose->newsgroups_entry);
2866 gtk_table_set_row_spacing(GTK_TABLE(compose->table), 2, 0);
2867 gtk_widget_queue_resize(compose->table_vbox);
2868 compose->use_newsgroups = FALSE;
2870 menuitem = gtk_item_factory_get_item(ifactory, "/View/To");
2871 gtk_check_menu_item_set_active
2872 (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2873 gtk_widget_set_sensitive(menuitem, FALSE);
2874 menuitem = gtk_item_factory_get_item(ifactory, "/View/Cc");
2875 gtk_check_menu_item_set_active
2876 (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2877 gtk_widget_set_sensitive(menuitem, FALSE);
2879 menuitem = gtk_item_factory_get_item(ifactory, "/View/Followup to");
2880 gtk_check_menu_item_set_active
2881 (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2882 gtk_widget_set_sensitive(menuitem, FALSE);
2885 if (account->set_autocc) {
2886 compose_entry_show(compose, COMPOSE_ENTRY_CC);
2887 if (account->auto_cc && compose->mode != COMPOSE_REEDIT)
2888 compose_entry_set(compose, account->auto_cc,
2891 if (account->set_autobcc) {
2892 compose_entry_show(compose, COMPOSE_ENTRY_BCC);
2893 if (account->auto_bcc && compose->mode != COMPOSE_REEDIT)
2894 compose_entry_set(compose, account->auto_bcc,
2897 if (account->set_autoreplyto) {
2898 compose_entry_show(compose, COMPOSE_ENTRY_REPLY_TO);
2899 if (account->auto_replyto && compose->mode != COMPOSE_REEDIT)
2900 compose_entry_set(compose, account->auto_replyto,
2901 COMPOSE_ENTRY_REPLY_TO);
2904 menuitem = gtk_item_factory_get_item(ifactory, "/View/Ruler");
2905 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2906 prefs_common.show_ruler);
2910 menuitem = gtk_item_factory_get_item(ifactory, "/Message/Sign");
2911 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2912 account->default_sign);
2913 menuitem = gtk_item_factory_get_item(ifactory, "/Message/Encrypt");
2914 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2915 account->default_encrypt);
2917 activate_gnupg_mode(compose, account);
2918 #endif /* USE_GPGME */
2920 if (!init && compose->mode != COMPOSE_REDIRECT)
2921 compose_insert_sig(compose, TRUE);
2924 gboolean compose_check_for_valid_recipient(Compose *compose) {
2925 gchar *recipient_headers_mail[] = {"To:", "Cc:", "Bcc:", NULL};
2926 gchar *recipient_headers_news[] = {"Newsgroups:", NULL};
2927 gboolean recipient_found = FALSE;
2931 /* free to and newsgroup list */
2932 slist_free_strings(compose->to_list);
2933 g_slist_free(compose->to_list);
2934 compose->to_list = NULL;
2936 slist_free_strings(compose->newsgroup_list);
2937 g_slist_free(compose->newsgroup_list);
2938 compose->newsgroup_list = NULL;
2940 /* search header entries for to and newsgroup entries */
2941 for (list = compose->header_list; list; list = list->next) {
2944 header = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry), 0, -1);
2945 entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
2947 if (entry[0] != '\0') {
2948 for (strptr = recipient_headers_mail; *strptr != NULL; strptr++) {
2949 if (!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
2950 compose->to_list = address_list_append(compose->to_list, entry);
2951 recipient_found = TRUE;
2954 for (strptr = recipient_headers_news; *strptr != NULL; strptr++) {
2955 if (!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
2956 compose->newsgroup_list = newsgroup_list_append(compose->newsgroup_list, entry);
2957 recipient_found = TRUE;
2964 return recipient_found;
2967 static gboolean compose_check_entries(Compose *compose, gboolean check_subject)
2971 if (compose_check_for_valid_recipient(compose) == FALSE) {
2972 alertpanel_error(_("Recipient is not specified."));
2976 str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
2977 if (*str == '\0' && check_subject == TRUE) {
2980 aval = alertpanel(_("Send"),
2981 _("Subject is empty. Send it anyway?"),
2982 _("Yes"), _("No"), NULL);
2983 if (aval != G_ALERTDEFAULT)
2990 gint compose_send(Compose *compose)
2997 if (compose_check_entries(compose, TRUE) == FALSE)
3000 val = compose_queue(compose, &msgnum, &folder);
3002 alertpanel_error(_("Could not queue message for sending"));
3007 alertpanel_error(_("The message was queued but could not be sent.\nUse \"Send queued messages\" from the main window to retry."));
3011 msgpath = folder_item_fetch_msg(folder, msgnum);
3012 val = procmsg_send_message_queue(msgpath);
3015 folder_item_remove_msg(folder, msgnum);
3017 folder_item_scan(folder);
3022 #if 0 /* compose restructure */
3023 gint compose_send(Compose *compose)
3025 gchar tmp[MAXPATHLEN + 1];
3027 static gboolean lock = FALSE;
3031 g_return_val_if_fail(compose->account != NULL, -1);
3035 if (compose_check_entries(compose, TRUE) == FALSE) {
3040 /* write to temporary file */
3041 g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.%08x",
3042 get_tmp_dir(), G_DIR_SEPARATOR, (gint)compose);
3044 if (prefs_common.linewrap_at_send)
3045 compose_wrap_line_all(compose);
3047 if (compose_write_to_file(compose, tmp, FALSE) < 0) {
3052 if (!compose->to_list && !compose->newsgroup_list) {
3053 g_warning("can't get recipient list.");
3059 if (compose->to_list) {
3062 #if 0 /* NEW COMPOSE GUI */
3063 if (compose->account->protocol != A_NNTP)
3064 ac = compose->account;
3066 ac = account_find_from_address(compose->account->address);
3068 if (cur_account && cur_account->protocol != A_NNTP)
3071 ac = account_get_default();
3073 if (!ac || ac->protocol == A_NNTP) {
3074 alertpanel_error(_("Account for sending mail is not specified.\n"
3075 "Please select a mail account before sending."));
3082 ac = compose->account;
3084 ok = send_message(tmp, ac, compose->to_list);
3087 if (ok == 0 && compose->newsgroup_list) {
3088 ok = news_post(FOLDER(compose->account->folder), tmp);
3090 alertpanel_error(_("Error occurred while posting the message to %s ."),
3091 compose->account->nntp_server);
3098 /* queue message if failed to send */
3100 if (prefs_common.queue_msg) {
3105 _("Error occurred while sending the message.\n"
3106 "Put this message into queue folder?"),
3107 _("OK"), _("Cancel"), NULL);
3108 if (G_ALERTDEFAULT == val) {
3109 ok = compose_queue(compose, tmp);
3111 alertpanel_error(_("Can't queue the message."));
3114 alertpanel_error_log(_("Error occurred while sending the message."));
3116 if (compose->mode == COMPOSE_REEDIT) {
3117 compose_remove_reedit_target(compose);
3119 /* save message to outbox */
3120 if (prefs_common.savemsg) {
3123 outbox = account_get_special_folder
3124 (compose->account, F_OUTBOX);
3125 if (procmsg_save_to_outbox(outbox, tmp, FALSE) < 0)
3127 (_("Can't save the message to Sent."));
3137 static gboolean compose_use_attach(Compose *compose)
3139 return gtk_clist_get_row_data(GTK_CLIST(compose->attach_clist), 0) != NULL;
3142 static gint compose_redirect_write_headers_from_headerlist(Compose *compose,
3145 gchar buf[BUFFSIZE];
3147 gboolean first_address;
3149 ComposeHeaderEntry *headerentry;
3150 gchar *headerentryname;
3154 debug_print("Writing redirect header\n");
3156 cc_hdr = prefs_common.trans_hdr ? _("Cc:") : "Cc:";
3157 to_hdr = prefs_common.trans_hdr ? _("To:") : "To:";
3159 first_address = TRUE;
3160 for (list = compose->header_list; list; list = list->next) {
3161 headerentry = ((ComposeHeaderEntry *)list->data);
3162 headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
3164 if (g_strcasecmp(headerentryname, cc_hdr) == 0
3165 || g_strcasecmp(headerentryname, to_hdr) == 0) {
3166 str = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
3167 Xstrdup_a(str, str, return -1);
3169 if (str[0] != '\0') {
3170 compose_convert_header
3171 (buf, sizeof(buf), str,
3172 strlen("Resent-To") + 2, TRUE);
3173 if (first_address) {
3174 fprintf(fp, "Resent-To: ");
3175 first_address = FALSE;
3179 fprintf(fp, "%s", buf);
3183 /* if (!first_address) { */
3190 static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
3192 gchar buf[BUFFSIZE];
3194 /* struct utsname utsbuf; */
3196 g_return_val_if_fail(fp != NULL, -1);
3197 g_return_val_if_fail(compose->account != NULL, -1);
3198 g_return_val_if_fail(compose->account->address != NULL, -1);
3201 get_rfc822_date(buf, sizeof(buf));
3202 fprintf(fp, "Resent-Date: %s\n", buf);
3205 if (compose->account->name && *compose->account->name) {
3206 compose_convert_header
3207 (buf, sizeof(buf), compose->account->name,