0.8.8claws63
[claws.git] / src / main.c
index 4d8748ed0110194722cc85e97e52dbf13b55f647..97575d362e5a44050425d767babeef11003ef745 100644 (file)
 #include <sys/types.h>
 #include <signal.h>
 
-#if HAVE_LOCALE_H
-#  include <locale.h>
-#endif
-
 #if USE_GPGME
 #  include <gpgme.h>
 #  include "passphrase.h"
 #endif
 
+#include "sylpheed.h"
 #include "intl.h"
 #include "main.h"
 #include "mainwindow.h"
 #include "setup.h"
 #include "utils.h"
 #include "gtkutils.h"
+#include "log.h"
 
 #if USE_GPGME
 #  include "rfc2015.h"
 #endif
-#if USE_SSL
+#if USE_OPENSSL
 #  include "ssl.h"
 #endif
 
@@ -87,8 +85,9 @@
 
 gchar *prog_version;
 gchar *startup_dir;
+#ifdef CRASH_DIALOG
 gchar *argv0;
-gboolean debug_mode = FALSE;
+#endif
 
 static gint lock_socket = -1;
 static gint lock_socket_tag = 0;
@@ -165,16 +164,28 @@ int main(int argc, char *argv[])
        MainWindow *mainwin;
        FolderView *folderview;
 
-       setlocale(LC_ALL, "");
-       bindtextdomain(PACKAGE, LOCALEDIR);
-       textdomain(PACKAGE);
+       if(!sylpheed_init(&argc, &argv)) {
+               return 0;
+       }
 
        prog_version = PROG_VERSION;
        startup_dir = g_get_current_dir();
+#ifdef CRASH_DIALOG
        argv0 = g_strdup(argv[0]);
+#endif
 
        parse_cmd_opt(argc, argv);
 
+#ifdef CRASH_DIALOG
+       if (cmd.crash) {
+               gtk_set_locale();
+               gtk_init(&argc, &argv);
+               crash_main(cmd.crash_params);
+               return 0;
+       }
+       crash_install_handlers();
+#endif
+
        /* check and create unix domain socket */
        lock_socket = prohibit_duplicate_launch();
        if (lock_socket < 0) return 0;
@@ -187,14 +198,6 @@ int main(int argc, char *argv[])
        gtk_set_locale();
        gtk_init(&argc, &argv);
 
-#ifdef CRASH_DIALOG
-       if (cmd.crash) {
-               crash_main(cmd.crash_params);
-               return 0;
-       }
-       crash_install_handlers();
-#endif
-
 #if USE_THREADS || USE_LDAP
        g_thread_init(NULL);
        if (!g_thread_supported())
@@ -207,12 +210,6 @@ 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 */
        userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc",
                             NULL);
@@ -234,11 +231,6 @@ int main(int argc, char *argv[])
 
        CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
 
-       /* backup if old rc file exists */
-       if (is_file_exist(RC_DIR)) {
-               if (rename(RC_DIR, RC_DIR ".bak") < 0)
-                       FILE_OP_ERROR(RC_DIR, "rename");
-       }
        MAKE_DIR_IF_NOT_EXIST(RC_DIR);
        MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
        MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
@@ -246,11 +238,6 @@ int main(int argc, char *argv[])
        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")) {
-               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");
 
        prefs_common_init();
@@ -373,6 +360,7 @@ int main(int argc, char *argv[])
 #if USE_ASPELL       
        gtkaspell_checkers_delete();
 #endif
+       sylpheed_done();
 
        return 0;
 }
@@ -383,7 +371,7 @@ static void parse_cmd_opt(int argc, char *argv[])
 
        for (i = 1; i < argc; i++) {
                if (!strncmp(argv[i], "--debug", 7))
-                       debug_mode = TRUE;
+                       debug_set_mode(TRUE);
                else if (!strncmp(argv[i], "--receive-all", 13))
                        cmd.receive_all = TRUE;
                else if (!strncmp(argv[i], "--receive", 9))
@@ -605,10 +593,6 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        if (!cmd.crash)
                unlink(get_crashfile_name());
 
-#if USE_SSL
-       ssl_done();
-#endif
-
        gtk_main_quit();
 }
 
@@ -800,16 +784,11 @@ static void send_queue(void)
                        if (procmsg_send_queue
                                (folder->queue, prefs_common.savemsg) < 0)
                                alertpanel_error(_("Some errors occurred while sending queued messages."));
-                       statusbar_pop_all();
                        folder_item_scan(folder->queue);
                        if (prefs_common.savemsg && folder->outbox) {
-                               folder_update_item(folder->outbox, TRUE);
                                if (folder->outbox == def_outbox)
                                        def_outbox = NULL;
                        }
                }
        }
-
-       if (prefs_common.savemsg && def_outbox)
-               folder_update_item(def_outbox, TRUE);
 }