gboolean check_subject);
static gint compose_write_to_file (Compose *compose,
FILE *fp,
- gint action);
+ gint action,
+ gboolean attach_parts);
static gint compose_write_body_to_file (Compose *compose,
const gchar *file);
static gint compose_remove_reedit_target (Compose *compose,
"Charset conversion failed."));
} else if (val == -3) {
alertpanel_error(_("Could not queue message for sending:\n\n"
- "Signature failed."));
+ "Signature failed: %s"), privacy_get_error());
} else if (val == -2 && errno != 0) {
alertpanel_error(_("Could not queue message for sending:\n\n%s."), strerror(errno));
} else {
return -1;
}
-static gint compose_write_to_file(Compose *compose, FILE *fp, gint action)
+static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gboolean attach_parts)
{
GtkTextBuffer *buffer;
GtkTextIter start, end;
MimeInfo *mimemsg, *mimetext;
gint line;
+ if (action == COMPOSE_WRITE_FOR_SEND)
+ attach_parts = TRUE;
+
/* create message MimeInfo */
mimemsg = procmime_mimeinfo_new();
mimemsg->type = MIMETYPE_MESSAGE;
procmime_encode_content(mimetext, encoding);
/* append attachment parts */
- if (compose_use_attach(compose)) {
+ if (compose_use_attach(compose) && attach_parts) {
MimeInfo *mimempart;
gchar *boundary = NULL;
mimempart = procmime_mimeinfo_new();
}
} else {
gint result = 0;
- if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND)) < 0) {
+ if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND, TRUE)) < 0) {
lock = FALSE;
fclose(fp);
g_unlink(tmp);
header = g_string_sized_new(64);
/* Date */
- if (compose->account->add_date) {
- get_rfc822_date(buf, sizeof(buf));
- g_string_append_printf(header, "Date: %s\n", buf);
- }
+ get_rfc822_date(buf, sizeof(buf));
+ g_string_append_printf(header, "Date: %s\n", buf);
/* From */
if (ac == compose->account) def_menu = num;
- name = g_markup_printf_escaped("From: <i>%s</i>",
+ name = g_markup_printf_escaped(_("From: <i>%s</i>"),
ac->account_name);
if (ac == compose->account) {
alertpanel_error(_("Could not queue message:\n\n%s."), strerror(errno));
} else if (val == -3) {
alertpanel_error(_("Could not queue message for sending:\n\n"
- "Signature failed."));
+ "Signature failed: %s"), privacy_get_error());
} else if (val == -4) {
alertpanel_error(_("Could not queue message for sending:\n\n"
"Charset conversion failed."));
/* end of headers */
fprintf(fp, "X-Sylpheed-End-Special-Headers: 1\n");
- if (compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_STORE) < 0) {
+ 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;
}
g_free(tmp);
- draft->mtime = 0; /* force updating */
if (compose->mode == COMPOSE_REEDIT) {
compose_remove_reedit_target(compose, TRUE);
procmsg_msginfo_set_flags(newmsginfo, MSG_LOCKED, MSG_DRAFT);
else
procmsg_msginfo_set_flags(newmsginfo, 0, MSG_DRAFT);
- if (compose_use_attach(compose))
+ if (compose_use_attach(compose) && action != COMPOSE_AUTO_SAVE)
procmsg_msginfo_set_flags(newmsginfo, 0,
MSG_HAS_ATTACHMENT);
{
Compose *compose = (Compose *)user_data;
GList *list, *tmp;
+ AlertValue val = G_ALERTDEFAULT;
+
+ switch (prefs_common.compose_dnd_mode) {
+ case COMPOSE_DND_ASK:
+ val = alertpanel_full(_("Insert or attach?"),
+ _("Do you want to insert the contents of the file(s) "
+ "into the message body, or attach it to the email?"),
+ GTK_STOCK_CANCEL, _("+_Insert"), _("_Attach"),
+ TRUE, NULL, ALERT_QUESTION, G_ALERTALTERNATE);
+ break;
+ case COMPOSE_DND_INSERT:
+ val = G_ALERTALTERNATE;
+ break;
+ case COMPOSE_DND_ATTACH:
+ val = G_ALERTOTHER;
+ break;
+ default:
+ /* unexpected case */
+ g_warning("error: unexpected compose_dnd_mode option value in compose_insert_drag_received_cb()");
+ }
+
+ if (val & G_ALERTDISABLE) {
+ val &= ~G_ALERTDISABLE;
+ /* remember what action to perform by default, only if we don't click Cancel */
+ if (val == G_ALERTALTERNATE)
+ prefs_common.compose_dnd_mode = COMPOSE_DND_INSERT;
+ else
+ if (val == G_ALERTOTHER)
+ prefs_common.compose_dnd_mode = COMPOSE_DND_ATTACH;
+ }
+
+ if (val == G_ALERTDEFAULT) {
+ gtk_drag_finish(drag_context, FALSE, FALSE, time);
+ return;
+ } else if (val == G_ALERTOTHER) {
+ compose_attach_drag_received_cb(widget, drag_context, x, y, data, info, time, user_data);
+ return;
+ }
/* strangely, testing data->type == gdk_atom_intern("text/uri-list", TRUE)
* does not work */