COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
- COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END
} ComposeCallAdvancedAction;
static void compose_destroy (Compose *compose);
static void compose_entries_set (Compose *compose,
- const gchar *mailto);
+ const gchar *mailto,
+ ComposeEntryType to_type);
static gint compose_parse_header (Compose *compose,
MsgInfo *msginfo);
static gchar *compose_parse_references (const gchar *ref,
static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
FolderItem *folder_item);
#endif
+static void compose_attach_update_label(Compose *compose);
+
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data);
static GtkItemFactoryEntry compose_popup_entries[] =
{
compose_advanced_action_cb,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
NULL},
- {N_("/_Edit/A_dvanced/Delete entire line"),
- NULL,
- compose_advanced_action_cb,
- COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
- NULL},
{N_("/_Edit/A_dvanced/Delete to end of line"),
"<control>K",
compose_advanced_action_cb,
NULL, compose_set_encoding_cb, C_AUTO, "<RadioItem>"},
{N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/7bit ascii (US-ASC_II)"),
+ {N_("/_Options/Character _encoding/7bit ASCII (US-ASC_II)"),
ENC_ACTION(C_US_ASCII)},
{N_("/_Options/Character _encoding/Unicode (_UTF-8)"),
ENC_ACTION(C_UTF_8)},
{N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Western European (ISO-8859-_1)"),
+ {N_("/_Options/Character _encoding/Western European"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Western European/ISO-8859-_1"),
ENC_ACTION(C_ISO_8859_1)},
- {N_("/_Options/Character _encoding/Western European (ISO-8859-15)"),
+ {N_("/_Options/Character _encoding/Western European/ISO-8859-15"),
ENC_ACTION(C_ISO_8859_15)},
- {N_("/_Options/Character _encoding/Western European (Windows-1252)"),
+ {N_("/_Options/Character _encoding/Western European/Windows-1252"),
ENC_ACTION(C_WINDOWS_1252)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Character _encoding/Central European (ISO-8859-_2)"),
ENC_ACTION(C_ISO_8859_2)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/_Baltic (ISO-8859-13)"),
+ {N_("/_Options/Character _encoding/Baltic"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Baltic/ISO-8859-13"),
ENC_ACTION(C_ISO_8859_13)},
- {N_("/_Options/Character _encoding/Baltic (ISO-8859-_4)"),
+ {N_("/_Options/Character _encoding/Baltic/ISO-8859-_4"),
ENC_ACTION(C_ISO_8859_4)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Character _encoding/Greek (ISO-8859-_7)"),
ENC_ACTION(C_ISO_8859_7)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Hebrew (ISO-8859-_8)"),
+ {N_("/_Options/Character _encoding/Hebrew"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Hebrew/ISO-8859-_8"),
ENC_ACTION(C_ISO_8859_8)},
- {N_("/_Options/Character _encoding/Hebrew (Windows-1255)"),
+ {N_("/_Options/Character _encoding/Hebrew/Windows-1255"),
ENC_ACTION(C_WINDOWS_1255)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Arabic (ISO-8859-_6)"),
+ {N_("/_Options/Character _encoding/Arabic"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Arabic/ISO-8859-_6"),
ENC_ACTION(C_ISO_8859_6)},
- {N_("/_Options/Character _encoding/Arabic (Windows-1256)"),
+ {N_("/_Options/Character _encoding/Arabic/Windows-1256"),
ENC_ACTION(C_CP1256)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Character _encoding/Turkish (ISO-8859-_9)"),
ENC_ACTION(C_ISO_8859_9)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Cyrillic (ISO-8859-_5)"),
+ {N_("/_Options/Character _encoding/Cyrillic"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Cyrillic/ISO-8859-_5"),
ENC_ACTION(C_ISO_8859_5)},
- {N_("/_Options/Character _encoding/Cyrillic (KOI8-_R)"),
+ {N_("/_Options/Character _encoding/Cyrillic/KOI8-_R"),
ENC_ACTION(C_KOI8_R)},
- {N_("/_Options/Character _encoding/Cyrillic (KOI8-U)"),
+ {N_("/_Options/Character _encoding/Cyrillic/KOI8-U"),
ENC_ACTION(C_KOI8_U)},
- {N_("/_Options/Character _encoding/Cyrillic (Windows-1251)"),
+ {N_("/_Options/Character _encoding/Cyrillic/Windows-1251"),
ENC_ACTION(C_WINDOWS_1251)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Japanese (ISO-2022-_JP)"),
+ {N_("/_Options/Character _encoding/Japanese"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Japanese/ISO-2022-_JP"),
ENC_ACTION(C_ISO_2022_JP)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
-
- {N_("/_Options/Character _encoding/Simplified Chinese (_GB2312)"),
+ {N_("/_Options/Character _encoding/Japanese/ISO-2022-JP-2"),
+ ENC_ACTION(C_ISO_2022_JP_2)},
+ {N_("/_Options/Character _encoding/Japanese/_EUC-JP"),
+ ENC_ACTION(C_EUC_JP)},
+ {N_("/_Options/Character _encoding/Japanese/_Shift__JIS"),
+ ENC_ACTION(C_SHIFT_JIS)},
+
+ {N_("/_Options/Character _encoding/Chinese"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Chinese/Simplified (_GB2312)"),
ENC_ACTION(C_GB2312)},
- {N_("/_Options/Character _encoding/Simplified Chinese (GBK)"),
+ {N_("/_Options/Character _encoding/Chinese/Simplified (GBK)"),
ENC_ACTION(C_GBK)},
- {N_("/_Options/Character _encoding/Traditional Chinese (_Big5)"),
+ {N_("/_Options/Character _encoding/Chinese/Traditional (_Big5)"),
ENC_ACTION(C_BIG5)},
- {N_("/_Options/Character _encoding/Traditional Chinese (EUC-_TW)"),
+ {N_("/_Options/Character _encoding/Chinese/Traditional (EUC-_TW)"),
ENC_ACTION(C_EUC_TW)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Korean (EUC-_KR)"),
+ {N_("/_Options/Character _encoding/Korean"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Korean/EUC-_KR"),
ENC_ACTION(C_EUC_KR)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+ {N_("/_Options/Character _encoding/Korean/ISO-2022-KR"),
+ ENC_ACTION(C_ISO_2022_KR)},
- {N_("/_Options/Character _encoding/Thai (TIS-620)"),
+ {N_("/_Options/Character _encoding/Thai"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Thai/TIS-620"),
ENC_ACTION(C_TIS_620)},
- {N_("/_Options/Character _encoding/Thai (Windows-874)"),
+ {N_("/_Options/Character _encoding/Thai/Windows-874"),
ENC_ACTION(C_WINDOWS_874)},
{N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
return compose_generic_new( account, NULL, NULL, NULL, listAddress );
}
+#define SCROLL_TO_CURSOR(compose) { \
+ GtkTextMark *cmark = gtk_text_buffer_get_insert( \
+ gtk_text_view_get_buffer( \
+ GTK_TEXT_VIEW(compose->text))); \
+ gtk_text_view_scroll_mark_onscreen( \
+ GTK_TEXT_VIEW(compose->text), \
+ cmark); \
+}
+
Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
GPtrArray *attach_files, GList *listAddress )
{
GtkItemFactory *ifactory;
const gchar *subject_format = NULL;
const gchar *body_format = NULL;
+ gchar *mailto_from = NULL;
+ PrefsAccount *mailto_account = NULL;
+ MsgInfo* dummyinfo = NULL;
- if (item && item->prefs && item->prefs->enable_default_account)
+ /* check if mailto defines a from */
+ if (mailto && *mailto != '\0') {
+ scan_mailto_url(mailto, &mailto_from, NULL, NULL, NULL, NULL, NULL, NULL);
+ /* mailto defines a from, check if we can get account prefs from it,
+ if not, the account prefs will be guessed using other ways, but we'll keep
+ the from anyway */
+ if (mailto_from)
+ mailto_account = account_find_from_address(mailto_from, TRUE);
+ if (mailto_account)
+ account = mailto_account;
+ }
+
+ /* if no account prefs set from mailto, set if from folder prefs (if any) */
+ if (!mailto_account && item && item->prefs && item->prefs->enable_default_account)
account = account_find_from_id(item->prefs->default_account);
+ /* if no account prefs set, fallback to the current one */
if (!account) account = cur_account;
g_return_val_if_fail(account != NULL, NULL);
compose = compose_create(account, item, COMPOSE_NEW, FALSE);
+ /* override from name if mailto asked for it */
+ if (mailto_from) {
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), mailto_from);
+ g_free(mailto_from);
+ } else
+ /* override from name according to folder properties */
+ if (item && item->prefs &&
+ item->prefs->compose_with_format &&
+ item->prefs->compose_override_from_format &&
+ *item->prefs->compose_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+
+ dummyinfo = compose_msginfo_new_from_compose(compose);
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ tmp = malloc(strlen(item->prefs->compose_override_from_format)+1);
+ pref_get_unescaped_pref(tmp, item->prefs->compose_override_from_format);
+
+#ifdef USE_ASPELL
+ quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("New message From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ }
+
ifactory = gtk_item_factory_from_widget(compose->menubar);
compose->replyinfo = NULL;
if (account->protocol != A_NNTP) {
if (mailto && *mailto != '\0') {
- compose_entries_set(compose, mailto);
+ compose_entries_set(compose, mailto, COMPOSE_TO);
} else if (item && item->prefs->enable_default_to) {
compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
menu_set_active(ifactory, "/Options/Request Return Receipt", TRUE);
}
} else {
- if (mailto) {
- compose_entry_append(compose, mailto, COMPOSE_NEWSGROUPS);
+ if (mailto && *mailto != '\0') {
+ if (!strchr(mailto, '@'))
+ compose_entries_set(compose, mailto, COMPOSE_NEWSGROUPS);
+ else
+ compose_entries_set(compose, mailto, COMPOSE_TO);
} else if (item && FOLDER_CLASS(item->folder) == news_get_class()) {
compose_entry_append(compose, item->path, COMPOSE_NEWSGROUPS);
}
}
if (subject_format || body_format) {
- MsgInfo* dummyinfo = NULL;
if ( subject_format
&& *subject_format != '\0' )
gchar *tmp = NULL;
gchar *buf = NULL;
- dummyinfo = compose_msginfo_new_from_compose(compose);
+ if (!dummyinfo)
+ dummyinfo = compose_msginfo_new_from_compose(compose);
/* decode \-escape sequences in the internal representation of the quote format */
tmp = malloc(strlen(subject_format)+1);
subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
#ifdef USE_ASPELL
- quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account,
+ quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account);
+ quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(tmp);
quote_fmt_parse();
alertpanel_error(_("New message subject format error."));
else
gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
g_free(subject);
GtkTextIter start, end;
gchar *tmp = NULL;
- if ( dummyinfo == NULL )
+ if (!dummyinfo)
dummyinfo = compose_msginfo_new_from_compose(compose);
text = GTK_TEXT_VIEW(compose->text);
body_format,
NULL, tmp, FALSE, TRUE,
_("New message body format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
g_free(tmp);
}
- procmsg_msginfo_free( dummyinfo );
}
+ procmsg_msginfo_free( dummyinfo );
if (attach_files) {
gint i;
compose_exec_ext_editor(compose);
compose->draft_timeout_tag = -1;
+ SCROLL_TO_CURSOR(compose);
+
compose->modified = FALSE;
compose_set_title(compose);
return compose;
if (privacy != NULL) {
if (compose->privacy_system == NULL)
compose->privacy_system = g_strdup(privacy);
+ else if (*(compose->privacy_system) == '\0') {
+ g_free(compose->privacy_system);
+ compose->privacy_system = g_strdup(privacy);
+ }
compose_update_privacy_system_menu_item(compose, FALSE);
compose_use_encryption(compose, TRUE);
}
g_warning("compose_reply_mode(): invalid Compose Mode: %d\n", mode);
}
+ if (compose == NULL) {
+ alertpanel_error(_("Unable to reply. The original email probably doesn't exist."));
+ return NULL;
+ }
ifactory = gtk_item_factory_from_widget(compose->menubar);
compose->rmode = mode;
g_free(folderidentifier);
}
- if (compose_parse_header(compose, msginfo) < 0) return NULL;
+ if (compose_parse_header(compose, msginfo) < 0) {
+ compose->updating = FALSE;
+ compose_destroy(compose);
+ return NULL;
+ }
+
+ /* override from name according to folder properties */
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->reply_with_format &&
+ msginfo->folder->prefs->reply_override_from_format &&
+ *msginfo->folder->prefs->reply_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ tmp = malloc(strlen(msginfo->folder->prefs->reply_override_from_format)+1);
+ pref_get_unescaped_pref(tmp, msginfo->folder->prefs->reply_override_from_format);
+
+#ifdef USE_ASPELL
+ quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("Message reply From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ }
textview = (GTK_TEXT_VIEW(compose->text));
textbuf = gtk_text_view_get_buffer(textview);
compose_quote_fmt(compose, compose->replyinfo,
body_fmt, qmark, body, FALSE, TRUE,
_("Message reply format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
}
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
-
+ SCROLL_TO_CURSOR(compose);
+
if (compose->deferred_destroy) {
compose_destroy(compose);
return NULL;
g_free(buf2);
}
+ /* override from name according to folder properties */
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->forward_with_format &&
+ msginfo->folder->prefs->forward_override_from_format &&
+ *msginfo->folder->prefs->forward_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+ MsgInfo *full_msginfo = NULL;
+
+ if (!as_attach)
+ full_msginfo = procmsg_msginfo_get_full_info(msginfo);
+ if (!full_msginfo)
+ full_msginfo = procmsg_msginfo_copy(msginfo);
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
+ pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
+
+#ifdef USE_ASPELL
+ quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("Message forward From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ procmsg_msginfo_free(full_msginfo);
+ }
+
textview = GTK_TEXT_VIEW(compose->text);
textbuf = gtk_text_view_get_buffer(textview);
compose_create_tags(textview, compose);
compose_quote_fmt(compose, full_msginfo,
body_fmt, qmark, body, FALSE, TRUE,
_("Message forward format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
compose_attach_parts(compose, msginfo);
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
compose->updating = TRUE;
+ /* override from name according to folder properties */
+ if (msginfo_list->data) {
+ MsgInfo *msginfo = msginfo_list->data;
+
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->forward_with_format &&
+ msginfo->folder->prefs->forward_override_from_format &&
+ *msginfo->folder->prefs->forward_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
+ pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
+
+#ifdef USE_ASPELL
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("Message forward From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ }
+ }
+
textview = GTK_TEXT_VIEW(compose->text);
textbuf = gtk_text_view_get_buffer(textview);
compose_create_tags(textview, compose);
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
}
if (!account && !procheader_get_header_from_msginfo(msginfo, queueheader_buf,
sizeof(queueheader_buf), "S:")) {
- account = account_find_from_address(queueheader_buf);
+ account = account_find_from_address(queueheader_buf, FALSE);
}
if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf,
sizeof(queueheader_buf), "X-Claws-Sign:")) {
gchar from[BUFFSIZE];
if (!procheader_get_header_from_msginfo(msginfo, from, sizeof(from), "FROM:")) {
extract_address(from);
- account = account_find_from_address(from);
+ account = account_find_from_address(from, FALSE);
}
}
if (!account) {
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
compose_set_title(compose);
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
}
}
-static void compose_entries_set(Compose *compose, const gchar *mailto)
+static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEntryType to_type)
{
gchar *to = NULL;
gchar *cc = NULL;
+ gchar *bcc = NULL;
gchar *subject = NULL;
gchar *body = NULL;
gchar *temp = NULL;
gsize len = 0;
- gchar *attach = NULL;
-
- scan_mailto_url(mailto, &to, &cc, NULL, &subject, &body, &attach);
+ gchar **attach = NULL;
+
+ /* get mailto parts but skip from */
+ scan_mailto_url(mailto, NULL, &to, &cc, &bcc, &subject, &body, &attach);
if (to)
- compose_entry_append(compose, to, COMPOSE_TO);
+ compose_entry_append(compose, to, to_type);
if (cc)
compose_entry_append(compose, cc, COMPOSE_CC);
+ if (bcc)
+ compose_entry_append(compose, bcc, COMPOSE_BCC);
if (subject) {
if (!g_utf8_validate (subject, -1, NULL)) {
temp = g_locale_to_utf8 (subject, -1, NULL, &len, NULL);
}
if (attach) {
- gchar *utf8_filename = conv_filename_to_utf8(attach);
- if (utf8_filename) {
- if (compose_attach_append(compose, attach, utf8_filename, NULL)) {
- alertpanel_notice(_("The file '%s' has been attached."), attach);
- }
- g_free(utf8_filename);
- } else {
- alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
+ gint i = 0, att = 0;
+ gchar *warn_files = NULL;
+ while (attach[i] != NULL) {
+ gchar *utf8_filename = conv_filename_to_utf8(attach[i]);
+ if (utf8_filename) {
+ if (compose_attach_append(compose, attach[i], utf8_filename, NULL)) {
+ gchar *tmp = g_strdup_printf("%s%s\n",
+ warn_files?warn_files:"",
+ utf8_filename);
+ g_free(warn_files);
+ warn_files = tmp;
+ att++;
+ }
+ g_free(utf8_filename);
+ } else {
+ alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
+ }
+ i++;
+ }
+ if (warn_files) {
+ alertpanel_notice(ngettext(
+ "The following file has been attached: \n%s",
+ "The following files have been attached: \n%s", att), warn_files);
+ g_free(warn_files);
}
}
g_free(to);
g_free(cc);
+ g_free(bcc);
g_free(subject);
g_free(body);
- g_free(attach);
+ g_strfreev(attach);
}
static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
extract_address(hentry[H_LIST_POST].body);
if (hentry[H_LIST_POST].body[0] != '\0') {
scan_mailto_url(hentry[H_LIST_POST].body,
- &to, NULL, NULL, NULL, NULL, NULL);
+ NULL, &to, NULL, NULL, NULL, NULL, NULL);
if (to) {
g_free(compose->ml_post);
compose->ml_post = to;
if (qmark != NULL) {
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(qmark);
quote_fmt_parse();
trimmed_body++;
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account,
+ quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account);
+ quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE);
#endif
if (need_unescape) {
gchar *tmp = NULL;
buf = quote_fmt_get_buffer();
if (buf == NULL) {
gint line = quote_fmt_get_line();
- gchar *msg = g_strdup_printf(err_msg, line);
- alertpanel_error(msg);
- g_free(msg);
+ alertpanel_error(err_msg, line);
goto error;
}
} else
Xstrdup_a(tmp1, msginfo->from, return);
extract_address(tmp1);
if (to_all || to_sender ||
- !account_find_from_address(tmp1))
+ !account_find_from_address(tmp1, FALSE))
compose_entry_append(compose,
(compose->replyto && !to_sender)
? compose->replyto :
if (!folder_has_parent_of_type(msginfo->folder, F_QUEUE) &&
!folder_has_parent_of_type(msginfo->folder, F_OUTBOX) &&
!folder_has_parent_of_type(msginfo->folder, F_DRAFT)) {
- compose_entry_append(compose,
- msginfo->from ? msginfo->from : "",
- COMPOSE_TO);
+ if (compose->replyto) {
+ compose_entry_append(compose,
+ compose->replyto,
+ COMPOSE_TO);
+ } else {
+ compose_entry_append(compose,
+ msginfo->from ? msginfo->from : "",
+ COMPOSE_TO);
+ }
} else {
/* replying to own mail, use original recp */
compose_entry_append(compose,
-1);
g_auto_pointer_free(auto_ainfo);
+ compose_attach_update_label(compose);
return TRUE;
}
gboolean keep_cursor = FALSE;
if (!gtk_text_iter_forward_line(&iter_) ||
- gtk_text_iter_ends_line(&iter_))
+ gtk_text_iter_ends_line(&iter_)) {
return FALSE;
-
+ }
next_quote_str = compose_get_quote_str(buffer, &iter_, "e_len);
if ((quote_str || next_quote_str) &&
end = iter_;
if (quote_len > 0) {
gtk_text_iter_forward_chars(&end, quote_len);
- if (gtk_text_iter_ends_line(&end))
+ if (gtk_text_iter_ends_line(&end)) {
return FALSE;
+ }
}
/* don't join itemized lines */
- if (compose_is_itemized(buffer, &end))
+ if (compose_is_itemized(buffer, &end)) {
return FALSE;
+ }
/* don't join signature separator */
- if (compose_is_sig_separator(compose, buffer, &iter_))
+ if (compose_is_sig_separator(compose, buffer, &iter_)) {
return FALSE;
-
+ }
/* delete quote str */
if (quote_len > 0)
gtk_text_buffer_delete(buffer, &iter_, &end);
removed = TRUE;
}
}
- if (uri_start > 0 && uri_stop > 0) {
+ if (uri_start >= 0 && uri_stop > 0) {
GtkTextIter uri_start_iter, uri_end_iter, back;
gtk_text_buffer_get_iter_at_offset(
buffer, &uri_start_iter, uri_start);
for (list = compose->header_list; list; list = list->next) {
gchar *header;
gchar *entry;
- header = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry), 0, -1);
+ header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
-
g_strstrip(entry);
+ g_strstrip(header);
if (entry[0] != '\0') {
for (strptr = recipient_headers_mail; *strptr != NULL; strptr++) {
if (!strcmp(header, prefs_common_translated_header_name(*strptr))) {
gchar *entry;
gchar *header;
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
- header = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry), 0, -1);
+ header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
g_strstrip(entry);
+ g_strstrip(header);
if (strcmp(entry, compose->account->auto_cc)
|| strcmp(header, prefs_common_translated_header_name("Cc:"))) {
found_other = TRUE;
gchar *entry;
gchar *header;
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
- header = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry), 0, -1);
+ header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
g_strstrip(entry);
+ g_strstrip(header);
if (strcmp(entry, compose->account->auto_bcc)
|| strcmp(header, prefs_common_translated_header_name("Bcc:"))) {
found_other = TRUE;
if (*str == '\0' && check_everything == TRUE &&
compose->mode != COMPOSE_REDIRECT) {
AlertValue aval;
+ gchar *button_label;
+ gchar *message;
- aval = alertpanel(_("Send"),
- _("Subject is empty. Send it anyway?"),
- GTK_STOCK_CANCEL, _("+_Send"), NULL);
+ if (compose->sending)
+ button_label = _("+_Send");
+ else
+ button_label = _("+_Queue");
+ message = g_strdup_printf(_("Subject is empty. %s"),
+ compose->sending?_("Send it anyway?"):
+ _("Queue it anyway?"));
+
+ aval = alertpanel(compose->sending?_("Send"):_("Send later"), message,
+ GTK_STOCK_CANCEL, button_label, NULL);
+ g_free(message);
if (aval != G_ALERTALTERNATE)
return FALSE;
}
goto bail;
}
- tmsgid = g_strdup(compose->msgid);
+ tmsgid = compose->msgid ? g_strdup(compose->msgid) : NULL;
if (discard_window) {
compose->sending = FALSE;
compose_close(compose);
g_free(msgpath);
} else {
val = procmsg_send_message_queue(msgpath, &errstr, folder, msgnum, &queued_removed);
- g_unlink(msgpath);
+ claws_unlink(msgpath);
g_free(msgpath);
}
if (!discard_window) {
}
} else {
if (errstr) {
- gchar *tmp = g_strdup_printf(_("%s\nUse \"Send queued messages\" from "
+ alertpanel_error_log(_("%s\nUse \"Send queued messages\" from "
"the main window to retry."), errstr);
g_free(errstr);
- alertpanel_error_log(tmp);
- g_free(tmp);
} else {
alertpanel_error_log(_("The message was queued but could not be "
"sent.\nUse \"Send queued messages\" from "
const gchar *headerentryname;
const gchar *cc_hdr;
const gchar *to_hdr;
+ gboolean err = FALSE;
debug_print("Writing redirect header\n");
first_to_address = TRUE;
for (list = compose->header_list; list; list = list->next) {
headerentry = ((ComposeHeaderEntry *)list->data);
- headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
+ headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_BIN(headerentry->combo)->child));
if (g_utf8_collate(headerentryname, to_hdr) == 0) {
const gchar *entstr = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
strlen("Resent-To") + 2, TRUE);
if (first_to_address) {
- fprintf(fp, "Resent-To: ");
+ err |= (fprintf(fp, "Resent-To: ") < 0);
first_to_address = FALSE;
} else {
- fprintf(fp, ",");
+ err |= (fprintf(fp, ",") < 0);
}
- fprintf(fp, "%s", buf);
+ err |= (fprintf(fp, "%s", buf) < 0);
}
}
}
if (!first_to_address) {
- fprintf(fp, "\n");
+ err |= (fprintf(fp, "\n") < 0);
}
first_cc_address = TRUE;
for (list = compose->header_list; list; list = list->next) {
headerentry = ((ComposeHeaderEntry *)list->data);
- headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
+ headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_BIN(headerentry->combo)->child));
if (g_utf8_collate(headerentryname, cc_hdr) == 0) {
const gchar *strg = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
strlen("Resent-Cc") + 2, TRUE);
if (first_cc_address) {
- fprintf(fp, "Resent-Cc: ");
+ err |= (fprintf(fp, "Resent-Cc: ") < 0);
first_cc_address = FALSE;
} else {
- fprintf(fp, ",");
+ err |= (fprintf(fp, ",") < 0);
}
- fprintf(fp, "%s", buf);
+ err |= (fprintf(fp, "%s", buf) < 0);
}
}
}
if (!first_cc_address) {
- fprintf(fp, "\n");
+ err |= (fprintf(fp, "\n") < 0);
}
- return(0);
+ return (err ? -1:0);
}
static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
gchar *str;
const gchar *entstr;
/* struct utsname utsbuf; */
+ gboolean err = FALSE;
g_return_val_if_fail(fp != NULL, -1);
g_return_val_if_fail(compose->account != NULL, -1);
/* Resent-Date */
get_rfc822_date(buf, sizeof(buf));
- fprintf(fp, "Resent-Date: %s\n", buf);
+ err |= (fprintf(fp, "Resent-Date: %s\n", buf) < 0);
/* Resent-From */
if (compose->account->name && *compose->account->name) {
compose_convert_header
(compose, buf, sizeof(buf), compose->account->name,
strlen("From: "), TRUE);
- fprintf(fp, "Resent-From: %s <%s>\n",
- buf, compose->account->address);
+ err |= (fprintf(fp, "Resent-From: %s <%s>\n",
+ buf, compose->account->address) < 0);
} else
- fprintf(fp, "Resent-From: %s\n", compose->account->address);
+ err |= (fprintf(fp, "Resent-From: %s\n", compose->account->address) < 0);
/* Subject */
entstr = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
if (*str != '\0') {
compose_convert_header(compose, buf, sizeof(buf), str,
strlen("Subject: "), FALSE);
- fprintf(fp, "Subject: %s\n", buf);
+ err |= (fprintf(fp, "Subject: %s\n", buf) < 0);
}
}
/* 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) {
generate_msgid(buf, sizeof(buf));
- fprintf(fp, "Resent-Message-ID: <%s>\n", buf);
+ err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
compose->msgid = g_strdup(buf);
+ } else {
+ compose->msgid = NULL;
}
- compose_redirect_write_headers_from_headerlist(compose, fp);
+ if (compose_redirect_write_headers_from_headerlist(compose, fp))
+ return -1;
/* separator between header and body */
- fputs("\n", fp);
+ err |= (fputs("\n", fp) == EOF);
- return 0;
+ return (err ? -1:0);
}
static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
gchar buf[BUFFSIZE];
int i = 0;
gboolean skip = FALSE;
+ gboolean err = FALSE;
gchar *not_included[]={
"Return-Path:", "Delivered-To:", "Received:",
"Subject:", "X-UIDL:", "AF:",
if (!prefs_common.redirect_keep_from) {
if (g_ascii_strncasecmp(buf, "From:",
strlen("From:")) == 0) {
- fputs(" (by way of ", fdest);
+ err |= (fputs(" (by way of ", fdest) == EOF);
if (compose->account->name
&& *compose->account->name) {
compose_convert_header
compose->account->name,
strlen("From: "),
FALSE);
- fprintf(fdest, "%s <%s>",
+ err |= (fprintf(fdest, "%s <%s>",
buf,
- compose->account->address);
+ compose->account->address) < 0);
} else
- fprintf(fdest, "%s",
- compose->account->address);
- fputs(")", fdest);
+ err |= (fprintf(fdest, "%s",
+ compose->account->address) < 0);
+ err |= (fputs(")", fdest) == EOF);
}
}
goto error;
}
- compose_redirect_write_headers(compose, fdest);
+ if (err)
+ goto error;
+
+ if (compose_redirect_write_headers(compose, fdest))
+ goto error;
while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
if (fwrite(buf, sizeof(gchar), len, fdest) != len)
encoding = ENC_QUOTED_PRINTABLE;
}
- debug_print("main text: %d bytes encoded as %s in %d\n",
+ debug_print("main text: %zd bytes encoded as %s in %d\n",
strlen(buf), out_codeset, encoding);
/* check for line length limit */
FILE_OP_ERROR(file, "fwrite");
g_free(chars);
fclose(fp);
- g_unlink(file);
+ claws_unlink(file);
return -1;
}
if (fclose(fp) == EOF) {
FILE_OP_ERROR(file, "fclose");
- g_unlink(file);
+ claws_unlink(file);
return -1;
}
return 0;
gint num;
static gboolean lock = FALSE;
PrefsAccount *mailac = NULL, *newsac = NULL;
-
+ gboolean err = FALSE;
+
debug_print("queueing message...\n");
g_return_val_if_fail(compose->account != NULL, -1);
}
/* write queue header */
- tmp = g_strdup_printf("%s%cqueue.%p", get_tmp_dir(),
- G_DIR_SEPARATOR, compose);
+ tmp = g_strdup_printf("%s%cqueue.%p%08x", get_tmp_dir(),
+ G_DIR_SEPARATOR, compose, (guint) rand());
+ debug_print("queuing to %s\n", tmp);
if ((fp = g_fopen(tmp, "wb")) == NULL) {
FILE_OP_ERROR(tmp, "fopen");
g_free(tmp);
}
/* queueing variables */
- fprintf(fp, "AF:\n");
- fprintf(fp, "NF:0\n");
- fprintf(fp, "PS:10\n");
- fprintf(fp, "SRH:1\n");
- fprintf(fp, "SFN:\n");
- fprintf(fp, "DSR:\n");
+ err |= (fprintf(fp, "AF:\n") < 0);
+ err |= (fprintf(fp, "NF:0\n") < 0);
+ err |= (fprintf(fp, "PS:10\n") < 0);
+ err |= (fprintf(fp, "SRH:1\n") < 0);
+ err |= (fprintf(fp, "SFN:\n") < 0);
+ err |= (fprintf(fp, "DSR:\n") < 0);
if (compose->msgid)
- fprintf(fp, "MID:<%s>\n", compose->msgid);
+ err |= (fprintf(fp, "MID:<%s>\n", compose->msgid) < 0);
else
- fprintf(fp, "MID:\n");
- fprintf(fp, "CFG:\n");
- fprintf(fp, "PT:0\n");
- fprintf(fp, "S:%s\n", compose->account->address);
- fprintf(fp, "RQ:\n");
+ err |= (fprintf(fp, "MID:\n") < 0);
+ err |= (fprintf(fp, "CFG:\n") < 0);
+ err |= (fprintf(fp, "PT:0\n") < 0);
+ err |= (fprintf(fp, "S:%s\n", compose->account->address) < 0);
+ err |= (fprintf(fp, "RQ:\n") < 0);
if (mailac)
- fprintf(fp, "SSV:%s\n", mailac->smtp_server);
+ err |= (fprintf(fp, "SSV:%s\n", mailac->smtp_server) < 0);
else
- fprintf(fp, "SSV:\n");
+ err |= (fprintf(fp, "SSV:\n") < 0);
if (newsac)
- fprintf(fp, "NSV:%s\n", newsac->nntp_server);
+ err |= (fprintf(fp, "NSV:%s\n", newsac->nntp_server) < 0);
else
- fprintf(fp, "NSV:\n");
- fprintf(fp, "SSH:\n");
+ err |= (fprintf(fp, "NSV:\n") < 0);
+ err |= (fprintf(fp, "SSH:\n") < 0);
/* write recepient list */
if (compose->to_list) {
- fprintf(fp, "R:<%s>", (gchar *)compose->to_list->data);
+ err |= (fprintf(fp, "R:<%s>", (gchar *)compose->to_list->data) < 0);
for (cur = compose->to_list->next; cur != NULL;
cur = cur->next)
- fprintf(fp, ",<%s>", (gchar *)cur->data);
- fprintf(fp, "\n");
+ err |= (fprintf(fp, ",<%s>", (gchar *)cur->data) < 0);
+ err |= (fprintf(fp, "\n") < 0);
}
/* write newsgroup list */
if (compose->newsgroup_list) {
- fprintf(fp, "NG:");
- fprintf(fp, "%s", (gchar *)compose->newsgroup_list->data);
+ err |= (fprintf(fp, "NG:") < 0);
+ err |= (fprintf(fp, "%s", (gchar *)compose->newsgroup_list->data) < 0);
for (cur = compose->newsgroup_list->next; cur != NULL; cur = cur->next)
- fprintf(fp, ",%s", (gchar *)cur->data);
- fprintf(fp, "\n");
+ err |= (fprintf(fp, ",%s", (gchar *)cur->data) < 0);
+ err |= (fprintf(fp, "\n") < 0);
}
/* Sylpheed account IDs */
if (mailac)
- fprintf(fp, "MAID:%d\n", mailac->account_id);
+ err |= (fprintf(fp, "MAID:%d\n", mailac->account_id) < 0);
if (newsac)
- fprintf(fp, "NAID:%d\n", newsac->account_id);
+ err |= (fprintf(fp, "NAID:%d\n", newsac->account_id) < 0);
if (compose->privacy_system != NULL) {
- fprintf(fp, "X-Claws-Privacy-System:%s\n", compose->privacy_system);
- fprintf(fp, "X-Claws-Sign:%d\n", compose->use_signing);
+ err |= (fprintf(fp, "X-Claws-Privacy-System:%s\n", compose->privacy_system) < 0);
+ err |= (fprintf(fp, "X-Claws-Sign:%d\n", compose->use_signing) < 0);
if (compose->use_encryption) {
gchar *encdata;
if (!compose_warn_encryption(compose)) {
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -6;
}
}
if (encdata != NULL) {
if (strcmp(encdata, "_DONT_ENCRYPT_")) {
- fprintf(fp, "X-Claws-Encrypt:%d\n", compose->use_encryption);
- fprintf(fp, "X-Claws-Encrypt-Data:%s\n",
- encdata);
+ err |= (fprintf(fp, "X-Claws-Encrypt:%d\n", compose->use_encryption) < 0);
+ err |= (fprintf(fp, "X-Claws-Encrypt-Data:%s\n",
+ encdata) < 0);
} /* else we finally dont want to encrypt */
} else {
- fprintf(fp, "X-Claws-Encrypt:%d\n", compose->use_encryption);
+ err |= (fprintf(fp, "X-Claws-Encrypt:%d\n", compose->use_encryption) < 0);
/* and if encdata was null, it means there's been a problem in
* key selection */
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -5;
}
gchar *savefolderid;
savefolderid = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
- fprintf(fp, "SCF:%s\n", savefolderid);
+ err |= (fprintf(fp, "SCF:%s\n", savefolderid) < 0);
g_free(savefolderid);
}
/* Save copy folder */
if (compose->return_receipt) {
- fprintf(fp, "RRCPT:1\n");
+ err |= (fprintf(fp, "RRCPT:1\n") < 0);
}
/* Message-ID of message replying to */
if ((compose->replyinfo != NULL) && (compose->replyinfo->msgid != NULL)) {
gchar *folderid;
folderid = folder_item_get_identifier(compose->replyinfo->folder);
- fprintf(fp, "RMID:%s\t%d\t%s\n", folderid, compose->replyinfo->msgnum, compose->replyinfo->msgid);
+ err |= (fprintf(fp, "RMID:%s\t%d\t%s\n", folderid, compose->replyinfo->msgnum, compose->replyinfo->msgid) < 0);
g_free(folderid);
}
/* Message-ID of message forwarding to */
gchar *folderid;
folderid = folder_item_get_identifier(compose->fwdinfo->folder);
- fprintf(fp, "FMID:%s\t%d\t%s\n", folderid, compose->fwdinfo->msgnum, compose->fwdinfo->msgid);
+ err |= (fprintf(fp, "FMID:%s\t%d\t%s\n", folderid, compose->fwdinfo->msgnum, compose->fwdinfo->msgid) < 0);
g_free(folderid);
}
/* end of headers */
- fprintf(fp, "X-Claws-End-Special-Headers: 1\n");
+ err |= (fprintf(fp, "X-Claws-End-Special-Headers: 1\n") < 0);
if (compose->redirect_filename != NULL) {
if (compose_redirect_write_to_file(compose, fp) < 0) {
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -2;
}
if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND, TRUE)) < 0) {
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return result - 1; /* -2 for a generic error, -3 for signing error, -4 for encoding */
}
}
-
+ if (err == TRUE) {
+ g_warning("failed to write queue message\n");
+ fclose(fp);
+ claws_unlink(tmp);
+ g_free(tmp);
+ lock = FALSE;
+ return -2;
+ }
if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmp, "fclose");
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
lock = FALSE;
return -2;
}
if (!queue) {
g_warning("can't find queue folder\n");
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
lock = FALSE;
return -1;
folder_item_scan(queue);
if ((num = folder_item_add_msg(queue, tmp, NULL, FALSE)) < 0) {
g_warning("can't queue the message\n");
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
lock = FALSE;
return -1;
}
if (msgpath == NULL) {
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
} else
*msgpath = tmp;
for (list = compose->header_list; list; list = list->next) {
headerentry = ((ComposeHeaderEntry *)list->data);
- headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
+ headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_BIN(headerentry->combo)->child));
if (!g_utf8_collate(trans_fieldname, headerentryname)) {
str = gtk_editable_get_chars(GTK_EDITABLE(headerentry->entry), 0, -1);
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) {
generate_msgid(buf, sizeof(buf));
g_string_append_printf(header, "Message-ID: <%s>\n", buf);
compose->msgid = g_strdup(buf);
+ } else {
+ compose->msgid = NULL;
}
if (compose->remove_references == FALSE) {
gboolean standard_header = FALSE;
headerentry = ((ComposeHeaderEntry *)list->data);
-
- tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry)));
- if (strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
+
+ tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(headerentry->combo)->child)));
+ g_strstrip(tmp);
+ if (*tmp == '\0' || strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
g_free(tmp);
continue;
}
if (*address != '\0') {
gchar *name = procheader_get_fromname(address);
extract_address(address);
- addressbook_add_contact(name, address, NULL);
+ addressbook_add_contact(name, address, NULL, NULL);
}
g_free(address);
}
GtkWidget *combo;
GtkWidget *entry;
- GList *combo_list = NULL;
gchar **string;
const gchar *header = NULL;
ComposeHeaderEntry *headerentry;
gboolean standard_header = FALSE;
-
+
headerentry = g_new0(ComposeHeaderEntry, 1);
/* Combo box */
- combo = gtk_combo_new();
+ combo = gtk_combo_box_entry_new_text();
string = headers;
while(*string != NULL) {
- combo_list = g_list_append(combo_list, (gchar*)prefs_common_translated_header_name(*string));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
+ (gchar*)prefs_common_translated_header_name(*string));
string++;
}
- gtk_combo_set_popdown_strings(GTK_COMBO(combo), combo_list);
- g_list_free(combo_list);
- gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry), TRUE);
- g_signal_connect(G_OBJECT(GTK_COMBO(combo)->entry), "grab_focus",
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
+ g_signal_connect(G_OBJECT(GTK_BIN(combo)->child), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
gtk_widget_show(combo);
gtk_table_attach(GTK_TABLE(compose->header_table), combo, 0, 1,
GTK_SHRINK, GTK_FILL, 0, 0);
if (compose->header_last) {
const gchar *last_header_entry = gtk_entry_get_text(
- GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
+ GTK_ENTRY(GTK_BIN(compose->header_last->combo)->child));
string = headers;
while (*string != NULL) {
if (!strcmp(*string, last_header_entry))
string++;
}
if (standard_header)
- header = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
+ header = gtk_entry_get_text(GTK_ENTRY(GTK_BIN(compose->header_last->combo)->child));
}
if (!compose->header_last || !standard_header) {
switch(compose->account->protocol) {
}
}
if (header)
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), header);
+ gtk_entry_set_text(GTK_ENTRY(GTK_BIN(combo)->child), header);
- g_signal_connect_after(G_OBJECT(GTK_COMBO(combo)->entry), "grab_focus",
+ g_signal_connect_after(G_OBJECT(GTK_BIN(combo)->child), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
/* Entry field */
last_header = compose->header_last;
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(last_header->combo)->entry), header);
+ gtk_entry_set_text(GTK_ENTRY(GTK_BIN(last_header->combo)->child), header);
gtk_entry_set_text(GTK_ENTRY(last_header->entry), text);
}
gtk_widget_show(header_table);
gtk_container_set_border_width(GTK_CONTAINER(header_table), BORDER_WIDTH);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(header_scrolledwin), header_table);
- gtk_viewport_set_shadow_type(GTK_VIEWPORT(GTK_BIN(header_scrolledwin)->child), GTK_SHADOW_ETCHED_IN);
+ gtk_viewport_set_shadow_type(GTK_VIEWPORT(GTK_BIN(header_scrolledwin)->child), GTK_SHADOW_NONE);
count = 0;
/* option menu for selecting accounts */
FolderItem *dest;
gchar * path;
- dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
+ dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE);
if (!dest) return;
path = folder_item_get_identifier(dest);
Compose *compose)
{
gint prev_autowrap;
- GtkTextBuffer *buffer;
+ GtkTextBuffer *buffer = GTK_TEXT_VIEW(text)->buffer;
#if USE_ASPELL
if (event->button == 3) {
GtkTextIter iter;
gint x, y;
/* move the cursor to allow GtkAspell to check the word
* under the mouse */
- gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text),
- GTK_TEXT_WINDOW_TEXT, event->x, event->y,
- &x, &y);
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text),
- &iter, x, y);
+ if (event->x && event->y) {
+ gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text),
+ GTK_TEXT_WINDOW_TEXT, event->x, event->y,
+ &x, &y);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text),
+ &iter, x, y);
+ } else {
+ GtkTextMark *mark = gtk_text_buffer_get_insert(buffer);
+ gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
+ }
/* get selection */
stuff_selected = gtk_text_buffer_get_selection_bounds(
- GTK_TEXT_VIEW(text)->buffer,
+ buffer,
&sel_start, &sel_end);
- gtk_text_buffer_place_cursor (GTK_TEXT_VIEW(text)->buffer, &iter);
+ gtk_text_buffer_place_cursor (buffer, &iter);
/* reselect stuff */
if (stuff_selected
&& gtk_text_iter_in_range(&iter, &sel_start, &sel_end)) {
- gtk_text_buffer_select_range(GTK_TEXT_VIEW(text)->buffer,
+ gtk_text_buffer_select_range(buffer,
&sel_start, &sel_end);
}
return FALSE; /* pass the event so that the right-click goes through */
event.button = 3;
event.time = gtk_get_current_event_time();
+ event.x = 0;
+ event.y = 0;
return text_clicked(compose->text, &event, compose);
}
GtkWidget *handlebox;
GtkWidget *notebook;
+
+ GtkWidget *attach_hbox;
+ GtkWidget *attach_lab1;
+ GtkWidget *attach_lab2;
GtkWidget *vbox2;
compose_create_header(compose),
gtk_label_new_with_mnemonic(_("Hea_der")));
/* attachment list */
+ attach_hbox = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(attach_hbox);
+
+ attach_lab1 = gtk_label_new_with_mnemonic(_("_Attachments"));
+ gtk_widget_show(attach_lab1);
+ gtk_box_pack_start(GTK_BOX(attach_hbox), attach_lab1, TRUE, TRUE, 0);
+
+ attach_lab2 = gtk_label_new("");
+ gtk_widget_show(attach_lab2);
+ gtk_box_pack_start(GTK_BOX(attach_hbox), attach_lab2, FALSE, FALSE, 0);
+
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
compose_create_attach(compose),
- gtk_label_new_with_mnemonic(_("_Attachments")));
+ attach_hbox);
/* Others Tab */
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
compose_create_others(compose),
compose->paned = paned;
+ compose->attach_label = attach_lab2;
+
compose->notebook = notebook;
compose->edit_vbox = edit_vbox;
compose->ruler_hbox = ruler_hbox;
menu_set_sensitive(ifactory, "/Options/Reply mode", compose->mode == COMPOSE_REPLY);
if (account->protocol != A_NNTP)
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry),
+ gtk_entry_set_text(GTK_ENTRY(GTK_BIN(compose->header_last->combo)->child),
prefs_common_translated_header_name("To:"));
else
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry),
+ gtk_entry_set_text(GTK_ENTRY(GTK_BIN(compose->header_last->combo)->child),
prefs_common_translated_header_name("Newsgroups:"));
addressbook_set_target_compose(compose);
if (compose->privacy_system != NULL) {
gchar *systemid;
-
menuitem = gtk_item_factory_get_widget(ifactory, branch_path);
g_return_if_fail(menuitem != NULL);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
if (warn && !found && strlen(compose->privacy_system)) {
- gchar *tmp = g_strdup_printf(
- _("The privacy system '%s' cannot be loaded. You "
+ alertpanel_warning(_("The privacy system '%s' cannot be loaded. You "
"will not be able to sign or encrypt this message."),
compose->privacy_system);
- alertpanel_warning(tmp);
- g_free(tmp);
}
}
/* process the other fields */
compose_template_apply_fields(compose, tmpl);
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
compose_changed_cb(NULL, compose);
}
msginfo = dummyinfo;
}
+ if (tmpl->from && *tmpl->from != '\0') {
+#ifdef USE_ASPELL
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmpl->from);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL) {
+ alertpanel_error(_("Template From format error."));
+ } else {
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ }
+ }
+
if (tmpl->to && *tmpl->to != '\0') {
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#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,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#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,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#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,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(tmpl->subject);
quote_fmt_parse();
g_free(ainfo);
}
+static void compose_attach_update_label(Compose *compose)
+{
+ GtkTreeIter iter;
+ gint i = 1;
+ gchar *text;
+ GtkTreeModel *model;
+
+ if(compose == NULL)
+ return;
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(compose->attach_clist));
+ if(!gtk_tree_model_get_iter_first(model, &iter)) {
+ gtk_label_set_text(GTK_LABEL(compose->attach_label), "");
+ return;
+ }
+
+ while(gtk_tree_model_iter_next(model, &iter))
+ i++;
+
+ text = g_strdup_printf("(%d)", i);
+ gtk_label_set_text(GTK_LABEL(compose->attach_label), text);
+ g_free(text);
+}
+
static void compose_attach_remove_selected(Compose *compose)
{
GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist);
}
g_list_free(sel);
+ compose_attach_update_label(compose);
}
static struct _AttachProperty
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, (0 + 1),
GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- mimetype_entry = gtk_combo_new();
+ mimetype_entry = gtk_combo_box_entry_new_text();
gtk_table_attach(GTK_TABLE(table), mimetype_entry, 1, 2, 0, (0 + 1),
GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
(GCompareFunc)strcmp2);
}
- gtk_combo_set_popdown_strings(GTK_COMBO(mimetype_entry), strlist);
-
for (mime_type_list = strlist; mime_type_list != NULL;
- mime_type_list = mime_type_list->next)
+ mime_type_list = mime_type_list->next) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(mimetype_entry), mime_type_list->data);
g_free(mime_type_list->data);
+ }
g_list_free(strlist);
-
- mimetype_entry = GTK_COMBO(mimetype_entry)->entry;
+ gtk_combo_box_set_active(GTK_COMBO_BOX(mimetype_entry), 0);
+ mimetype_entry = GTK_BIN(mimetype_entry)->child;
label = gtk_label_new(_("Encoding"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
if (setpgid(0, getppid()))
perror("setpgid");
- if (prefs_common.ext_editor_cmd &&
- (p = strchr(prefs_common.ext_editor_cmd, '%')) &&
+ if (prefs_common_get_ext_editor_cmd() &&
+ (p = strchr(prefs_common_get_ext_editor_cmd(), '%')) &&
*(p + 1) == 's' && !strchr(p + 2, '%')) {
- g_snprintf(buf, sizeof(buf), prefs_common.ext_editor_cmd, file);
+ g_snprintf(buf, sizeof(buf), prefs_common_get_ext_editor_cmd(), file);
} else {
- if (prefs_common.ext_editor_cmd)
+ if (prefs_common_get_ext_editor_cmd())
g_warning("External editor command line is invalid: '%s'\n",
- prefs_common.ext_editor_cmd);
+ prefs_common_get_ext_editor_cmd());
g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, file);
}
compose_insert_file(compose, compose->exteditor_file);
compose_changed_cb(NULL, compose);
- if (g_unlink(compose->exteditor_file) < 0)
+ if (claws_unlink(compose->exteditor_file) < 0)
FILE_OP_ERROR(compose->exteditor_file, "unlink");
} else if (buf[0] == '1') { /* failed */
g_warning("Couldn't exec external editor\n");
- if (g_unlink(compose->exteditor_file) < 0)
+ if (claws_unlink(compose->exteditor_file) < 0)
FILE_OP_ERROR(compose->exteditor_file, "unlink");
} else if (buf[0] == '2') {
g_warning("Couldn't write to file\n");
MsgInfo *newmsginfo;
FILE *fp;
gboolean target_locked = FALSE;
-
+ gboolean err = FALSE;
+
if (lock) return FALSE;
if (compose->sending)
G_DIR_SEPARATOR, compose);
if ((fp = g_fopen(tmp, "wb")) == NULL) {
FILE_OP_ERROR(tmp, "fopen");
- goto unlock;
+ goto warn_err;
}
/* chmod for security */
}
/* Save draft infos */
- fprintf(fp, "X-Claws-Account-Id:%d\n", compose->account->account_id);
- fprintf(fp, "S:%s\n", compose->account->address);
+ err |= (fprintf(fp, "X-Claws-Account-Id:%d\n", compose->account->account_id) < 0);
+ err |= (fprintf(fp, "S:%s\n", compose->account->address) < 0);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn))) {
gchar *savefolderid;
savefolderid = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
- fprintf(fp, "SCF:%s\n", savefolderid);
+ err |= (fprintf(fp, "SCF:%s\n", savefolderid) < 0);
g_free(savefolderid);
}
if (compose->return_receipt) {
- fprintf(fp, "RRCPT:1\n");
+ err |= (fprintf(fp, "RRCPT:1\n") < 0);
}
if (compose->privacy_system) {
- fprintf(fp, "X-Claws-Sign:%d\n", compose->use_signing);
- fprintf(fp, "X-Claws-Encrypt:%d\n", compose->use_encryption);
- fprintf(fp, "X-Claws-Privacy-System:%s\n", compose->privacy_system);
+ err |= (fprintf(fp, "X-Claws-Sign:%d\n", compose->use_signing) < 0);
+ err |= (fprintf(fp, "X-Claws-Encrypt:%d\n", compose->use_encryption) < 0);
+ err |= (fprintf(fp, "X-Claws-Privacy-System:%s\n", compose->privacy_system) < 0);
}
/* Message-ID of message replying to */
gchar *folderid;
folderid = folder_item_get_identifier(compose->replyinfo->folder);
- fprintf(fp, "RMID:%s\t%d\t%s\n", folderid, compose->replyinfo->msgnum, compose->replyinfo->msgid);
+ err |= (fprintf(fp, "RMID:%s\t%d\t%s\n", folderid, compose->replyinfo->msgnum, compose->replyinfo->msgid) < 0);
g_free(folderid);
}
/* Message-ID of message forwarding to */
gchar *folderid;
folderid = folder_item_get_identifier(compose->fwdinfo->folder);
- fprintf(fp, "FMID:%s\t%d\t%s\n", folderid, compose->fwdinfo->msgnum, compose->fwdinfo->msgid);
+ err |= (fprintf(fp, "FMID:%s\t%d\t%s\n", folderid, compose->fwdinfo->msgnum, compose->fwdinfo->msgid) < 0);
g_free(folderid);
}
/* end of headers */
- fprintf(fp, "X-Claws-End-Special-Headers: 1\n");
+ err |= (fprintf(fp, "X-Claws-End-Special-Headers: 1\n") < 0);
+
+ if (err) {
+ fclose(fp);
+ goto warn_err;
+ }
if (compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_STORE, action != COMPOSE_AUTO_SAVE) < 0) {
fclose(fp);
- g_unlink(tmp);
- g_free(tmp);
- goto unlock;
+ goto warn_err;
+ }
+ if (fclose(fp) == EOF) {
+ goto warn_err;
}
- fclose(fp);
if (compose->targetinfo) {
target_locked = MSG_IS_LOCKED(compose->targetinfo->flags);
debug_print("got draft msgnum %d from adding\n", msgnum);
}
if (msgnum < 0) {
- g_unlink(tmp);
+warn_err:
+ claws_unlink(tmp);
g_free(tmp);
if (action != COMPOSE_AUTO_SAVE) {
if (action != COMPOSE_DRAFT_FOR_EXIT)
gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
DRAFTED_AT_EXIT, NULL);
if (is_file_exist(filepath))
- g_unlink(filepath);
+ claws_unlink(filepath);
g_free(filepath);
}
compose_draft(data, action);
}
-static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data)
{
- Compose *compose = (Compose *)data;
- GList *file_list;
-
- if (compose->redirect_filename != NULL)
- return;
-
- file_list = filesel_select_multiple_files_open(_("Select file"));
-
- if (file_list) {
+ if (compose && file_list) {
GList *tmp;
for ( tmp = file_list; tmp; tmp = tmp->next) {
gchar *utf8_filename = conv_filename_to_utf8(file);
compose_attach_append(compose, file, utf8_filename, NULL);
compose_changed_cb(NULL, compose);
+ if (free_data) {
g_free(file);
+ tmp->data = NULL;
+ }
g_free(utf8_filename);
}
+ }
+}
+
+static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+{
+ Compose *compose = (Compose *)data;
+ GList *file_list;
+
+ if (compose->redirect_filename != NULL)
+ return;
+
+ file_list = filesel_select_multiple_files_open(_("Select file"));
+
+ if (file_list) {
+ compose_attach_from_list(compose, file_list, TRUE);
g_list_free(file_list);
- }
+ }
}
static void compose_insert_file_cb(gpointer data, guint action,
#endif
if (compose->modified) {
+ if (!g_mutex_trylock(compose->mutex)) {
+ /* we don't want to lock the mutex once it's available,
+ * because as the only other part of compose.c locking
+ * it is compose_close - which means once unlocked,
+ * the compose struct will be freed */
+ debug_print("couldn't lock mutex, probably sending\n");
+ return;
+ }
val = alertpanel(_("Discard message"),
_("This message has been modified. Discard it?"),
_("_Discard"), _("_Save to Drafts"), GTK_STOCK_CANCEL);
-
+ g_mutex_unlock(compose->mutex);
switch (val) {
case G_ALERTDEFAULT:
if (prefs_common.autosave)
}
} else if (GTK_IS_EDITABLE(entry))
gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
-
+
+ compose->modified = TRUE;
}
static void entry_allsel(GtkWidget *entry)
GtkTextBuffer *buffer;
GtkTextMark *mark;
GtkTextIter ins, start_iter, end_iter;
- gboolean found;
g_return_if_fail(GTK_IS_TEXT_VIEW(text));
gtk_text_iter_set_line_offset(&start_iter, 0);
end_iter = ins;
- if (gtk_text_iter_ends_line(&end_iter))
- found = gtk_text_iter_forward_char(&end_iter);
- else
- found = gtk_text_iter_forward_to_line_end(&end_iter);
-
- if (found)
- gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
+ if (gtk_text_iter_ends_line(&end_iter)){
+ if (!gtk_text_iter_forward_char(&end_iter))
+ gtk_text_iter_backward_char(&start_iter);
+ }
+ else
+ gtk_text_iter_forward_to_line_end(&end_iter);
+ gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
}
static void textview_delete_to_line_end (GtkTextView *text)
GtkTextBuffer *buffer;
GtkTextMark *mark;
GtkTextIter ins, end_iter;
- gboolean found;
g_return_if_fail(GTK_IS_TEXT_VIEW(text));
gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
end_iter = ins;
if (gtk_text_iter_ends_line(&end_iter))
- found = gtk_text_iter_forward_char(&end_iter);
+ gtk_text_iter_forward_char(&end_iter);
else
- found = gtk_text_iter_forward_to_line_end(&end_iter);
- if (found)
- gtk_text_buffer_delete(buffer, &ins, &end_iter);
+ gtk_text_iter_forward_to_line_end(&end_iter);
+ gtk_text_buffer_delete(buffer, &ins, &end_iter);
}
static void compose_advanced_action_cb(Compose *compose,
{textview_delete_forward_word},
{textview_delete_backward_word},
{textview_delete_line},
- {NULL}, /* gtk_stext_delete_line_n */
{textview_delete_to_line_end}
};
if (gdk_atom_name(data->type) && !strcmp(gdk_atom_name(data->type), "text/uri-list")) {
AlertValue val = G_ALERTDEFAULT;
+ list = uri_list_extract_filenames((const gchar *)data->data);
+
+ if (list == NULL && strstr((gchar *)(data->data), "://")) {
+ /* Assume a list of no files, and data has ://, is a remote link */
+ gchar *tmpdata = g_strstrip(g_strdup((const gchar *)data->data));
+ gchar *tmpfile = get_tmp_file();
+ str_write_to_file(tmpdata, tmpfile);
+ g_free(tmpdata);
+ compose_insert_file(compose, tmpfile);
+ claws_unlink(tmpfile);
+ g_free(tmpfile);
+ gtk_drag_finish(drag_context, TRUE, FALSE, time);
+ compose_beautify_paragraph(compose, NULL, TRUE);
+ return;
+ }
switch (prefs_common.compose_dnd_mode) {
case COMPOSE_DND_ASK:
val = alertpanel_full(_("Insert or attach?"),
if (val == G_ALERTDEFAULT || val == G_ALERTCANCEL) {
gtk_drag_finish(drag_context, FALSE, FALSE, time);
+ list_free_strings(list);
+ g_list_free(list);
return;
} else if (val == G_ALERTOTHER) {
compose_attach_drag_received_cb(widget, drag_context, x, y, data, info, time, user_data);
+ list_free_strings(list);
+ g_list_free(list);
return;
}
- list = uri_list_extract_filenames((const gchar *)data->data);
+
for (tmp = list; tmp != NULL; tmp = tmp->next) {
compose_insert_file(compose, (const gchar *)tmp->data);
}
gchar *tmpfile = get_tmp_file();
str_write_to_file((const gchar *)data->data, tmpfile);
compose_insert_file(compose, tmpfile);
- g_unlink(tmpfile);
+ claws_unlink(tmpfile);
g_free(tmpfile);
gtk_drag_finish(drag_context, TRUE, FALSE, time);
#endif
vadj = gtk_viewport_get_vadjustment(GTK_VIEWPORT(compose->header_table->parent));
gtk_adjustment_set_value(vadj, (show_first ? vadj->lower : vadj->upper));
+ gtk_adjustment_changed(vadj);
}
static void text_inserted(GtkTextBuffer *buffer, GtkTextIter *iter,
if (paste_as_quotation) {
gchar *new_text;
const gchar *qmark;
+ guint pos = 0;
+ GtkTextIter start_iter;
if (len < 0)
len = strlen(text);
mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
gtk_text_buffer_place_cursor(buffer, iter);
+ pos = gtk_text_iter_get_offset(iter);
+
compose_quote_fmt(compose, NULL, "%Q", qmark, new_text, TRUE, FALSE,
_("Quote format error at line %d."));
quote_fmt_reset_vartable();
gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
gtk_text_buffer_place_cursor(buffer, iter);
+ gtk_text_buffer_delete_mark(buffer, mark);
+
+ gtk_text_buffer_get_iter_at_offset(buffer, &start_iter, pos);
+ mark = gtk_text_buffer_create_mark(buffer, NULL, &start_iter, FALSE);
+ compose_beautify_paragraph(compose, &start_iter, FALSE);
+ gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
+ gtk_text_buffer_delete_mark(buffer, mark);
} else {
if (strcmp(text, "\n") || compose->automatic_break
|| gtk_text_iter_starts_line(iter))
gtk_text_buffer_insert(buffer, iter, text, len);
else {
- debug_print("insert nowrap \\n\n");
- gtk_text_buffer_insert_with_tags_by_name(buffer,
- iter, text, len, "no_join", NULL);
+ /* check if the preceding is just whitespace or quote */
+ GtkTextIter start_line;
+ gchar *tmp = NULL, *quote = NULL;
+ gint quote_len = 0, is_normal = 0;
+ start_line = *iter;
+ gtk_text_iter_set_line_offset(&start_line, 0);
+ tmp = gtk_text_buffer_get_text(buffer, &start_line, iter, FALSE);
+ g_strstrip(tmp);
+ if (*tmp == '\0') {
+ is_normal = 1;
+ } else {
+ quote = compose_get_quote_str(buffer, &start_line, "e_len);
+ if (quote)
+ is_normal = 1;
+ g_free(quote);
+ }
+ g_free(tmp);
+
+ if (is_normal) {
+ gtk_text_buffer_insert(buffer, iter, text, len);
+ } else {
+ gtk_text_buffer_insert_with_tags_by_name(buffer,
+ iter, text, len, "no_join", NULL);
+ }
}
}
- mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
-
- compose_beautify_paragraph(compose, iter, FALSE);
-
- gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
- gtk_text_buffer_delete_mark(buffer, mark);
+ if (!paste_as_quotation) {
+ mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
+ compose_beautify_paragraph(compose, iter, FALSE);
+ gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
+ gtk_text_buffer_delete_mark(buffer, mark);
+ }
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
G_CALLBACK(text_inserted),
gchar *to;
Xstrdup_a(to, msginfo->to, return NULL);
extract_address(to);
- account = account_find_from_address(to);
+ account = account_find_from_address(to, FALSE);
}
if (!account && prefs_common.forward_account_autosel) {
(msginfo, cc,sizeof cc , "Cc:")) {
gchar *buf = cc + strlen("Cc:");
extract_address(buf);
- account = account_find_from_address(buf);
+ account = account_find_from_address(buf, FALSE);
}
}
(msginfo, deliveredto,sizeof deliveredto , "Delivered-To:")) {
gchar *buf = deliveredto + strlen("Delivered-To:");
extract_address(buf);
- account = account_find_from_address(buf);
+ account = account_find_from_address(buf, FALSE);
}
}
} else
compose = compose_reply_mode((ComposeMode)action, msginfo_list, body);
- if (originally_enc) {
+ if (compose && originally_enc) {
compose_force_encryption(compose, compose->account, FALSE);
}
for (list = compose->header_list; list; list = list->next) {
gchar *header = gtk_editable_get_chars(
GTK_EDITABLE(
- GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry), 0, -1);
+ GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
gchar *entry = gtk_editable_get_chars(
GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);