[evolution-exchange] Adapt to libedata-book and libedata-cal API changes.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange] Adapt to libedata-book and libedata-cal API changes.
- Date: Thu, 22 Jul 2010 01:23:26 +0000 (UTC)
commit 6930fd015a012b0ce201b6f38425455b86e56527
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Jul 21 08:12:45 2010 -0400
Adapt to libedata-book and libedata-cal API changes.
addressbook/e-book-backend-db-cache.c | 9 ++++++-
addressbook/e-book-backend-exchange.c | 38 +++++++++++---------------------
addressbook/e-book-backend-gal.c | 17 ++++----------
3 files changed, 25 insertions(+), 39 deletions(-)
---
diff --git a/addressbook/e-book-backend-db-cache.c b/addressbook/e-book-backend-db-cache.c
index 8ced250..a70771f 100644
--- a/addressbook/e-book-backend-db-cache.c
+++ b/addressbook/e-book-backend-db-cache.c
@@ -27,6 +27,7 @@
#include "e-book-backend-db-cache.h"
#include <libedata-book/e-book-backend.h>
#include <libedata-book/e-book-backend-sexp.h>
+#include <libedataserver/e-data-server-util.h>
void
string_to_dbt(const gchar *str, DBT *dbt)
@@ -40,9 +41,12 @@ string_to_dbt(const gchar *str, DBT *dbt)
static gchar *
get_filename_from_uri (const gchar *uri)
{
+ const gchar *cache_dir;
gchar *mangled_uri, *filename;
gint i;
+ 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++) {
@@ -54,8 +58,9 @@ get_filename_from_uri (const gchar *uri)
}
/* generate the file name */
- filename = g_build_filename (g_get_home_dir (), ".evolution/cache/addressbook",
- mangled_uri, "cache.db", NULL);
+ filename = g_build_filename (
+ cache_dir, "addressbook",
+ mangled_uri, "cache.db", NULL);
/* free memory */
g_free (mangled_uri);
diff --git a/addressbook/e-book-backend-exchange.c b/addressbook/e-book-backend-exchange.c
index ba8d5f5..ec61d2d 100644
--- a/addressbook/e-book-backend-exchange.c
+++ b/addressbook/e-book-backend-exchange.c
@@ -2800,12 +2800,16 @@ e_book_backend_exchange_load_source (EBookBackend *backend,
{
EBookBackendExchange *be = E_BOOK_BACKEND_EXCHANGE (backend);
EBookBackendExchangePrivate *bepriv = be->priv;
+ const gchar *cache_dir;
const gchar *offline;
+ gchar *filename;
e_return_data_book_error_if_fail (bepriv->connected == FALSE, E_DATA_BOOK_STATUS_OTHER_ERROR);
d(printf("ebbe_load_source(%p, %p[%s])\n", backend, source, e_source_peek_name (source)));
+ cache_dir = e_book_backend_get_cache_dir (backend);
+
offline = e_source_get_property (source, "offline_sync");
if (offline && g_str_equal (offline, "1"))
bepriv->marked_for_offline = TRUE;
@@ -2823,16 +2827,22 @@ e_book_backend_exchange_load_source (EBookBackend *backend,
}
bepriv->original_uri = g_strdup (bepriv->exchange_uri);
+ filename = g_build_filename (cache_dir, "cache.xml", NULL);
+
if (bepriv->mode == E_DATA_BOOK_MODE_LOCAL) {
e_book_backend_set_is_writable (backend, FALSE);
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
- if (!e_book_backend_cache_exists (bepriv->original_uri)) {
+ if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
g_propagate_error (error, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ g_free (filename);
return;
}
}
- bepriv->cache = e_book_backend_cache_new (bepriv->original_uri);
+
+ bepriv->cache = e_book_backend_cache_new (filename);
+
+ g_free (filename);
/* Once aunthentication in address book works this can be removed */
if (bepriv->mode == E_DATA_BOOK_MODE_LOCAL) {
@@ -2889,18 +2899,6 @@ e_book_backend_exchange_get_static_capabilites (EBookBackend *backend)
return g_strdup ("net,bulk-removes,do-initial-query,cache-completions,contact-lists");
}
-static gboolean
-e_book_backend_exchange_construct (EBookBackendExchange *backend)
-{
- g_return_val_if_fail (backend != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK_BACKEND_EXCHANGE (backend), FALSE);
-
- if (!e_book_backend_construct (E_BOOK_BACKEND (backend)))
- return FALSE;
-
- return TRUE;
-}
-
static void
e_book_backend_exchange_set_mode (EBookBackend *backend,
EDataBookMode mode)
@@ -2937,19 +2935,9 @@ e_book_backend_exchange_set_mode (EBookBackend *backend,
EBookBackend *
e_book_backend_exchange_new (void)
{
- EBookBackendExchange *backend;
-
exchange_share_config_listener_get_account_for_uri (NULL, NULL);
- backend = g_object_new (e_book_backend_exchange_get_type (), NULL);
-
- if (!e_book_backend_exchange_construct (backend)) {
- g_object_unref (backend);
-
- return NULL;
- }
-
- return E_BOOK_BACKEND (backend);
+ return g_object_new (E_TYPE_BOOK_BACKEND_EXCHANGE, NULL);
}
static void
diff --git a/addressbook/e-book-backend-gal.c b/addressbook/e-book-backend-gal.c
index 9ef092d..95c549e 100644
--- a/addressbook/e-book-backend-gal.c
+++ b/addressbook/e-book-backend-gal.c
@@ -2609,6 +2609,7 @@ load_source (EBookBackend *backend,
gchar *book_name = NULL;
gint i;
#if defined(ENABLE_CACHE) && ENABLE_CACHE
+ const gchar *cache_dir;
gchar *dirname, *filename;
gint db_error;
DB *db;
@@ -2670,13 +2671,14 @@ load_source (EBookBackend *backend,
#if defined(ENABLE_CACHE) && ENABLE_CACHE
if (bl->priv->marked_for_offline) {
d(printf("offlin==============\n"));
- bl->priv->summary_file_name = g_build_filename (g_get_home_dir(), ".evolution/cache/addressbook" , uri, book_name, NULL);
+ cache_dir = e_book_backend_get_cache_dir (backend);
+ bl->priv->summary_file_name = g_build_filename (cache_dir, book_name, NULL);
bl->priv->summary_file_name = g_build_filename (bl->priv->summary_file_name, "cache.summary", NULL);
bl->priv->summary = e_book_backend_summary_new (bl->priv->summary_file_name,
SUMMARY_FLUSH_TIMEOUT);
e_book_backend_summary_load (bl->priv->summary);
- dirname = g_build_filename (g_get_home_dir(), ".evolution/cache/addressbook", uri, book_name, NULL);
+ dirname = g_build_filename (cache_dir, book_name, NULL);
filename = g_build_filename (dirname, "cache.db", NULL);
g_free (book_name);
@@ -2829,16 +2831,7 @@ get_static_capabilities (EBookBackend *backend)
EBookBackend *
e_book_backend_gal_new (void)
{
- EBookBackendGAL *backend;
-
- backend = g_object_new (E_TYPE_BOOK_BACKEND_GAL, NULL);
- if (!e_book_backend_construct (E_BOOK_BACKEND (backend))) {
- g_object_unref (backend);
-
- return NULL;
- }
-
- return E_BOOK_BACKEND (backend);
+ return g_object_new (E_TYPE_BOOK_BACKEND_GAL, NULL);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]