[evolution-data-server/october-code-drop-post-api-change: 20/39] EBookBackendSqliteDB: Fixed e_book_backend_sqlitedb_cursor_calculate().



commit ffbb21396903c5fcbedd5ce6ea08a1f987ae99a5
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Sat Oct 19 01:11:00 2013 +0200

    EBookBackendSqliteDB: Fixed e_book_backend_sqlitedb_cursor_calculate().
    
    Now total + 1 is reported for a position at the "END" of the list.

 .../libedata-book/e-book-backend-sqlitedb.c        |   24 +++++++++++++++++--
 1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb.c 
b/addressbook/libedata-book/e-book-backend-sqlitedb.c
index d4b23cd..68ea3b3 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -6424,16 +6424,26 @@ e_book_backend_sqlitedb_cursor_calculate (EBookBackendSqliteDB *ebsdb,
                                          GError              **error)
 {
        gboolean success = TRUE;
+       gint local_total = 0;
 
        g_return_val_if_fail (E_IS_BOOK_BACKEND_SQLITEDB (ebsdb), FALSE);
        g_return_val_if_fail (cursor != NULL, FALSE);
 
        /* If we're in a clear cursor state, then the position is 0 */
        if (position && cursor->state.values[0] == NULL) {
-               *position = 0;
 
-               /* Mark the local pointer NULL, no need to calculate this anymore */
-               position = NULL;
+               if (cursor->state.position == EBSDB_CURSOR_ORIGIN_BEGIN) {
+                       /* Mark the local pointer NULL, no need to calculate this anymore */
+                       *position = 0;
+                       position = NULL;
+               } else if (cursor->state.position == EBSDB_CURSOR_ORIGIN_END) {
+
+                       /* Make sure that we look up the total so we can
+                        * set the position to 'total + 1'
+                        */
+                       if (!total)
+                               total = &local_total;
+               }
        }
 
        /* Early return if there is nothing to do */
@@ -6459,8 +6469,16 @@ e_book_backend_sqlitedb_cursor_calculate (EBookBackendSqliteDB *ebsdb,
                /* The GError is already set. */
                book_backend_sqlitedb_rollback_transaction (ebsdb, NULL);
 
+
        UNLOCK_MUTEX (&ebsdb->priv->lock);
 
+       /* In the case we're at the end, we just set the position
+        * to be the total + 1
+        */
+       if (success && position && total &&
+           cursor->state.position == EBSDB_CURSOR_ORIGIN_END)
+               *position = *total + 1;
+
        return success;
 }
 


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