[evolution-data-server/openismus-work-3-8: 18/43] Ported migration routine from EBookBackendFile to use EBookSqlite



commit 1c737c2d0557ae1b76b77d4d23410fe3b16d4bcf
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Sun Dec 1 16:06:33 2013 +0900

    Ported migration routine from EBookBackendFile to use EBookSqlite

 .../file/e-book-backend-file-migrate-bdb.c         |   23 ++++++++++---------
 .../file/e-book-backend-file-migrate-bdb.h         |   10 ++++----
 2 files changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file-migrate-bdb.c 
b/addressbook/backends/file/e-book-backend-file-migrate-bdb.c
index feec8dc..e5dacb3 100644
--- a/addressbook/backends/file/e-book-backend-file-migrate-bdb.c
+++ b/addressbook/backends/file/e-book-backend-file-migrate-bdb.c
@@ -306,10 +306,10 @@ e_book_backend_file_maybe_upgrade_db (DB *db)
 }
 
 static gboolean
-migrate_bdb_to_sqlitedb (EBookBackendSqliteDB *sqlitedb,
-                         const gchar *sqlite_folder_id,
-                         DB *db,
-                         GError **error)
+migrate_bdb_to_sqlite (EBookSqlite *sqlitedb,
+                      DB *db,
+                      GCancellable *cancellable,
+                      GError **error)
 {
        DBC            *dbc;
        DBT             id_dbt, vcard_dbt;
@@ -363,9 +363,7 @@ migrate_bdb_to_sqlitedb (EBookBackendSqliteDB *sqlitedb,
 
        /* Add the contacts to the SQLite (only if there are any contacts to add) */
        if (contacts &&
-           !e_book_backend_sqlitedb_add_contacts (sqlitedb,
-                                                  sqlite_folder_id,
-                                                  contacts, FALSE, error)) {
+           !e_book_sqlite_add_contacts (sqlitedb, contacts, NULL, TRUE, cancellable, error)) {
                if (error && *error) {
                        g_warning ("Failed to add contacts to sqlite db: %s", (*error)->message);
                } else {
@@ -378,7 +376,10 @@ migrate_bdb_to_sqlitedb (EBookBackendSqliteDB *sqlitedb,
 
        e_util_free_object_slist (contacts);
 
-       if (!e_book_backend_sqlitedb_set_is_populated (sqlitedb, sqlite_folder_id, TRUE, error)) {
+       if (!e_book_sqlite_set_key_value_int (sqlitedb,
+                                             E_BOOK_SQL_IS_POPULATED_KEY,
+                                             TRUE,
+                                             error)) {
                if (error && *error) {
                        g_warning ("Failed to set the sqlitedb populated flag: %s", (*error)->message);
                } else {
@@ -391,10 +392,10 @@ migrate_bdb_to_sqlitedb (EBookBackendSqliteDB *sqlitedb,
 }
 
 gboolean
-e_book_backend_file_migrate_bdb (EBookBackendSqliteDB *sqlitedb,
-                                 const gchar *sqlite_folder_id,
+e_book_backend_file_migrate_bdb (EBookSqlite *sqlitedb,
                                  const gchar *dirname,
                                  const gchar *filename,
+                                GCancellable *cancellable,
                                  GError **error)
 {
        DB        *db = NULL;
@@ -517,7 +518,7 @@ e_book_backend_file_migrate_bdb (EBookBackendSqliteDB *sqlitedb,
        /* Now we have our old BDB up and running and migrated to the latest known BDB version,
         * lets go ahead and now migrate it to the sqlite DB
         */
-       if (migrate_bdb_to_sqlitedb (sqlitedb, sqlite_folder_id, db, error))
+       if (migrate_bdb_to_sqlite (sqlitedb, db, cancellable, error))
                status = TRUE;
 
  close_db:
diff --git a/addressbook/backends/file/e-book-backend-file-migrate-bdb.h 
b/addressbook/backends/file/e-book-backend-file-migrate-bdb.h
index ab8dc77..823ee00 100644
--- a/addressbook/backends/file/e-book-backend-file-migrate-bdb.h
+++ b/addressbook/backends/file/e-book-backend-file-migrate-bdb.h
@@ -28,11 +28,11 @@
 
 G_BEGIN_DECLS
 
-gboolean e_book_backend_file_migrate_bdb (EBookBackendSqliteDB  *sqlitedb,
-                                         const gchar           *sqlite_folder_id,
-                                         const gchar           *dirname,
-                                         const gchar           *filename,
-                                         GError               **error);
+gboolean e_book_backend_file_migrate_bdb (EBookSqlite    *sqlitedb,
+                                         const gchar    *dirname,
+                                         const gchar    *filename,
+                                         GCancellable   *cancellable,
+                                         GError        **error);
 
 G_END_DECLS
 


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