[evolution-data-server/openismus-work-3-8: 82/118] EBookBackend: Added new methods for creating and deleting cursors.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-3-8: 82/118] EBookBackend: Added new methods for creating and deleting cursors.
- Date: Wed, 2 Oct 2013 21:22:37 +0000 (UTC)
commit 0a95d4ef8b5affeea5f09172e077b91e6c4e528b
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Tue Jul 2 17:44:31 2013 +0900
EBookBackend: Added new methods for creating and deleting cursors.
addressbook/libedata-book/e-book-backend.c | 78 ++++++++++++++++++++++++++++
addressbook/libedata-book/e-book-backend.h | 20 +++++++-
2 files changed, 97 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index af25c76..90c0edb 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -1504,3 +1504,81 @@ e_book_backend_respond_opened (EBookBackend *backend,
e_data_book_respond_open (book, opid, error);
}
+
+/**
+ * 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 a70d621..c1777b3 100644
--- a/addressbook/libedata-book/e-book-backend.h
+++ b/addressbook/libedata-book/e-book-backend.h
@@ -30,8 +30,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 \
@@ -203,6 +204,14 @@ struct _EBookBackendClass {
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);
/* Notification signals */
void (*sync) (EBookBackend *backend);
@@ -308,6 +317,15 @@ 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);
+
/* protected functions for subclasses */
void e_book_backend_set_is_removed (EBookBackend *backend,
gboolean is_removed);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]