#include "procmsg.h"
#include "menu.h"
#include "stock_pixmap.h"
-#include "send.h"
+#include "send_message.h"
#include "imap.h"
#include "news.h"
#include "customheader.h"
#include "prefs_common.h"
#include "prefs_account.h"
-#include "prefs_actions.h"
+#include "action.h"
#include "account.h"
#include "filesel.h"
#include "procheader.h"
followup_and_reply_to);
static void compose_reedit_set_entry (Compose *compose,
MsgInfo *msginfo);
-static void compose_insert_sig (Compose *compose);
+static void compose_insert_sig (Compose *compose,
+ gboolean replace);
+static gchar *compose_get_signature_str (Compose *compose);
static void compose_insert_file (Compose *compose,
const gchar *file);
static void compose_attach_append (Compose *compose,
gboolean autowrap);
static void compose_set_title (Compose *compose);
static void compose_select_account (Compose *compose,
- PrefsAccount *account);
+ PrefsAccount *account,
+ gboolean init);
static PrefsAccount *compose_current_mail_account(void);
/* static gint compose_send (Compose *compose); */
static void compose_convert_header (gchar *dest,
gint len,
gchar *src,
- gint header_len);
+ gint header_len,
+ gboolean addr_field);
static void compose_generate_msgid (Compose *compose,
gchar *buf,
gint len);
static void compose_insert_file_cb (gpointer data,
guint action,
GtkWidget *widget);
+static void compose_insert_sig_cb (gpointer data,
+ guint action,
+ GtkWidget *widget);
static void compose_close_cb (gpointer data,
guint action,
Compose *compose);
static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
gboolean to_all, gboolean to_ml,
- gboolean ignore_replyto,
+ gboolean to_sender,
gboolean followup_and_reply_to,
const gchar *body);
{N_("/_File"), NULL, NULL, 0, "<Branch>"},
{N_("/_File/_Attach file"), "<control>M", compose_attach_cb, 0, NULL},
{N_("/_File/_Insert file"), "<control>I", compose_insert_file_cb, 0, NULL},
- {N_("/_File/Insert si_gnature"), "<control>G", compose_insert_sig, 0, NULL},
+ {N_("/_File/Insert si_gnature"), "<control>G", compose_insert_sig_cb, 0, NULL},
{N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_File/_Close"), "<control>W", compose_close_cb, 0, NULL},
text = GTK_STEXT(compose->text);
gtk_stext_freeze(text);
- if (prefs_common.auto_sig)
- compose_insert_sig(compose);
+ if (account->auto_sig)
+ compose_insert_sig(compose, FALSE);
gtk_editable_set_position(GTK_EDITABLE(text), 0);
gtk_stext_set_point(text, 0);
}
*/
+void compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
+{
+ MsgInfo *msginfo;
+ guint list_len;
+
+ g_return_if_fail(msginfo_list != NULL);
+
+ msginfo = (MsgInfo*)g_slist_nth_data(msginfo_list, 0);
+ g_return_if_fail(msginfo != NULL);
+
+ list_len = g_slist_length(msginfo_list);
+
+ switch (mode) {
+ case COMPOSE_REPLY:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ FALSE, prefs_common.default_reply_list, FALSE, body);
+ break;
+ case COMPOSE_REPLY_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, FALSE, prefs_common.default_reply_list, FALSE, body);
+ break;
+ case COMPOSE_REPLY_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, FALSE, prefs_common.default_reply_list, FALSE, NULL);
+ break;
+ case COMPOSE_REPLY_TO_SENDER:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ FALSE, FALSE, TRUE, body);
+ break;
+ case COMPOSE_FOLLOWUP_AND_REPLY_TO:
+ compose_followup_and_reply_to(msginfo,
+ prefs_common.reply_with_quote,
+ FALSE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, FALSE, FALSE, TRUE, body);
+ break;
+ case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, FALSE, FALSE, TRUE, NULL);
+ break;
+ case COMPOSE_REPLY_TO_ALL:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ TRUE, FALSE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, TRUE, FALSE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, TRUE, FALSE, FALSE, NULL);
+ break;
+ case COMPOSE_REPLY_TO_LIST:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ FALSE, TRUE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_LIST_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, FALSE, TRUE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, FALSE, TRUE, FALSE, NULL);
+ break;
+ case COMPOSE_FORWARD:
+ if (prefs_common.forward_as_attachment) {
+ compose_reply_mode(COMPOSE_FORWARD_AS_ATTACH, msginfo_list, body);
+ return;
+ } else {
+ compose_reply_mode(COMPOSE_FORWARD_INLINE, msginfo_list, body);
+ return;
+ }
+ break;
+ case COMPOSE_FORWARD_INLINE:
+ /* check if we reply to more than one Message */
+ if (list_len == 1) {
+ compose_forward(NULL, msginfo, FALSE, body);
+ break;
+ }
+ /* more messages FALL THROUGH */
+ case COMPOSE_FORWARD_AS_ATTACH:
+ compose_forward_multiple(NULL, msginfo_list);
+ break;
+ case COMPOSE_REDIRECT:
+ compose_redirect(NULL, msginfo);
+ break;
+ default:
+ g_warning("compose_reply(): invalid Compose Mode: %d\n", mode);
+ }
+}
+
void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
- gboolean to_ml, gboolean ignore_replyto,
+ gboolean to_ml, gboolean to_sender,
const gchar *body)
{
compose_generic_reply(msginfo, quote, to_all, to_ml,
- ignore_replyto, FALSE, body);
+ to_sender, FALSE, body);
}
void compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
gboolean to_all,
- gboolean ignore_replyto,
+ gboolean to_sender,
const gchar *body)
{
compose_generic_reply(msginfo, quote, to_all, FALSE,
- ignore_replyto, TRUE, body);
+ to_sender, TRUE, body);
}
static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
gboolean to_all, gboolean to_ml,
- gboolean ignore_replyto,
+ gboolean to_sender,
gboolean followup_and_reply_to,
const gchar *body)
{
g_return_if_fail(account != NULL);
- if (ignore_replyto && account->protocol == A_NNTP &&
+ if (to_sender && account->protocol == A_NNTP &&
!followup_and_reply_to) {
reply_account =
account_find_from_address(account->address);
if (compose_parse_header(compose, msginfo) < 0) return;
compose_reply_set_entry(compose, msginfo, to_all, to_ml,
- ignore_replyto, followup_and_reply_to);
+ to_sender, followup_and_reply_to);
compose_show_first_last_header(compose, TRUE);
text = GTK_STEXT(compose->text);
qmark, body);
}
- if (prefs_common.auto_sig)
- compose_insert_sig(compose);
+ if (account->auto_sig)
+ compose_insert_sig(compose, FALSE);
if (quote && prefs_common.linewrap_quote)
compose_wrap_line_all(compose);
procmsg_msginfo_free(full_msginfo);
}
- if (prefs_common.auto_sig)
- compose_insert_sig(compose);
+ if (account->auto_sig)
+ compose_insert_sig(compose, FALSE);
if (prefs_common.linewrap_quote)
compose_wrap_line_all(compose);
g_free(msgfile);
}
- if (prefs_common.auto_sig)
- compose_insert_sig(compose);
+ if (account->auto_sig)
+ compose_insert_sig(compose, FALSE);
if (prefs_common.linewrap_quote)
compose_wrap_line_all(compose);
compose_attach_cb(compose, 0, NULL);
break;
case A_SIG:
- compose_insert_sig(compose);
+ compose_insert_sig(compose, FALSE);
break;
case A_EXTEDITOR:
compose_ext_editor_cb(compose, 0, NULL);
static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
{
static HeaderEntry hentry[] = {{"Reply-To:", NULL, TRUE},
- {"Cc:", NULL, FALSE},
+ {"Cc:", NULL, TRUE},
{"References:", NULL, FALSE},
- {"Bcc:", NULL, FALSE},
- {"Newsgroups:", NULL, FALSE},
- {"Followup-To:", NULL, FALSE},
+ {"Bcc:", NULL, TRUE},
+ {"Newsgroups:", NULL, TRUE},
+ {"Followup-To:", NULL, TRUE},
{"List-Post:", NULL, FALSE},
{"X-Priority:", NULL, FALSE},
{NULL, NULL, FALSE}};
gchar *buf;
gchar *p, *lastp;
gint len;
-
+ gchar *trimmed_body = body;
+
if (!msginfo)
msginfo = &dummyinfo;
}
if (fmt && *fmt != '\0') {
- quote_fmt_init(msginfo, quote_str, body);
+ while (trimmed_body && strlen(trimmed_body) > 1
+ && trimmed_body[0]=='\n')
+ *trimmed_body++;
+
+ quote_fmt_init(msginfo, quote_str, trimmed_body);
quote_fmt_scan_string(fmt);
quote_fmt_parse();
static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
gboolean to_all, gboolean to_ml,
- gboolean ignore_replyto,
+ gboolean to_sender,
gboolean followup_and_reply_to)
{
GSList *cc_list = NULL;
g_return_if_fail(compose->account != NULL);
g_return_if_fail(msginfo != NULL);
- if (compose->account->protocol != A_NNTP || followup_and_reply_to) {
+ if (compose->account->protocol != A_NNTP) {
if (!compose->replyto && to_ml && compose->ml_post
&& !(msginfo->folder && msginfo->folder->prefs->enable_default_reply_to))
compose_entry_append(compose,
compose->ml_post,
COMPOSE_TO);
- else if (!(to_all || ignore_replyto)
+ else if (!(to_all || to_sender)
&& msginfo->folder
&& msginfo->folder->prefs->enable_default_reply_to) {
compose_entry_append(compose,
COMPOSE_TO);
} else
compose_entry_append(compose,
- (compose->replyto && !ignore_replyto)
- ? compose->replyto
- : msginfo->from ? msginfo->from : "",
- COMPOSE_TO);
+ (compose->replyto && !to_sender)
+ ? compose->replyto :
+ msginfo->from ? msginfo->from : "",
+ COMPOSE_TO);
} else {
- if (ignore_replyto)
+ if (to_sender || (compose->followup_to &&
+ !strncmp(compose->followup_to, "poster", 6)))
compose_entry_append
- (compose, msginfo->from ? msginfo->from : "",
+ (compose,
+ (compose->replyto ? compose->replyto :
+ msginfo->from ? msginfo->from : ""),
COMPOSE_TO);
- else {
- if (compose->followup_to && !strncmp(compose->followup_to, "poster", 6)) {
- compose_entry_append
- (compose,
- ((compose->replyto && !ignore_replyto)
- ? compose->replyto
- : msginfo->from ? msginfo->from : ""),
- COMPOSE_TO);
- } else {
- compose_entry_append
- (compose,
- compose->followup_to ? compose->followup_to
- : compose->newsgroups ? compose->newsgroups
- : "",
- COMPOSE_NEWSGROUPS);
- }
- }
+
+ else if (followup_and_reply_to || to_all) {
+ compose_entry_append
+ (compose,
+ (compose->replyto ? compose->replyto :
+ msginfo->from ? msginfo->from : ""),
+ COMPOSE_TO);
+
+ compose_entry_append
+ (compose,
+ compose->followup_to ? compose->followup_to :
+ compose->newsgroups ? compose->newsgroups : "",
+ COMPOSE_NEWSGROUPS);
+ }
+ else
+ compose_entry_append
+ (compose,
+ compose->followup_to ? compose->followup_to :
+ compose->newsgroups ? compose->newsgroups : "",
+ COMPOSE_NEWSGROUPS);
}
if (msginfo->subject && *msginfo->subject) {
}
if (replyto && from)
- cc_list = address_list_append(cc_list, from);
- cc_list = address_list_append(cc_list, msginfo->to);
- cc_list = address_list_append(cc_list, compose->cc);
+ cc_list = address_list_append_with_comments(cc_list, from);
+ cc_list = address_list_append_with_comments(cc_list, msginfo->to);
+ cc_list = address_list_append_with_comments(cc_list, compose->cc);
to_table = g_hash_table_new(g_str_hash, g_str_equal);
if (replyto)
- g_hash_table_insert(to_table, replyto, GINT_TO_POINTER(1));
+ g_hash_table_insert(to_table, g_strdup(replyto), GINT_TO_POINTER(1));
if (compose->account)
- g_hash_table_insert(to_table, compose->account->address,
+ g_hash_table_insert(to_table, g_strdup(compose->account->address),
GINT_TO_POINTER(1));
/* remove address on To: and that of current account */
for (cur = cc_list; cur != NULL; ) {
GSList *next = cur->next;
+ gchar *addr;
- if (g_hash_table_lookup(to_table, cur->data) != NULL)
+ addr = g_strdup(cur->data);
+ extract_address(addr);
+
+ if (GPOINTER_TO_INT(g_hash_table_lookup(to_table, addr)) == 1)
cc_list = g_slist_remove(cc_list, cur->data);
else
- g_hash_table_insert(to_table, cur->data, cur);
+ g_hash_table_insert(to_table, addr, GINT_TO_POINTER(1));
cur = next;
}
+ hash_free_strings(to_table);
g_hash_table_destroy(to_table);
if (cc_list) {
#undef SET_ENTRY
#undef SET_ADDRESS
-static void compose_exec_sig(Compose *compose, gchar *sigfile)
+static void compose_insert_sig(Compose *compose, gboolean replace)
{
- FILE *sigprg;
- gchar *buf;
- size_t buf_len = 128;
-
- if (strlen(sigfile) < 2)
- return;
-
- sigprg = popen(sigfile+1, "r");
- if (sigprg) {
+ GtkSText *text = GTK_STEXT(compose->text);
+ gint cur_pos;
- buf = g_malloc(buf_len);
+ g_return_if_fail(compose->account != NULL);
- if (!buf) {
- gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, \
- "Unable to insert signature (malloc failed)\n", -1);
+ cur_pos = gtk_editable_get_position(GTK_EDITABLE(text));
- pclose(sigprg);
- return;
- }
+ gtk_stext_freeze(text);
+
+ if (replace && compose->sig_str) {
+ gint pos;
+ gint len;
- while (!feof(sigprg)) {
- bzero(buf, buf_len);
- fread(buf, buf_len-1, 1, sigprg);
- gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, buf, -1);
+ if (compose->sig_str[0] == '\0')
+ pos = -1;
+ else
+ pos = gtkut_stext_find(text, 0, compose->sig_str, TRUE);
+
+ if (pos != -1) {
+ len = get_mbs_len(compose->sig_str);
+ if (len >= 0) {
+ gtk_stext_set_point(text, pos);
+ gtk_stext_forward_delete(text, len);
+ } else {
+ len = gtk_stext_get_length(text);
+ gtk_stext_set_point(text, len);
+ }
+ } else {
+ len = gtk_stext_get_length(text);
+ gtk_stext_set_point(text, len);
}
+ } else
+ gtk_stext_insert(text, NULL, NULL, NULL, "\n\n", 2);
- g_free(buf);
- pclose(sigprg);
- }
- else
- {
- gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, \
- "Can't exec file: ", -1);
- gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, \
- sigfile+1, -1);
- }
+ g_free(compose->sig_str);
+ compose->sig_str = compose_get_signature_str(compose);
+ if (!compose->sig_str || (replace && !compose->account->auto_sig))
+ compose->sig_str = g_strdup("");
+
+ gtk_stext_insert(text, NULL, NULL, NULL, compose->sig_str, -1);
+
+ gtk_stext_thaw(text);
+
+ if (cur_pos > gtk_stext_get_length(text))
+ cur_pos = gtk_stext_get_length(text);
+
+ gtk_editable_set_position(GTK_EDITABLE(text), cur_pos);
+ gtk_stext_set_point(text, cur_pos);
}
-static void compose_insert_sig(Compose *compose)
+static gchar *compose_get_signature_str(Compose *compose)
{
- gchar *sigfile;
+ gchar *sig_body = NULL;
+ gchar *sig_str = NULL;
- if (compose->account && compose->account->sig_path)
- sigfile = g_strdup(compose->account->sig_path);
- else
- sigfile = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
- DEFAULT_SIGNATURE, NULL);
+ g_return_val_if_fail(compose->account != NULL, NULL);
- if (!is_file_or_fifo_exist(sigfile) && sigfile[0] != '|') {
- g_free(sigfile);
- return;
+ if (!compose->account->sig_path)
+ return NULL;
+
+ if (compose->account->sig_type == SIG_FILE) {
+ if (!is_file_or_fifo_exist(compose->account->sig_path)) {
+ g_warning("can't open signature file: %s\n",
+ compose->account->sig_path);
+ return NULL;
+ }
}
- gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, "\n\n", 2);
- if (prefs_common.sig_sep) {
- gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL,
- prefs_common.sig_sep, -1);
- gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL,
- "\n", 1);
+ if (compose->account->sig_type == SIG_COMMAND)
+ sig_body = get_command_output(compose->account->sig_path);
+ else {
+ gchar *tmp;
+
+ tmp = file_read_to_str(compose->account->sig_path);
+ if (!tmp)
+ return NULL;
+ sig_body = normalize_newlines(tmp);
+ g_free(tmp);
}
- if (sigfile[0] == '|')
- compose_exec_sig(compose, sigfile);
- else
- compose_insert_file(compose, sigfile);
- g_free(sigfile);
+ if (compose->account->sig_sep) {
+ sig_str = g_strconcat(compose->account->sig_sep, "\n", sig_body,
+ NULL);
+ g_free(sig_body);
+ } else
+ sig_str = sig_body;
+
+ return sig_str;
}
static void compose_insert_file(Compose *compose, const gchar *file)
} \
}
+#define DISP_WIDTH(len) \
+ ((len > 2 && conv_get_current_charset() == C_UTF_8) ? 2 : \
+ (len == 2 && conv_get_current_charset() == C_UTF_8) ? 1 : len)
+
#define INDENT_CHARS ">|#"
#define SPACE_CHARS " \t"
line_len = cur_len + ch_len;
}
- if (cur_len + ch_len > prefs_common.linewrap_len &&
+ if (cur_len + DISP_WIDTH(ch_len) > prefs_common.linewrap_len &&
line_len > 0) {
gint tlen = ch_len;
p_end++;
cur_pos++;
line_pos++;
- cur_len = cur_len - line_len + ch_len;
+ cur_len = cur_len - line_len + DISP_WIDTH(ch_len);
line_len = 0;
continue;
}
if (ch_len > 1) {
line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
+ line_len = cur_len + DISP_WIDTH(ch_len);
}
- cur_len += ch_len;
+ cur_len += DISP_WIDTH(ch_len);
}
compose_end:
g_print("after delete l_pos=");
dump_text(text, line_pos, tlen, 1);
#endif
+ /* move beginning of line if we are on LF */
+ GET_CHAR(line_pos, cb, clen);
+ if (clen == 1 && *cb == '\n')
+ line_pos++;
+#ifdef WRAP_DEBUG
+ g_print("new line_pos=%d\n", line_pos);
+#endif
+
continue;
}
}
/* are we over wrapping length set in preferences ? */
- if (cur_len + ch_len > linewrap_len) {
+ if (cur_len + DISP_WIDTH(ch_len) > linewrap_len) {
gint clen;
#ifdef WRAP_DEBUG
STEXT_FREEZE();
gtk_stext_set_point(text, line_pos);
gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
- /* gtk_stext_compact_buffer(text); */
+ gtk_stext_compact_buffer(text);
tlen++;
line_pos++;
/* for loop will increase it */
if (ch_len > 1) {
line_pos = cur_pos + 1;
- line_len = cur_len + ch_len;
+ line_len = cur_len + DISP_WIDTH(ch_len);
}
/* advance to next character in buffer */
- cur_len += ch_len;
+ cur_len += DISP_WIDTH(ch_len);
}
if (frozen)
return ac;
}
-static void compose_select_account(Compose *compose, PrefsAccount *account)
+static void compose_select_account(Compose *compose, PrefsAccount *account,
+ gboolean init)
{
GtkWidget *menuitem;
GtkItemFactory *ifactory;
activate_gnupg_mode(compose, account);
#endif /* USE_GPGME */
+
+ if (!init)
+ compose_insert_sig(compose, TRUE);
}
gboolean compose_check_for_valid_recipient(Compose *compose) {
}
if (msgnum == 0) {
- alertpanel_error(_("The message was queue but could not be send.\nUse \"Send queued messages\" from the main window to send it"));
+ alertpanel_error(_("The message was queued but could not be sent.\nUse \"Send queued messages\" from the main window to retry."));
return 0;
}
if (str[0] != '\0') {
compose_convert_header
(buf, sizeof(buf), str,
- strlen("Resent-To") + 2);
+ strlen("Resent-To") + 2, TRUE);
if (first_address) {
fprintf(fp, "Resent-To: ");
first_address = FALSE;
if (compose->account->name && *compose->account->name) {
compose_convert_header
(buf, sizeof(buf), compose->account->name,
- strlen("From: "));
+ strlen("From: "), TRUE);
fprintf(fp, "Resent-From: %s <%s>\n",
buf, compose->account->address);
} else
g_strstrip(str);
if (*str != '\0') {
compose_convert_header(buf, sizeof(buf), str,
- strlen("Subject: "));
+ strlen("Subject: "), FALSE);
fprintf(fp, "Subject: %s\n", buf);
}
}
compose_convert_header
(buf, sizeof(buf),
compose->account->name,
- strlen("From: "));
+ strlen("From: "),
+ FALSE);
fprintf(fdest, "%s <%s>",
buf,
compose->account->address);
return -1;
} else {
buf = chars;
+ out_codeset = src_codeset;
chars = NULL;
}
}
for (row = 0; (ainfo = gtk_clist_get_row_data(clist, row)) != NULL;
row++) {
- gchar buf[BUFFSIZE];
- gchar inbuf[B64_LINE_SIZE], outbuf[B64_BUFFSIZE];
-
if ((attach_fp = fopen(ainfo->file, "rb")) == NULL) {
g_warning("Can't open file %s\n", ainfo->file);
continue;
fprintf(fp, "Content-Disposition: inline\n");
} else {
compose_convert_header(filename, sizeof(filename),
- ainfo->name, 12);
+ ainfo->name, 12, FALSE);
fprintf(fp, "Content-Type: %s;\n"
" name=\"%s\"\n",
ainfo->content_type, filename);
#define QUOTE_IF_REQUIRED(out, str) \
{ \
- if (*str != '"' && (strchr(str, ',') \
- || strchr(str, '.'))) { \
+ if (*str != '"' && strpbrk(str, ",.[]<>")) { \
gchar *__tmp; \
gint len; \
\
compose->to_list = address_list_append \
(compose->to_list, str); \
compose_convert_header \
- (buf, sizeof(buf), str, strlen(header) + 2); \
+ (buf, sizeof(buf), str, strlen(header) + 2, \
+ TRUE); \
fprintf(fp, "%s: %s\n", header, buf); \
} \
} \
if (str[0] != '\0') {
compose_convert_header
(buf, sizeof(buf), str,
- strlen(header) + 2);
+ strlen(header) + 2, TRUE);
if (first_address) {
fprintf(fp, "%s: ", header);
first_address = FALSE;
if (compose->account->name && *compose->account->name) {
compose_convert_header
(buf, sizeof(buf), compose->account->name,
- strlen("From: "));
+ strlen("From: "), TRUE);
QUOTE_IF_REQUIRED(name, buf);
fprintf(fp, "From: %s <%s>\n",
name, compose->account->address);
newsgroup_list_append
(compose->newsgroup_list, str);
compose_convert_header(buf, sizeof(buf), str,
- strlen("Newsgroups: "));
+ strlen("Newsgroups: "),
+ TRUE);
fprintf(fp, "Newsgroups: %s\n", buf);
}
}
g_strstrip(str);
if (*str != '\0') {
compose_convert_header(buf, sizeof(buf), str,
- strlen("Subject: "));
+ strlen("Subject: "), FALSE);
fprintf(fp, "Subject: %s\n", buf);
}
}
remove_space(str);
if (*str != '\0') {
compose_convert_header(buf, sizeof(buf), str,
- strlen("Followup-To: "));
+ strlen("Followup-To: "),
+ TRUE);
fprintf(fp, "Followup-To: %s\n", buf);
}
}
g_strstrip(str);
if (*str != '\0') {
compose_convert_header(buf, sizeof(buf), str,
- strlen("Reply-To: "));
+ strlen("Reply-To: "),
+ TRUE);
fprintf(fp, "Reply-To: %s\n", buf);
}
}
!IS_IN_CUSTOM_HEADER("Organization")) {
compose_convert_header(buf, sizeof(buf),
compose->account->organization,
- strlen("Organization: "));
+ strlen("Organization: "), FALSE);
fprintf(fp, "Organization: %s\n", buf);
}
/* Program version and system info */
/* uname(&utsbuf); */
- if (g_slist_length(compose->to_list) && !IS_IN_CUSTOM_HEADER("X-Mailer")) {
+ if (g_slist_length(compose->to_list) && !IS_IN_CUSTOM_HEADER("X-Mailer") &&
+ !compose->newsgroup_list) {
fprintf(fp, "X-Mailer: %s (GTK+ %d.%d.%d; %s)\n",
prog_version,
gtk_major_version, gtk_minor_version, gtk_micro_version,
compose_convert_header
(buf, sizeof(buf),
chdr->value ? chdr->value : "",
- strlen(chdr->name) + 2);
+ strlen(chdr->name) + 2, FALSE);
fprintf(fp, "%s: %s\n", chdr->name, buf);
}
}
if (compose->return_receipt) {
if (compose->account->name
&& *compose->account->name) {
- compose_convert_header(buf, sizeof(buf), compose->account->name, strlen("Disposition-Notification-To: "));
+ compose_convert_header(buf, sizeof(buf),
+ compose->account->name,
+ strlen("Disposition-Notification-To: "),
+ TRUE);
fprintf(fp, "Disposition-Notification-To: %s <%s>\n", buf, compose->account->address);
} else
fprintf(fp, "Disposition-Notification-To: %s\n", compose->account->address);
#undef IS_IN_CUSTOM_HEADER
static void compose_convert_header(gchar *dest, gint len, gchar *src,
- gint header_len)
+ gint header_len, gboolean addr_field)
{
g_return_if_fail(src != NULL);
g_return_if_fail(dest != NULL);
g_strchomp(src);
- conv_encode_header(dest, len, src, header_len);
+ conv_encode_header(dest, len, src, header_len, addr_field);
}
static void compose_generate_msgid(Compose *compose, gchar *buf, gint len)
}
#endif
- update_compose_actions_menu(ifactory, "/Tools/Actions", compose);
+ action_update_compose_menu(ifactory, compose);
undostruct = undo_init(text);
compose->modified = FALSE;
compose->return_receipt = FALSE;
- compose->paste_as_quotation = FALSE;
compose->to_list = NULL;
compose->newsgroup_list = NULL;
+ compose->undostruct = undostruct;
+
+ compose->sig_str = NULL;
+
compose->exteditor_file = NULL;
compose->exteditor_pid = -1;
compose->exteditor_readdes = -1;
compose->exteditor_tag = -1;
- compose->redirect_filename = NULL;
- compose->undostruct = undostruct;
#if USE_ASPELL
menu_set_sensitive(ifactory, "/Spelling", FALSE);
if (mode != COMPOSE_REDIRECT) {
}
#endif
- compose_select_account(compose, account);
+ compose_select_account(compose, account, TRUE);
#if USE_ASPELL
compose->gtkaspell = gtkaspell;
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry), prefs_common.trans_hdr ? _("Newsgroups:") : "Newsgroups:");
addressbook_set_target_compose(compose);
- update_compose_actions_menu(ifactory, "/Tools/Actions", compose);
+ action_update_compose_menu(ifactory, compose);
if (mode != COMPOSE_REDIRECT)
compose_set_template_menu(compose);
compose_entry_append(compose, tmpl->bcc, COMPOSE_BCC);
if (replace)
- gtk_stext_clear(GTK_STEXT(compose->text));
+ gtkut_stext_clear(GTK_STEXT(compose->text));
if ((compose->replyinfo == NULL) && (compose->fwdinfo == NULL)) {
parsed_str = compose_quote_fmt(compose, NULL, tmpl->value,
parsed_str = NULL;
}
- if (replace && parsed_str && prefs_common.auto_sig)
- compose_insert_sig(compose);
+ if (replace && parsed_str && compose->account->auto_sig)
+ compose_insert_sig(compose, FALSE);
if (replace && parsed_str) {
gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
if (compose->redirect_filename)
g_free(compose->redirect_filename);
+ if (compose->undostruct)
+ undo_destroy(compose->undostruct);
+
+ g_free(compose->sig_str);
g_free(compose->exteditor_file);
close(pipe_fds[0]);
if (compose_write_body_to_file(compose, tmp) < 0) {
- fd_write(pipe_fds[1], "2\n", 2);
+ fd_write_all(pipe_fds[1], "2\n", 2);
_exit(1);
}
pid_ed = compose_exec_ext_editor_real(tmp);
if (pid_ed < 0) {
- fd_write(pipe_fds[1], "1\n", 2);
+ fd_write_all(pipe_fds[1], "1\n", 2);
_exit(1);
}
/* wait until editor is terminated */
waitpid(pid_ed, NULL, 0);
- fd_write(pipe_fds[1], "0\n", 2);
+ fd_write_all(pipe_fds[1], "0\n", 2);
close(pipe_fds[1]);
_exit(0);
g_return_if_fail(ac != NULL);
if (ac != compose->account)
- compose_select_account(compose, ac);
+ compose_select_account(compose, ac, FALSE);
}
static void attach_selected(GtkCList *clist, gint row, gint column,
}
}
+static void compose_insert_sig_cb(gpointer data, guint action,
+ GtkWidget *widget)
+{
+ Compose *compose = (Compose *)data;
+
+ compose_insert_sig(compose, FALSE);
+}
+
static gint compose_delete_cb(GtkWidget *widget, GdkEventAny *event,
gpointer data)
{
{
if (compose->focused_editable &&
GTK_WIDGET_HAS_FOCUS(compose->focused_editable)) {
- compose->paste_as_quotation = TRUE;
+ /* let text_insert() (called directly or at a later time
+ * after the gtk_editable_paste_clipboard) know that
+ * text is to be inserted as a quotation. implemented
+ * by using a simple refcount... */
+ gint paste_as_quotation = GPOINTER_TO_INT(gtk_object_get_data(
+ GTK_OBJECT(compose->focused_editable),
+ "paste_as_quotation"));
+ gtk_object_set_data(GTK_OBJECT(compose->focused_editable),
+ "paste_as_quotation",
+ GINT_TO_POINTER(paste_as_quotation + 1));
gtk_editable_paste_clipboard
(GTK_EDITABLE(compose->focused_editable));
- compose->paste_as_quotation = FALSE;
}
}
gint length, gint *position, Compose *compose)
{
GtkEditable *editable = GTK_EDITABLE(widget);
+ gint paste_as_quotation = GPOINTER_TO_INT(gtk_object_get_data
+ (GTK_OBJECT(widget), "paste_as_quotation"));
gtk_signal_handler_block_by_func(GTK_OBJECT(widget),
GTK_SIGNAL_FUNC(text_inserted),
compose);
- if (compose->paste_as_quotation) {
+ if (paste_as_quotation) {
gchar *new_text;
gchar *qmark;
gint pos;
gtk_editable_set_position(editable, pos);
*position = pos;
g_free(new_text);
+ gtk_object_set_data(GTK_OBJECT(widget), "paste_as_quotation",
+ GINT_TO_POINTER(paste_as_quotation - 1));
} else
gtk_editable_insert_text(editable, text, length, position);