/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2015 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
*/
#ifdef HAVE_CONFIG_H
#define COMPOSE_DRAFT_TIMEOUT_UNSET -1
#define COMPOSE_DRAFT_TIMEOUT_FORBIDDEN -2
+static GdkColor default_header_bgcolor = {
+ (gulong)0,
+ (gushort)0,
+ (gushort)0,
+ (gushort)0
+};
+
+static GdkColor default_header_color = {
+ (gulong)0,
+ (gushort)0,
+ (gushort)0,
+ (gushort)0
+};
+
static GList *compose_list = NULL;
static GSList *extra_headers = NULL;
ComposeMode mode,
gboolean batch);
-static void compose_entry_mark_default_to (Compose *compose,
+static void compose_entry_indicate (Compose *compose,
const gchar *address);
static Compose *compose_followup_and_reply_to (MsgInfo *msginfo,
ComposeQuoteMode quote_mode,
static void compose_check_forwards_go (GtkAction *action, gpointer data);
#endif
-static PrefsAccount *compose_guess_forward_account_from_msginfo (MsgInfo *msginfo);
+static PrefsAccount *compose_find_account (MsgInfo *msginfo);
static MsgInfo *compose_msginfo_new_from_compose(Compose *compose);
cm_return_val_if_fail(msginfo != NULL, NULL);
cm_return_val_if_fail(msginfo->folder != NULL, NULL);
- if (!account &&
- !(account = compose_guess_forward_account_from_msginfo
- (msginfo)))
+ if (!account && !(account = compose_find_account(msginfo)))
account = cur_account;
if (!prefs_common.forward_as_attachment)
/* guess account from first selected message */
if (!account &&
- !(account = compose_guess_forward_account_from_msginfo
- (msginfo_list->data)))
+ !(account = compose_find_account(msginfo_list->data)))
account = cur_account;
cm_return_val_if_fail(account != NULL, NULL);
while (*tmp == ' ' || *tmp == '\t')
tmp++;
compose_add_header_entry(compose, header, tmp, pref_type);
+ compose_entry_indicate(compose, tmp);
g_free(o_tmp);
continue;
}
while (*tmp == ' ' || *tmp == '\t')
tmp++;
compose_add_header_entry(compose, header, tmp, pref_type);
+ compose_entry_indicate(compose, tmp);
g_free(o_tmp);
}
}
-static void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
+static void compose_entry_indicate(Compose *compose, const gchar *mailto)
{
-#if !GTK_CHECK_VERSION(3, 0, 0)
- static GdkColor yellow;
- static GdkColor black;
- static gboolean yellow_initialised = FALSE;
-#else
- static GdkColor yellow = { (guint32)0, (guint16)0xf5, (guint16)0xf6, (guint16)0xbe };
- static GdkColor black = { (guint32)0, (guint16)0x0, (guint16)0x0, (guint16)0x0 };
-#endif
GSList *h_list;
GtkEntry *entry;
-#if !GTK_CHECK_VERSION(3, 0, 0)
- if (!yellow_initialised) {
- gdk_color_parse("#f5f6be", &yellow);
- gdk_color_parse("#000000", &black);
- yellow_initialised = gdk_colormap_alloc_color(
- gdk_colormap_get_system(), &yellow, FALSE, TRUE);
- yellow_initialised &= gdk_colormap_alloc_color(
- gdk_colormap_get_system(), &black, FALSE, TRUE);
- }
-#endif
-
for (h_list = compose->header_list; h_list != NULL; h_list = h_list->next) {
entry = GTK_ENTRY(((ComposeHeaderEntry *)h_list->data)->entry);
if (gtk_entry_get_text(entry) &&
!g_utf8_collate(gtk_entry_get_text(entry), mailto)) {
-#if !GTK_CHECK_VERSION(3, 0, 0)
- if (yellow_initialised) {
-#endif
gtk_widget_modify_base(
GTK_WIDGET(((ComposeHeaderEntry *)h_list->data)->entry),
- GTK_STATE_NORMAL, &yellow);
+ GTK_STATE_NORMAL, &default_header_bgcolor);
gtk_widget_modify_text(
GTK_WIDGET(((ComposeHeaderEntry *)h_list->data)->entry),
- GTK_STATE_NORMAL, &black);
-#if !GTK_CHECK_VERSION(3, 0, 0)
- }
-#endif
+ GTK_STATE_NORMAL, &default_header_color);
}
}
}
case A_SEND:
compose_send_cb(NULL, compose);
break;
- case A_SENDL:
+ case A_SEND_LATER:
compose_send_later_cb(NULL, compose);
break;
case A_DRAFT:
if (compose->mode == COMPOSE_REEDIT) {
if (msginfo->inreplyto && *msginfo->inreplyto)
compose->inreplyto = g_strdup(msginfo->inreplyto);
- return 0;
- }
- if (msginfo->msgid && *msginfo->msgid)
- compose->inreplyto = g_strdup(msginfo->msgid);
-
- if (!compose->references) {
- if (msginfo->msgid && *msginfo->msgid) {
- if (msginfo->inreplyto && *msginfo->inreplyto)
- compose->references =
- g_strdup_printf("<%s>\n\t<%s>",
- msginfo->inreplyto,
- msginfo->msgid);
- else
+ if (msginfo->msgid && *msginfo->msgid)
+ compose->msgid = g_strdup(msginfo->msgid);
+ } else {
+ if (msginfo->msgid && *msginfo->msgid)
+ compose->inreplyto = g_strdup(msginfo->msgid);
+
+ if (!compose->references) {
+ if (msginfo->msgid && *msginfo->msgid) {
+ if (msginfo->inreplyto && *msginfo->inreplyto)
+ compose->references =
+ g_strdup_printf("<%s>\n\t<%s>",
+ msginfo->inreplyto,
+ msginfo->msgid);
+ else
+ compose->references =
+ g_strconcat("<", msginfo->msgid, ">",
+ NULL);
+ } else if (msginfo->inreplyto && *msginfo->inreplyto) {
compose->references =
- g_strconcat("<", msginfo->msgid, ">",
+ g_strconcat("<", msginfo->inreplyto, ">",
NULL);
- } else if (msginfo->inreplyto && *msginfo->inreplyto) {
- compose->references =
- g_strconcat("<", msginfo->inreplyto, ">",
- NULL);
+ }
}
}
if (respect_default_to && folder->prefs->enable_default_to) {
compose_entry_append(compose, folder->prefs->default_to,
COMPOSE_TO, PREF_FOLDER);
- compose_entry_mark_default_to(compose, folder->prefs->default_to);
+ compose_entry_indicate(compose, folder->prefs->default_to);
}
- if (folder->prefs->enable_default_cc)
+ if (folder->prefs->enable_default_cc) {
compose_entry_append(compose, folder->prefs->default_cc,
COMPOSE_CC, PREF_FOLDER);
- if (folder->prefs->enable_default_bcc)
+ compose_entry_indicate(compose, folder->prefs->default_cc);
+ }
+ if (folder->prefs->enable_default_bcc) {
compose_entry_append(compose, folder->prefs->default_bcc,
COMPOSE_BCC, PREF_FOLDER);
- if (folder->prefs->enable_default_replyto)
+ compose_entry_indicate(compose, folder->prefs->default_bcc);
+ }
+ if (folder->prefs->enable_default_replyto) {
compose_entry_append(compose, folder->prefs->default_replyto,
COMPOSE_REPLYTO, PREF_FOLDER);
+ compose_entry_indicate(compose, folder->prefs->default_replyto);
+ }
}
static void compose_reply_set_subject(Compose *compose, MsgInfo *msginfo)
compose_entry_append(compose,
msginfo->folder->prefs->default_reply_to,
COMPOSE_TO, PREF_FOLDER);
- compose_entry_mark_default_to(compose,
+ compose_entry_indicate(compose,
msginfo->folder->prefs->default_reply_to);
} else {
gchar *tmp1 = NULL;
compose->followup_to ? compose->followup_to :
compose->newsgroups ? compose->newsgroups : "",
COMPOSE_NEWSGROUPS, PREF_NONE);
+
+ compose_entry_append
+ (compose,
+ msginfo->cc ? msginfo->cc : "",
+ COMPOSE_CC, PREF_NONE);
}
else
compose_entry_append
cm_return_val_if_fail(compose->account->address != NULL, -1);
/* Resent-Date */
- get_rfc822_date(buf, sizeof(buf));
+ if (prefs_common.hide_timezone)
+ get_rfc822_date_hide_tz(buf, sizeof(buf));
+ else
+ get_rfc822_date(buf, sizeof(buf));
err |= (fprintf(fp, "Resent-Date: %s\n", buf) < 0);
/* Resent-From */
}
/* Resent-Message-ID */
- if (compose->account->set_domain && compose->account->domain) {
- g_snprintf(buf, sizeof(buf), "%s", compose->account->domain);
- } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
- g_snprintf(buf, sizeof(buf), "%s",
- strchr(compose->account->address, '@') ?
- strchr(compose->account->address, '@')+1 :
- compose->account->address);
- } else {
- g_snprintf(buf, sizeof(buf), "%s", "");
- }
-
if (compose->account->gen_msgid) {
- gchar *addr = NULL;
- if (compose->account->msgid_with_addr) {
- addr = compose->account->address;
- }
- generate_msgid(buf, sizeof(buf), addr);
- err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
+ gchar *addr = prefs_account_generate_msgid(compose->account);
+ err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", addr) < 0);
if (compose->msgid)
g_free(compose->msgid);
- compose->msgid = g_strdup(buf);
+ compose->msgid = addr;
} else {
compose->msgid = NULL;
}
gchar *from_name = NULL;
FolderItem *outbox;
- if (action == COMPOSE_WRITE_FOR_SEND)
+ if (action == COMPOSE_WRITE_FOR_SEND) {
attach_parts = TRUE;
+ /* We're sending the message, generate a Message-ID
+ * if necessary. */
+ if (compose->msgid == NULL &&
+ compose->account->gen_msgid) {
+ compose->msgid = prefs_account_generate_msgid(compose->account);
+ }
+ }
+
/* create message MimeInfo */
mimemsg = procmime_mimeinfo_new();
mimemsg->type = MIMETYPE_MESSAGE;
}
g_free(chars);
- if (encoding == ENC_8BIT || encoding == ENC_7BIT) {
+ if (prefs_common.rewrite_first_from && (encoding == ENC_8BIT || encoding == ENC_7BIT)) {
if (!strncmp(buf, "From ", sizeof("From ")-1) ||
strstr(buf, "\nFrom ") != NULL) {
encoding = ENC_QUOTED_PRINTABLE;
privacy_system_can_sign(compose->privacy_system)) {
encoding = ENC_QUOTED_PRINTABLE;
}
-
+
+#ifdef G_OS_WIN32
+ debug_print("main text: %Id bytes encoded as %s in %d\n",
+#else
debug_print("main text: %zd bytes encoded as %s in %d\n",
+#endif
strlen(buf), out_codeset, encoding);
/* check for line length limit */
faddr = g_strconcat(name, addr, NULL);
g_free(name);
g_free(addr);
- debug_print("new auto-quoted address: '%s'", faddr);
+ debug_print("new auto-quoted address: '%s'\n", faddr);
}
}
if (result == NULL)
header = g_string_sized_new(64);
/* Date */
- get_rfc822_date(buf, sizeof(buf));
+ if (prefs_common.hide_timezone)
+ get_rfc822_date_hide_tz(buf, sizeof(buf));
+ else
+ get_rfc822_date(buf, sizeof(buf));
g_string_append_printf(header, "Date: %s\n", buf);
/* From */
g_free(str);
/* Message-ID */
- if (compose->account->set_domain && compose->account->domain) {
- g_snprintf(buf, sizeof(buf), "%s", compose->account->domain);
- } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
- g_snprintf(buf, sizeof(buf), "%s",
- strchr(compose->account->address, '@') ?
- strchr(compose->account->address, '@')+1 :
- compose->account->address);
- } else {
- g_snprintf(buf, sizeof(buf), "%s", "");
- }
-
- if (compose->account->gen_msgid) {
- gchar *addr = NULL;
- if (compose->account->msgid_with_addr) {
- addr = compose->account->address;
- }
- generate_msgid(buf, sizeof(buf), addr);
- g_string_append_printf(header, "Message-ID: <%s>\n", buf);
- if (compose->msgid)
- g_free(compose->msgid);
- compose->msgid = g_strdup(buf);
- } else {
- compose->msgid = NULL;
+ if (compose->msgid != NULL && strlen(compose->msgid) > 0) {
+ g_string_append_printf(header, "Message-ID: <%s>\n",
+ compose->msgid);
}
if (compose->remove_references == FALSE) {
gtk_widget_show(window);
}
+ gtkut_convert_int_to_gdk_color(prefs_common.default_header_bgcolor,
+ &default_header_bgcolor);
+ gtkut_convert_int_to_gdk_color(prefs_common.default_header_color,
+ &default_header_color);
+
return compose;
}
ac->address);
gtk_entry_set_text(GTK_ENTRY(from_name), from);
}
+ if (cur_account != compose->account) {
+ gtk_widget_modify_base(
+ GTK_WIDGET(from_name),
+ GTK_STATE_NORMAL, &default_header_bgcolor);
+ gtk_widget_modify_text(
+ GTK_WIDGET(from_name),
+ GTK_STATE_NORMAL, &default_header_color);
+ }
}
COMBOBOX_ADD(menu, name, ac->account_id);
g_free(name);
return TRUE;
}
+static gboolean compose_can_autosave(Compose *compose)
+{
+ if (compose->privacy_system && compose->use_encryption)
+ return prefs_common.autosave && prefs_common.autosave_encrypted;
+ else
+ return prefs_common.autosave;
+}
+
static gboolean compose_input_cb(GIOChannel *source, GIOCondition condition,
gpointer data)
{
gtk_text_buffer_set_text(buffer, "", -1);
compose_insert_file(compose, compose->exteditor_file);
compose_changed_cb(NULL, compose);
- compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
+
+ /* Check if we should save the draft or not */
+ if (compose_can_autosave(compose))
+ compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
if (claws_unlink(compose->exteditor_file) < 0)
FILE_OP_ERROR(compose->exteditor_file, "unlink");
GtkTreeIter iter;
GSList *list, *saved_list = NULL;
HeaderEntryState *state;
- GtkRcStyle *style = NULL;
-#if !GTK_CHECK_VERSION(3, 0, 0)
- static GdkColor yellow;
- static gboolean color_set = FALSE;
-#else
- static GdkColor yellow = { (guint32)0, (guint32)0xf5, (guint32)0xf6, (guint32)0xbe };
-#endif
/* Get ID of active account in the combo box */
menu = gtk_combo_box_get_model(optmenu);
compose_destroy_headerentry(compose, hentry);
continue;
}
-
state = g_malloc0(sizeof(HeaderEntryState));
state->header = gtk_editable_get_chars(GTK_EDITABLE(
gtk_bin_get_child(GTK_BIN(hentry->combo))), 0, -1);
state->entry = gtk_editable_get_chars(
GTK_EDITABLE(hentry->entry), 0, -1);
state->type = hentry->type;
-
-#if !GTK_CHECK_VERSION(3, 0, 0)
- if (!color_set) {
- gdk_color_parse("#f5f6be", &yellow);
- color_set = gdk_colormap_alloc_color(
- gdk_colormap_get_system(),
- &yellow, FALSE, TRUE);
- }
-#endif
-
- style = gtk_widget_get_modifier_style(hentry->entry);
- state->entry_marked = gdk_color_equal(&yellow,
- &style->base[GTK_STATE_NORMAL]);
saved_list = g_slist_append(saved_list, state);
compose_destroy_headerentry(compose, hentry);
if (ac->set_autocc && ac->auto_cc)
compose_entry_append(compose, ac->auto_cc,
COMPOSE_CC, PREF_ACCOUNT);
-
- if (ac->set_autobcc && ac->auto_bcc)
+ if (ac->set_autobcc && ac->auto_bcc)
compose_entry_append(compose, ac->auto_bcc,
COMPOSE_BCC, PREF_ACCOUNT);
-
if (ac->set_autoreplyto && ac->auto_replyto)
compose_entry_append(compose, ac->auto_replyto,
COMPOSE_REPLYTO, PREF_ACCOUNT);
for (list = saved_list; list; list = list->next) {
state = (HeaderEntryState *) list->data;
-
+
compose_add_header_entry(compose, state->header,
state->entry, state->type);
- if (state->entry_marked)
- compose_entry_mark_default_to(compose, state->entry);
-
- g_free(state->header);
+
+ g_free(state->header);
g_free(state->entry);
g_free(state);
}
g_slist_free(saved_list);
-
+
combobox_select_by_data(GTK_COMBO_BOX(compose->header_last->combo),
(ac->protocol == A_NNTP) ?
COMPOSE_NEWSGROUPS : COMPOSE_TO);
* which unsets it (via focus_out_event callback on compose window). */
manage_window_focus_in(compose->window, NULL, NULL);
- file_list = filesel_select_multiple_files_open(_("Select file"));
+ file_list = filesel_select_multiple_files_open(_("Select file"), NULL);
if (file_list) {
compose_attach_from_list(compose, file_list, TRUE);
GList *file_list;
gint files_inserted = 0;
- file_list = filesel_select_multiple_files_open(_("Select file"));
+ file_list = filesel_select_multiple_files_open(_("Select file"), NULL);
if (file_list) {
GList *tmp;
compose_close_cb(NULL, compose);
}
-static gboolean compose_can_autosave(Compose *compose)
-{
- if (compose->privacy_system && compose->use_encryption)
- return prefs_common.autosave && prefs_common.autosave_encrypted;
- else
- return prefs_common.autosave;
-}
-
static void compose_close_cb(GtkAction *action, gpointer data)
{
Compose *compose = (Compose *)data;
{
Compose *compose = (Compose *)data;
+#ifdef G_OS_UNIX
+ if (compose->exteditor_tag != -1) {
+ debug_print("ignoring open external editor: external editor still open\n");
+ return;
+ }
+#endif
compose_exec_ext_editor(compose);
}
Compose *compose = (Compose *)user_data;
GList *list, *tmp;
GdkAtom type;
+ guint num_files;
+ gchar *msg;
/* strangely, testing data->type == gdk_atom_intern("text/uri-list", TRUE)
* does not work */
const gchar* ddata = (const gchar *)gtk_selection_data_get_data(data);
list = uri_list_extract_filenames(ddata);
+ num_files = g_list_length(list);
if (list == NULL && strstr(ddata, "://")) {
/* Assume a list of no files, and data has ://, is a remote link */
gchar *tmpdata = g_strstrip(g_strdup(ddata));
}
switch (prefs_common.compose_dnd_mode) {
case COMPOSE_DND_ASK:
- val = alertpanel_full(_("Insert or attach?"),
- _("Do you want to insert the contents of the file(s) "
- "into the message body, or attach it to the email?"),
+ msg = g_strdup_printf(
+ ngettext(
+ "Do you want to insert the contents of the file "
+ "into the message body, or attach it to the email?",
+ "Do you want to insert the contents of the %d files "
+ "into the message body, or attach them to the email?",
+ num_files),
+ num_files);
+ val = alertpanel_full(_("Insert or attach?"), msg,
GTK_STOCK_CANCEL, g_strconcat("+", _("_Insert"), NULL), _("_Attach"),
TRUE, NULL, ALERT_QUESTION, G_ALERTALTERNATE);
+ g_free(msg);
break;
case COMPOSE_DND_INSERT:
val = G_ALERTALTERNATE;
*\brief Guess originating forward account from MsgInfo and several
* "common preference" settings. Return NULL if no guess.
*/
-static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo)
+static PrefsAccount *compose_find_account(MsgInfo *msginfo)
{
PrefsAccount *account = NULL;
if (msginfo->folder->prefs->enable_default_account)
account = account_find_from_id(msginfo->folder->prefs->default_account);
- if (!account)
- account = msginfo->folder->folder->account;
-
if (!account && msginfo->to && prefs_common.forward_account_autosel) {
gchar *to;
Xstrdup_a(to, msginfo->to, return NULL);
account = account_find_from_address(buf, FALSE);
}
}
+
+ if (!account)
+ account = msginfo->folder->folder->account;
return account;
}