evolution-data-server r8744 - in trunk/camel: . providers



Author: psankar
Date: Tue May  6 11:13:21 2008
New Revision: 8744
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8744&view=rev

Log:
Added cdb - CamelDataBase to the Camel Store.


Modified:
   trunk/camel/Makefile.am
   trunk/camel/camel-db.c
   trunk/camel/camel-db.h
   trunk/camel/camel-store.c
   trunk/camel/camel-store.h
   trunk/camel/providers/Makefile.am

Modified: trunk/camel/Makefile.am
==============================================================================
--- trunk/camel/Makefile.am	(original)
+++ trunk/camel/Makefile.am	Tue May  6 11:13:21 2008
@@ -293,7 +293,8 @@
 	$(top_builddir)/libedataserver/libedataserver-${API_VERSION}.la \
 	$(CAMEL_LIBS)							\
 	$(SOCKET_LIBS)							\
-	$(REGEX_LIBS)
+	$(REGEX_LIBS)							\
+	-lsqlite3
 
 
 camel_lock_helper_1_2_SOURCES = 		\

Modified: trunk/camel/camel-db.c
==============================================================================
--- trunk/camel/camel-db.c	(original)
+++ trunk/camel/camel-db.c	Tue May  6 11:13:21 2008
@@ -1,6 +1,7 @@
 /* Srinivasa Ragavan - <sragavan novell com> - GPL v2 or later */
 
 #include <glib.h>
+#include <sqlite3.h>
 #include "camel-db.h"
 
 #define d(x)

Modified: trunk/camel/camel-db.h
==============================================================================
--- trunk/camel/camel-db.h	(original)
+++ trunk/camel/camel-db.h	Tue May  6 11:13:21 2008
@@ -2,9 +2,12 @@
 
 #ifndef __CAMEL_DB_H
 #define __CAMEL_DB_H
+
 #include <sqlite3.h>
 #include <glib.h>
+
 #define CAMEL_DB_FILE "folders.db"
+
 struct _CamelDB {
 	sqlite3 *db;
 	GMutex *lock;

Modified: trunk/camel/camel-store.c
==============================================================================
--- trunk/camel/camel-store.c	(original)
+++ trunk/camel/camel-store.c	Tue May  6 11:13:21 2008
@@ -42,7 +42,7 @@
 #include "camel-store.h"
 #include "camel-vtrash-folder.h"
 
-#define d(x)
+#define d(x) (x)
 #define w(x)
 
 static CamelServiceClass *parent_class = NULL;
@@ -145,6 +145,7 @@
 	store->mode = CAMEL_STORE_READ|CAMEL_STORE_WRITE;
 
 	store->priv = g_malloc0 (sizeof (*store->priv));
+	store->cdb = NULL;
 	g_static_rec_mutex_init (&store->priv->folder_lock);
 }
 
@@ -156,6 +157,9 @@
 	if (store->folders)
 		camel_object_bag_destroy(store->folders);
 
+	if (store->cdb)
+		camel_db_close (store->cdb);
+
 	g_static_rec_mutex_free (&store->priv->folder_lock);
 
 	g_free (store->priv);
@@ -200,6 +204,9 @@
 	   CamelException *ex)
 {
 	CamelStore *store = CAMEL_STORE(service);
+	char *path, *tmp;
+
+	char *CREATE_STORE_TABLE_QRY = "CREATE TABLE folders (folder TEXT PRIMARY KEY, version INTEGER, lflags INTEGER, nextuid INTEGER, time INTEGER, savedcount INTEGER, unread INTEGER, deleted INTEGER, junk INTEGER, bdata TEXT)";
 
 	parent_class->construct(service, session, provider, url, ex);
 	if (camel_exception_is_set (ex))
@@ -207,6 +214,26 @@
 
 	if (camel_url_get_param(url, "filter"))
 		store->flags |= CAMEL_STORE_FILTER_INBOX;
+
+	d(printf ("\n\astore's construct function is called \n\a"));
+	tmp = camel_session_get_storage_path (session, service, ex);
+	path = g_strdup_printf ("%s/%s", tmp, CAMEL_DB_FILE);
+	store->cdb = camel_db_open (path);
+	if (store->cdb) {
+		d(printf ("\n\aDATABASE Opened \n\a"));
+		/* If the tables aren't already there create atleast the store's table*/
+		if (!camel_db_command (store->cdb, "select folder from folders")) {
+			if (!camel_db_command (store->cdb, CREATE_STORE_TABLE_QRY))
+				g_warning ("Unable to create store structing db");
+			else
+				d(printf ("\n\aTABLE CREATED \n\a"));
+		}
+	} else {
+		d(printf ("\n\aDATABASE cannot be opened \n\a"));
+	}
+	g_free (tmp);
+	g_free (path);
+
 }
 
 static CamelFolder *

Modified: trunk/camel/camel-store.h
==============================================================================
--- trunk/camel/camel-store.h	(original)
+++ trunk/camel/camel-store.h	Tue May  6 11:13:21 2008
@@ -33,6 +33,8 @@
 #include <camel/camel-object.h>
 #include <camel/camel-service.h>
 
+#include <camel/camel-db.h>
+
 G_BEGIN_DECLS
 
 enum {
@@ -124,6 +126,8 @@
 
 	guint32 flags;
 	guint32 mode;
+
+	CamelDB *cdb;
 };
 
 /* open mode for folder */

Modified: trunk/camel/providers/Makefile.am
==============================================================================
--- trunk/camel/providers/Makefile.am	(original)
+++ trunk/camel/providers/Makefile.am	Tue May  6 11:13:21 2008
@@ -17,6 +17,8 @@
 SENDMAIL_DIR=sendmail
 endif
 
-SUBDIRS = pop3 $(SENDMAIL_DIR) smtp imap $(IMAP4_DIR) $(NNTP_DIR) local $(IMAPP_DIR) groupwise hula
+## SUBDIRS = pop3 $(SENDMAIL_DIR) smtp imap $(IMAP4_DIR) $(NNTP_DIR) local $(IMAPP_DIR) groupwise hula
+
+SUBDIRS = imap local
 
 



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