... and also redo the SSL stuff.
[claws.git] / src / main.c
index e7ab3ff1102cc53df828443a2983142ddfe11a82..0fde8f1e0185f97e645e592e3d1e9c0e4456775d 100644 (file)
@@ -83,6 +83,10 @@ gboolean debug_mode = FALSE;
 static gint lock_socket = -1;
 static gint lock_socket_tag = 0;
 
+#if USE_SSL
+SSL_CTX *ssl_ctx;
+#endif
+
 static struct Cmd {
        gboolean receive;
        gboolean receive_all;
@@ -196,6 +200,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",
@@ -226,6 +237,22 @@ int main(int argc, char *argv[])
        gpgme_register_idle(idle_function_for_gpgme);
 #endif
 
+#if USE_SSL
+       {
+               SSL_METHOD *meth;
+               
+               SSLeay_add_ssl_algorithms();
+               meth = SSLv2_client_method();
+               SSL_load_error_strings();
+               ssl_ctx = SSL_CTX_new(meth);
+               if(ssl_ctx == NULL) {
+                       debug_print(_("SSL disabled\n"));
+               } else {
+                       debug_print(_("SSL loaded: \n"));
+               }
+       }
+#endif
+
        prefs_common_save_config();
        prefs_filter_read_config();
        prefs_filter_write_config();
@@ -271,6 +298,12 @@ int main(int argc, char *argv[])
 
        gtk_main();
 
+#if USE_SSL
+       if(ssl_ctx) {
+               SSL_CTX_free(ssl_ctx);
+       }
+#endif
+
        return 0;
 }
 
@@ -369,6 +402,8 @@ 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);