[evolution-data-server/evolution-data-server-3-12] Bug 735523 - Migrate sync_data from EBookBackendSqliteDB to EBookSqlite



commit f98c4aaaf001a34118f96d3b0ace3ad8889ba663
Author: David Woodhouse <David Woodhouse intel com>
Date:   Sat Aug 23 10:05:06 2014 -0500

    Bug 735523 - Migrate sync_data from EBookBackendSqliteDB to EBookSqlite
    
    We migrated the is_populated field, but not sync_data. EWS will need that.
    
    (cherry picked from commit 52c1ab355f3d28bce8aed7259fa276665cd9bf0b)

 addressbook/libedata-book/e-book-sqlite.c |   24 ++++++++++++++++++++----
 addressbook/libedata-book/e-book-sqlite.h |   13 +++++++++++++
 2 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-sqlite.c b/addressbook/libedata-book/e-book-sqlite.c
index 0ae89cd..0540ff7 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -2655,15 +2655,16 @@ ebsql_set_locale_internal (EBookSqlite *ebsql,
 
 /* Called with the lock held and inside a transaction */
 static gboolean
-ebsql_init_is_populated (EBookSqlite *ebsql,
-                         gint previous_schema,
-                         GError **error)
+ebsql_init_legacy_keys (EBookSqlite *ebsql,
+                        gint previous_schema,
+                        GError **error)
 {
        gboolean success = TRUE;
 
        /* Schema 8 is when we moved from EBookSqlite */
        if (previous_schema >= 1 && previous_schema < 8) {
                gint is_populated = 0;
+               gchar *sync_data = NULL;
 
                /* We need to hold on to the value of any previously set 'is_populated' flag */
                success = ebsql_exec_printf (
@@ -2681,6 +2682,21 @@ ebsql_init_is_populated (EBookSqlite *ebsql,
                                is_populated ? "1" : "0",
                                ebsql->priv->folderid);
                }
+
+               /* Repeat for 'sync_data' */
+               success = ebsql_exec_printf (
+                       ebsql, "SELECT sync_data FROM folders WHERE folder_id = %Q",
+                       get_string_cb, &sync_data, NULL, error, ebsql->priv->folderid);
+
+               if (success) {
+                       success = ebsql_exec_printf (
+                               ebsql, "INSERT or REPLACE INTO keys (key, value, folder_id) values (%Q, %Q, 
%Q)",
+                               NULL, NULL, NULL, error,
+                               E_BOOK_SQL_SYNC_DATA_KEY,
+                               sync_data, ebsql->priv->folderid);
+
+                       g_free (sync_data);
+               }
        }
 
        return success;
@@ -2902,7 +2918,7 @@ ebsql_new_internal (const gchar *path,
 
        /* When porting from older schemas, we need to port the old 'is-populated' flag */
        if (success)
-               success = ebsql_init_is_populated (ebsql, previous_schema, error);
+               success = ebsql_init_legacy_keys (ebsql, previous_schema, error);
 
        /* Load / resolve the current locale setting
         *
diff --git a/addressbook/libedata-book/e-book-sqlite.h b/addressbook/libedata-book/e-book-sqlite.h
index 67ba6ff..9aa1b3a 100644
--- a/addressbook/libedata-book/e-book-sqlite.h
+++ b/addressbook/libedata-book/e-book-sqlite.h
@@ -69,6 +69,19 @@
  **/
 #define E_BOOK_SQL_IS_POPULATED_KEY "eds-reserved-namespace-is-populated"
 
+/**
+ * E_BOOK_SQL_SYNC_DATA_KEY:
+ *
+ * This key can be used with e_book_sqlite_get_key_value().
+ *
+ * In the case of a migration from an older SQLite, any value which
+ * was previously stored with e_book_sqlitedb_set_sync_data()
+ * can be retrieved with this key.
+ *
+ * Since: 3.12
+ **/
+#define E_BOOK_SQL_SYNC_DATA_KEY "eds-reserved-namespace-sync-data"
+
 G_BEGIN_DECLS
 
 typedef struct _EBookSqlite EBookSqlite;


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