* src/folderview.c
[claws.git] / src / main.c
index ebd242a3d850d5ff2afab0baee35e5d93c669d8f..c26dc13ae9070b421cf5e68cc472b57a91fd198d 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[]);
@@ -152,12 +157,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())
@@ -215,6 +228,7 @@ int main(int argc, char *argv[])
        MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
        MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
        MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
+       MAKE_DIR_IF_NOT_EXIST(get_tmp_dir());
        MAKE_DIR_IF_NOT_EXIST(RC_DIR G_DIR_SEPARATOR_S "uidl");
 
        if (is_file_exist(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log")) {
@@ -404,7 +418,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) {
@@ -443,14 +462,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);
 }
@@ -485,6 +503,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);
@@ -553,7 +580,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);