aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <bertrand@helixcode.com>2000-01-22 09:35:11 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-01-22 09:35:11 +0800
commite8a2fed920088141d8ed47c6803bc166b18c5418 (patch)
treeadcebb99ddf323a7c408145556b000b2862ff8d9
parent8fbfb0ae4829f216501380e2f63ed6b4cc1a3306 (diff)
downloadgsoc2013-evolution-e8a2fed920088141d8ed47c6803bc166b18c5418.tar
gsoc2013-evolution-e8a2fed920088141d8ed47c6803bc166b18c5418.tar.gz
gsoc2013-evolution-e8a2fed920088141d8ed47c6803bc166b18c5418.tar.bz2
gsoc2013-evolution-e8a2fed920088141d8ed47c6803bc166b18c5418.tar.lz
gsoc2013-evolution-e8a2fed920088141d8ed47c6803bc166b18c5418.tar.xz
gsoc2013-evolution-e8a2fed920088141d8ed47c6803bc166b18c5418.tar.zst
gsoc2013-evolution-e8a2fed920088141d8ed47c6803bc166b18c5418.zip
add exception handling everywhere in the store related functions
2000-01-21 bertrand <bertrand@helixcode.com> * camel/camel-store.c: add exception handling everywhere in the store related functions arguments. * camel/providers/mbox/camel-mbox-folder.c: idem * camel/providers/mbox/camel-mbox-folder.h: idem * camel/providers/mbox/camel-mbox-store.h: idem * camel/providers/mbox/Makefile.am (libcamelmbox_la_SOURCES): added camel-mbox-provider.c to the mbox provider sources. svn path=/trunk/; revision=1605
-rw-r--r--ChangeLog6
-rw-r--r--camel/camel-folder-pt-proxy.c2
-rw-r--r--camel/camel-folder.c20
-rw-r--r--camel/camel-folder.h13
-rw-r--r--camel/camel-session.c4
-rw-r--r--camel/camel-store.c36
-rw-r--r--camel/camel-store.h19
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c4
-rw-r--r--camel/providers/mbox/camel-mbox-store.c18
-rw-r--r--camel/providers/mbox/camel-mbox-store.h4
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/test10.c50
12 files changed, 115 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index e08136fd86..9d21f809f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2000-01-21 bertrand <bertrand@helixcode.com>
+ * camel/camel-store.c: add exception handling everywhere in
+ the store related functions arguments.
+ * camel/providers/mbox/camel-mbox-folder.c: idem
+ * camel/providers/mbox/camel-mbox-folder.h: idem
+ * camel/providers/mbox/camel-mbox-store.h: idem
+
* camel/providers/mbox/Makefile.am (libcamelmbox_la_SOURCES):
added camel-mbox-provider.c to the mbox provider
sources.
diff --git a/camel/camel-folder-pt-proxy.c b/camel/camel-folder-pt-proxy.c
index e21c2bcd9a..3e620666f5 100644
--- a/camel/camel-folder-pt-proxy.c
+++ b/camel/camel-folder-pt-proxy.c
@@ -138,7 +138,7 @@ camel_folder_pt_proxy_class_init (CamelFolderPtProxyClass *camel_folder_pt_proxy
camel_folder_class->get_message_count = _get_message_count;
camel_folder_class->append_message = _append_message;
camel_folder_class->list_permanent_flags = _list_permanent_flags;
- camel_folder_class->copy_message_to;
+ camel_folder_class->copy_message_to = _copy_message_to;
camel_folder_class->get_message_uid = _get_message_uid;
camel_folder_class->get_message_by_uid = _get_message_by_uid;
camel_folder_class->get_uid_list = _get_uid_list;
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 4efae9544f..3b22011d55 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -156,7 +156,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->get_message_count = _get_message_count;
camel_folder_class->append_message = _append_message;
camel_folder_class->list_permanent_flags = _list_permanent_flags;
- camel_folder_class->copy_message_to;
+ camel_folder_class->copy_message_to = _copy_message_to;
camel_folder_class->get_message_uid = _get_message_uid;
camel_folder_class->get_message_by_uid = _get_message_by_uid;
camel_folder_class->get_uid_list = _get_uid_list;
@@ -496,7 +496,7 @@ _set_name (CamelFolder *folder,
return;
}
- separator = camel_store_get_separator (folder->parent_store);
+ separator = camel_store_get_separator (folder->parent_store, ex);
camel_exception_clear (ex);
if (folder->parent_folder) {
parent_full_name = camel_folder_get_full_name (folder->parent_folder, ex);
@@ -776,7 +776,7 @@ _get_subfolder (CamelFolder *folder,
camel_exception_set (ex,
CAMEL_EXCEPTION_FOLDER_NULL,
"folder object is NULL");
- return;
+ return NULL;
}
@@ -784,24 +784,24 @@ _get_subfolder (CamelFolder *folder,
camel_exception_set (ex,
CAMEL_EXCEPTION_INVALID_PARAM,
"folder_name parameter is NULL");
- return;
+ return NULL;
}
if (!folder->parent_store) {
camel_exception_set (ex,
CAMEL_EXCEPTION_FOLDER_INVALID,
"folder has no parent store");
- return;
+ return NULL;
}
current_folder_full_name = camel_folder_get_full_name (folder, ex);
if (camel_exception_get_id (ex)) return NULL;
- separator = camel_store_get_separator (folder->parent_store);
+ separator = camel_store_get_separator (folder->parent_store, ex);
full_name = g_strdup_printf ("%s%d%s", current_folder_full_name, separator, folder_name);
- new_folder = camel_store_get_folder (folder->parent_store, full_name);
+ new_folder = camel_store_get_folder (folder->parent_store, full_name, ex);
return new_folder;
}
@@ -889,7 +889,7 @@ _create (CamelFolder *folder, CamelException *ex)
return TRUE;
- sep = camel_store_get_separator (folder->parent_store);
+ sep = camel_store_get_separator (folder->parent_store, ex);
if (folder->parent_folder) {
camel_folder_create (folder->parent_folder, ex);
if (camel_exception_get_id (ex)) return FALSE;
@@ -903,7 +903,7 @@ _create (CamelFolder *folder, CamelException *ex)
g_warning("have to handle the case where the path is not OK\n");
return FALSE;
} else {
- parent = camel_store_get_folder (folder->parent_store, prefix);
+ parent = camel_store_get_folder (folder->parent_store, prefix, ex);
camel_folder_create (parent, ex);
if (camel_exception_get_id (ex)) return FALSE;
}
@@ -1297,7 +1297,7 @@ camel_folder_expunge (CamelFolder *folder, CamelException *ex)
return NULL;
}
- CF_CLASS (folder)->expunge (folder, ex);
+ return CF_CLASS (folder)->expunge (folder, ex);
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index c00a17d8b6..36cdc50f29 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -220,17 +220,10 @@ void camel_folder_open (CamelFolder *folder,
CamelFolderOpenMode mode,
CamelException *ex);
-void camel_folder_open_async (CamelFolder *folder,
- CamelFolderOpenMode mode,
- CamelFolderAsyncCallback callback,
- gpointer user_data,
- CamelException *ex);
-void camel_folder_close_async (CamelFolder *folder,
- gboolean expunge,
- CamelFolderAsyncCallback callback,
- gpointer user_data,
- CamelException *ex);
+void camel_folder_close (CamelFolder *folder,
+ gboolean expunge,
+ CamelException *ex);
gboolean camel_folder_create (CamelFolder *folder, CamelException *ex);
CamelFolder *camel_folder_get_parent_folder (CamelFolder *folder, CamelException *ex);
diff --git a/camel/camel-session.c b/camel/camel-session.c
index ff065b8c74..923d60c629 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -139,7 +139,7 @@ camel_session_get_store_from_provider (CamelSession *session, CamelProvider *pro
store = CAMEL_STORE (gtk_object_new (provider->object_type, NULL));
#warning set the url to a useful value.
- camel_store_init(store, session, NULL);
+ camel_store_init(store, session, NULL, NULL);
return store;
}
@@ -208,7 +208,7 @@ camel_session_get_store (CamelSession *session, const gchar *url_string)
if (url->protocol) {
new_store = camel_session_get_store_for_protocol (session, url->protocol);
if (new_store)
- camel_store_init (new_store, session, url_string);
+ camel_store_init (new_store, session, url_string, NULL);
}
g_url_free (url);
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 5b69490521..590d5e15bd 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -32,12 +32,12 @@ static CamelServiceClass *parent_class = NULL;
/* Returns the class for a CamelStore */
#define CS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass)
-static void _set_separator(CamelStore *store, gchar sep);
-static CamelFolder *_get_root_folder(CamelStore *store);
-static CamelFolder *_get_default_folder(CamelStore *store);
-static void _init(CamelStore *store, CamelSession *session, const gchar *url_name);
-static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name);
-static gchar _get_separator (CamelStore *store);
+static void _set_separator(CamelStore *store, gchar sep, CamelException *ex);
+static CamelFolder *_get_root_folder(CamelStore *store, CamelException *ex);
+static CamelFolder *_get_default_folder(CamelStore *store, CamelException *ex);
+static void _init(CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
+static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
+static gchar _get_separator (CamelStore *store, CamelException *ex);
static void _finalize (GtkObject *object);
@@ -105,10 +105,10 @@ camel_store_get_type (void)
*
**/
void
-camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name)
+camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex)
{
g_assert(store);
- CS_CLASS(store)->init (store, session, url_name);
+ CS_CLASS(store)->init (store, session, url_name, ex);
}
@@ -124,7 +124,7 @@ camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_nam
*
**/
static void
-_init (CamelStore *store, CamelSession *session, const gchar *url_name)
+_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex)
{
#warning re-enable assertion here.
@@ -160,7 +160,7 @@ _finalize (GtkObject *object)
*
**/
static void
-_set_separator (CamelStore *store, gchar sep)
+_set_separator (CamelStore *store, gchar sep, CamelException *ex)
{
store->separator = sep;
}
@@ -170,7 +170,7 @@ _set_separator (CamelStore *store, gchar sep)
static gchar
-_get_separator (CamelStore *store)
+_get_separator (CamelStore *store, CamelException *ex)
{
g_assert(store);
return store->separator;
@@ -187,9 +187,9 @@ _get_separator (CamelStore *store)
* Return value: the separator
**/
gchar
-camel_store_get_separator (CamelStore *store)
+camel_store_get_separator (CamelStore *store, CamelException *ex)
{
- return CS_CLASS(store)->get_separator (store);
+ return CS_CLASS(store)->get_separator (store, ex);
}
@@ -199,7 +199,7 @@ camel_store_get_separator (CamelStore *store)
static CamelFolder *
-_get_folder (CamelStore *store, const gchar *folder_name)
+_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
{
return NULL;
}
@@ -223,9 +223,9 @@ _get_folder (CamelStore *store, const gchar *folder_name)
* Return value: the folder
**/
CamelFolder *
-camel_store_get_folder (CamelStore *store, const gchar *folder_name)
+camel_store_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
{
- return CS_CLASS(store)->get_folder (store, folder_name);
+ return CS_CLASS(store)->get_folder (store, folder_name, ex);
}
@@ -239,7 +239,7 @@ camel_store_get_folder (CamelStore *store, const gchar *folder_name)
* @Return value: the tolevel folder.
**/
static CamelFolder *
-_get_root_folder (CamelStore *store)
+_get_root_folder (CamelStore *store, CamelException *ex)
{
return NULL;
}
@@ -254,7 +254,7 @@ _get_root_folder (CamelStore *store)
* @Return value: the default folder.
**/
static CamelFolder *
-_get_default_folder (CamelStore *store)
+_get_default_folder (CamelStore *store, CamelException *ex)
{
return NULL;
}
diff --git a/camel/camel-store.h b/camel/camel-store.h
index 71f368e2e2..e78192bed4 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -41,6 +41,7 @@ typedef struct _CamelStore CamelStore;
#include "camel-folder.h"
#include "camel-service.h"
#include "camel-session.h"
+#include "camel-exception.h"
#define CAMEL_STORE_TYPE (camel_store_get_type ())
#define CAMEL_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_STORE_TYPE, CamelStore))
@@ -62,12 +63,12 @@ struct _CamelStore
typedef struct {
CamelServiceClass parent_class;
- void (*init) (CamelStore *store, CamelSession *session, const gchar *url_name);
- void (*set_separator) (CamelStore *store, gchar sep);
- gchar (*get_separator) (CamelStore *store);
- CamelFolder * (*get_folder) (CamelStore *store, const gchar *folder_name);
- CamelFolder * (*get_root_folder) (CamelStore *store);
- CamelFolder * (*get_default_folder) (CamelStore *store);
+ void (*init) (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
+ void (*set_separator) (CamelStore *store, gchar sep, CamelException *ex);
+ gchar (*get_separator) (CamelStore *store, CamelException *ex);
+ CamelFolder * (*get_folder) (CamelStore *store, const gchar *folder_name, CamelException *ex);
+ CamelFolder * (*get_root_folder) (CamelStore *store, CamelException *ex);
+ CamelFolder * (*get_default_folder) (CamelStore *store, CamelException *ex);
} CamelStoreClass;
@@ -77,9 +78,9 @@ typedef struct {
/* Standard Gtk function */
GtkType camel_store_get_type (void);
-void camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name);
-CamelFolder *camel_store_get_folder (CamelStore *store, const gchar *folder_name);
-gchar camel_store_get_separator (CamelStore *store);
+void camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
+CamelFolder *camel_store_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
+gchar camel_store_get_separator (CamelStore *store, CamelException *ex);
#ifdef __cplusplus
}
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 0392628284..e3638e23d4 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -346,8 +346,8 @@ _set_name (CamelFolder *folder, const gchar *name, CamelException *ex)
g_free (mbox_folder->folder_file_path);
g_free (mbox_folder->folder_dir_path);
- separator = camel_store_get_separator (folder->parent_store);
- root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store));
+ separator = camel_store_get_separator (folder->parent_store, ex);
+ root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store), ex);
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name full_name is %s\n", folder->full_name);
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name root_dir_path is %s\n", root_dir_path);
diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
index 83704ea018..f8b3b62718 100644
--- a/camel/providers/mbox/camel-mbox-store.c
+++ b/camel/providers/mbox/camel-mbox-store.c
@@ -32,8 +32,8 @@ static CamelStoreClass *parent_class=NULL;
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-static void _init (CamelStore *store, CamelSession *session, const gchar *url_name);
-static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name);
+static void _init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
+static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
static void
@@ -92,7 +92,7 @@ camel_mbox_store_get_type (void)
/* These evil public functions are here for test only */
void
-camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel)
+camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel, CamelException *ex)
{
store->toplevel_dir = g_strdup (toplevel);
CAMEL_STORE(store)->separator = '/';
@@ -100,7 +100,7 @@ camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel)
const gchar *
-camel_mbox_store_get_toplevel_dir (CamelMboxStore *store)
+camel_mbox_store_get_toplevel_dir (CamelMboxStore *store, CamelException *ex)
{
return store->toplevel_dir;
}
@@ -108,14 +108,14 @@ camel_mbox_store_get_toplevel_dir (CamelMboxStore *store)
static void
-_init (CamelStore *store, CamelSession *session, const gchar *url_name)
+_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex)
{
CamelMboxStore *mbox_store = CAMEL_MBOX_STORE (store);
Gurl *store_url;
g_assert (url_name);
/* call parent implementation */
- parent_class->init (store, session, url_name);
+ parent_class->init (store, session, url_name, ex);
/* find the path in the URL*/
@@ -133,7 +133,7 @@ _init (CamelStore *store, CamelSession *session, const gchar *url_name)
static CamelFolder *
-_get_folder (CamelStore *store, const gchar *folder_name)
+_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
{
CamelMboxFolder *new_mbox_folder;
CamelFolder *new_folder;
@@ -145,8 +145,8 @@ _get_folder (CamelStore *store, const gchar *folder_name)
new_mbox_folder = gtk_type_new (CAMEL_MBOX_FOLDER_TYPE);
new_folder = CAMEL_FOLDER (new_mbox_folder);
- CF_CLASS (new_folder)->init_with_store (new_folder, store, NULL);
- CF_CLASS (new_folder)->set_name (new_folder, folder_name, NULL);
+ CF_CLASS (new_folder)->init_with_store (new_folder, store, ex);
+ CF_CLASS (new_folder)->set_name (new_folder, folder_name, ex);
return new_folder;
diff --git a/camel/providers/mbox/camel-mbox-store.h b/camel/providers/mbox/camel-mbox-store.h
index 8033d9d695..a5aea965e2 100644
--- a/camel/providers/mbox/camel-mbox-store.h
+++ b/camel/providers/mbox/camel-mbox-store.h
@@ -60,8 +60,8 @@ typedef struct {
/* Standard Gtk function */
GtkType camel_mbox_store_get_type (void);
-void camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel);
-const gchar *camel_mbox_store_get_toplevel_dir (CamelMboxStore *store);
+void camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel, CamelException *ex);
+const gchar *camel_mbox_store_get_toplevel_dir (CamelMboxStore *store, CamelException *ex);
#ifdef __cplusplus
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a7f0cb1883..5bdb8a806f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -31,4 +31,5 @@ noinst_PROGRAMS = \
test3 \
test7 \
test8 \
- test9
+ test9 \
+ test10
diff --git a/tests/test10.c b/tests/test10.c
new file mode 100644
index 0000000000..3db63bfd3e
--- /dev/null
+++ b/tests/test10.c
@@ -0,0 +1,50 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+
+#include "camel.h"
+#include "camel-mbox-folder.h"
+#include "camel-mbox-parser.h"
+#include "camel-mbox-utils.h"
+#include "camel-mbox-summary.h"
+#include "camel-log.h"
+#include "camel-exception.h"
+#include "md5-utils.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <glib.h>
+
+int
+main (int argc, char**argv)
+{
+ CamelSession *session;
+ CamelException *ex;
+ CamelStore *store;
+ gchar *store_url = "mbox:///tmp/evmail";
+ CamelFolder *folder;
+
+
+ camel_debug_level = 10;
+
+ gtk_init (&argc, &argv);
+ camel_init ();
+ ex = camel_exception_new ();
+ camel_provider_register_as_module ("../camel/providers/mbox/.libs/libcamelmbox.so");
+
+ session = camel_session_new ();
+ store = camel_session_get_store (session, store_url);
+
+
+ folder = camel_store_get_folder (store, "Inbox");
+
+ camel_folder_open (folder, FOLDER_OPEN_RW, ex);
+
+
+ return 1;
+}
+
+
+