aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder.c
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 /camel/camel-folder.c
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
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r--camel/camel-folder.c140
1 files changed, 135 insertions, 5 deletions
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);
}