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



commit 97ff060334247edbde950d712276b2f7712e576d
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 92d78ba..264294b 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -3349,3 +3349,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 3c80a39..fcbe45e 100644
--- a/addressbook/libedata-book/e-book-backend.h
+++ b/addressbook/libedata-book/e-book-backend.h
@@ -33,8 +33,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 \
@@ -221,6 +222,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,
@@ -394,6 +403,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]