New address book.
[claws.git] / src / main.c
index e7ab3ff1102cc53df828443a2983142ddfe11a82..90bc4e11b6d281d3797880830a7b8d42eaf62a2e 100644 (file)
@@ -75,6 +75,9 @@
 #if USE_GPGME
 #  include "rfc2015.h"
 #endif
+#if USE_SSL
+#  include "ssl.h"
+#endif
 
 gchar *prog_version;
 gchar *startup_dir;
@@ -156,6 +159,10 @@ int main(int argc, char *argv[])
        gtk_widget_push_colormap(gdk_imlib_get_colormap());
 #endif
 
+#if USE_SSL
+       ssl_init();
+#endif
+
        srandom((gint)time(NULL));
 
        /* parse gtkrc files */
@@ -196,6 +203,13 @@ int main(int argc, char *argv[])
        MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
        MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
 
+       if (is_file_exist(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log")) {
+               if (rename(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log",
+                          RC_DIR G_DIR_SEPARATOR_S "sylpheed.log.bak") < 0)
+                       FILE_OP_ERROR("sylpheed.log", "rename");
+       }
+       set_log_file(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log");
+
        if (is_file_exist(RC_DIR G_DIR_SEPARATOR_S "assortrc") &&
            !is_file_exist(RC_DIR G_DIR_SEPARATOR_S "filterrc")) {
                if (rename(RC_DIR G_DIR_SEPARATOR_S "assortrc",
@@ -232,6 +246,7 @@ int main(int argc, char *argv[])
        prefs_display_header_read_config();
        prefs_display_header_write_config();
        prefs_filtering_read_config();
+       addressbook_read_file();
 
        gtkut_widget_init();
 
@@ -248,7 +263,15 @@ int main(int argc, char *argv[])
        account_read_config_all();
        account_save_config_all();
 
-       if (folder_read_list() < 0) setup(mainwin);
+       if (folder_read_list() < 0) {
+               setup(mainwin);
+               folder_write_list();
+       }
+       if (!account_get_list()) {
+               account_edit_open();
+               account_add();
+       }
+
        account_set_missing_folder();
        folderview_set(folderview);
 
@@ -369,12 +392,18 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        /* delete temporary files */
        remove_all_files(get_mime_tmp_dir());
 
+       close_log_file();
+
        /* delete unix domain socket */
        gdk_input_remove(lock_socket_tag);
        fd_close(lock_socket);
        filename = get_socket_name();
        unlink(filename);
 
+#if USE_SSL
+       ssl_done();
+#endif
+
        gtk_main_quit();
 }