added autosave
[claws.git] / src / main.c
index bbabc67a3bee50cd64f2fa2e10b245fc4eb07940..d2430b7728cbd5ef5b4289d705e40fcc0e00cea1 100644 (file)
@@ -113,6 +113,7 @@ static void idle_function_for_gpgme(void);
 #endif /* USE_GPGME */
 
 static gint prohibit_duplicate_launch  (void);
+static gchar * get_crashfile_name      (void);
 static void lock_socket_input_cb       (gpointer          data,
                                         gint              source,
                                         GdkInputCondition condition);
@@ -323,6 +324,14 @@ int main(int argc, char *argv[])
        /* make one all-folder processing before using sylpheed */
        folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
 
+       /* if Sylpheed crashed, rebuild caches */
+       if (!cmd.crash && is_file_exist(get_crashfile_name())) {
+               debug_print("Sylpheed crashed, checking for new messages\n");
+               folderview_check_new_all();
+       }
+       /* make the crash-indicator file */
+       str_write_to_file("foo", get_crashfile_name());
+
        addressbook_read_file();
 
        inc_autocheck_timer_init(mainwin);
@@ -540,6 +549,10 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        fd_close(lock_socket);
        filename = get_socket_name();
        unlink(filename);
+       
+       /* delete crashfile */
+       if (!cmd.crash)
+               unlink(get_crashfile_name());
 
 #if USE_SSL
        ssl_done();
@@ -576,6 +589,18 @@ gchar *get_socket_name(void)
        return filename;
 }
 
+static gchar *get_crashfile_name(void)
+{
+       static gchar *filename = NULL;
+
+       if (filename == NULL) {
+               filename = g_strdup_printf("%s%csylpheed-crashed",
+                                          get_tmp_dir(), G_DIR_SEPARATOR);
+       }
+
+       return filename;
+}
+
 static gint prohibit_duplicate_launch(void)
 {
        gint uxsock;