Fix bug #591676 (MSG_QUEUED lost on restart)
[claws.git] / src / main.c
index 2195622f5c554288fe145e14879716e6008c6a09..182a718a2c8ec174ada475cce338cdc3f2c383e6 100644 (file)
@@ -40,7 +40,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <signal.h>
-#include <execinfo.h>
 
 #if HAVE_LOCALE_H
 #  include <locale.h>
@@ -89,6 +88,7 @@
 
 gchar *prog_version;
 gchar *startup_dir;
+gchar *argv0;
 gboolean debug_mode = FALSE;
 
 static gint lock_socket = -1;
@@ -116,7 +116,11 @@ static gint prohibit_duplicate_launch      (void);
 static void lock_socket_input_cb       (gpointer          data,
                                         gint              source,
                                         GdkInputCondition condition);
-static gchar *get_socket_name          (void);
+#ifndef CLAWS                                   
+static 
+#endif
+gchar *get_socket_name         (void);
+
 
 static void open_compose_new           (const gchar    *address,
                                         GPtrArray      *attach_files);
@@ -157,6 +161,7 @@ int main(int argc, char *argv[])
 
        prog_version = PROG_VERSION;
        startup_dir = g_get_current_dir();
+       argv0 = g_strdup(argv[0]);
 
        parse_cmd_opt(argc, argv);
 
@@ -259,7 +264,7 @@ int main(int argc, char *argv[])
 
                        val = alertpanel_message_with_disable
                                (_("Warning"),
-                                _("GnuPG is not installed properly.\n"
+                                _("GnuPG is not installed properly, or needs to be upgraded.\n"
                                   "OpenPGP support disabled."));
                        if (val & G_ALERTDISABLE)
                                prefs_common.gpg_warning = FALSE;
@@ -268,8 +273,8 @@ int main(int argc, char *argv[])
        gpgme_register_idle(idle_function_for_gpgme);
 #endif
 
-#if USE_PSPELL
-       gtkpspellcheckers = gtkpspell_checkers_new();
+#if USE_ASPELL
+       gtkaspellcheckers = gtkaspell_checkers_new();
 #endif
        
 
@@ -346,8 +351,8 @@ int main(int argc, char *argv[])
 
        addressbook_destroy();
 
-#if USE_PSPELL       
-       gtkpspell_checkers_delete();
+#if USE_ASPELL       
+       gtkaspell_checkers_delete();
 #endif
 
        return 0;
@@ -444,10 +449,10 @@ static gint get_queued_message_num(void)
 
 static void save_all_caches(FolderItem *item, gpointer data)
 {
-       if(!item->cache)
+       if (!item->cache)
                return;
-               
-       folder_item_write_cache(item);
+       if (!item->stype == F_QUEUE)    
+               folder_item_write_cache(item);
 }
 
 static void initial_processing(FolderItem *item, gpointer data)
@@ -467,7 +472,10 @@ static void initial_processing(FolderItem *item, gpointer data)
        
        folder_item_apply_processing(item);
 
-       debug_print(_("done.\n"));
+       if (item->stype == F_QUEUE)
+               folder_item_scan(item);
+       
+       debug_print("done.\n");
        STATUSBAR_POP(mainwin);
        main_window_cursor_normal(mainwin);
 }
@@ -502,6 +510,15 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        if (prefs_common.clean_on_exit)
                main_window_empty_trash(mainwin, prefs_common.ask_on_clean);
 
+       /* save prefs for opened folder */
+       if(mainwin->folderview->opened)
+       {
+               FolderItem *item;
+
+               item = gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
+               summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
+       }
+
        /* save all state before exiting */
        folder_write_list();
        folder_func_to_all_folders(save_all_caches, NULL);
@@ -543,7 +560,14 @@ static void idle_function_for_gpgme(void)
 }
 #endif /* USE_GPGME */
 
-static gchar *get_socket_name(void)
+/*
+ * CLAWS: want this public so crash dialog can delete the
+ * lock file too
+ */
+#ifndef CLAWS
+static
+#endif
+gchar *get_socket_name(void)
 {
        static gchar *filename = NULL;
 
@@ -570,7 +594,7 @@ static gint prohibit_duplicate_launch(void)
 
        /* remote command mode */
 
-       debug_print(_("another Sylpheed is already running.\n"));
+       debug_print("another Sylpheed is already running.\n");
 
        if (cmd.receive_all)
                fd_write(uxsock, "receive_all\n", 12);