revert bug #591676 changes
[claws.git] / src / main.c
index ac5e7f83bba3bb7c2e7e210dcf83b7995734f6a7..bbabc67a3bee50cd64f2fa2e10b245fc4eb07940 100644 (file)
 
 #include "version.h"
 
+#include "crash.h"
+
 gchar *prog_version;
 gchar *startup_dir;
+gchar *argv0;
 gboolean debug_mode = FALSE;
 
 static gint lock_socket = -1;
@@ -99,6 +102,8 @@ static struct Cmd {
        GPtrArray *attach_files;
        gboolean status;
        gboolean send;
+       gboolean crash;
+       gchar   *crash_params;
 } cmd;
 
 static void parse_cmd_opt(int argc, char *argv[]);
@@ -111,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);
@@ -152,12 +161,20 @@ 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);
 
        gtk_set_locale();
        gtk_init(&argc, &argv);
 
+       if (cmd.crash) {
+               crash_main(cmd.crash_params);
+               return 0;
+       }
+
+       crash_install_handlers();
+
 #if USE_THREADS || USE_LDAP
        g_thread_init(NULL);
        if (!g_thread_supported())
@@ -247,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;
@@ -256,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
        
 
@@ -334,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;
@@ -405,7 +422,12 @@ static void parse_cmd_opt(int argc, char *argv[])
                        puts(_("  --version              output version information and exit"));
 
                        exit(1);
+               } else if (!strncmp(argv[i], "--crash", 7)) {
+                       cmd.crash = TRUE;
+                       cmd.crash_params = g_strdup(argv[i + 1]);
+                       i++;
                }
+               
        }
 
        if (cmd.attach_files && cmd.compose == FALSE) {
@@ -427,9 +449,8 @@ 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);
 }
 
@@ -444,14 +465,13 @@ static void initial_processing(FolderItem *item, gpointer data)
                              ? item->path 
                              : _("top level folder"));
        debug_print("%s\n", buf);
-       STATUSBAR_PUSH(mainwin, buf);
        g_free(buf);
 
        main_window_cursor_wait(mainwin);
        
        folder_item_apply_processing(item);
 
-       debug_print(_("done.\n"));
+       debug_print("done.\n");
        STATUSBAR_POP(mainwin);
        main_window_cursor_normal(mainwin);
 }
@@ -486,6 +506,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);
@@ -527,7 +556,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;
 
@@ -554,7 +590,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);