static void compose_show_first_last_header (Compose *compose, gboolean show_first);
+static void compose_allow_user_actions (Compose *compose, gboolean allow);
+
#if USE_ASPELL
static void compose_check_all (Compose *compose);
static void compose_highlight_all (Compose *compose);
static GtkItemFactoryEntry compose_entries[] =
{
{N_("/_File"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_File/_Save"),
+ "<control>S", compose_draft_cb, 1, NULL},
+ {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_File/_Attach file"), "<control>M", compose_attach_cb, 0, NULL},
{N_("/_File/_Insert file"), "<control>I", compose_insert_file_cb, 0, NULL},
{N_("/_File/Insert si_gnature"), "<control>G", compose_insert_sig_cb, 0, NULL},
compose_send_cb, 0, NULL},
{N_("/_Message/Send _later"), "<shift><control>S",
compose_send_later_cb, 0, NULL},
- {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Message/Save to _draft folder"),
- "<shift><control>D", compose_draft_cb, 0, NULL},
- {N_("/_Message/Save and _keep editing"),
- "<control>S", compose_draft_cb, 1, NULL},
#if 0 /* NEW COMPOSE GUI */
{N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Message/_To"), NULL, compose_toggle_to_cb , 0, "<ToggleItem>"},
menu_set_sensitive(ifactory, "/Property...", FALSE);
ifactory = gtk_item_factory_from_widget(compose->menubar);
+ menu_set_sensitive(ifactory, "/File/Save", FALSE);
menu_set_sensitive(ifactory, "/File/Insert file", FALSE);
menu_set_sensitive(ifactory, "/File/Attach file", FALSE);
menu_set_sensitive(ifactory, "/File/Insert signature", FALSE);
menu_set_sensitive(ifactory, "/Edit", FALSE);
- menu_set_sensitive(ifactory, "/Message/Save to draft folder", FALSE);
- menu_set_sensitive(ifactory, "/Message/Save and keep editing", FALSE);
#if USE_GPGME
menu_set_sensitive(ifactory, "/Message/Sign", FALSE);
menu_set_sensitive(ifactory, "/Message/Encrypt", FALSE);
{
gint msgnum;
FolderItem *folder;
- gint val;
+ gint val = -1;
gchar *msgpath;
+ compose_allow_user_actions (compose, FALSE);
+ compose->sending = TRUE;
+
if (compose_check_entries(compose, TRUE) == FALSE)
- return -1;
+ goto bail;
val = compose_queue(compose, &msgnum, &folder);
+
if (val) {
alertpanel_error(_("Could not queue message for sending"));
- return -1;
+ goto bail;
}
+ compose->sending = FALSE;
+ gtk_widget_destroy(compose->window);
+ /* No more compose access in the normal codepath after this point! */
+
if (msgnum == 0) {
- alertpanel_error(_("The message was queued but could not be sent.\nUse \"Send queued messages\" from the main window to retry."));
+ alertpanel_error(_("The message was queued but could not be "
+ "sent.\nUse \"Send queued messages\" from "
+ "the main window to retry."));
return 0;
}
val = procmsg_send_message_queue(msgpath);
g_free(msgpath);
- folder_item_remove_msg(folder, msgnum);
-
- folder_item_scan(folder);
+ if (val == 0) {
+ folder_item_remove_msg(folder, msgnum);
+ folder_item_scan(folder);
+ }
+
+ return 0;
- return val;
+bail:
+ compose_allow_user_actions (compose, TRUE);
+ compose->sending = FALSE;
+
+ return -1;
}
#if 0 /* compose restructure */
gchar *canon_buf;
const gchar *out_codeset;
EncodingType encoding;
+ gboolean already_encoded = FALSE;
if ((fp = fopen(file, "wb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
compose->use_signing && !compose->gnupg_mode &&
encoding == ENC_8BIT)
encoding = ENC_BASE64;
+
+ if (compose->use_encryption && compose->gnupg_mode)
+ encoding = ENC_8BIT; /* this will be encrypted to a 7bit string */
#endif
src_codeset = CS_UTF_8;
buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
if (!buf) {
- AlertValue aval;
+ AlertValue aval = G_ALERTDEFAULT;
gchar *msg;
- msg = g_strdup_printf(_("Can't convert the character encoding of the message from\n"
+ if (!is_draft) {
+ msg = g_strdup_printf(_("Can't convert the character encoding of the message from\n"
"%s to %s.\n"
"Send it anyway?"), src_codeset, out_codeset);
- aval = alertpanel
- (_("Error"), msg, _("Yes"), _("+No"), NULL);
- g_free(msg);
-
+ aval = alertpanel_with_type
+ (_("Error"), msg, _("Yes"), _("+No"), NULL, NULL, ALERT_ERROR);
+ g_free(msg);
+ }
+
if (aval != G_ALERTDEFAULT) {
g_free(chars);
fclose(fp);
#if USE_GPGME
if (!is_draft && compose->use_signing && compose->gnupg_mode) {
+ gchar *outbuf;
+
+ if (encoding == ENC_QUOTED_PRINTABLE) {
+ outbuf = g_malloc(strlen(buf) * 4);
+ qp_encode_line(outbuf, buf);
+ g_free(buf);
+ buf = g_strdup(outbuf);
+ already_encoded = TRUE;
+ g_free(outbuf);
+ }
+
if (compose_clearsign_text(compose, &buf) < 0) {
g_warning("clearsign failed\n");
fclose(fp);
} else if (encoding == ENC_QUOTED_PRINTABLE) {
gchar *outbuf;
size_t outlen;
-
- outbuf = g_malloc(len * 4);
- qp_encode_line(outbuf, buf);
- outlen = strlen(outbuf);
+ if (!already_encoded) {
+ outbuf = g_malloc(len * 4);
+ qp_encode_line(outbuf, buf);
+ outlen = strlen(outbuf);
+ } else {
+ outbuf = g_strdup(buf);
+ outlen = len;
+ }
if (fwrite(outbuf, sizeof(gchar), outlen, fp) != outlen) {
FILE_OP_ERROR(file, "fwrite");
fclose(fp);
if (!g_strcasecmp(trans_hdr, headerentryname)) {
const gchar *entstr = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
- gchar *tmpstr = conv_codeset_strdup(entstr, CS_UTF_8, conv_get_current_charset_str());
- Xstrdup_a(str, tmpstr, return -1);
+ Xstrdup_a(str, entstr, return -1);
g_strstrip(str);
if (str[0] != '\0') {
if (write_header)
g_string_append(headerstr, str);
write_header = TRUE;
}
- g_free(tmpstr);
}
}
if (write_header) {
attach_scrwin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(attach_scrwin),
GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
+ GTK_POLICY_AUTOMATIC);
gtk_widget_set_size_request(attach_scrwin, -1, 80);
attach_clist = gtk_clist_new_with_titles(N_ATTACH_COLS, titles);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
gtk_widget_set_size_request(window, -1, prefs_common.compose_height);
- gtk_window_set_wmclass(GTK_WINDOW(window), "compose window", "Sylpheed");
if (!geometry.max_width) {
geometry.max_width = gdk_screen_width();
/* text widget */
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
- GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(edit_vbox), scrolledwin, TRUE, TRUE, 0);
gtk_widget_set_size_request(scrolledwin, prefs_common.compose_width, -1);
menu_set_sensitive(ifactory, "/Message/Send", sensitive);
menu_set_sensitive(ifactory, "/Message/Send later", sensitive);
- menu_set_sensitive(ifactory, "/Message/Save to draft folder",
- sensitive);
menu_set_sensitive(ifactory, "/File/Insert file", sensitive);
menu_set_sensitive(ifactory, "/File/Insert signature", sensitive);
menu_set_sensitive(ifactory, "/Edit/Wrap current paragraph", sensitive);
compose->draft_timeout_tag = -1;
}
- compose_allow_user_actions (compose, FALSE);
- compose->sending = TRUE;
- val = compose_send(compose);
- compose_allow_user_actions (compose, TRUE);
- compose->sending = FALSE;
-
- if (val == 0) gtk_widget_destroy(compose->window);
+ compose_send(compose);
}
static void compose_send_later_cb(gpointer data, guint action,
for ( tmp = file_list; tmp; tmp = tmp->next) {
gchar *file = (gchar *) tmp->data;
gchar *filedup = g_strdup(file);
- gchar *shortfile;
+ const gchar *shortfile = g_basename(filedup);
ComposeInsertResult res;
res = compose_insert_file(compose, file);
- shortfile = g_basename(filedup);
if (res == COMPOSE_INSERT_READ_ERROR) {
alertpanel_error(_("File '%s' could not be read."), shortfile);
} else if (res == COMPOSE_INSERT_INVALID_CHARACTER) {