EBookBackend: Added apis for backends to support Direct Read Access
authorTristan Van Berkom <tristanvb@openismus.com>
Fri, 15 Feb 2013 08:54:24 +0000 (17:54 +0900)
committerTristan Van Berkom <tristanvb@openismus.com>
Fri, 15 Feb 2013 09:47:06 +0000 (18:47 +0900)
e_book_backend_get_direct_book:
  A backend can return an EDataBookDirect from here to indicate
  that it supports direct read access, the properties of the EDataBookDirect
  are used by the client to access the book directly

e_book_backend_configure_direct:
  A backend opened in direct read access mode can be configured with
  the string that it's server side counterpart provided, this string
  belongs to the backend; for the local file backend it is used as
  a path to ensure the same SQLite DB is opened by the client as the
  one running in the server.

addressbook/libedata-book/e-book-backend.c
addressbook/libedata-book/e-book-backend.h
configure.ac

index 200d8e2..7eaf505 100644 (file)
@@ -1098,6 +1098,54 @@ e_book_backend_set_is_removed (EBookBackend *backend,
 }
 
 /**
+ * e_book_backend_get_direct_book:
+ * @backend: an #EBookBackend
+ *
+ * Tries to create an #EDataBookDirect for @backend if
+ * backend supports direct read access.
+ *
+ * Returns: (transfer full): A new #EDataBookDirect object, or %NULL if @backend does not support direct access
+ *
+ * Since: 3.8
+ */
+EDataBookDirect *
+e_book_backend_get_direct_book (EBookBackend *backend)
+{
+       g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), NULL);
+
+       if (E_BOOK_BACKEND_GET_CLASS (backend)->get_direct_book)
+               return E_BOOK_BACKEND_GET_CLASS (backend)->get_direct_book (backend);
+
+       return NULL;
+}
+
+/**
+ * e_book_backend_configure_direct:
+ * @backend: an #EBookBackend
+ * @config: The configuration string for the given backend
+ *
+ * This method is called on @backend in direct read access mode.
+ * The @config argument is the same configuration string which
+ * the same backend reported in the #EDataBookDirect returned
+ * by e_book_backend_get_direct_book().
+ *
+ * The configuration string is optional and is used to ensure
+ * that direct access backends are properly configured to
+ * interface with the same data as the running server side backend.
+ *
+ * Since: 3.8
+ */
+void
+e_book_backend_configure_direct (EBookBackend *backend,
+                                const gchar *config)
+{
+       g_return_if_fail (E_IS_BOOK_BACKEND (backend));
+
+       if (E_BOOK_BACKEND_GET_CLASS (backend)->configure_direct)
+               E_BOOK_BACKEND_GET_CLASS (backend)->configure_direct (backend, config);
+}
+
+/**
  * e_book_backend_sync:
  * @backend: an #EBookbackend
  *
index 272e911..62430b8 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <libedata-book/e-data-book.h>
 #include <libedata-book/e-data-book-view.h>
+#include <libedata-book/e-data-book-direct.h>
 
 /* Standard GObject macros */
 #define E_TYPE_BOOK_BACKEND \
@@ -195,6 +196,11 @@ struct _EBookBackendClass {
        void            (*notify_update)        (EBookBackend *backend,
                                                 const EContact *contact);
 
+
+       EDataBookDirect *
+               (* get_direct_book)             (EBookBackend *backend);
+       void    (* configure_direct)            (EBookBackend *backend, const gchar *config);
+
        /* Notification signals */
        void            (*sync)                 (EBookBackend *backend);
 };
@@ -290,6 +296,10 @@ void               e_book_backend_notify_property_changed
                                                 const gchar *prop_name,
                                                 const gchar *prop_value);
 
+EDataBookDirect *
+                e_book_backend_get_direct_book  (EBookBackend *backend);
+void            e_book_backend_configure_direct (EBookBackend *backend, const gchar *config);
+
 void           e_book_backend_sync             (EBookBackend *backend);
 
 /* protected functions for subclasses */
index 2a012dd..0dbb3f4 100644 (file)
@@ -118,7 +118,7 @@ LIBEDATACAL_CURRENT=20
 LIBEDATACAL_REVISION=0
 LIBEDATACAL_AGE=0
 
-LIBEDATABOOK_CURRENT=16
+LIBEDATABOOK_CURRENT=17
 LIBEDATABOOK_REVISION=0
 LIBEDATABOOK_AGE=0