From: Colin Leroy Date: Wed, 3 Oct 2007 16:58:44 +0000 (+0000) Subject: 2007-10-03 [colin] 3.0.2cvs3 X-Git-Tag: rel_3_1_0~160 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=c5b05b39b963f8aad8d16f95b567418c06eca315 2007-10-03 [colin] 3.0.2cvs3 * src/main.c * src/common/utils.c * src/common/utils.h Implement run-time alternative config directories --- diff --git a/ChangeLog b/ChangeLog index 3545edd09..647129293 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-03 [colin] 3.0.2cvs3 + + * src/main.c + * src/common/utils.c + * src/common/utils.h + Implement run-time alternative config directories + 2007-10-03 [colin] 3.0.2cvs2 * src/folderview.c diff --git a/PATCHSETS b/PATCHSETS index 2687173a9..6113cb7b5 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2915,3 +2915,4 @@ ( cvs diff -u -r 1.179.2.190 -r 1.179.2.191 src/imap.c; ) > 3.0.1cvs49.patchset ( cvs diff -u -r 1.42.2.35 -r 1.42.2.36 NEWS; cvs diff -u -r 1.8.2.42 -r 1.8.2.43 README; cvs diff -u -r 1.1.2.24 -r 1.1.2.25 RELEASE_NOTES; cvs diff -u -r 1.654.2.2969 -r 1.654.2.2970 configure.ac; ) > 3.0.2cvs1.patchset ( cvs diff -u -r 1.207.2.185 -r 1.207.2.186 src/folderview.c; ) > 3.0.2cvs2.patchset +( cvs diff -u -r 1.115.2.167 -r 1.115.2.168 src/main.c; cvs diff -u -r 1.36.2.114 -r 1.36.2.115 src/common/utils.c; cvs diff -u -r 1.20.2.51 -r 1.20.2.52 src/common/utils.h; ) > 3.0.2cvs3.patchset diff --git a/configure.ac b/configure.ac index 5c802bcdd..f8862bef7 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=0 MICRO_VERSION=2 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=2 +EXTRA_VERSION=3 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/common/utils.c b/src/common/utils.c index 0b2adc727..f620d34f7 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -1921,15 +1921,42 @@ const gchar *get_home_dir(void) #endif } +static gchar *claws_rc_dir = NULL; +static gboolean rc_dir_alt = FALSE; const gchar *get_rc_dir(void) { - static gchar *rc_dir = NULL; - if (!rc_dir) - rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, + if (!claws_rc_dir) + claws_rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, RC_DIR, NULL); - return rc_dir; + return claws_rc_dir; +} + +void set_rc_dir(const gchar *dir) +{ + if (claws_rc_dir != NULL) { + g_print("Error: rc_dir already set\n"); + } else { + rc_dir_alt = TRUE; + if (g_path_is_absolute(dir)) + claws_rc_dir = g_strdup(dir); + else { + claws_rc_dir = g_strconcat(g_get_current_dir(), + G_DIR_SEPARATOR_S, dir, NULL); + } + debug_print("set rc_dir to %s\n", claws_rc_dir); + if (!is_dir_exist(claws_rc_dir)) { + if (make_dir_hier(claws_rc_dir) != 0) { + g_print("Error: can't create %s\n", + claws_rc_dir); + } + } + } +} + +gboolean rc_dir_is_alt(void) { + return rc_dir_alt; } const gchar *get_mail_base_dir(void) diff --git a/src/common/utils.h b/src/common/utils.h index f335211a2..f434740ec 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -384,6 +384,8 @@ gint scan_mailto_url (const gchar *mailto, /* return static strings */ const gchar *get_home_dir (void); const gchar *get_rc_dir (void); +void set_rc_dir (const gchar *dir); +gboolean rc_dir_is_alt (void); const gchar *get_mail_base_dir (void); const gchar *get_news_cache_dir (void); const gchar *get_imap_cache_dir (void); diff --git a/src/main.c b/src/main.c index 04ad8728b..76ec27324 100644 --- a/src/main.c +++ b/src/main.c @@ -800,12 +800,13 @@ int main(int argc, char *argv[]) return 0; } - prefs_prepare_cache(); prog_version = PROG_VERSION; argv0 = g_strdup(argv[0]); parse_cmd_opt(argc, argv); + prefs_prepare_cache(); + #ifdef CRASH_DIALOG if (cmd.crash) { gtk_set_locale(); @@ -1499,7 +1500,7 @@ static void parse_cmd_opt(int argc, char *argv[]) cmd.send = TRUE; } else if (!strncmp(argv[i], "--version", 9) || !strncmp(argv[i], "-v", 2)) { - g_print("Claws Mail version " VERSION); + g_print("Claws Mail version " VERSION "\n"); exit(0); } else if (!strncmp(argv[i], "--status-full", 13)) { const gchar *p = argv[i + 1]; @@ -1546,7 +1547,7 @@ static void parse_cmd_opt(int argc, char *argv[]) g_print("%s\n", _(" --send send all queued messages")); g_print("%s\n", _(" --status [folder]... show the total number of messages")); g_print("%s\n", _(" --status-full [folder]...\n" - " show the status of each folder")); + " 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 'folder/sub_folder'")); g_print("%s\n", _(" --online switch to online mode")); @@ -1556,6 +1557,8 @@ static void parse_cmd_opt(int argc, char *argv[]) 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_print("%s\n", _(" --alternate-config-dir [dir]\n" + " use specified configuration directory")); g_free(base); exit(1); @@ -1564,8 +1567,10 @@ static void parse_cmd_opt(int argc, char *argv[]) cmd.crash_params = g_strdup(argv[i + 1]); i++; } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) { - g_print(RC_DIR); + g_print(RC_DIR "\n"); exit(0); + } else if (!strncmp(argv[i], "--alternate-config-dir", sizeof "--alternate-config-dir" - 1) && i+1 < argc) { + set_rc_dir(argv[i+1]); } else if (!strncmp(argv[i], "--exit", 6) || !strncmp(argv[i], "--quit", 6) || !strncmp(argv[i], "-q", 2)) { @@ -1732,10 +1737,15 @@ gboolean claws_is_starting(void) gchar *claws_get_socket_name(void) { static gchar *filename = NULL; - + const gchar *socket_dir = NULL; + + if (rc_dir_is_alt()) + socket_dir = get_rc_dir(); + else + socket_dir = g_get_tmp_dir(); if (filename == NULL) { filename = g_strdup_printf("%s%cclaws-mail-%d", - g_get_tmp_dir(), G_DIR_SEPARATOR, + socket_dir, G_DIR_SEPARATOR, #if HAVE_GETUID getuid()); #else