2007-01-18 [paul] 2.7.1cvs22
[claws.git] / src / main.c
index 2127609c639035490a840453b3fb8559eef9e8f6..3a57e677361d0df88127cbce645e593c248b8794 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -157,9 +157,7 @@ static gint lock_socket_remove              (void);
 static void lock_socket_input_cb       (gpointer          data,
                                         gint              source,
                                         GdkInputCondition condition);
-#ifndef CLAWS                                   
-static 
-#endif
+
 gchar *get_socket_name         (void);
 
 
@@ -273,7 +271,7 @@ static gboolean migrate_old_config(const gchar *old_cfg_dir, const gchar *new_cf
        GtkWidget *window = NULL;
        if (alertpanel(_("Migration of configuration"),
                       message,
-                      GTK_STOCK_NO, GTK_STOCK_YES, NULL) != G_ALERTALTERNATE) {
+                      GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL) != G_ALERTALTERNATE) {
                return FALSE;
        }
        
@@ -501,6 +499,9 @@ static void sc_session_manager_connect(MainWindow *mainwin)
 }
 #endif
 
+static gboolean sc_exiting = FALSE;
+static gboolean sc_starting = FALSE;
+
 int main(int argc, char *argv[])
 {
        gchar *userrc;
@@ -511,6 +512,8 @@ int main(int argc, char *argv[])
        gint num_folder_class = 0;
        START_TIMING("startup");
        
+       sc_starting = TRUE;
+
        if (!claws_init(&argc, &argv)) {
                return 0;
        }
@@ -602,11 +605,11 @@ int main(int argc, char *argv[])
                prefs_destroy_cache();
                gboolean r = FALSE;
                if (is_dir_exist(OLD_GTK2_RC_DIR))
-                       r = migrate_old_config(OLD_GTK2_RC_DIR, RC_DIR, _("Sylpheed-Claws 2.6.0"));
+                       r = migrate_old_config(OLD_GTK2_RC_DIR, RC_DIR, "Sylpheed-Claws 2.6.0");
                else if (is_dir_exist(OLDER_GTK2_RC_DIR))
-                       r = migrate_old_config(OLDER_GTK2_RC_DIR, RC_DIR, _("Sylpheed-Claws 1.9.15"));
+                       r = migrate_old_config(OLDER_GTK2_RC_DIR, RC_DIR, "Sylpheed-Claws 1.9.15");
                else if (is_dir_exist(OLD_GTK1_RC_DIR))
-                       r = migrate_old_config(OLD_GTK1_RC_DIR, RC_DIR, _("Sylpheed-Claws 1.0.5"));
+                       r = migrate_old_config(OLD_GTK1_RC_DIR, RC_DIR, "Sylpheed-Claws 1.0.5");
                if (r == FALSE && !is_dir_exist(RC_DIR) && make_dir(RC_DIR) < 0)
                        exit(1);
        }
@@ -628,10 +631,6 @@ int main(int argc, char *argv[])
        gtk_accel_map_load (userrc);
        g_free(userrc);
 
-       gtk_settings_set_long_property(gtk_settings_get_default(), 
-                                      "gtk-can-change-accels",
-                                      (glong)TRUE, "XProperty");
-
        CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), 1);
 
        MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir());
@@ -675,7 +674,7 @@ int main(int argc, char *argv[])
        gtkaspell_checkers_init();
        prefs_spelling_init();
 #endif
-       
+
        sock_set_io_timeout(prefs_common.io_timeout_secs);
 #ifdef HAVE_LIBETPAN
        imap_main_set_timeout(prefs_common.io_timeout_secs);
@@ -728,8 +727,10 @@ int main(int argc, char *argv[])
                if (!run_wizard(mainwin, FALSE))
                        exit(1);
                account_read_config_all();
-               if(!account_get_list())
+               if(!account_get_list()) {
                        exit_claws(mainwin);
+                       exit(1);
+               }
        }
 
        
@@ -811,13 +812,21 @@ int main(int argc, char *argv[])
        if (!folder_have_mailbox()) {
                prefs_destroy_cache();
                main_window_cursor_normal(mainwin);
-               alertpanel_error(_("Claws Mail has detected a configured "
+               if (folder_get_list() != NULL) {
+                       alertpanel_error(_("Claws Mail has detected a configured "
+                                  "mailbox, but is it incomplete. It is "
+                                  "possibly due to a failing IMAP account. Use "
+                                  "\"Rebuild folder tree\" on the mailbox's folder "
+                                  "to try to fix it."));
+               } else {
+                       alertpanel_error(_("Claws Mail has detected a configured "
                                   "mailbox, but could not load it. It is "
                                   "probably provided by an out-of-date "
                                   "external plugin. Please reinstall the "
-                                  "plugin and try again.\nIt may also be 
-                                  "due to a failing IMAP account."));
-               exit(1);
+                                  "plugin and try again."));
+                       exit_claws(mainwin);
+                       exit(1);
+               }
        }
        
        static_mainwindow = mainwin;
