#include "hooks.h"
#include "privacy.h"
#include "timing.h"
+#include "autofaces.h"
enum
{
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)},
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;
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_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);
} else {
qmark = prefs_common.quotemark;
- body_fmt = prefs_common.quotefmt;
+ body_fmt = gettext(prefs_common.quotefmt);
}
}
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();
}
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);
g_free(msgfile);
} else {
const gchar *qmark = NULL;
- const gchar *body_fmt = prefs_common.fw_quotefmt;
+ const gchar *body_fmt = gettext(prefs_common.fw_quotefmt);
MsgInfo *full_msginfo;
full_msginfo = procmsg_msginfo_get_full_info(msginfo);
} else {
qmark = prefs_common.fw_quotemark;
- body_fmt = prefs_common.fw_quotefmt;
+ body_fmt = gettext(prefs_common.fw_quotefmt);
}
/* empty quotemark is not allowed */
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 = 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);
}
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) {
}
}
-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;
}
cursor_pos = quote_fmt_get_cursor_pos();
+ if (cursor_pos == -1)
+ cursor_pos = gtk_text_iter_get_offset(&iter);
compose->set_cursor_pos = cursor_pos;
- if (cursor_pos == -1) {
- cursor_pos = 0;
- }
+
gtk_text_buffer_get_start_iter(buffer, &iter);
gtk_text_buffer_get_iter_at_offset(buffer, &iter, cursor_pos);
gtk_text_buffer_place_cursor(buffer, &iter);
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,
GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
GtkTextMark *mark;
GtkTextIter iter, iter_end;
- gint cur_pos;
+ gint cur_pos, ins_pos;
gboolean prev_autowrap;
gboolean found = FALSE;
gboolean exists = FALSE;
mark = gtk_text_buffer_get_insert(buffer);
gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
cur_pos = gtk_text_iter_get_offset (&iter);
+ ins_pos = cur_pos;
gtk_text_buffer_get_end_iter(buffer, &iter);
if (found) {
/* include previous \n\n */
- gtk_text_iter_backward_chars(&first_iter, 2);
+ gtk_text_iter_backward_chars(&first_iter, 1);
start_iter = first_iter;
end_iter = first_iter;
/* skip re-start */
g_free(compose->sig_str);
compose->sig_str = NULL;
} else {
+ if (compose->sig_inserted == FALSE)
+ gtk_text_buffer_insert(buffer, &iter, "\n", -1);
+ compose->sig_inserted = TRUE;
+
+ cur_pos = gtk_text_iter_get_offset(&iter);
gtk_text_buffer_insert(buffer, &iter, compose->sig_str, -1);
/* remove \n\n */
gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
- gtk_text_iter_forward_chars(&iter, 2);
+ gtk_text_iter_forward_chars(&iter, 1);
gtk_text_buffer_get_end_iter(buffer, &iter_end);
gtk_text_buffer_apply_tag_by_name(buffer,"signature",&iter, &iter_end);
if (cur_pos > gtk_text_buffer_get_char_count (buffer))
cur_pos = gtk_text_buffer_get_char_count (buffer);
}
+
/* put the cursor where it should be
- * either where the quote_fmt says, either before the signature */
+ * either where the quote_fmt says, either where it was */
if (compose->set_cursor_pos < 0)
- gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
+ gtk_text_buffer_get_iter_at_offset(buffer, &iter, ins_pos);
else
gtk_text_buffer_get_iter_at_offset(buffer, &iter,
compose->set_cursor_pos);
}
if (compose->account->sig_sep) {
- sig_str = g_strconcat("\n\n", compose->account->sig_sep, "\n", sig_body,
+ sig_str = g_strconcat("\n", compose->account->sig_sep, "\n", sig_body,
NULL);
g_free(sig_body);
} else
- sig_str = g_strconcat("\n\n", sig_body, NULL);
+ sig_str = g_strconcat("\n", sig_body, NULL);
if (sig_str) {
if (g_utf8_validate(sig_str, -1, NULL) == TRUE)
ainfo->content_type = g_strdup("application/octet-stream");
}
- ainfo->size = size;
- size_text = to_human_readable(size);
+ ainfo->size = (goffset)size;
+ size_text = to_human_readable((goffset)size);
store = GTK_LIST_STORE(gtk_tree_view_get_model
(GTK_TREE_VIEW(compose->attach_clist)));
-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);
subject = gtk_editable_get_chars(
GTK_EDITABLE(compose->subject_entry), 0, -1);
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
if (subject && strlen(subject))
str = g_strdup_printf(_("%s - Compose message%s"),
subject, edited);
gchar *entry;
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))) {
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->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;
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->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;
button_label = _("+_Send");
else
button_label = _("+_Queue");
- message = g_strdup_printf(_("Subject is empty. %s it anyway?"),
- compose->sending?_("Send"):_("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);
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 {
g_snprintf(buf, sizeof(buf), "%s", "");
}
- generate_msgid(buf, sizeof(buf));
- err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
- compose->msgid = g_strdup(buf);
+
+ if (compose->account->gen_msgid) {
+ generate_msgid(buf, sizeof(buf));
+ err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
+ compose->msgid = g_strdup(buf);
+ } else {
+ compose->msgid = NULL;
+ }
if (compose_redirect_write_headers_from_headerlist(compose, fp))
return -1;
gchar *chars;
gchar *buf;
const gchar *out_codeset;
- EncodingType encoding;
+ EncodingType encoding = ENC_UNKNOWN;
MimeInfo *mimemsg, *mimetext;
gint line;
+ const gchar *src_codeset = CS_INTERNAL;
if (action == COMPOSE_WRITE_FOR_SEND)
attach_parts = TRUE;
gtk_text_buffer_get_start_iter(buffer, &start);
gtk_text_buffer_get_end_iter(buffer, &end);
chars = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
- if (is_ascii_str(chars)) {
- buf = chars;
- chars = NULL;
+
+ out_codeset = conv_get_charset_str(compose->out_encoding);
+
+ if (!out_codeset && is_ascii_str(chars)) {
+ out_codeset = CS_US_ASCII;
+ } else if (prefs_common.outgoing_fallback_to_ascii &&
+ is_ascii_str(chars)) {
out_codeset = CS_US_ASCII;
encoding = ENC_7BIT;
- } else {
- const gchar *src_codeset = CS_INTERNAL;
+ }
- out_codeset = conv_get_charset_str(compose->out_encoding);
+ if (!out_codeset) {
+ gchar *test_conv_global_out = NULL;
+ gchar *test_conv_reply = NULL;
- if (!out_codeset) {
- gchar *test_conv_global_out = NULL;
- gchar *test_conv_reply = NULL;
+ /* automatic mode. be automatic. */
+ codeconv_set_strict(TRUE);
- /* automatic mode. be automatic. */
- codeconv_set_strict(TRUE);
-
- out_codeset = conv_get_outgoing_charset_str();
- if (out_codeset) {
- debug_print("trying to convert to %s\n", out_codeset);
- test_conv_global_out = conv_codeset_strdup(chars, src_codeset, out_codeset);
- }
-
- if (!test_conv_global_out && compose->orig_charset
- && strcmp(compose->orig_charset, CS_US_ASCII)) {
- out_codeset = compose->orig_charset;
- debug_print("failure; trying to convert to %s\n", out_codeset);
- test_conv_reply = conv_codeset_strdup(chars, src_codeset, out_codeset);
- }
-
- if (!test_conv_global_out && !test_conv_reply) {
- /* we're lost */
- out_codeset = CS_INTERNAL;
- debug_print("failure; finally using %s\n", out_codeset);
- }
- g_free(test_conv_global_out);
- g_free(test_conv_reply);
- codeconv_set_strict(FALSE);
+ out_codeset = conv_get_outgoing_charset_str();
+ if (out_codeset) {
+ debug_print("trying to convert to %s\n", out_codeset);
+ test_conv_global_out = conv_codeset_strdup(chars, src_codeset, out_codeset);
}
- if (!g_ascii_strcasecmp(out_codeset, CS_US_ASCII))
- out_codeset = CS_ISO_8859_1;
+ if (!test_conv_global_out && compose->orig_charset
+ && strcmp(compose->orig_charset, CS_US_ASCII)) {
+ out_codeset = compose->orig_charset;
+ debug_print("failure; trying to convert to %s\n", out_codeset);
+ test_conv_reply = conv_codeset_strdup(chars, src_codeset, out_codeset);
+ }
+ if (!test_conv_global_out && !test_conv_reply) {
+ /* we're lost */
+ out_codeset = CS_INTERNAL;
+ debug_print("failure; finally using %s\n", out_codeset);
+ }
+ g_free(test_conv_global_out);
+ g_free(test_conv_reply);
+ codeconv_set_strict(FALSE);
+ }
+
+ if (encoding == ENC_UNKNOWN) {
if (prefs_common.encoding_method == CTE_BASE64)
encoding = ENC_BASE64;
else if (prefs_common.encoding_method == CTE_QUOTED_PRINTABLE)
encoding = ENC_8BIT;
else
encoding = procmime_get_encoding_for_charset(out_codeset);
+ }
- debug_print("src encoding = %s, out encoding = %s, transfer encoding = %s\n",
- src_codeset, out_codeset, procmime_get_encoding_str(encoding));
-
- if (action == COMPOSE_WRITE_FOR_SEND) {
- codeconv_set_strict(TRUE);
- buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
- codeconv_set_strict(FALSE);
-
- if (!buf) {
- AlertValue aval;
- gchar *msg;
+ debug_print("src encoding = %s, out encoding = %s, transfer encoding = %s\n",
+ src_codeset, out_codeset, procmime_get_encoding_str(encoding));
- msg = g_strdup_printf(_("Can't convert the character encoding of the message \n"
- "to the specified %s charset.\n"
- "Send it as %s?"), out_codeset, src_codeset);
- aval = alertpanel_full(_("Error"), msg, GTK_STOCK_CANCEL, _("+_Send"), NULL, FALSE,
- NULL, ALERT_ERROR, G_ALERTDEFAULT);
- g_free(msg);
+ if (action == COMPOSE_WRITE_FOR_SEND) {
+ codeconv_set_strict(TRUE);
+ buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
+ codeconv_set_strict(FALSE);
- if (aval != G_ALERTALTERNATE) {
- g_free(chars);
- return -3;
- } else {
- buf = chars;
- out_codeset = src_codeset;
- chars = NULL;
- }
+ if (!buf) {
+ AlertValue aval;
+ gchar *msg;
+
+ msg = g_strdup_printf(_("Can't convert the character encoding of the message \n"
+ "to the specified %s charset.\n"
+ "Send it as %s?"), out_codeset, src_codeset);
+ aval = alertpanel_full(_("Error"), msg, GTK_STOCK_CANCEL, _("+_Send"), NULL, FALSE,
+ NULL, ALERT_ERROR, G_ALERTDEFAULT);
+ g_free(msg);
+
+ if (aval != G_ALERTALTERNATE) {
+ g_free(chars);
+ return -3;
+ } else {
+ buf = chars;
+ out_codeset = src_codeset;
+ chars = NULL;
}
- } else {
- buf = chars;
- out_codeset = src_codeset;
- chars = NULL;
}
+ } else {
+ buf = chars;
+ out_codeset = src_codeset;
+ chars = NULL;
}
g_free(chars);
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;
if (!compose_warn_encryption(compose)) {
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -6;
}
* key selection */
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -5;
}
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);
- g_unlink(tmp);
+ 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;
} else {
g_snprintf(buf, sizeof(buf), "%s", "");
}
- generate_msgid(buf, sizeof(buf));
- g_string_append_printf(header, "Message-ID: <%s>\n", buf);
- compose->msgid = g_strdup(buf);
+
+ 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) {
/* In-Reply-To */
}
}
+ /* Automatic Faces and X-Faces */
+ if (get_account_xface (buf, sizeof(buf), compose->account->account_name) == 0) {
+ g_string_append_printf(header, "X-Face: %s\n", buf);
+ }
+ else if (get_default_xface (buf, sizeof(buf)) == 0) {
+ g_string_append_printf(header, "X-Face: %s\n", buf);
+ }
+ if (get_account_face (buf, sizeof(buf), compose->account->account_name) == 0) {
+ g_string_append_printf(header, "Face: %s\n", buf);
+ }
+ else if (get_default_face (buf, sizeof(buf)) == 0) {
+ g_string_append_printf(header, "Face: %s\n", buf);
+ }
+
/* PRIORITY */
switch (compose->priority) {
case PRIORITY_HIGHEST: g_string_append_printf(header, "Importance: high\n"
gboolean standard_header = FALSE;
headerentry = ((ComposeHeaderEntry *)list->data);
-
+
tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(headerentry->combo)->child)));
- if (strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
+ 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);
}
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);
}
gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL,
&geometry, GDK_HINT_MIN_SIZE);
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
if (compose_force_window_origin)
gtk_widget_set_uposition(window, prefs_common.compose_x,
prefs_common.compose_y);
if (compose->privacy_system != NULL) {
gchar *systemid;
-
menuitem = gtk_item_factory_get_widget(ifactory, branch_path);
g_return_if_fail(menuitem != NULL);
/* 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();
ainfo->file = file;
}
if (size)
- ainfo->size = size;
+ ainfo->size = (goffset)size;
/* update tree store */
text = to_human_readable(ainfo->size);
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");
}
if (msgnum < 0) {
warn_err:
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
if (action != COMPOSE_AUTO_SAVE) {
if (action != COMPOSE_DRAFT_FOR_EXIT)
procmsg_msginfo_free(compose->targetinfo);
compose->targetinfo = procmsg_msginfo_new();
compose->targetinfo->msgnum = msgnum;
- compose->targetinfo->size = s.st_size;
+ compose->targetinfo->size = (goffset)s.st_size;
compose->targetinfo->mtime = s.st_mtime;
compose->targetinfo->folder = draft;
if (target_locked)
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);
}
-
- compose_attach_update_label(compose);
}
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)
static void compose_cut_cb(Compose *compose)
{
if (compose->focused_editable
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
&& GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
#endif
)
static void compose_copy_cb(Compose *compose)
{
if (compose->focused_editable
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
&& GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
#endif
)
{
gint wrap_quote = prefs_common.linewrap_quote;
if (compose->focused_editable
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
&& GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
#endif
) {
GtkTextBuffer *buffer;
BLOCK_WRAP();
if (compose->focused_editable
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
&& GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
#endif
)
GtkTextBuffer *buffer;
BLOCK_WRAP();
if (compose->focused_editable
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
&& GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
#endif
)
static void compose_allsel_cb(Compose *compose)
{
if (compose->focused_editable
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
&& GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
#endif
)
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 (GTK_IS_EDITABLE(widget) || GTK_IS_TEXT_VIEW(widget))
compose->focused_editable = widget;
-#ifdef MAEMO
+#ifdef GENERIC_UMPC
if (GTK_IS_TEXT_VIEW(widget)
&& gtk_paned_get_child1(GTK_PANED(compose->paned)) != compose->edit_vbox) {
gtk_widget_ref(compose->notebook);
static void compose_changed_cb(GtkTextBuffer *textbuf, Compose *compose)
{
compose->modified = TRUE;
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
compose_set_title(compose);
#endif
}
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
|| 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);
+ }
}
}
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);
}
}