[evolution-exchange] Use the new base directory functions in E-D-S.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange] Use the new base directory functions in E-D-S.
- Date: Tue, 27 Jul 2010 15:47:24 +0000 (UTC)
commit 1f83c293c3a2b041d048d41c92a8807f6879d0c6
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jun 8 18:35:23 2010 -0400
Use the new base directory functions in E-D-S.
Put an end to hard-coding "$HOME/.evolution".
addressbook/e-book-backend-db-cache.c | 24 +++++++-----------------
calendar/e-cal-backend-exchange.c | 8 ++++++--
server/storage/exchange-account.c | 11 ++++++++---
3 files changed, 21 insertions(+), 22 deletions(-)
---
diff --git a/addressbook/e-book-backend-db-cache.c b/addressbook/e-book-backend-db-cache.c
index a70771f..ed83036 100644
--- a/addressbook/e-book-backend-db-cache.c
+++ b/addressbook/e-book-backend-db-cache.c
@@ -41,28 +41,18 @@ string_to_dbt(const gchar *str, DBT *dbt)
static gchar *
get_filename_from_uri (const gchar *uri)
{
- const gchar *cache_dir;
+ const gchar *user_cache_dir;
gchar *mangled_uri, *filename;
- gint i;
- cache_dir = e_get_user_cache_dir ();
+ user_cache_dir = e_get_user_cache_dir ();
- /* mangle the URI to not contain invalid characters */
- mangled_uri = g_strdup (uri);
- for (i = 0; i < strlen (mangled_uri); i++) {
- switch (mangled_uri[i]) {
- case ':' :
- case '/' :
- mangled_uri[i] = '_';
- }
- }
+ /* Mangle the URI to not contain invalid characters. */
+ mangled_uri = g_strdelimit (g_strdup (uri), ":/", '_');
- /* generate the file name */
filename = g_build_filename (
- cache_dir, "addressbook",
+ user_cache_dir, "addresbook",
mangled_uri, "cache.db", NULL);
- /* free memory */
g_free (mangled_uri);
return filename;
diff --git a/calendar/e-cal-backend-exchange.c b/calendar/e-cal-backend-exchange.c
index 09f0b8a..9ded72a 100644
--- a/calendar/e-cal-backend-exchange.c
+++ b/calendar/e-cal-backend-exchange.c
@@ -165,6 +165,7 @@ load_cache (ECalBackendExchange *cbex, E2kUri *e2kuri, GError **perror)
icalcomponent_kind kind;
icalproperty *prop;
gchar *lastmod, *mangled_uri, *storage_dir;
+ const gchar *user_cache_dir;
const gchar *uristr;
gint i;
struct stat buf;
@@ -193,7 +194,10 @@ load_cache (ECalBackendExchange *cbex, E2kUri *e2kuri, GError **perror)
mangled_uri[i] = '_';
}
}
- cbex->priv->local_attachment_store = g_strdup_printf ("%s/.evolution/exchange/%s", g_get_home_dir (), mangled_uri);
+
+ user_cache_dir = e_get_user_cache_dir ();
+ cbex->priv->local_attachment_store = g_build_filename (
+ user_cache_dir, "calendar", mangled_uri, NULL);
storage_dir = g_path_get_dirname (cbex->priv->object_cache_file);
if (g_lstat(cbex->priv->local_attachment_store , &buf) < 0) {
@@ -1712,7 +1716,7 @@ save_attach_file (const gchar *dest_file, gchar *file_contents, gint len)
d(printf ("dest_file is :%s\n", dest_file));
- /* Write it to our local exchange store in .evolution */
+ /* Write it to our local exchange store. */
fd = g_open (dest_file, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd < 0) {
d(printf ("open of destination file for attachments failed\n"));
diff --git a/server/storage/exchange-account.c b/server/storage/exchange-account.c
index 3108cf0..f608dce 100644
--- a/server/storage/exchange-account.c
+++ b/server/storage/exchange-account.c
@@ -42,6 +42,7 @@
/* Added for get_authtype */
#include "exchange-esource.h"
#include <libedataserverui/e-passwords.h>
+#include <libedataserver/e-data-server-util.h>
#include <gtk/gtk.h>
@@ -2260,6 +2261,8 @@ exchange_account_new (EAccountList *account_list, EAccount *adata)
gchar *enc_user, *mailbox;
const gchar *param, *proto="http", *owa_path, *pf_server, *owa_url;
const gchar *passwd_exp_warn_period, *offline_sync;
+ const gchar *user_data_dir;
+ gchar *user_at_host;
E2kUri *uri;
uri = e2k_uri_new (adata->source->url);
@@ -2279,9 +2282,11 @@ exchange_account_new (EAccountList *account_list, EAccount *adata)
account->account_name = g_strdup (adata->name);
- account->storage_dir = g_strdup_printf ("%s/.evolution/exchange/%s %s",
- g_get_home_dir (),
- uri->user, uri->host);
+ user_data_dir = e_get_user_data_dir ();
+ user_at_host = g_strdup_printf ("%s %s", uri->user, uri->host);
+ account->storage_dir = g_build_filename (
+ user_data_dir, "exchange", user_at_host, NULL);
+ g_free (user_at_host);
/*account->account_filename = strrchr (account->storage_dir, '/') + 1;
e_filename_make_safe (account->account_filename); */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]