COMPOSE_WRITE_FOR_STORE
} ComposeWriteType;
+typedef enum
+{
+ COMPOSE_QUOTE_FORCED,
+ COMPOSE_QUOTE_CHECK,
+ COMPOSE_QUOTE_SKIP
+} ComposeQuoteMode;
+
#define B64_LINE_SIZE 57
#define B64_BUFFSIZE 77
static void compose_entry_mark_default_to (Compose *compose,
const gchar *address);
static Compose *compose_followup_and_reply_to (MsgInfo *msginfo,
- gboolean quote,
+ ComposeQuoteMode quote_mode,
gboolean to_all,
gboolean to_sender,
const gchar *body);
static Compose *compose_forward_multiple (PrefsAccount *account,
GSList *msginfo_list);
static Compose *compose_reply (MsgInfo *msginfo,
- gboolean quote,
+ ComposeQuoteMode quote_mode,
gboolean to_all,
gboolean to_ml,
gboolean to_sender,
const gchar *text,
gint len,
Compose *compose);
-static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
- gboolean to_all, gboolean to_ml,
+static Compose *compose_generic_reply(MsgInfo *msginfo,
+ ComposeQuoteMode quote_mode,
+ gboolean to_all,
+ gboolean to_ml,
gboolean to_sender,
gboolean followup_and_reply_to,
const gchar *body);
GtkTextBuffer *textbuf;
GtkTextIter iter;
GtkItemFactory *ifactory;
+ gchar *subject_format = NULL;
+ gchar *body_format = NULL;
if (item && item->prefs && item->prefs->enable_default_account)
account = account_find_from_id(item->prefs->default_account);
}
compose_add_field_list( compose, listAddress );
- if (prefs_common.compose_with_format) {
+ if (item && item->prefs && item->prefs->compose_with_format) {
+ subject_format = item->prefs->compose_subject_format;
+ body_format = item->prefs->compose_body_format;
+ } else if (account->compose_with_format) {
+ subject_format = account->compose_subject_format;
+ body_format = account->compose_body_format;
+ } else if (prefs_common.compose_with_format) {
+ subject_format = prefs_common.compose_subject_format;
+ body_format = prefs_common.compose_body_format;
+ }
+
+ if (subject_format || body_format) {
MsgInfo* dummyinfo = NULL;
- if ( prefs_common.compose_subject_format
- && *prefs_common.compose_subject_format != '\0' )
+ if ( subject_format
+ && *subject_format != '\0' )
{
gchar *subject = NULL;
gchar *tmp = NULL;
dummyinfo = compose_msginfo_new_from_compose(compose);
/* decode \-escape sequences in the internal representation of the quote format */
- tmp = malloc(strlen(prefs_common.compose_subject_format)+1);
- pref_get_unescaped_pref(tmp, prefs_common.compose_subject_format);
+ tmp = malloc(strlen(subject_format)+1);
+ pref_get_unescaped_pref(tmp, subject_format);
subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
+#ifdef USE_ASPELL
quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account,
compose->gtkaspell);
+#else
+ quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account);
+#endif
quote_fmt_scan_string(tmp);
quote_fmt_parse();
g_free(tmp);
}
- if ( prefs_common.compose_body_format
- && *prefs_common.compose_body_format != '\0' )
+ if ( body_format
+ && *body_format != '\0' )
{
GtkTextView *text;
GtkTextBuffer *buffer;
tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
compose_quote_fmt(compose, dummyinfo,
- prefs_common.compose_body_format,
+ body_format,
NULL, tmp, FALSE, TRUE,
- _("New message body format error."));
+ _("New message body format error at line %d."));
quote_fmt_reset_vartable();
g_free(tmp);
switch (mode) {
case COMPOSE_REPLY:
- compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
FALSE, prefs_common.default_reply_list, FALSE, body);
break;
case COMPOSE_REPLY_WITH_QUOTE:
- compose = compose_reply(msginfo, TRUE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED,
FALSE, prefs_common.default_reply_list, FALSE, body);
break;
case COMPOSE_REPLY_WITHOUT_QUOTE:
- compose = compose_reply(msginfo, FALSE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP,
FALSE, prefs_common.default_reply_list, FALSE, NULL);
break;
case COMPOSE_REPLY_TO_SENDER:
- compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
FALSE, FALSE, TRUE, body);
break;
case COMPOSE_FOLLOWUP_AND_REPLY_TO:
compose = compose_followup_and_reply_to(msginfo,
- prefs_common.reply_with_quote,
+ COMPOSE_QUOTE_CHECK,
FALSE, FALSE, body);
break;
case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
- compose = compose_reply(msginfo, TRUE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED,
FALSE, FALSE, TRUE, body);
break;
case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
- compose = compose_reply(msginfo, FALSE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP,
FALSE, FALSE, TRUE, NULL);
break;
case COMPOSE_REPLY_TO_ALL:
- compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
TRUE, FALSE, FALSE, body);
break;
case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
- compose = compose_reply(msginfo, TRUE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED,
TRUE, FALSE, FALSE, body);
break;
case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
- compose = compose_reply(msginfo, FALSE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP,
TRUE, FALSE, FALSE, NULL);
break;
case COMPOSE_REPLY_TO_LIST:
- compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
FALSE, TRUE, FALSE, body);
break;
case COMPOSE_REPLY_TO_LIST_WITH_QUOTE:
- compose = compose_reply(msginfo, TRUE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED,
FALSE, TRUE, FALSE, body);
break;
case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE:
- compose = compose_reply(msginfo, FALSE,
+ compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP,
FALSE, TRUE, FALSE, NULL);
break;
case COMPOSE_FORWARD:
compose = compose_redirect(NULL, msginfo, FALSE);
break;
default:
- g_warning("compose_reply(): invalid Compose Mode: %d\n", mode);
+ g_warning("compose_reply_mode(): invalid Compose Mode: %d\n", mode);
}
ifactory = gtk_item_factory_from_widget(compose->menubar);
return compose;
}
-static Compose *compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
- gboolean to_ml, gboolean to_sender,
+static Compose *compose_reply(MsgInfo *msginfo,
+ ComposeQuoteMode quote_mode,
+ gboolean to_all,
+ gboolean to_ml,
+ gboolean to_sender,
const gchar *body)
{
- return compose_generic_reply(msginfo, quote, to_all, to_ml,
+ return compose_generic_reply(msginfo, quote_mode, to_all, to_ml,
to_sender, FALSE, body);
}
-static Compose *compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
+static Compose *compose_followup_and_reply_to(MsgInfo *msginfo,
+ ComposeQuoteMode quote_mode,
gboolean to_all,
gboolean to_sender,
const gchar *body)
{
- return compose_generic_reply(msginfo, quote, to_all, FALSE,
+ return compose_generic_reply(msginfo, quote_mode, to_all, FALSE,
to_sender, TRUE, body);
}
compose); \
}
-static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
+static Compose *compose_generic_reply(MsgInfo *msginfo,
+ ComposeQuoteMode quote_mode,
gboolean to_all, gboolean to_ml,
gboolean to_sender,
gboolean followup_and_reply_to,
GtkItemFactory *ifactory;
Compose *compose;
PrefsAccount *account = NULL;
- PrefsAccount *reply_account;
GtkTextView *textview;
GtkTextBuffer *textbuf;
+ gboolean quote = FALSE;
+ gchar *qmark = NULL;
+ gchar *body_fmt = NULL;
g_return_val_if_fail(msginfo != NULL, NULL);
g_return_val_if_fail(msginfo->folder != NULL, NULL);
g_return_val_if_fail(account != NULL, NULL);
- if (to_sender && account->protocol == A_NNTP &&
- !followup_and_reply_to) {
- reply_account =
- account_find_from_address(account->address);
- if (!reply_account)
- reply_account = compose_current_mail_account();
- if (!reply_account)
- return NULL;
- } else
- reply_account = account;
-
compose = compose_create(account, COMPOSE_REPLY, FALSE);
compose->updating = TRUE;
compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
#endif
- if (quote) {
- gchar *qmark;
+ if (quote_mode == COMPOSE_QUOTE_FORCED ||
+ (quote_mode == COMPOSE_QUOTE_CHECK && prefs_common.reply_with_quote)) {
+ /* use the reply format of folder (if enabled), or the account's one
+ (if enabled) or fallback to the global reply format, which is always
+ enabled (even if empty), and use the relevant quotemark */
+ quote = TRUE;
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->reply_with_format) {
+ qmark = msginfo->folder->prefs->reply_quotemark;
+ body_fmt = msginfo->folder->prefs->reply_body_format;
+
+ } else if (account->reply_with_format) {
+ qmark = account->reply_quotemark;
+ body_fmt = account->reply_body_format;
- if (prefs_common.quotemark && *prefs_common.quotemark)
+ } else {
qmark = prefs_common.quotemark;
- else
- qmark = "> ";
+ body_fmt = prefs_common.quotefmt;
+ }
+ }
+ if (quote) {
+ /* empty quotemark is not allowed */
+ if (qmark == NULL || *qmark == '\0')
+ qmark = "> ";
compose_quote_fmt(compose, compose->replyinfo,
- prefs_common.quotefmt,
- qmark, body, FALSE, TRUE,
- _("Message reply format error."));
+ body_fmt, qmark, body, FALSE, TRUE,
+ _("Message reply format error at line %d."));
quote_fmt_reset_vartable();
}
if (procmime_msginfo_is_encrypted(compose->replyinfo)) {
if (as_attach) {
gchar *msgfile;
- msgfile = procmsg_get_message_file_path(msginfo);
+ msgfile = procmsg_get_message_file(msginfo);
if (!is_file_exist(msgfile))
g_warning("%s: file not exist\n", msgfile);
else
g_free(msgfile);
} else {
- gchar *qmark;
+ gchar *qmark = NULL;
+ gchar *body_fmt = prefs_common.fw_quotefmt;
MsgInfo *full_msginfo;
full_msginfo = procmsg_msginfo_get_full_info(msginfo);
if (!full_msginfo)
full_msginfo = procmsg_msginfo_copy(msginfo);
- if (prefs_common.fw_quotemark &&
- *prefs_common.fw_quotemark)
+ /* use the forward format of folder (if enabled), or the account's one
+ (if enabled) or fallback to the global forward format, which is always
+ enabled (even if empty), and use the relevant quotemark */
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->forward_with_format) {
+ qmark = msginfo->folder->prefs->forward_quotemark;
+ body_fmt = msginfo->folder->prefs->forward_body_format;
+
+ } else if (account->forward_with_format) {
+ qmark = account->forward_quotemark;
+ body_fmt = account->forward_body_format;
+
+ } else {
qmark = prefs_common.fw_quotemark;
- else
+ body_fmt = prefs_common.fw_quotefmt;
+ }
+
+ /* empty quotemark is not allowed */
+ if (qmark && !*qmark)
qmark = "> ";
compose_quote_fmt(compose, full_msginfo,
- prefs_common.fw_quotefmt,
- qmark, body, FALSE, TRUE,
- _("Message forward format error."));
+ body_fmt, qmark, body, FALSE, TRUE,
+ _("Message forward format error at line %d."));
quote_fmt_reset_vartable();
compose_attach_parts(compose, msginfo);
undo_block(compose->undostruct);
for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
- msgfile = procmsg_get_message_file_path((MsgInfo *)msginfo->data);
+ msgfile = procmsg_get_message_file((MsgInfo *)msginfo->data);
if (!is_file_exist(msgfile))
g_warning("%s: file not exist\n", msgfile);
gtk_widget_grab_focus(compose->header_last->entry);
- filename = procmsg_get_message_file_path(msginfo);
+ filename = procmsg_get_message_file(msginfo);
if (filename == NULL) {
compose->updating = FALSE;
gtk_editable_set_editable(GTK_EDITABLE(compose->subject_entry), FALSE);
compose_quote_fmt(compose, msginfo, "%M", NULL, NULL, FALSE, FALSE,
- _("Message redirect format error."));
+ _("Message redirect format error at line %d."));
quote_fmt_reset_vartable();
gtk_text_view_set_editable(GTK_TEXT_VIEW(compose->text), FALSE);
}
if (qmark != NULL) {
+#ifdef USE_ASPELL
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+#endif
quote_fmt_scan_string(qmark);
quote_fmt_parse();
while (*trimmed_body == '\n')
trimmed_body++;
+#ifdef USE_ASPELL
quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account,
compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account);
+#endif
if (need_unescape) {
gchar *tmp = NULL;
buf = quote_fmt_get_buffer();
if (buf == NULL) {
- alertpanel_error(err_msg);
+ gint line = quote_fmt_get_line();
+ gchar *msg = g_strdup_printf(err_msg, line);
+ alertpanel_error(msg);
+ g_free(msg);
goto error;
}
} else
/* if we meet a pgp signature, we don't attach it, but
* we force signing. */
- if (strcmp(content_type, "application/pgp-signature") &&
+ if ((strcmp(content_type, "application/pgp-signature") &&
strcmp(content_type, "application/pkcs7-signature") &&
- strcmp(content_type, "application/x-pkcs7-signature")) {
+ strcmp(content_type, "application/x-pkcs7-signature"))
+ || compose->mode == COMPOSE_REDIRECT) {
partname = procmime_mimeinfo_get_parameter(child, "filename");
if (partname == NULL)
partname = procmime_mimeinfo_get_parameter(child, "name");
g_free(msgpath);
}
if (!discard_window) {
- compose->sending = FALSE;
- compose_allow_user_actions (compose, TRUE);
if (val != 0) {
if (!queued_removed)
folder_item_remove_msg(folder, msgnum);
procmsg_msginfo_free(tmp);
}
}
- if (!discard_window)
+ if (!discard_window) {
+ compose->sending = FALSE;
+ compose_allow_user_actions (compose, TRUE);
compose_close(compose);
+ }
} else {
if (errstr) {
gchar *tmp = g_strdup_printf(_("%s\nUse \"Send queued messages\" from "
gchar *qmark;
gchar *parsed_str = NULL;
gint cursor_pos = 0;
- const gchar *err_msg = _("Template body format error.");
+ const gchar *err_msg = _("Template body format error at line %d.");
if (!tmpl) return;
/* process the body */
}
if (tmpl->to && *tmpl->to != '\0') {
+#ifdef USE_ASPELL
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+#endif
quote_fmt_scan_string(tmpl->to);
quote_fmt_parse();
}
if (tmpl->cc && *tmpl->cc != '\0') {
+#ifdef USE_ASPELL
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+#endif
quote_fmt_scan_string(tmpl->cc);
quote_fmt_parse();
}
if (tmpl->bcc && *tmpl->bcc != '\0') {
+#ifdef USE_ASPELL
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+#endif
quote_fmt_scan_string(tmpl->bcc);
quote_fmt_parse();
/* process the subject */
if (tmpl->subject && *tmpl->subject != '\0') {
+#ifdef USE_ASPELL
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+#endif
quote_fmt_scan_string(tmpl->subject);
quote_fmt_parse();
gtk_text_buffer_place_cursor(buffer, iter);
compose_quote_fmt(compose, NULL, "%Q", qmark, new_text, TRUE, FALSE,
- _("Quote format error."));
+ _("Quote format error at line %d."));
quote_fmt_reset_vartable();
g_free(new_text);
g_object_set_data(G_OBJECT(compose->text), "paste_as_quotation",
if (procmime_msginfo_is_encrypted(orig_msginfo)) {
originally_enc = TRUE;
}
- }
+ tmp_msginfo->folder = orig_msginfo->folder;
+ tmp_msginfo->msgnum = orig_msginfo->msgnum;
+ }
}
}