evolution-data-server r8819 - branches/camel-db-summary/camel
- From: psankar svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8819 - branches/camel-db-summary/camel
- Date: Wed, 21 May 2008 11:33:08 +0000 (UTC)
Author: psankar
Date: Wed May 21 11:33:08 2008
New Revision: 8819
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8819&view=rev
Log:
Added Exception handling to camel_db_open
Modified:
branches/camel-db-summary/camel/Makefile.am
branches/camel-db-summary/camel/camel-db.c
branches/camel-db-summary/camel/camel-db.h
branches/camel-db-summary/camel/camel-store.c
branches/camel-db-summary/camel/camel-store.h
Modified: branches/camel-db-summary/camel/Makefile.am
==============================================================================
--- branches/camel-db-summary/camel/Makefile.am (original)
+++ branches/camel-db-summary/camel/Makefile.am Wed May 21 11:33:08 2008
@@ -299,6 +299,7 @@
$(top_builddir)/libedataserver/libedataserver-${API_VERSION}.la \
$(CAMEL_LIBS) \
$(SOCKET_LIBS) \
+ -lsqlite3 \
$(REGEX_LIBS)
Modified: branches/camel-db-summary/camel/camel-db.c
==============================================================================
--- branches/camel-db-summary/camel/camel-db.c (original)
+++ branches/camel-db-summary/camel/camel-db.c Wed May 21 11:33:08 2008
@@ -20,18 +20,26 @@
}
CamelDB *
-camel_db_open (const char *path)
+camel_db_open (const char *path, CamelException *ex)
{
CamelDB *cdb;
sqlite3 *db;
int ret;
ret = sqlite3_open(path, &db);
- if(ret) {
- d(g_warning("Can't open database %s: %s\n", path, sqlite3_errmsg(db)));
- sqlite3_close(db);
+ if (ret) {
+
+ if (!db) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Insufficient memory"));
+ } else {
+ char *error;
+ error = sqlite3_errmsg (db);
+ d(printf("Can't open database %s: %s\n", path, error));
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _(error));
+ sqlite3_close(db);
+ }
return NULL;
- }
+ }
cdb = g_new (CamelDB, 1);
cdb->db = db;
Modified: branches/camel-db-summary/camel/camel-db.h
==============================================================================
--- branches/camel-db-summary/camel/camel-db.h (original)
+++ branches/camel-db-summary/camel/camel-db.h Wed May 21 11:33:08 2008
@@ -5,6 +5,8 @@
#include <sqlite3.h>
#include <glib.h>
#define CAMEL_DB_FILE "folders.db"
+
+#include <camel-exception.h>
struct _CamelDB {
sqlite3 *db;
GMutex *lock;
@@ -14,7 +16,7 @@
typedef int (*CamelDBSelectCB) (void *data, int ncol, char **colvalues, char **colnames);
-CamelDB * camel_db_open (const char *path);
+CamelDB * camel_db_open (const char *path, CamelException *ex);
void camel_db_close (CamelDB *cdb);
gboolean camel_db_command (CamelDB *cdb, const char *stmt);
int camel_db_select (CamelDB *cdb, const char* stmt, CamelDBSelectCB callback, gpointer data);
Modified: branches/camel-db-summary/camel/camel-store.c
==============================================================================
--- branches/camel-db-summary/camel/camel-store.c (original)
+++ branches/camel-db-summary/camel/camel-store.c Wed May 21 11:33:08 2008
@@ -157,7 +157,13 @@
camel_object_bag_destroy(store->folders);
g_static_rec_mutex_free (&store->priv->folder_lock);
-
+
+ if (store->cdb) {
+ camel_db_close (store->cdb);
+ g_free (store->cdb);
+ store->cdb = NULL;
+ }
+
g_free (store->priv);
}
@@ -200,11 +206,18 @@
CamelException *ex)
{
CamelStore *store = CAMEL_STORE(service);
+ char *store_path, *store_db_path;
parent_class->construct(service, session, provider, url, ex);
if (camel_exception_is_set (ex))
return;
+ store_path = camel_session_get_storage_path (session, service, ex);
+ store_db_path = g_strdup_printf ("%s/%s", store_path, CAMEL_DB_FILE);
+ store->cdb = camel_db_open (store_db_path, ex);
+ g_free (store_path);
+ g_free (store_db_path);
+
if (camel_url_get_param(url, "filter"))
store->flags |= CAMEL_STORE_FILTER_INBOX;
}
Modified: branches/camel-db-summary/camel/camel-store.h
==============================================================================
--- branches/camel-db-summary/camel/camel-store.h (original)
+++ branches/camel-db-summary/camel/camel-store.h Wed May 21 11:33:08 2008
@@ -32,6 +32,7 @@
#include <camel/camel-object.h>
#include <camel/camel-service.h>
+#include <camel/camel-db.h>
G_BEGIN_DECLS
@@ -121,6 +122,7 @@
struct _CamelStorePrivate *priv;
CamelObjectBag *folders;
+ CamelDB *cdb;
guint32 flags;
guint32 mode;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]