[evolution-data-server/openismus-work-master: 71/81] EBookBackend: Added new methods for creating and deleting cursors.



commit fe3d3ed6f2eadf901468e40aa7eeea281f933180
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 |   77 ++++++++++++++++++++++++++++
 addressbook/libedata-book/e-book-backend.h |   20 +++++++-
 2 files changed, 96 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index 2e25e95..45b1124 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -3310,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 a00bcef..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 \
@@ -215,6 +216,14 @@ struct _EBookBackendClass {
                                                 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,
@@ -387,6 +396,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);
+
 GSimpleAsyncResult *
                e_book_backend_prepare_for_completion
                                                (EBookBackend *backend,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]