[evolution-data-server/openismus-work-master: 4/12] EBookBackendFile: Implement the new backend methods for direct access
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master: 4/12] EBookBackendFile: Implement the new backend methods for direct access
- Date: Tue, 22 Jan 2013 10:11:16 +0000 (UTC)
commit 1d30990f43ceb10ee1860ec19e7300fd29e0beba
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Thu Nov 22 17:45:08 2012 +0900
EBookBackendFile: Implement the new backend methods for direct access
addressbook/backends/file/Makefile.am | 1 +
addressbook/backends/file/e-book-backend-file.c | 51 +++++++++++++++++++++-
2 files changed, 49 insertions(+), 3 deletions(-)
---
diff --git a/addressbook/backends/file/Makefile.am b/addressbook/backends/file/Makefile.am
index de53c5d..3f646c6 100644
--- a/addressbook/backends/file/Makefile.am
+++ b/addressbook/backends/file/Makefile.am
@@ -11,6 +11,7 @@ libebookbackendfile_la_CPPFLAGS = \
$(CAMEL_CFLAGS) \
$(EVOLUTION_ADDRESSBOOK_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
+ -DBACKENDDIR="\"$(ebook_backenddir)\"" \
$(NULL)
libebookbackendfile_la_SOURCES = \
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 9d001c4..62a69e1 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -66,6 +66,7 @@
G_DEFINE_TYPE (EBookBackendFile, e_book_backend_file, E_TYPE_BOOK_BACKEND_SYNC)
struct _EBookBackendFilePrivate {
+ gchar *base_directory;
gchar *photo_dirname;
gchar *revision;
gint rev_counter;
@@ -1310,8 +1311,13 @@ e_book_backend_file_open (EBookBackendSync *backend,
source = e_backend_get_source (E_BACKEND (backend));
registry = e_book_backend_get_registry (E_BOOK_BACKEND (backend));
- dirname = e_book_backend_file_extract_path_from_source (
- registry, source, GET_PATH_DB_DIR);
+
+ if (bf->priv->base_directory)
+ dirname = g_strdup (bf->priv->base_directory);
+ else
+ dirname = e_book_backend_file_extract_path_from_source (
+ registry, source, GET_PATH_DB_DIR);
+
filename = g_build_filename (dirname, "addressbook.db", NULL);
backup = g_build_filename (dirname, "addressbook.db.old", NULL);
@@ -1477,7 +1483,9 @@ e_book_backend_file_open (EBookBackendSync *backend,
g_free (filename);
g_free (backup);
- /* Resolve the photo directory here */
+ /* Resolve the photo directory here (no need for photo directory
+ * in read access mode, it's only used for write access methods)
+ */
dirname = e_book_backend_file_extract_path_from_source (
registry, source, GET_PATH_PHOTO_DIR);
if (!only_if_exists && !create_directory (dirname, perror))
@@ -1634,6 +1642,7 @@ e_book_backend_file_finalize (GObject *object)
g_free (priv->photo_dirname);
g_free (priv->revision);
+ g_free (priv->base_directory);
g_rec_mutex_clear (&priv->revision_mutex);
g_rw_lock_clear (&(priv->lock));
@@ -1641,6 +1650,40 @@ e_book_backend_file_finalize (GObject *object)
G_OBJECT_CLASS (e_book_backend_file_parent_class)->finalize (object);
}
+
+static EDataBookDirect *
+e_book_backend_file_get_direct_book (EBookBackend *backend)
+{
+ EDataBookDirect *direct;
+ ESourceRegistry *registry;
+ ESource *source;
+ gchar *backend_path;
+ gchar *dirname;
+
+ source = e_backend_get_source (E_BACKEND (backend));
+ registry = e_book_backend_get_registry (backend);
+ dirname = e_book_backend_file_extract_path_from_source (
+ registry, source, GET_PATH_DB_DIR);
+
+ backend_path = g_build_filename (BACKENDDIR, "libebookbackendfile.so", NULL);
+ direct = e_data_book_direct_new (backend_path, "EBookBackendFileFactory", dirname);
+
+ g_free (backend_path);
+ g_free (dirname);
+
+ return direct;
+}
+
+static void
+e_book_backend_file_configure_direct (EBookBackend *backend,
+ const gchar *config)
+{
+ EBookBackendFilePrivate *priv;
+
+ priv = E_BOOK_BACKEND_FILE_GET_PRIVATE (backend);
+ priv->base_directory = g_strdup (config);
+}
+
static void
e_book_backend_file_class_init (EBookBackendFileClass *class)
{
@@ -1658,6 +1701,8 @@ e_book_backend_file_class_init (EBookBackendFileClass *class)
backend_class->stop_view = e_book_backend_file_stop_view;
backend_class->sync = e_book_backend_file_sync;
backend_class->notify_update = e_book_backend_file_notify_update;
+ backend_class->get_direct_book = e_book_backend_file_get_direct_book;
+ backend_class->configure_direct = e_book_backend_file_configure_direct;
sync_class->open_sync = e_book_backend_file_open;
sync_class->get_backend_property_sync = e_book_backend_file_get_backend_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]