evolution-data-server r9402 - trunk/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9402 - trunk/camel
- Date: Wed, 20 Aug 2008 10:55:30 +0000 (UTC)
Author: sragavan
Date: Wed Aug 20 10:55:30 2008
New Revision: 9402
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9402&view=rev
Log:
2008-08-20 Srinivasa Ragavan <sragavan novell com>
* camel/camel-db.c: Add provision to do summary specific sorts.
Summaries can now be loaded in a sorted mode.
* camel/camel-db.h:
Modified:
trunk/camel/ChangeLog
trunk/camel/camel-db.c
trunk/camel/camel-db.h
Modified: trunk/camel/camel-db.c
==============================================================================
--- trunk/camel/camel-db.c (original)
+++ trunk/camel/camel-db.c Wed Aug 20 10:55:30 2008
@@ -38,12 +38,12 @@
#if CAMEL_DB_DEBUG
/* Enable d(x) if you want */
-#define d(x)
+#define d(x)
/* Yeah it leaks, so fix it while debugging */
#define START(stmt) g_print ("\n===========\nDB SQL operation [%s] started\n", stmt); cdb->timer = g_timer_new ();
#define END g_timer_stop (cdb->timer); g_print ("DB Operation ended. Time Taken : %f\n###########\n", g_timer_elapsed (cdb->timer, NULL));
#else
-#define d(x)
+#define d(x) x
#define START(x)
#define END
#endif
@@ -120,6 +120,9 @@
cdb = g_new (CamelDB, 1);
cdb->db = db;
cdb->lock = g_mutex_new ();
+ /* These will be written once the Summary takes control of the CDB. */
+ cdb->sort_by = NULL;
+ cdb->collate = NULL;
d(g_print ("\nDatabase succesfully opened \n"));
/* Which is big / costlier ? A Stack frame or a pointer */
@@ -148,6 +151,25 @@
}
}
+int
+camel_db_set_collate (CamelDB *cdb, const char *col, const char *collate, CamelDBCollate func)
+{
+ int ret;
+
+ if (!cdb)
+ return TRUE;
+
+ g_mutex_lock (cdb->lock);
+ cdb->sort_by = col;
+ cdb->collate = collate;
+ cdb->collate_cb = func;
+ d(g_print("Creating Collation %s on %s with %p\n", collate, col, func));
+ ret = sqlite3_create_collation(cdb->db, collate, SQLITE_UTF8, NULL, func);
+ g_mutex_unlock (cdb->lock);
+
+ return ret;
+}
+
/* Should this be really exposed ? */
int
camel_db_command (CamelDB *cdb, const char *stmt, CamelException *ex)
@@ -570,8 +592,8 @@
{
char *sel_query;
int ret;
-
- sel_query = sqlite3_mprintf("SELECT uid FROM %Q", folder_name);
+
+ sel_query = sqlite3_mprintf("SELECT uid FROM %Q%s%s%s%s", folder_name, db->sort_by ? " order by " : "", db->sort_by ? db->sort_by: "", (db->sort_by && db->collate) ? " collate " : "", (db->sort_by && db->collate) ? db->collate : "");
ret = camel_db_select (db, sel_query, read_uids_callback, array, ex);
sqlite3_free (sel_query);
Modified: trunk/camel/camel-db.h
==============================================================================
--- trunk/camel/camel-db.h (original)
+++ trunk/camel/camel-db.h Wed Aug 20 10:55:30 2008
@@ -8,9 +8,14 @@
#include "camel-exception.h"
+typedef int(*CamelDBCollate)(void*,int,const void*,int,const void*);
+
struct _CamelDB {
sqlite3 *db;
GMutex *lock;
+ const char *sort_by;
+ const char *collate;
+ CamelDBCollate collate_cb;
#if CAMEL_DB_DEBUG
GTimer *timer;
#endif
@@ -160,7 +165,7 @@
void camel_db_free_sqlized_string (char *string);
char * camel_db_get_column_name (const char *raw_name);
-
+int camel_db_set_collate (CamelDB *cdb, const char *col, const char *collate, CamelDBCollate func);
/* Migration APIS */
int camel_db_migrate_vfolders_to_14(CamelDB *cdb, const char *folder, CamelException *ex);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]