aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>2000-02-22 19:16:36 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-02-22 19:16:36 +0800
commitf65a2d78c6cb123fd94b173aa4e877f22d314d4c (patch)
tree3a3cba1006293ae988dd1213a0f88bdd90dab8b7
parent7c6897ee95e4346e991185c014bcfce003809fd8 (diff)
downloadgsoc2013-evolution-f65a2d78c6cb123fd94b173aa4e877f22d314d4c.tar
gsoc2013-evolution-f65a2d78c6cb123fd94b173aa4e877f22d314d4c.tar.gz
gsoc2013-evolution-f65a2d78c6cb123fd94b173aa4e877f22d314d4c.tar.bz2
gsoc2013-evolution-f65a2d78c6cb123fd94b173aa4e877f22d314d4c.tar.lz
gsoc2013-evolution-f65a2d78c6cb123fd94b173aa4e877f22d314d4c.tar.xz
gsoc2013-evolution-f65a2d78c6cb123fd94b173aa4e877f22d314d4c.tar.zst
gsoc2013-evolution-f65a2d78c6cb123fd94b173aa4e877f22d314d4c.zip
fix to show a sample correct implementation.
2000-02-22 bertrand <Bertrand.Guiheneuf@aful.org> * message-list.c (message_list_set_folder): fix to show a sample correct implementation. * camel-folder.c (camel_folder_get_subfolder): (camel_folder_create): (camel_folder_delete): (camel_folder_delete_messages): (camel_folder_list_subfolders): (camel_folder_expunge): (camel_folder_get_message_by_number): (camel_folder_get_message_count): (camel_folder_append_message): (camel_folder_copy_message_to): (camel_folder_get_summary): (camel_folder_get_message_uid): (camel_folder_get_message_by_uid): (camel_folder_get_uid_list): Check folder state (open/close) and raise an exception if it is not ok. * providers/mbox/camel-mbox-folder.c (_create): create the file and the path with two different names. * camel-folder.c (_create): handle the case when the folder name starts with '/' * camel-exception.c (camel_exception_new): use (void) instead of () in decl. * camel-exception.h: cosmetic fixes. * camel-exception.c (camel_exception_init): new routine. Fix a bug in mail/message-list.c * camel-folder.h: cosmetic changes. * camel-stream-b64.c (reset__static): added a reset method. Thanks message-browser to find so much bugs :) * providers/mbox/Makefile.am (libcamelmbox_la_LIBADD): readd Unicode libs. Fixes and exception handling in camel-folder. Fixes in mail/evolution-mail to make it not segfault and to demonstrate a correct implementation. svn path=/trunk/; revision=1902
-rw-r--r--camel/ChangeLog35
-rw-r--r--camel/camel-exception.c22
-rw-r--r--camel/camel-exception.h29
-rw-r--r--camel/camel-folder.c140
-rw-r--r--camel/camel-folder.h118
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c10
-rw-r--r--camel/providers/mbox/camel-mbox-store.c8
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/folder-browser.c5
-rw-r--r--mail/message-list.c42
10 files changed, 341 insertions, 73 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 96d6de92d9..b5a3785ebc 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,40 @@
2000-02-22 bertrand <Bertrand.Guiheneuf@aful.org>
+ * camel-folder.c (camel_folder_get_subfolder):
+ (camel_folder_create):
+ (camel_folder_delete):
+ (camel_folder_delete_messages):
+ (camel_folder_list_subfolders):
+ (camel_folder_expunge):
+ (camel_folder_get_message_by_number):
+ (camel_folder_get_message_count):
+ (camel_folder_append_message):
+ (camel_folder_copy_message_to):
+ (camel_folder_get_summary):
+ (camel_folder_get_message_uid):
+ (camel_folder_get_message_by_uid):
+ (camel_folder_get_uid_list):
+ Check folder state (open/close) and raise an
+ exception if it is not ok.
+
+ * providers/mbox/camel-mbox-folder.c (_create):
+ create the file and the path with two different
+ names.
+
+ * camel-folder.c (_create): handle the case
+ when the folder name starts with '/'
+
+ * camel-exception.c (camel_exception_new): use
+ (void) instead of () in decl.
+
+ * camel-exception.h: cosmetic fixes.
+
+ * camel-exception.c (camel_exception_init): new routine.
+ Fix a bug in mail/message-list.c
+
+
+ * camel-folder.h: cosmetic changes.
+
* camel-stream-b64.c (reset__static): added a
reset method. Thanks message-browser to find
so much bugs :)
diff --git a/camel/camel-exception.c b/camel/camel-exception.c
index a983150612..1e75e90d17 100644
--- a/camel/camel-exception.c
+++ b/camel/camel-exception.c
@@ -38,7 +38,7 @@
* Return value: The newly allocated exception object.
**/
CamelException *
-camel_exception_new ()
+camel_exception_new (void)
{
CamelException *ex;
@@ -51,6 +51,26 @@ camel_exception_new ()
return ex;
}
+/**
+ * camel_exception_init: init a (statically allocated) exception.
+ *
+ * Init an exception. This routine is mainly
+ * useful when using a statically allocated
+ * exception.
+ *
+ *
+ **/
+void
+camel_exception_init (CamelException *ex)
+{
+ ex->desc = NULL;
+
+ /* set the Exception Id to NULL */
+ ex->id = CAMEL_EXCEPTION_NONE;
+
+ return ex;
+}
+
/**
* camel_exception_clear: Clear an exception
diff --git a/camel/camel-exception.h b/camel/camel-exception.h
index ef484db111..53f1366fbb 100644
--- a/camel/camel-exception.h
+++ b/camel/camel-exception.h
@@ -54,29 +54,30 @@ struct _CamelException {
/* creation and destruction functions */
-CamelException *camel_exception_new ();
-void camel_exception_free (CamelException *exception);
+CamelException * camel_exception_new (void);
+void camel_exception_free (CamelException *exception);
+void camel_exception_init (CamelException *ex);
/* exception content manipulation */
-void camel_exception_clear (CamelException *exception);
-void camel_exception_set (CamelException *ex,
- ExceptionId id,
- const char *desc);
-void camel_exception_setv (CamelException *ex,
- ExceptionId id,
- const char *format,
- ...);
+void camel_exception_clear (CamelException *exception);
+void camel_exception_set (CamelException *ex,
+ ExceptionId id,
+ const char *desc);
+void camel_exception_setv (CamelException *ex,
+ ExceptionId id,
+ const char *format,
+ ...);
/* exception content transfer */
-void camel_exception_xfer (CamelException *ex_dst,
- CamelException *ex_src);
+void camel_exception_xfer (CamelException *ex_dst,
+ CamelException *ex_src);
/* exception content retrieval */
-ExceptionId camel_exception_get_id (CamelException *ex);
-const gchar *camel_exception_get_description (CamelException *ex);
+ExceptionId camel_exception_get_id (CamelException *ex);
+const gchar * camel_exception_get_description (CamelException *ex);
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 6da6f89ac8..ae102451ec 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -504,7 +504,7 @@ _set_name (CamelFolder *folder,
if (camel_folder_is_open (folder, ex)) {
if (camel_exception_get_id (ex)) return;
camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
"CamelFolder::set_name is valid only on closed folders");
return;
}
@@ -748,7 +748,7 @@ camel_folder_exists (CamelFolder *folder, CamelException *ex)
"folder object is NULL");
return FALSE;
}
-
+
return (CF_CLASS(folder)->exists (folder, ex));
}
@@ -869,6 +869,15 @@ camel_folder_get_subfolder (CamelFolder *folder, gchar *folder_name, CamelExcept
"folder object is NULL");
return FALSE;
}
+
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::get_subfolder is valid only on open folders");
+ return NULL;
+ }
return (CF_CLASS(folder)->get_subfolder(folder,folder_name, ex));
}
@@ -941,8 +950,10 @@ _create (CamelFolder *folder, CamelException *ex)
folder->full_name, sep, &prefix, NULL,
STRING_DICHOTOMY_STRIP_TRAILING | STRING_DICHOTOMY_RIGHT_DIR);
if (dich_result!='o') {
- g_warning("have to handle the case where the path is not OK\n");
- return FALSE;
+ if (prefix == NULL) {
+ /* separator is the first caracter, no folder above */
+ return TRUE;
+ }
} else {
parent = camel_store_get_folder (folder->parent_store, prefix, ex);
camel_folder_create (parent, ex);
@@ -978,6 +989,15 @@ camel_folder_create (CamelFolder *folder, CamelException *ex)
return FALSE;
}
+ /* check if the folder is closed */
+ if (camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return FALSE;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::create is valid only on close folders");
+ return FALSE;
+ }
+
return (CF_CLASS(folder)->create(folder, ex));
}
@@ -1070,7 +1090,8 @@ _delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
*
* Return value: TRUE if deletion was successful
**/
-gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
+gboolean
+camel_folder_delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
{
if (!folder) {
camel_exception_set (ex,
@@ -1079,6 +1100,15 @@ gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse, CamelExcept
return FALSE;
}
+ /* check if the folder is closed */
+ if (camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return FALSE;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::delete is valid only on closed folders");
+ return FALSE;
+ }
+
return CF_CLASS(folder)->delete(folder, recurse, ex);
}
@@ -1128,6 +1158,15 @@ camel_folder_delete_messages (CamelFolder *folder, CamelException *ex)
return FALSE;
}
+ /* check if the folder is closed */
+ if (camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return FALSE;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::delete_messages is valid only on closed folders");
+ return FALSE;
+ }
+
return CF_CLASS(folder)->delete_messages(folder, ex);
}
@@ -1297,6 +1336,15 @@ camel_folder_list_subfolders (CamelFolder *folder, CamelException *ex)
"folder object is NULL");
return NULL;
}
+
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::list_subfolder is valid only on open folders");
+ return NULL;
+ }
return CF_CLASS(folder)->list_subfolders(folder, ex);
}
@@ -1337,6 +1385,15 @@ camel_folder_expunge (CamelFolder *folder, CamelException *ex)
"folder object is NULL");
return NULL;
}
+
+ /* check if the folder is closed */
+ if (camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::expunge is valid only on closed folders");
+ return NULL;
+ }
return CF_CLASS (folder)->expunge (folder, ex);
}
@@ -1425,6 +1482,15 @@ camel_folder_get_message_by_number (CamelFolder *folder, gint number, CamelExcep
return NULL;
}
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::get_message_by_number is valid only on open folders");
+ return NULL;
+ }
+
return CF_CLASS (folder)->get_message_by_number (folder, number, ex);
}
@@ -1456,6 +1522,15 @@ camel_folder_get_message_count (CamelFolder *folder, CamelException *ex)
"folder object is NULL");
return -1;
}
+
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return -1;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::get_message_count is valid only on open folders");
+ return -1;
+ }
return CF_CLASS (folder)->get_message_count (folder, ex);
}
@@ -1499,6 +1574,15 @@ camel_folder_append_message (CamelFolder *folder,
return;
}
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::append_message is valid only on open folders");
+ return;
+ }
+
CF_CLASS (folder)->append_message (folder, message, ex);
}
@@ -1560,6 +1644,15 @@ camel_folder_copy_message_to (CamelFolder *folder,
return;
}
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::copy_message_to is valid only on open folders");
+ return;
+ }
+
CF_CLASS (folder)->copy_message_to (folder, message, dest_folder, ex);;
}
@@ -1606,6 +1699,15 @@ camel_folder_get_summary (CamelFolder *folder,
return NULL;
}
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::get_summary is valid only on open folders");
+ return NULL;
+ }
+
return folder->summary;
}
@@ -1676,6 +1778,15 @@ camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, Ca
return NULL;
}
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::get_message_uid is valid only on open folders");
+ return NULL;
+ }
+
return CF_CLASS (folder)->get_message_uid (folder, message, ex);
}
@@ -1767,6 +1878,16 @@ camel_folder_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelEx
return NULL;
}
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::get_message_by_uid is valid only on open folders");
+ return NULL;
+ }
+
+
return CF_CLASS (folder)->get_message_by_uid (folder, uid, ex);
}
@@ -1821,6 +1942,15 @@ camel_folder_get_uid_list (CamelFolder *folder, CamelException *ex)
return NULL;
}
+ /* check if the folder is open */
+ if (!camel_folder_is_open (folder, ex)) {
+ if (camel_exception_get_id (ex)) return NULL;
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ "CamelFolder::get_uid_list is valid only on open folders");
+ return NULL;
+ }
+
return CF_CLASS (folder)->get_uid_list (folder, ex);
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index ebc8e6aa20..a646ce961e 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -212,80 +212,106 @@ GtkType camel_folder_get_type (void);
-CamelFolder *camel_folder_get_subfolder (CamelFolder *folder,
- gchar *folder_name,
- CamelException *ex);
+CamelFolder * camel_folder_get_subfolder (CamelFolder *folder,
+ gchar *folder_name,
+ CamelException *ex);
-void camel_folder_open (CamelFolder *folder,
- CamelFolderOpenMode mode,
- CamelException *ex);
+void camel_folder_open (CamelFolder *folder,
+ CamelFolderOpenMode mode,
+ CamelException *ex);
-void camel_folder_close (CamelFolder *folder,
- gboolean expunge,
- 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);
-CamelStore *camel_folder_get_parent_store (CamelFolder *folder, CamelException *ex);
-GList *camel_folder_list_subfolders (CamelFolder *folder, CamelException *ex);
+gboolean camel_folder_create (CamelFolder *folder,
+ CamelException *ex);
+CamelFolder * camel_folder_get_parent_folder (CamelFolder *folder,
+ CamelException *ex);
+CamelStore * camel_folder_get_parent_store (CamelFolder *folder,
+ CamelException *ex);
+GList * camel_folder_list_subfolders (CamelFolder *folder,
+ CamelException *ex);
/* delete operations */
-gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
-gboolean camel_folder_delete_messages (CamelFolder *folder, CamelException *ex);
-GList *camel_folder_expunge (CamelFolder *folder, CamelException *ex);
+gboolean camel_folder_delete (CamelFolder *folder,
+ gboolean recurse,
+ CamelException *ex);
+gboolean camel_folder_delete_messages (CamelFolder *folder,
+ CamelException *ex);
+GList * camel_folder_expunge (CamelFolder *folder,
+ CamelException *ex);
/* folder name manipulation operations */
-void camel_folder_set_name (CamelFolder *folder,
- const gchar *name,
- CamelException *ex);
-const gchar *camel_folder_get_name (CamelFolder *folder, CamelException *ex);
-const gchar *camel_folder_get_full_name (CamelFolder *folder, CamelException *ex);
+void camel_folder_set_name (CamelFolder *folder,
+ const gchar *name,
+ CamelException *ex);
+const gchar * camel_folder_get_name (CamelFolder *folder,
+ CamelException *ex);
+const gchar * camel_folder_get_full_name (CamelFolder *folder,
+ CamelException *ex);
/* various properties accessors */
-gboolean camel_folder_exists (CamelFolder *folder, CamelException *ex);
-const GList *camel_folder_list_permanent_flags (CamelFolder *folder, CamelException *ex);
-CamelFolderOpenMode camel_folder_get_mode (CamelFolder *folder, CamelException *ex);
-gboolean camel_folder_is_open (CamelFolder *folder, CamelException *ex);
+gboolean camel_folder_exists (CamelFolder *folder,
+ CamelException *ex);
+const GList * camel_folder_list_permanent_flags (CamelFolder *folder,
+ CamelException *ex);
+CamelFolderOpenMode camel_folder_get_mode (CamelFolder *folder,
+ CamelException *ex);
+gboolean camel_folder_is_open (CamelFolder *folder,
+ CamelException *ex);
/* message manipulation */
-void camel_folder_append_message (CamelFolder *folder,
- CamelMimeMessage *message, CamelException *ex);
-void camel_folder_copy_message_to (CamelFolder *folder,
- CamelMimeMessage *message,
- CamelFolder *dest_folder,
- CamelException *ex);
+void camel_folder_append_message (CamelFolder *folder,
+ CamelMimeMessage *message,
+ CamelException *ex);
+void camel_folder_copy_message_to (CamelFolder *folder,
+ CamelMimeMessage *message,
+ CamelFolder *dest_folder,
+ CamelException *ex);
/* summary related operations */
-gboolean camel_folder_has_summary_capability (CamelFolder *folder, CamelException *ex);
-CamelFolderSummary *camel_folder_get_summary (CamelFolder *folder, CamelException *ex);
+gboolean camel_folder_has_summary_capability (CamelFolder *folder,
+ CamelException *ex);
+CamelFolderSummary *camel_folder_get_summary (CamelFolder *folder,
+ CamelException *ex);
/* number based access operations */
-gboolean camel_folder_has_message_number_capability (CamelFolder *folder, CamelException *ex);
-CamelMimeMessage *camel_folder_get_message_by_number (CamelFolder *folder,
- gint number, CamelException *ex);
-gint camel_folder_get_message_count (CamelFolder *folder, CamelException *ex);
+gboolean camel_folder_has_message_number_capability (CamelFolder *folder,
+ CamelException *ex);
+CamelMimeMessage * camel_folder_get_message_by_number (CamelFolder *folder,
+ gint number,
+ CamelException *ex);
+gint camel_folder_get_message_count (CamelFolder *folder,
+ CamelException *ex);
/* uid based access operations */
-gboolean camel_folder_has_uid_capability (CamelFolder *folder, CamelException *ex);
-const gchar * camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-CamelMimeMessage *camel_folder_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
-GList *camel_folder_get_uid_list (CamelFolder *folder, CamelException *ex);
+gboolean camel_folder_has_uid_capability (CamelFolder *folder,
+ CamelException *ex);
+const gchar * camel_folder_get_message_uid (CamelFolder *folder,
+ CamelMimeMessage *message,
+ CamelException *ex);
+CamelMimeMessage * camel_folder_get_message_by_uid (CamelFolder *folder,
+ const gchar *uid,
+ CamelException *ex);
+GList * camel_folder_get_uid_list (CamelFolder *folder,
+ CamelException *ex);
/* search api */
-gboolean camel_folder_has_search_capability (CamelFolder *folder,
- CamelException *ex);
-GList *camel_folder_search_by_expression (CamelFolder *folder,
- const char *expression,
- CamelException *ex);
+gboolean camel_folder_has_search_capability (CamelFolder *folder,
+ CamelException *ex);
+GList * camel_folder_search_by_expression (CamelFolder *folder,
+ const char *expression,
+ CamelException *ex);
#ifdef __cplusplus
}
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index ad899090dc..593f5699eb 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -388,13 +388,14 @@ _set_name (CamelFolder *folder, const gchar *name, CamelException *ex)
static gboolean
_exists (CamelFolder *folder, CamelException *ex)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
+ CamelMboxFolder *mbox_folder;
struct stat stat_buf;
gint stat_error;
gboolean exists;
CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::exists\n");
-
+
+
/* check if the folder object exists */
if (!folder) {
camel_exception_set (ex,
@@ -403,6 +404,9 @@ _exists (CamelFolder *folder, CamelException *ex)
return FALSE;
}
+ mbox_folder = CAMEL_MBOX_FOLDER(folder);
+
+
/* check if the mbox file path is determined */
if (!mbox_folder->folder_file_path) {
camel_exception_set (ex,
@@ -492,7 +496,7 @@ _create (CamelFolder *folder, CamelException *ex)
/* get the paths of what we need to create */
folder_file_path = mbox_folder->folder_file_path;
- folder_dir_path = mbox_folder->folder_file_path;
+ folder_dir_path = mbox_folder->folder_dir_path;
if (!(folder_file_path || folder_dir_path)) {
camel_exception_set (ex,
diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
index 9c5e889aa7..76ceed282a 100644
--- a/camel/providers/mbox/camel-mbox-store.c
+++ b/camel/providers/mbox/camel-mbox-store.c
@@ -21,6 +21,10 @@
* USA
*/
+
+#include <config.h>
+#include "camel-log.h"
+
#include "camel-mbox-store.h"
#include "camel-mbox-folder.h"
#include "camel-exception.h"
@@ -104,12 +108,14 @@ _get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
/* call the standard routine for that when */
/* it is done ... */
+ CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxStore::get_folder\n");
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, ex);
CF_CLASS (new_folder)->set_name (new_folder, folder_name, ex);
-
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxStore::get_folder\n");
+
return new_folder;
}
diff --git a/mail/ChangeLog b/mail/ChangeLog
index a4ba0b1fce..f16399f24c 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,8 @@
+2000-02-22 bertrand <Bertrand.Guiheneuf@aful.org>
+
+ * message-list.c (message_list_set_folder):
+ fix to show a sample correct implementation.
+
2000-02-21 Matt Loper <matt@helixcode.com>
* Makefile.am: added -lunicode to evolution_mail_LDADD.
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index e6fe8d496a..85a09395a8 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -65,7 +65,10 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name)
gtk_object_unref (GTK_OBJECT (fb->folder));
fb->folder = new_folder;
-
+
+ camel_folder_exists (new_folder, NULL);
+ printf ("In folder browser, folder = %p\n", new_folder);
+
message_list_set_folder (fb->message_list, new_folder);
return TRUE;
diff --git a/mail/message-list.c b/mail/message-list.c
index 7da9b9fa8b..6f571c1029 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -457,19 +457,57 @@ void
message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder)
{
CamelException ex;
-
+ gboolean folder_exists;
+
g_return_if_fail (message_list != NULL);
g_return_if_fail (camel_folder != NULL);
g_return_if_fail (IS_MESSAGE_LIST (message_list));
g_return_if_fail (CAMEL_IS_FOLDER (camel_folder));
g_return_if_fail (camel_folder_has_summary_capability (camel_folder, &ex));
+
+ camel_exception_init (&ex);
+
if (message_list->folder)
gtk_object_unref (GTK_OBJECT (message_list->folder));
message_list->folder = camel_folder;
- message_list->folder_summary = camel_folder_get_summary (camel_folder, &ex);
+ folder_exists = camel_folder_exists (camel_folder, NULL);
+
+ if (camel_exception_get_id (&ex)) {
+ printf ("Unable to test for folder existence \n");
+ return;
+ }
+
+ if (!folder_exists) {
+ g_warning ("Folder does not exist, creating it\n");
+ /*
+ if you don't want the directory to be created
+ automatically here remove this.
+ */
+ camel_folder_create (camel_folder, &ex);
+ if (camel_exception_get_id (&ex)) {
+ printf ("Unable to create folder\n");
+ return;
+ }
+
+ }
+
+
+ camel_folder_open (camel_folder, FOLDER_OPEN_RW, &ex);
+ if (camel_exception_get_id (&ex)) {
+ printf ("Unable to open folder\n");
+ return;
+ }
+
+ message_list->folder_summary = camel_folder_get_summary (camel_folder, &ex);
+ if (camel_exception_get_id (&ex)) {
+ printf ("Unable to get summary \n");
+ return;
+ }
+
+
gtk_object_ref (GTK_OBJECT (camel_folder));
printf ("Modelo cambio!\n");