@@ -863,7 +872,10 @@ int main(int argc, char *argv[])
        }
 
        prefs_destroy_cache();
+       
+       sc_starting = FALSE;
        END_TIMING();
+       
        gtk_main();
 
        exit_claws(mainwin);
@@ -883,8 +895,6 @@ static void save_all_caches(FolderItem *item, gpointer data)
        folder_item_free_cache(item, TRUE);
 }
 
-static gboolean sc_exiting = FALSE;
-
 static void exit_claws(MainWindow *mainwin)
 {
        gchar *filename;
@@ -1020,7 +1030,8 @@ static void parse_cmd_opt(int argc, char *argv[])
                        }
                } else if (!strncmp(argv[i], "--send", 6)) {
                        cmd.send = TRUE;
-               } else if (!strncmp(argv[i], "--version", 9)) {
+               } else if (!strncmp(argv[i], "--version", 9) ||
+                          !strncmp(argv[i], "-v", 2)) {
                        puts("Claws Mail version " VERSION);
                        exit(0);
                } else if (!strncmp(argv[i], "--status-full", 13)) {
@@ -1053,7 +1064,8 @@ static void parse_cmd_opt(int argc, char *argv[])
                        cmd.online_mode = ONLINE_MODE_ONLINE;
                } else if (!strncmp(argv[i], "--offline", 9)) {
                        cmd.online_mode = ONLINE_MODE_OFFLINE;
-               } else if (!strncmp(argv[i], "--help", 6)) {
+               } else if (!strncmp(argv[i], "--help", 6) ||
+                          !strncmp(argv[i], "-h", 2)) {
                        gchar *base = g_path_get_basename(argv[0]);
                        g_print(_("Usage: %s [OPTION]...\n"), base);
 
@@ -1069,13 +1081,13 @@ static void parse_cmd_opt(int argc, char *argv[])
                        g_print("%s\n", _("  --status-full [folder]...\n"
                               "                         show the status of each folder"));
                        g_print("%s\n", _("  --select folder[/msg]  jumps to the specified folder/message\n" 
-                                         "                         folder is a folder id like '#mh/Mailbox/inbox'"));
+                                         "                         folder is a folder id like 'folder/sub_folder'"));
                        g_print("%s\n", _("  --online               switch to online mode"));
                        g_print("%s\n", _("  --offline              switch to offline mode"));
-                       g_print("%s\n", _("  --exit                 exit Claws Mail"));
+                       g_print("%s\n", _("  --exit --quit -q       exit Claws Mail"));
                        g_print("%s\n", _("  --debug                debug mode"));
-                       g_print("%s\n", _("  --help                 display this help and exit"));
-                       g_print("%s\n", _("  --version              output version information and exit"));
+                       g_print("%s\n", _("  --help -h              display this help and exit"));
+                       g_print("%s\n", _("  --version -v           output version information and exit"));
                        g_print("%s\n", _("  --config-dir           output configuration directory"));
 
                        g_free(base);
@@ -1087,7 +1099,9 @@ static void parse_cmd_opt(int argc, char *argv[])
                } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
                        puts(RC_DIR);
                        exit(0);
-               } else if (!strncmp(argv[i], "--exit", 6)) {
+               } else if (!strncmp(argv[i], "--exit", 6) ||
+                          !strncmp(argv[i], "--quit", 6) ||
+                          !strncmp(argv[i], "-q", 2)) {
                        cmd.exit = TRUE;
                } else if (!strncmp(argv[i], "--select", 8) && i+1 < argc) {
                        cmd.target = argv[i+1];
@@ -1111,9 +1125,11 @@ static void parse_cmd_opt(int argc, char *argv[])
                                        cmd.subscribe = TRUE;
                                        cmd.subscribe_uri = p;
                                }
+                       } else {
+                               g_print(_("Unknown option\n"));
+                               exit(1);
                        }
                }
-               
        }
 
        if (cmd.attach_files && cmd.compose == FALSE) {
@@ -1246,13 +1262,15 @@ gboolean claws_is_exiting(void)
        return sc_exiting;
 }
 
+gboolean claws_is_starting(void)
+{
+       return sc_starting;
+}
+
 /*
  * CLAWS: want this public so crash dialog can delete the
  * lock file too
  */
-#ifndef CLAWS
-static
-#endif
 gchar *get_socket_name(void)
 {
        static gchar *filename = NULL;