GList *listAddress );
static Compose *compose_create (PrefsAccount *account,
- ComposeMode mode);
+ ComposeMode mode,
+ gboolean batch);
static GtkWidget *compose_account_option_menu_create
(Compose *compose);
void compose_remove_draft (Compose *compose);
static gint compose_queue (Compose *compose,
gint *msgnum,
- FolderItem **item);
+ FolderItem **item,
+ gchar **msgpath);
static gint compose_queue_sub (Compose *compose,
gint *msgnum,
FolderItem **item,
+ gchar **msgpath,
gboolean check_subject);
static void compose_add_attachments (Compose *compose,
MimeInfo *parent);
if (!account) account = cur_account;
g_return_val_if_fail(account != NULL, NULL);
- compose = compose_create(account, COMPOSE_NEW);
+ compose = compose_create(account, COMPOSE_NEW, FALSE);
ifactory = gtk_item_factory_from_widget(compose->menubar);
compose->replyinfo = NULL;
case COMPOSE_FORWARD_INLINE:
/* check if we reply to more than one Message */
if (list_len == 1) {
- compose = compose_forward(NULL, msginfo, FALSE, body, FALSE);
+ compose = compose_forward(NULL, msginfo, FALSE, body, FALSE, FALSE);
break;
}
/* more messages FALL THROUGH */
compose = compose_forward_multiple(NULL, msginfo_list);
break;
case COMPOSE_REDIRECT:
- compose = compose_redirect(NULL, msginfo);
+ compose = compose_redirect(NULL, msginfo, FALSE);
break;
default:
g_warning("compose_reply(): invalid Compose Mode: %d\n", mode);
} else
reply_account = account;
- compose = compose_create(account, COMPOSE_REPLY);
+ compose = compose_create(account, COMPOSE_REPLY, FALSE);
ifactory = gtk_item_factory_from_widget(compose->menubar);
menu_set_active(ifactory, "/Options/Remove references", FALSE);
Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
gboolean as_attach, const gchar *body,
- gboolean no_extedit)
+ gboolean no_extedit,
+ gboolean batch)
{
Compose *compose;
GtkTextView *textview;
(msginfo)))
account = cur_account;
- compose = compose_create(account, COMPOSE_FORWARD);
+ compose = compose_create(account, COMPOSE_FORWARD, batch);
compose->fwdinfo = procmsg_msginfo_get_full_info(msginfo);
if (!compose->fwdinfo)
MSG_SET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_FORWARDED);
}
- compose = compose_create(account, COMPOSE_FORWARD);
+ compose = compose_create(account, COMPOSE_FORWARD, FALSE);
textview = GTK_TEXT_VIEW(compose->text);
textbuf = gtk_text_view_get_buffer(textview);
if (!account) account = cur_account;
g_return_if_fail(account != NULL);
- compose = compose_create(account, COMPOSE_REEDIT);
+ compose = compose_create(account, COMPOSE_REEDIT, FALSE);
if (privacy_system != NULL) {
compose->privacy_system = privacy_system;
compose_use_signing(compose, use_signing);
compose_set_title(compose);
}
-Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
+Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo,
+ gboolean batch)
{
Compose *compose;
gchar *filename;
prefs_common.reply_account_autosel);
g_return_val_if_fail(account != NULL, NULL);
- compose = compose_create(account, COMPOSE_REDIRECT);
+ compose = compose_create(account, COMPOSE_REDIRECT, batch);
ifactory = gtk_item_factory_from_widget(compose->menubar);
compose_create_tags(GTK_TEXT_VIEW(compose->text), compose);
compose->replyinfo = NULL;
menu_set_sensitive(ifactory, "/Tools/Show ruler", FALSE);
menu_set_sensitive(ifactory, "/Tools/Actions", FALSE);
- gtk_widget_set_sensitive(compose->toolbar->draft_btn, FALSE);
- gtk_widget_set_sensitive(compose->toolbar->insert_btn, FALSE);
- gtk_widget_set_sensitive(compose->toolbar->attach_btn, FALSE);
- gtk_widget_set_sensitive(compose->toolbar->sig_btn, FALSE);
- gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, FALSE);
- gtk_widget_set_sensitive(compose->toolbar->linewrap_current_btn, FALSE);
- gtk_widget_set_sensitive(compose->toolbar->linewrap_all_btn, FALSE);
+ if (compose->toolbar->draft_btn)
+ gtk_widget_set_sensitive(compose->toolbar->draft_btn, FALSE);
+ if (compose->toolbar->insert_btn)
+ gtk_widget_set_sensitive(compose->toolbar->insert_btn, FALSE);
+ if (compose->toolbar->attach_btn)
+ gtk_widget_set_sensitive(compose->toolbar->attach_btn, FALSE);
+ if (compose->toolbar->sig_btn)
+ gtk_widget_set_sensitive(compose->toolbar->sig_btn, FALSE);
+ if (compose->toolbar->exteditor_btn)
+ gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, FALSE);
+ if (compose->toolbar->linewrap_current_btn)
+ gtk_widget_set_sensitive(compose->toolbar->linewrap_current_btn, FALSE);
+ if (compose->toolbar->linewrap_all_btn)
+ gtk_widget_set_sensitive(compose->toolbar->linewrap_all_btn, FALSE);
compose->modified = FALSE;
compose_set_title(compose);
return FALSE;
}
- str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
- if (*str == '\0' && check_subject == TRUE) {
- AlertValue aval;
+ if (!compose->batch) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
+ if (*str == '\0' && check_subject == TRUE) {
+ AlertValue aval;
- aval = alertpanel(_("Send"),
- _("Subject is empty. Send it anyway?"),
- GTK_STOCK_CANCEL, _("+_Send"), NULL);
- if (aval != G_ALERTALTERNATE)
- return FALSE;
+ aval = alertpanel(_("Send"),
+ _("Subject is empty. Send it anyway?"),
+ GTK_STOCK_CANCEL, _("+_Send"), NULL);
+ if (aval != G_ALERTALTERNATE)
+ return FALSE;
+ }
}
return TRUE;
gint msgnum;
FolderItem *folder;
gint val = -1;
- gchar *msgpath;
+ gchar *msgpath = NULL;
+ gboolean discard_window = FALSE;
+
+ if (prefs_common.send_dialog_mode != SEND_DIALOG_ALWAYS
+ || compose->batch == TRUE)
+ discard_window = TRUE;
compose_allow_user_actions (compose, FALSE);
compose->sending = TRUE;
- if (compose_check_entries(compose, TRUE) == FALSE)
+ if (compose_check_entries(compose, TRUE) == FALSE) {
+ if (compose->batch) {
+ gtk_widget_show_all(compose->window);
+ }
goto bail;
+ }
- val = compose_queue(compose, &msgnum, &folder);
+ val = compose_queue(compose, &msgnum, &folder, &msgpath);
if (val) {
+ if (compose->batch) {
+ gtk_widget_show_all(compose->window);
+ }
if (val == -4) {
alertpanel_error(_("Could not queue message for sending:\n\n"
"Charset conversion failed."));
goto bail;
}
-
- if (prefs_common.send_dialog_mode != SEND_DIALOG_ALWAYS) {
+ if (discard_window) {
compose->sending = FALSE;
compose_close(compose);
/* No more compose access in the normal codepath
}
if (msgnum == 0) {
+ if (!discard_window) {
+ goto bail;
+ }
alertpanel_error(_("The message was queued but could not be "
"sent.\nUse \"Send queued messages\" from "
"the main window to retry."));
- if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS) {
- compose->sending = FALSE;
- compose->modified = TRUE;
- compose_allow_user_actions (compose, TRUE);
- }
- return 0;
+ return -1;
}
- msgpath = folder_item_fetch_msg(folder, msgnum);
- val = procmsg_send_message_queue(msgpath);
- g_free(msgpath);
-
- if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS) {
+ if (msgpath == NULL) {
+ msgpath = folder_item_fetch_msg(folder, msgnum);
+ val = procmsg_send_message_queue(msgpath);
+ g_free(msgpath);
+ } else {
+ val = procmsg_send_message_queue(msgpath);
+ g_unlink(msgpath);
+ g_free(msgpath);
+ }
+ if (!discard_window) {
compose->sending = FALSE;
compose_allow_user_actions (compose, TRUE);
if (val != 0) {
if (val == 0) {
folder_item_remove_msg(folder, msgnum);
folder_item_scan(folder);
- if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS)
+ if (!discard_window)
compose_close(compose);
} else {
+ if (!discard_window) {
+ goto bail;
+ }
alertpanel_error(_("The message was queued but could not be "
"sent.\nUse \"Send queued messages\" from "
"the main window to retry."));
- if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS) {
- compose_allow_user_actions (compose, TRUE);
- compose->modified = TRUE;
- compose->sending = FALSE;
- }
return -1;
}
}
-static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
+static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item, gchar **msgpath)
{
- return compose_queue_sub (compose, msgnum, item, FALSE);
+ return compose_queue_sub (compose, msgnum, item, msgpath, FALSE);
}
-static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item, gboolean check_subject)
+static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item, gchar **msgpath, gboolean check_subject)
{
FolderItem *queue;
gchar *tmp;
return -1;
}
folder_item_scan(queue);
- if ((num = folder_item_add_msg(queue, tmp, NULL, TRUE)) < 0) {
+ if ((num = folder_item_add_msg(queue, tmp, NULL, FALSE)) < 0) {
g_warning("can't queue the message\n");
g_unlink(tmp);
g_free(tmp);
return -1;
}
- g_unlink(tmp);
- g_free(tmp);
+
+ if (msgpath == NULL) {
+ g_unlink(tmp);
+ g_free(tmp);
+ } else
+ *msgpath = tmp;
if (compose->mode == COMPOSE_REEDIT) {
compose_remove_reedit_target(compose, FALSE);
return FALSE;
}
-static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
+static Compose *compose_create(PrefsAccount *account, ComposeMode mode,
+ gboolean batch)
{
Compose *compose;
GtkWidget *window;
titles[COL_SIZE] = _("Size");
titles[COL_NAME] = _("Name");
+ compose->batch = batch;
compose->account = account;
compose->mutex = g_mutex_new();
activate_privacy_system(compose, account, TRUE);
toolbar_set_style(compose->toolbar->toolbar, compose->handlebox, prefs_common.toolbar_style);
- gtk_widget_show(window);
+ if (batch) {
+ gtk_widget_realize(window);
+ } else {
+ gtk_widget_show(window);
+ }
return compose;
}
menu_set_sensitive(ifactory, "/Edit/Edit with external editor",
sensitive);
- gtk_widget_set_sensitive(compose->text, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->send_btn, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->sendl_btn, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->draft_btn, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->insert_btn, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->sig_btn, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->linewrap_current_btn, sensitive);
- gtk_widget_set_sensitive(compose->toolbar->linewrap_all_btn, sensitive);
+ gtk_widget_set_sensitive(compose->text, sensitive);
+ if (compose->toolbar->send_btn)
+ gtk_widget_set_sensitive(compose->toolbar->send_btn, sensitive);
+ if (compose->toolbar->sendl_btn)
+ gtk_widget_set_sensitive(compose->toolbar->sendl_btn, sensitive);
+ if (compose->toolbar->draft_btn)
+ gtk_widget_set_sensitive(compose->toolbar->draft_btn, sensitive);
+ if (compose->toolbar->insert_btn)
+ gtk_widget_set_sensitive(compose->toolbar->insert_btn, sensitive);
+ if (compose->toolbar->sig_btn)
+ gtk_widget_set_sensitive(compose->toolbar->sig_btn, sensitive);
+ if (compose->toolbar->exteditor_btn)
+ gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, sensitive);
+ if (compose->toolbar->linewrap_current_btn)
+ gtk_widget_set_sensitive(compose->toolbar->linewrap_current_btn, sensitive);
+ if (compose->toolbar->linewrap_all_btn)
+ gtk_widget_set_sensitive(compose->toolbar->linewrap_all_btn, sensitive);
}
#endif /* G_OS_UNIX */
Compose *compose = (Compose *)data;
gint val;
- val = compose_queue_sub(compose, NULL, NULL, TRUE);
+ val = compose_queue_sub(compose, NULL, NULL, NULL, TRUE);
if (!val)
compose_close(compose);
else if (val == -2) {