[evolution-kolab/ek-wip-porting-imapx] CamelKolabImapxMetadataDb: removed Camel dependency
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting-imapx] CamelKolabImapxMetadataDb: removed Camel dependency
- Date: Sat, 3 Dec 2011 22:31:04 +0000 (UTC)
commit 1171d50187a1187629bdebc937226f5d8620bd4b
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Sat Dec 3 20:52:11 2011 +0100
CamelKolabImapxMetadataDb: removed Camel dependency
* removed CamelService, CamelSession args from metadata
db open() function, let it take a path argument instead
* retrieving the storage path is better done in the class
which *uses* CamelKolabImapxMetadataDb
src/camel/camel-kolab-imapx-metadata-db.c | 40 +++++++--------------
src/camel/camel-kolab-imapx-metadata-db.h | 54 ++++++++++++++++++++++------
2 files changed, 55 insertions(+), 39 deletions(-)
---
diff --git a/src/camel/camel-kolab-imapx-metadata-db.c b/src/camel/camel-kolab-imapx-metadata-db.c
index 8b523fc..37b9478 100644
--- a/src/camel/camel-kolab-imapx-metadata-db.c
+++ b/src/camel/camel-kolab-imapx-metadata-db.c
@@ -43,7 +43,6 @@
/*----------------------------------------------------------------------------*/
#include <string.h>
-#include <sqlite3.h>
/* Kolab error reporting */
#include <libekolabutil/kolab-util-error.h>
@@ -227,50 +226,37 @@ camel_kolab_imapx_metadata_db_free (CamelKolabImapxMetadataDb *mdb,
gboolean
camel_kolab_imapx_metadata_db_open (CamelKolabImapxMetadataDb *mdb,
- CamelService *service,
- CamelSession *session,
+ const gchar *cachepath,
GError **err)
{
- gchar *store_db_path = NULL;
- const gchar *user_cache_dir = NULL;
- sqlite3 *tmp_db;
+ sqlite3 *tmp_db = NULL;
+ gchar *filename = NULL;
g_assert (mdb != NULL);
- g_assert (service != NULL);
- g_assert (session != NULL);
+ g_assert (cachepath != NULL);
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
if (mdb->db != NULL)
return TRUE;
- user_cache_dir = camel_service_get_user_cache_dir (service);
- if ((user_cache_dir == NULL) || (strlen (user_cache_dir) < 2)) {
- g_set_error (err,
- KOLAB_CAMEL_KOLAB_ERROR,
- KOLAB_CAMEL_KOLAB_ERROR_DB,
- "%s: could not get a valid cache directory path",
- __func__);
- return FALSE;
- }
-
- store_db_path = g_build_filename (user_cache_dir,
- CAMEL_KOLAB_IMAPX_METADATA_DB_FILE,
- NULL);
+ filename = g_build_filename (cachepath,
+ CAMEL_KOLAB_IMAPX_METADATA_DB_FILE,
+ NULL);
- tmp_db = camel_kolab_imapx_metadata_db_open_trycreate (store_db_path);
+ tmp_db = camel_kolab_imapx_metadata_db_open_trycreate (filename);
if (tmp_db == NULL) {
g_set_error (err,
KOLAB_CAMEL_KOLAB_ERROR,
KOLAB_CAMEL_KOLAB_ERROR_DB,
"%s: could not open/create sqlite db for [%s]",
- __func__, store_db_path);
- g_free (store_db_path);
+ __func__, filename);
+ g_free (filename);
return FALSE;
}
mdb->db = tmp_db;
- mdb->path = store_db_path;
+ mdb->path = filename;
mdb->ctr = 0;
return TRUE;
@@ -473,8 +459,8 @@ camel_kolab_imapx_metadata_db_remove_folder (CamelKolabImapxMetadataDb *mdb,
const gchar *foldername,
GError **err)
{
- gchar *sql_str;
- gint sql_errno;
+ gchar *sql_str = NULL;
+ gint sql_errno = SQLITE_OK;
g_assert (mdb != NULL);
g_assert (mdb->db != NULL);
diff --git a/src/camel/camel-kolab-imapx-metadata-db.h b/src/camel/camel-kolab-imapx-metadata-db.h
index 278064d..09a0b7e 100644
--- a/src/camel/camel-kolab-imapx-metadata-db.h
+++ b/src/camel/camel-kolab-imapx-metadata-db.h
@@ -33,31 +33,61 @@
#include <glib.h>
#include <sqlite3.h>
-#include <camel/camel.h>
#include <camel/providers/imapx/camel-imapx-metadata.h>
#include "camel-kolab-imapx-folder.h"
/*----------------------------------------------------------------------------*/
-typedef struct _CamelKolabImapxMetadataDb {
+typedef struct _CamelKolabImapxMetadataDb CamelKolabImapxMetadataDb;
+struct _CamelKolabImapxMetadataDb {
sqlite3 *db; /* sqlite3 DB handle */
gchar *path; /* path to the sqlite3 metadata db file */
gint ctr; /* aux counter, usable with callback functions */
-} CamelKolabImapxMetadataDb;
+};
/*----------------------------------------------------------------------------*/
-CamelKolabImapxMetadataDb *camel_kolab_imapx_metadata_db_new (void);
-gboolean camel_kolab_imapx_metadata_db_free (CamelKolabImapxMetadataDb *mdb, GError **err);
-gboolean camel_kolab_imapx_metadata_db_open (CamelKolabImapxMetadataDb *mdb, CamelService *service, CamelSession *session, GError **err);
-gboolean camel_kolab_imapx_metadata_db_init (CamelKolabImapxMetadataDb *mdb, GError **err);
-gboolean camel_kolab_imapx_metadata_db_close (CamelKolabImapxMetadataDb *mdb, GError **err);
+CamelKolabImapxMetadataDb*
+camel_kolab_imapx_metadata_db_new (void);
-gboolean camel_kolab_imapx_metadata_db_folder_update (CamelKolabImapxMetadataDb *mdb, const gchar *foldername, const CamelKolabImapxFolderMetadata *kfmd, GError **err);
-gboolean camel_kolab_imapx_metadata_db_update (CamelKolabImapxMetadataDb *mdb, GHashTable *kolab_metadata, GError **err);
-CamelKolabImapxFolderMetadata *camel_kolab_imapx_metadata_db_lookup (CamelKolabImapxMetadataDb *mdb, const gchar *foldername, GError **err);
-gboolean camel_kolab_imapx_metadata_db_remove_folder (CamelKolabImapxMetadataDb *mdb, const gchar *foldername, GError **err);
+gboolean
+camel_kolab_imapx_metadata_db_free (CamelKolabImapxMetadataDb *mdb,
+ GError **err);
+
+gboolean
+camel_kolab_imapx_metadata_db_open (CamelKolabImapxMetadataDb *mdb,
+ const gchar *cachepath,
+ GError **err);
+
+gboolean
+camel_kolab_imapx_metadata_db_init (CamelKolabImapxMetadataDb *mdb,
+ GError **err);
+
+gboolean
+camel_kolab_imapx_metadata_db_close (CamelKolabImapxMetadataDb *mdb,
+ GError **err);
+
+gboolean
+camel_kolab_imapx_metadata_db_folder_update (CamelKolabImapxMetadataDb *mdb,
+ const gchar *foldername,
+ const CamelKolabImapxFolderMetadata *kfmd,
+ GError **err);
+
+gboolean
+camel_kolab_imapx_metadata_db_update (CamelKolabImapxMetadataDb *mdb,
+ GHashTable *kolab_metadata,
+ GError **err);
+
+CamelKolabImapxFolderMetadata*
+camel_kolab_imapx_metadata_db_lookup (CamelKolabImapxMetadataDb *mdb,
+ const gchar *foldername,
+ GError **err);
+
+gboolean
+camel_kolab_imapx_metadata_db_remove_folder (CamelKolabImapxMetadataDb *mdb,
+ const gchar *foldername,
+ GError **err);
/*----------------------------------------------------------------------------*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]