[evolution-data-server/cursor-staging: 5/17] EBookBackend: Adding cursor related APIs
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/cursor-staging: 5/17] EBookBackend: Adding cursor related APIs
- Date: Tue, 30 Jul 2013 21:35:28 +0000 (UTC)
commit c2a920d1139bced15f7010fad98b2af39cd2794b
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Fri May 17 20:03:45 2013 +0900
EBookBackend: Adding cursor related APIs
Added new ->set_locale() API and ->get_locale() API
Use these to dynamically set the locale of a running addressbook, and also
to fetch the currently configured locale of an addressbook at startup time
Also added new methods for creating and deleting cursors.
addressbook/libedata-book/e-book-backend.c | 127 ++++++++++++++++++++++++++++
addressbook/libedata-book/e-book-backend.h | 29 ++++++-
2 files changed, 155 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index fe03891..45b1124 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -3073,6 +3073,56 @@ e_book_backend_sync (EBookBackend *backend)
}
/**
+ * e_book_backend_set_locale:
+ * @backend: an #EBookbackend
+ * @locale: the new locale for the addressbook
+ *
+ * Notify the addressbook backend that the current locale has
+ * changed, this is important for backends which support
+ * ordered result lists which are locale sensitive.
+ *
+ * Since: 3.10
+ */
+void
+e_book_backend_set_locale (EBookBackend *backend,
+ const gchar *locale)
+{
+ g_return_if_fail (E_IS_BOOK_BACKEND (backend));
+
+ g_object_ref (backend);
+
+ if (E_BOOK_BACKEND_GET_CLASS (backend)->set_locale)
+ (* E_BOOK_BACKEND_GET_CLASS (backend)->set_locale) (backend, locale);
+
+ g_object_unref (backend);
+}
+
+/**
+ * e_book_backend_get_locale:
+ * @backend: an #EBookbackend
+ *
+ * Fetch the currently configured locale for the addressbook
+ *
+ * Since: 3.10
+ */
+const gchar *
+e_book_backend_get_locale (EBookBackend *backend)
+{
+ const gchar *locale = NULL;
+
+ g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), NULL);
+
+ g_object_ref (backend);
+
+ if (E_BOOK_BACKEND_GET_CLASS (backend)->get_locale)
+ locale = (* E_BOOK_BACKEND_GET_CLASS (backend)->get_locale) (backend);
+
+ g_object_unref (backend);
+
+ return locale;
+}
+
+/**
* e_book_backend_notify_update:
* @backend: an #EBookBackend
* @contact: a new or modified contact
@@ -3260,3 +3310,80 @@ e_book_backend_prepare_for_completion (EBookBackend *backend,
return simple;
}
+/**
+ * e_book_backend_create_cursor:
+ * @backend: an #EBookBackend
+ * @sort_fields: the #EContactFields to sort by
+ * @sort_types: the #EBookSortTypes for the sorted fields
+ * @n_fields: the number of fields in the @sort_fields and @sort_types
+ * @error: return location for a #GError, or %NULL
+ *
+ * Creates a new #EDataBookCursor for the given backend if the backend
+ * has cursor support. If the backend does not support cursors then
+ * a %E_CLIENT_ERROR_NOT_SUPPORTED error will be set in @error.
+ *
+ * Backends can also refuse to create cursors for some values of @sort_fields
+ * and report more specific errors.
+ *
+ * The returned cursor belongs to @backend and should be destroyed
+ * with e_book_backend_delete_cursor() when no longer needed.
+ *
+ * Returns: (transfer none): A newly created cursor, the cursor belongs
+ * to the backend and should not be unreffed, or %NULL
+ *
+ * Since: 3.10
+ */
+EDataBookCursor *
+e_book_backend_create_cursor (EBookBackend *backend,
+ EContactField *sort_fields,
+ EBookSortType *sort_types,
+ guint n_fields,
+ GError **error)
+{
+ EDataBookCursor *cursor = NULL;
+
+ g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), NULL);
+
+ g_object_ref (backend);
+
+ if (E_BOOK_BACKEND_GET_CLASS (backend)->create_cursor)
+ cursor = (* E_BOOK_BACKEND_GET_CLASS (backend)->create_cursor) (backend,
+ sort_fields,
+ sort_types,
+ n_fields,
+ error);
+ else
+ g_set_error (error,
+ E_CLIENT_ERROR,
+ E_CLIENT_ERROR_NOT_SUPPORTED,
+ "Addressbook backend does not support cursors");
+
+ g_object_unref (backend);
+
+ return cursor;
+}
+
+/**
+ * e_book_backend_delete_cursor:
+ * @backend: an #EBookBackend
+ * @cursor: the #EDataBookCursor to destroy
+ *
+ * Destroys @cursor
+ *
+ * Since: 3.10
+ */
+void
+e_book_backend_delete_cursor (EBookBackend *backend,
+ EDataBookCursor *cursor)
+{
+ g_return_if_fail (E_IS_BOOK_BACKEND (backend));
+
+ g_object_ref (backend);
+
+ if (E_BOOK_BACKEND_GET_CLASS (backend)->delete_cursor)
+ (* E_BOOK_BACKEND_GET_CLASS (backend)->delete_cursor) (backend, cursor);
+ else
+ g_warning ("Backend asked to delete a cursor, but does not support cursors");
+
+ g_object_unref (backend);
+}
diff --git a/addressbook/libedata-book/e-book-backend.h b/addressbook/libedata-book/e-book-backend.h
index a4668d1..48ffbce 100644
--- a/addressbook/libedata-book/e-book-backend.h
+++ b/addressbook/libedata-book/e-book-backend.h
@@ -27,8 +27,9 @@
#include <libebackend/libebackend.h>
#include <libedata-book/e-data-book.h>
-#include <libedata-book/e-data-book-view.h>
+#include <libedata-book/e-data-book-cursor.h>
#include <libedata-book/e-data-book-direct.h>
+#include <libedata-book/e-data-book-view.h>
/* Standard GObject macros */
#define E_TYPE_BOOK_BACKEND \
@@ -211,6 +212,19 @@ struct _EBookBackendClass {
void (*sync) (EBookBackend *backend);
+ void (*set_locale) (EBookBackend *backend,
+ const gchar *locale);
+ const gchar *(*get_locale) (EBookBackend *backend);
+
+ EDataBookCursor *
+ (*create_cursor) (EBookBackend *backend,
+ EContactField *sort_fields,
+ EBookSortType *sort_types,
+ guint n_fields,
+ GError **error);
+ void (* delete_cursor) (EBookBackend *backend,
+ EDataBookCursor *cursor);
+
/* Signals */
void (*closed) (EBookBackend *backend,
const gchar *sender);
@@ -378,6 +392,19 @@ void e_book_backend_configure_direct (EBookBackend *backend,
void e_book_backend_sync (EBookBackend *backend);
+void e_book_backend_set_locale (EBookBackend *backend,
+ const gchar *locale);
+const gchar *e_book_backend_get_locale (EBookBackend *backend);
+
+EDataBookCursor *
+ e_book_backend_create_cursor (EBookBackend *backend,
+ EContactField *sort_fields,
+ EBookSortType *sort_types,
+ guint n_fields,
+ GError **error);
+void e_book_backend_delete_cursor (EBookBackend *backend,
+ EDataBookCursor *cursor);
+
GSimpleAsyncResult *
e_book_backend_prepare_for_completion
(EBookBackend *backend,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]