aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/mail-config.c4
-rw-r--r--mail/mail-session.c24
2 files changed, 20 insertions, 8 deletions
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 4914f26135..a9f1870cc2 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -617,8 +617,8 @@ mail_config_init (void)
config = g_new0 (MailConfig, 1);
config->gconf = gconf_client_get_default ();
config->gtkrc = g_build_filename (
- e_get_user_data_dir (), "mail",
- "config", "gtkrc-mail-fonts", NULL);
+ mail_session_get_config_dir (),
+ "gtkrc-mail-fonts", NULL);
mail_config_clear ();
diff --git a/mail/mail-session.c b/mail/mail-session.c
index a985aef6b8..86f6fa180e 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -25,6 +25,7 @@
#include <config.h>
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -87,8 +88,8 @@ typedef struct _MailSessionClass {
} MailSessionClass;
static CamelSessionClass *ms_parent_class;
-static gchar * mail_data_dir;
-static gchar * mail_config_dir;
+static gchar *mail_data_dir;
+static gchar *mail_config_dir;
static gchar *get_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *prompt, const gchar *item, guint32 flags, CamelException *ex);
static void forget_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *item, CamelException *ex);
@@ -805,10 +806,7 @@ mail_session_init (void)
session = CAMEL_SESSION (camel_object_new (MAIL_SESSION_TYPE));
e_account_writable(NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD); /* Init the EAccount Setup */
- mail_data_dir = g_build_filename (e_get_user_data_dir (), "mail", NULL);
- mail_config_dir = g_build_filename (mail_data_dir, "config", NULL);
-
- camel_session_construct (session, mail_data_dir);
+ camel_session_construct (session, mail_session_get_data_dir ());
gconf = mail_config_get_gconf_client ();
gconf_client_add_dir (gconf, "/apps/evolution/mail/junk", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
@@ -877,12 +875,26 @@ mail_session_set_junk_headers (const gchar **name, const gchar **value, gint len
const gchar *
mail_session_get_data_dir (void)
{
+ if (G_UNLIKELY (mail_data_dir == NULL))
+ mail_data_dir = g_build_filename (
+ e_get_user_data_dir (), "mail", NULL);
+
return mail_data_dir;
}
const gchar *
mail_session_get_config_dir (void)
{
+ if (G_UNLIKELY (mail_config_dir == NULL)) {
+ mail_config_dir = g_build_filename (
+ mail_session_get_data_dir (), "config", NULL);
+
+ if (g_mkdir_with_parents (mail_config_dir, 0777) != 0)
+ g_critical (
+ "Cannot create directory %s: %s",
+ mail_config_dir, g_strerror (errno));
+ }
+
return mail_config_dir;
}