From ccad8ad56a93e7d59aeae5e314beac555398b289 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Fri, 10 Jan 2003 18:06:37 +0000 Subject: (set_default_folder_physical_uri_from_path): New function. (e_setup_check_config): Call it for each of the *_path keys. Do not set the default for *_path keys as those come from the GConf schema anyways. svn path=/trunk/; revision=19404 --- shell/e-setup.c | 66 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'shell/e-setup.c') diff --git a/shell/e-setup.c b/shell/e-setup.c index c9ca711d3f..d7d19a9c37 100644 --- a/shell/e-setup.c +++ b/shell/e-setup.c @@ -31,6 +31,8 @@ #include "e-shell-config.h" #include "e-shell-constants.h" +#include "e-util/e-path.h" + #include #include @@ -421,40 +423,62 @@ e_setup (const char *evolution_directory) } +static void +set_default_folder_physical_uri_from_path (GConfClient *client, + const char *evolution_directory, + const char *path_key_name) +{ + char *gconf_path; + char *path_value; + + gconf_path = g_strconcat ("/apps/evolution/shell/default_folders/", path_key_name, NULL); + path_value = gconf_client_get_string (client, gconf_path, NULL); + g_free (gconf_path); + + if (path_value != NULL + && strncmp (path_value, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0 + && strncmp (path_value + E_SHELL_URI_PREFIX_LEN, "/local/", 7) == 0) { + char *key_prefix; + char *local_physical_uri; + char *file_uri_prefix; + + key_prefix = g_strndup (path_key_name, strchr (path_key_name, '_') - path_key_name); + gconf_path = g_strconcat ("/apps/evolution/shell/default_folders/", key_prefix, "_uri", NULL); + file_uri_prefix = g_strconcat ("file://", evolution_directory, "/local", NULL); + local_physical_uri = e_path_to_physical (file_uri_prefix, path_value + E_SHELL_URI_PREFIX_LEN + 6); + + gconf_client_set_string (client, gconf_path, local_physical_uri, NULL); + + g_free (gconf_path); + g_free (key_prefix); + g_free (local_physical_uri); + g_free (file_uri_prefix); + } +} + void e_setup_check_config (const char *evolution_directory) { GConfClient *client; char *tmp; - char *uri; client = gconf_client_get_default (); - tmp = gconf_client_get_string (client, "/apps/evolution/shell/default_folders/mail_path", NULL); + tmp = gconf_client_get_string (client, "/apps/evolution/shell/default_folders/mail_uri", NULL); if (tmp != NULL && *tmp != 0) { g_object_unref (client); return; } - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/mail_path", E_LOCAL_INBOX_URI, NULL); - uri = g_strconcat ("file://", evolution_directory, "/local", strrchr (E_LOCAL_INBOX_URI, '/'), NULL); - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/mail_uri", uri, NULL); - g_free (uri); - - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/contacts_path", E_LOCAL_CONTACTS_URI, NULL); - uri = g_strconcat ("file://", evolution_directory, "/local", strrchr (E_LOCAL_CONTACTS_URI, '/'), NULL); - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/contacts_uri", uri, NULL); - g_free (uri); - - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/tasks_path", E_LOCAL_TASKS_URI, NULL); - uri = g_strconcat ("file://", evolution_directory, "/local", strrchr (E_LOCAL_TASKS_URI, '/'), NULL); - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/tasks_uri", uri, NULL); - g_free (uri); - - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/calendar_path", E_LOCAL_CALENDAR_URI, NULL); - uri = g_strconcat ("file://", evolution_directory, "/local", strrchr (E_LOCAL_CALENDAR_URI, '/'), NULL); - gconf_client_set_string (client, "/apps/evolution/shell/default_folders/calendar_uri", uri, NULL); - g_free (uri); + /* The following ugliness is to initially set up the physical URIs + based on the default path values (which come from GConf). Of + course, this way of configuring the default folders is a bit of a + mess and needs to be cleaned up... */ + + set_default_folder_physical_uri_from_path (client, evolution_directory, "mail_path"); + set_default_folder_physical_uri_from_path (client, evolution_directory, "contacts_path"); + set_default_folder_physical_uri_from_path (client, evolution_directory, "calendar_path"); + set_default_folder_physical_uri_from_path (client, evolution_directory, "tasks_path"); g_object_unref (client); } -- cgit v1.2.3