[evolution-data-server] CamelDB: Use camel_db_select while retrieving the folder version



commit 9d944e69ed19f0ff6322914fe88ab7e2261818ae
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Thu May 26 13:23:49 2011 +0530

    CamelDB: Use camel_db_select while retrieving the folder version

 camel/camel-db.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/camel/camel-db.c b/camel/camel-db.c
index 6f3460f..e7d8d3c 100644
--- a/camel/camel-db.c
+++ b/camel/camel-db.c
@@ -1530,25 +1530,26 @@ camel_db_write_folder_version (CamelDB *cdb,
 }
 
 static gint
+read_version_callback (gpointer ref, gint ncol, gchar ** cols, gchar ** name)
+{
+	gint *version = (gint *) ref;
+
+	if (cols [0])
+		*version = strtoul (cols [0], NULL, 10);
+
+	return 0;
+}
+
+static gint
 camel_db_get_folder_version (CamelDB *cdb,
                              const gchar *folder_name,
                              GError **error)
 {
 	gint version = -1, ret;
 	gchar *query;
-	sqlite3_stmt *stmt = NULL;
 
 	query = sqlite3_mprintf ("SELECT version FROM '%q_version'", folder_name);
-
-	ret = sqlite3_prepare_v2 (cdb->db, query, -1, &stmt, NULL);
-
-	if (ret == SQLITE_OK)
-		ret = sqlite3_step (stmt);
-	if (ret == SQLITE_ROW || ret == SQLITE_OK)
-		version = sqlite3_column_int (stmt, 0);
-
-	sqlite3_finalize (stmt);
-
+	ret = camel_db_select (cdb, query, read_version_callback, &version, error);
 	sqlite3_free (query);
 
 	return version;



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