#include "folderview.h"
#include "summaryview.h"
#include "prefs_common.h"
-#include "prefs_filter.h"
#include "prefs_account.h"
#include "prefs_actions.h"
#include "scoring.h"
static gint lock_socket = -1;
static gint lock_socket_tag = 0;
+typedef enum
+{
+ ONLINE_MODE_DONT_CHANGE,
+ ONLINE_MODE_ONLINE,
+ ONLINE_MODE_OFFLINE
+} OnlineMode;
+
+
static struct Cmd {
gboolean receive;
gboolean receive_all;
gboolean status;
gboolean send;
gboolean crash;
- gboolean online;
- gboolean offline;
+ int online_mode;
gchar *crash_params;
} cmd;
} \
}
+static MainWindow *static_mainwindow;
int main(int argc, char *argv[])
{
gchar *userrc;
prefs_common_read_config();
#if USE_GPGME
+ gpg_started = FALSE;
if (gpgme_check_engine()) { /* Also does some gpgme init */
rfc2015_disable_all();
debug_print("gpgme_engine_version:\n%s\n",
if (val & G_ALERTDISABLE)
prefs_common.gpg_warning = FALSE;
}
- }
+ } else
+ gpg_started = TRUE;
+
gpgme_register_idle(idle_function_for_gpgme);
#endif
prefs_common_save_config();
- prefs_filter_read_config();
- prefs_filter_write_config();
prefs_actions_read_config();
prefs_actions_write_config();
prefs_display_header_read_config();
if (cmd.send)
send_queue();
- if (cmd.offline)
+ if (cmd.online_mode == ONLINE_MODE_OFFLINE)
main_window_toggle_work_offline(mainwin, TRUE);
- if (cmd.online)
+ if (cmd.online_mode == ONLINE_MODE_ONLINE)
main_window_toggle_work_offline(mainwin, FALSE);
+ static_mainwindow = mainwin;
gtk_main();
addressbook_destroy();
} else if (!strncmp(argv[i], "--status", 8)) {
cmd.status = TRUE;
} else if (!strncmp(argv[i], "--online", 8)) {
- cmd.online = TRUE;
+ cmd.online_mode = ONLINE_MODE_ONLINE;
} else if (!strncmp(argv[i], "--offline", 9)) {
- cmd.offline = TRUE;
+ cmd.online_mode = ONLINE_MODE_OFFLINE;
} else if (!strncmp(argv[i], "--help", 6)) {
g_print(_("Usage: %s [OPTION]...\n"),
g_basename(argv[0]));
main_window_cursor_normal(mainwin);
}
+static void draft_all_messages(void)
+{
+ GList * compose_list = compose_get_compose_list();
+ GList * elem = NULL;
+ if(compose_list) {
+ for (elem = compose_list; elem != NULL && elem->data != NULL; elem = elem->next) {
+ Compose *c = (Compose*)elem->data;
+ compose_draft(c);
+ }
+ }
+}
+
+void clean_quit(void)
+{
+ draft_all_messages();
+
+ if (prefs_common.warn_queued_on_exit)
+ { /* disable the popup */
+ prefs_common.warn_queued_on_exit = FALSE;
+ app_will_exit(NULL, static_mainwindow);
+ prefs_common.warn_queued_on_exit = TRUE;
+ prefs_common_save_config();
+ } else {
+ app_will_exit(NULL, static_mainwindow);
+ }
+ exit(0);
+}
+
void app_will_exit(GtkWidget *widget, gpointer data)
{
MainWindow *mainwin = data;
gchar *filename;
-
+
if (compose_get_compose_list()) {
- if (alertpanel(_("Notice"),
- _("Composing message exists. Really quit?"),
- _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
- return;
+ gint val = alertpanel(_("Notice"),
+ _("Composing message exists."),
+ _("Draft them"), _("Discard them"), _("Don't quit"));
+ switch (val) {
+ case G_ALERTOTHER:
+ return;
+ case G_ALERTALTERNATE:
+ break;
+ default:
+ draft_all_messages();
+ }
+
manage_window_focus_in(mainwin->window, NULL, NULL);
}
main_window_get_size(mainwin);
main_window_get_position(mainwin);
prefs_common_save_config();
- prefs_filter_write_config();
account_save_config_all();
addressbook_export_to_file();
g_free(compose_str);
} else if (cmd.send) {
fd_write(uxsock, "send\n", 5);
- } else if (cmd.online) {
+ } else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
fd_write(uxsock, "online\n", 6);
- } else if (cmd.offline) {
+ } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
fd_write(uxsock, "offline\n", 7);
} else if (cmd.status) {
gchar buf[BUFFSIZE];
alertpanel_error(_("Some errors occurred while sending queued messages."));
statusbar_pop_all();
folder_item_scan(folder->queue);
- folderview_update_item(folder->queue, TRUE);
if (prefs_common.savemsg && folder->outbox) {
- folderview_update_item(folder->outbox, TRUE);
+ folder_update_item(folder->outbox, TRUE);
if (folder->outbox == def_outbox)
def_outbox = NULL;
}
}
if (prefs_common.savemsg && def_outbox)
- folderview_update_item(def_outbox, TRUE);
+ folder_update_item(def_outbox, TRUE);
}