COL_MIMETYPE = 0,
COL_SIZE = 1,
COL_NAME = 2,
- COL_DATA = 3,
- COL_AUTODATA = 4,
+ COL_CHARSET = 3,
+ COL_DATA = 4,
+ COL_AUTODATA = 5,
N_COL_COLUMNS
};
static gboolean compose_attach_append (Compose *compose,
const gchar *file,
const gchar *type,
- const gchar *content_type);
+ const gchar *content_type,
+ const gchar *charset);
static void compose_attach_parts (Compose *compose,
MsgInfo *msginfo);
gboolean followup_and_reply_to,
const gchar *body);
-static gboolean compose_headerentry_changed_cb (GtkWidget *entry,
+static void compose_headerentry_changed_cb (GtkWidget *entry,
ComposeHeaderEntry *headerentry);
static gboolean compose_headerentry_key_press_event_cb(GtkWidget *entry,
GdkEventKey *event,
for (i = 0; i < attach_files->len; i++) {
file = g_ptr_array_index(attach_files, i);
- compose_attach_append(compose, file, file, NULL);
+ compose_attach_append(compose, file, file, NULL, NULL);
}
}
GtkTextView *textview;
GtkTextBuffer *textbuf;
GtkTextIter iter;
+ ComposeMode mode;
cm_return_val_if_fail(msginfo != NULL, NULL);
cm_return_val_if_fail(msginfo->folder != NULL, NULL);
(msginfo)))
account = cur_account;
- compose = compose_create(account, msginfo->folder, COMPOSE_FORWARD, batch);
+ if (!prefs_common.forward_as_attachment)
+ mode = COMPOSE_FORWARD_INLINE;
+ else
+ mode = COMPOSE_FORWARD;
+ compose = compose_create(account, msginfo->folder, mode, batch);
compose->updating = TRUE;
compose->fwdinfo = procmsg_msginfo_get_full_info(msginfo);
g_warning("%s: file not exist\n", msgfile);
else
compose_attach_append(compose, msgfile, msgfile,
- "message/rfc822");
+ "message/rfc822", NULL);
g_free(msgfile);
} else {
g_warning("%s: file not exist\n", msgfile);
else
compose_attach_append(compose, msgfile, msgfile,
- "message/rfc822");
+ "message/rfc822", NULL);
g_free(msgfile);
}
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)) {
+ if (compose_attach_append(compose, attach[i], utf8_filename, NULL, NULL)) {
gchar *tmp = g_strdup_printf("%s%s\n",
warn_files?warn_files:"",
utf8_filename);
if (hentry[H_REPLY_TO].body[0] != '\0') {
compose->replyto =
conv_unmime_header(hentry[H_REPLY_TO].body,
- NULL);
+ NULL, TRUE);
}
g_free(hentry[H_REPLY_TO].body);
hentry[H_REPLY_TO].body = NULL;
}
if (hentry[H_CC].body != NULL) {
- compose->cc = conv_unmime_header(hentry[H_CC].body, NULL);
+ compose->cc = conv_unmime_header(hentry[H_CC].body, NULL, TRUE);
g_free(hentry[H_CC].body);
hentry[H_CC].body = NULL;
}
if (hentry[H_BCC].body != NULL) {
if (compose->mode == COMPOSE_REEDIT)
compose->bcc =
- conv_unmime_header(hentry[H_BCC].body, NULL);
+ conv_unmime_header(hentry[H_BCC].body, NULL, TRUE);
g_free(hentry[H_BCC].body);
hentry[H_BCC].body = NULL;
}
if (hentry[H_FOLLOWUP_TO].body[0] != '\0') {
compose->followup_to =
conv_unmime_header(hentry[H_FOLLOWUP_TO].body,
- NULL);
+ NULL, TRUE);
}
g_free(hentry[H_FOLLOWUP_TO].body);
hentry[H_FOLLOWUP_TO].body = NULL;
gtk_text_buffer_get_start_iter(buffer, &iter);
gtk_text_buffer_get_iter_at_offset(buffer, &iter, cursor_pos);
-
- /* Some quotes may not end with new line - when replying with
- * quote from GtkTextBuffer selection for example. Add new
- * line character so cursor is at the beginning of the line */
- if (!gtk_text_iter_starts_line(&iter)) {
- gtk_text_buffer_insert(buffer, &iter, "\n", 1);
- gtk_text_buffer_get_end_iter(buffer, &iter);
- compose->set_cursor_pos = gtk_text_iter_get_offset(&iter);
- }
gtk_text_buffer_place_cursor(buffer, &iter);
compose->autowrap = prev_autowrap;
static gboolean compose_attach_append(Compose *compose, const gchar *file,
const gchar *filename,
- const gchar *content_type)
+ const gchar *content_type,
+ const gchar *charset)
{
AttachInfo *ainfo;
GtkTreeIter iter;
if (file_from_uri && is_file_exist(file_from_uri)) {
result = compose_attach_append(
compose, file_from_uri,
- filename,
- content_type);
+ filename, content_type,
+ charset);
}
g_free(file_from_uri);
if (result)
procmsg_msginfo_free(msginfo);
} else {
- if (!g_ascii_strncasecmp(content_type, "text", 4))
+ if (!g_ascii_strncasecmp(content_type, "text/", 5)) {
+ ainfo->charset = g_strdup(charset);
ainfo->encoding = procmime_get_encoding_for_text_file(file, &has_binary);
- else
+ } else {
ainfo->encoding = ENC_BASE64;
+ }
name = g_path_get_basename(filename ? filename : file);
ainfo->name = g_strdup(name);
}
ainfo->content_type =
g_strdup("application/octet-stream");
ainfo->encoding = ENC_BASE64;
- } else if (!g_ascii_strncasecmp(ainfo->content_type, "text", 4))
+ } else if (!g_ascii_strncasecmp(ainfo->content_type, "text/", 5))
ainfo->encoding =
procmime_get_encoding_for_text_file(file, &has_binary);
else
if (!strcmp(ainfo->content_type, "unknown") || has_binary) {
g_free(ainfo->content_type);
ainfo->content_type = g_strdup("application/octet-stream");
+ g_free(ainfo->charset);
+ ainfo->charset = NULL;
}
ainfo->size = (goffset)size;
COL_MIMETYPE, ainfo->content_type,
COL_SIZE, size_text,
COL_NAME, ainfo->name,
+ COL_CHARSET, ainfo->charset,
COL_DATA, ainfo,
COL_AUTODATA, auto_ainfo,
-1);
if (partname == NULL)
partname = "";
compose_attach_append(compose, outfile,
- partname, content_type);
+ partname, content_type,
+ procmime_mimeinfo_get_parameter(child, "charset"));
} else {
compose_force_signing(compose, compose->account, NULL);
}
if (mimepart->type == MIMETYPE_MESSAGE &&
!g_ascii_strcasecmp(mimepart->subtype, "rfc822")) {
mimepart->disposition = DISPOSITIONTYPE_INLINE;
- } else {
- if (ainfo->name) {
- if (mimepart->type == MIMETYPE_APPLICATION &&
- !strcmp2(mimepart->subtype, "octet-stream"))
- g_hash_table_insert(mimepart->typeparameters,
- g_strdup("name"), g_strdup(ainfo->name));
- g_hash_table_insert(mimepart->dispositionparameters,
- g_strdup("filename"), g_strdup(ainfo->name));
+ } else if (mimepart->type == MIMETYPE_TEXT) {
+ if (!ainfo->name && compose->mode == COMPOSE_FORWARD_INLINE) {
+ /* Text parts with no name come from multipart/alternative
+ * forwards. Make sure the recipient won't look at the
+ * original HTML part by mistake. */
mimepart->disposition = DISPOSITIONTYPE_ATTACHMENT;
+ ainfo->name = g_strdup_printf(_("Original %s part"),
+ mimepart->subtype);
}
- }
-
- if (compose->use_signing) {
+ if (ainfo->charset)
+ g_hash_table_insert(mimepart->typeparameters,
+ g_strdup("charset"), g_strdup(ainfo->charset));
+ }
+ if (ainfo->name && mimepart->type != MIMETYPE_MESSAGE) {
+ if (mimepart->type == MIMETYPE_APPLICATION &&
+ !strcmp2(mimepart->subtype, "octet-stream"))
+ g_hash_table_insert(mimepart->typeparameters,
+ g_strdup("name"), g_strdup(ainfo->name));
+ g_hash_table_insert(mimepart->dispositionparameters,
+ g_strdup("filename"), g_strdup(ainfo->name));
+ mimepart->disposition = DISPOSITIONTYPE_ATTACHMENT;
+ }
+
+ if (mimepart->type == MIMETYPE_MESSAGE
+ || mimepart->type == MIMETYPE_MULTIPART)
+ ainfo->encoding = ENC_BINARY;
+ else if (compose->use_signing) {
if (ainfo->encoding == ENC_7BIT)
ainfo->encoding = ENC_QUOTED_PRINTABLE;
else if (ainfo->encoding == ENC_8BIT)
ainfo->encoding = ENC_BASE64;
}
+
+
procmime_encode_content(mimepart, ainfo->encoding);
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
+ G_TYPE_STRING,
G_TYPE_POINTER,
G_TYPE_AUTO_POINTER,
-1);
titles[COL_MIMETYPE] = _("MIME type");
titles[COL_SIZE] = _("Size");
titles[COL_NAME] = _("Name");
+ titles[COL_CHARSET] = _("Charset");
compose->batch = batch;
compose->account = account;
gtk_widget_set_size_request(scrolledwin, prefs_common.compose_width, -1);
text = gtk_text_view_new();
- gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
- gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
+ if (prefs_common.show_compose_margin) {
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
+ gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
+ }
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD_CHAR);
gtk_text_view_set_editable(GTK_TEXT_VIEW(text), TRUE);
}
}
}
- compose->gtkaspell = gtkaspell;
+ compose->gtkaspell = gtkaspell;
compose_spell_menu_changed(compose);
claws_spell_entry_set_gtkaspell(CLAWS_SPELL_ENTRY(subject_entry), gtkaspell);
#endif
g_free(ainfo->file);
g_free(ainfo->content_type);
g_free(ainfo->name);
+ g_free(ainfo->charset);
g_free(ainfo);
}
COL_MIMETYPE, ainfo->content_type,
COL_SIZE, text,
COL_NAME, ainfo->name,
+ COL_CHARSET, ainfo->charset,
-1);
break;
for ( tmp = file_list; tmp; tmp = tmp->next) {
gchar *file = (gchar *) tmp->data;
gchar *utf8_filename = conv_filename_to_utf8(file);
- compose_attach_append(compose, file, utf8_filename, NULL);
+ compose_attach_append(compose, file, utf8_filename, NULL, NULL);
compose_changed_cb(NULL, compose);
if (free_data) {
g_free(file);
gchar *utf8_filename = conv_filename_to_utf8((const gchar *)tmp->data);
compose_attach_append
(compose, (const gchar *)tmp->data,
- utf8_filename, NULL);
+ utf8_filename, NULL, NULL);
g_free(utf8_filename);
}
if (list) compose_changed_cb(NULL, compose);
TRUE, TRUE);
if (file) {
compose_attach_append(compose, (const gchar *)file,
- (const gchar *)file, "message/rfc822");
+ (const gchar *)file, "message/rfc822", NULL);
g_free(file);
}
}
return FALSE;
}
-static gboolean compose_headerentry_changed_cb(GtkWidget *entry,
+static gboolean scroll_postpone(gpointer data)
+{
+ Compose *compose = (Compose *)data;
+ GTK_EVENTS_FLUSH();
+ compose_show_first_last_header(compose, FALSE);
+ return FALSE;
+}
+
+static void compose_headerentry_changed_cb(GtkWidget *entry,
ComposeHeaderEntry *headerentry)
{
if (strlen(gtk_entry_get_text(GTK_ENTRY(entry))) != 0) {
(G_OBJECT(entry), G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, headerentry);
- /* Automatically scroll down */
- GTK_EVENTS_FLUSH();
- compose_show_first_last_header(headerentry->compose, FALSE);
-
+ g_timeout_add(0, scroll_postpone, headerentry->compose);
}
- return FALSE;
}
static void compose_show_first_last_header(Compose *compose, gboolean show_first)