diff options
author | Dan Winship <danw@src.gnome.org> | 2000-07-25 10:42:11 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-07-25 10:42:11 +0800 |
commit | 72183d80ecaa52aef8b45e9857d2464ad3e624ca (patch) | |
tree | 076ae2a90662000ed4f643609486ed0441dd2fed | |
parent | 58eab08d844f38038991580fea08a7b123d4169c (diff) | |
download | gsoc2013-evolution-72183d80ecaa52aef8b45e9857d2464ad3e624ca.tar.gz gsoc2013-evolution-72183d80ecaa52aef8b45e9857d2464ad3e624ca.tar.zst gsoc2013-evolution-72183d80ecaa52aef8b45e9857d2464ad3e624ca.zip |
Remove exceptions from a number of methods that work on what ought to be
* camel-folder.c: Remove exceptions from a number of methods that
work on what ought to be static data: get_parent_folder,
get_parent_store, get_message_count, get_unread_message_count,
get_permanent_flags, get_message_flags, set_message_flags,
get_message_user_flag, set_message_user_flag, get_uids,
get_summary, get_subfolder_names. Turn camel_folder_delete_message
into a macro. (Mostly a pull-up from the camel-async branch.)
* providers/{imap,mbox,nntp,pop3,vee}: Update for CamelFolder
changes
svn path=/trunk/; revision=4303
-rw-r--r-- | camel/ChangeLog | 13 | ||||
-rw-r--r-- | camel/camel-folder.c | 155 | ||||
-rw-r--r-- | camel/camel-folder.h | 78 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 97 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.c | 120 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-folder.c | 55 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-folder.c | 205 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-folder.h | 1 | ||||
-rw-r--r-- | camel/providers/vee/camel-vee-folder.c | 65 |
9 files changed, 318 insertions, 471 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index c2d1e70f00..a778fbbf7d 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,16 @@ +2000-07-24 Dan Winship <danw@helixcode.com> + + * camel-folder.c: Remove exceptions from a number of methods that + work on what ought to be static data: get_parent_folder, + get_parent_store, get_message_count, get_unread_message_count, + get_permanent_flags, get_message_flags, set_message_flags, + get_message_user_flag, set_message_user_flag, get_uids, + get_summary, get_subfolder_names. Turn camel_folder_delete_message + into a macro. (Mostly a pull-up from the camel-async branch.) + + * providers/{imap,mbox,nntp,pop3,vee}: Update for CamelFolder + changes + 2000-07-24 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-folder.c (imap_get_message_info): Updated diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 5b8b87af57..caac803ce8 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -63,35 +63,28 @@ static const gchar *get_full_name (CamelFolder *folder); static gboolean can_hold_folders (CamelFolder *folder); static gboolean can_hold_messages (CamelFolder *folder); -static guint32 get_permanent_flags (CamelFolder *folder, CamelException *ex); -static guint32 get_message_flags (CamelFolder *folder, const char *uid, - CamelException *ex); +static guint32 get_permanent_flags (CamelFolder *folder); +static guint32 get_message_flags (CamelFolder *folder, const char *uid); static void set_message_flags (CamelFolder *folder, const char *uid, - guint32 flags, guint32 set, CamelException *ex); + guint32 flags, guint32 set); static gboolean get_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, CamelException *ex); + const char *name); static void set_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, gboolean value, - CamelException *ex); + const char *name, gboolean value); -static GPtrArray *get_subfolder_names (CamelFolder *folder, - CamelException *ex); +static GPtrArray *get_subfolder_names (CamelFolder *folder); static void free_subfolder_names (CamelFolder *folder, GPtrArray *array); static CamelFolder *get_subfolder (CamelFolder *folder, const gchar *folder_name, gboolean create, CamelException *ex); -static CamelFolder *get_parent_folder (CamelFolder *folder, - CamelException *ex); -static CamelStore *get_parent_store (CamelFolder *folder, - CamelException *ex); - - -static gint get_message_count (CamelFolder *folder, CamelException *ex); +static CamelFolder *get_parent_folder (CamelFolder *folder); +static CamelStore *get_parent_store (CamelFolder *folder); -static gint get_unread_message_count (CamelFolder *folder, CamelException *ex); +static gint get_message_count (CamelFolder *folder); +static gint get_unread_message_count (CamelFolder *folder); static void expunge (CamelFolder *folder, CamelException *ex); @@ -101,20 +94,15 @@ static void append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, CamelException *ex); -static GPtrArray *get_uids (CamelFolder *folder, - CamelException *ex); +static GPtrArray *get_uids (CamelFolder *folder); static void free_uids (CamelFolder *folder, GPtrArray *array); -static GPtrArray *get_summary (CamelFolder *folder, - CamelException *ex); +static GPtrArray *get_summary (CamelFolder *folder); static void free_summary (CamelFolder *folder, GPtrArray *array); static CamelMimeMessage *get_message (CamelFolder *folder, const gchar *uid, CamelException *ex); -static void delete_message (CamelFolder *folder, - const gchar *uid, - CamelException *ex); static const CamelMessageInfo *get_message_info (CamelFolder *folder, const char *uid); @@ -172,7 +160,6 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) camel_folder_class->get_message_user_flag = get_message_user_flag; camel_folder_class->set_message_user_flag = set_message_user_flag; camel_folder_class->get_message = get_message; - camel_folder_class->delete_message = delete_message; camel_folder_class->get_uids = get_uids; camel_folder_class->free_uids = free_uids; camel_folder_class->get_summary = get_summary; @@ -461,7 +448,7 @@ camel_folder_get_subfolder (CamelFolder *folder, const gchar *folder_name, static CamelFolder * -get_parent_folder (CamelFolder *folder, CamelException *ex) +get_parent_folder (CamelFolder *folder) { return folder->parent_folder; } @@ -469,21 +456,20 @@ get_parent_folder (CamelFolder *folder, CamelException *ex) /** * camel_folder_get_parent_folder: * @folder: folder to get the parent of - * @ex: a CamelException * * Return value: the folder's parent **/ CamelFolder * -camel_folder_get_parent_folder (CamelFolder *folder, CamelException *ex) +camel_folder_get_parent_folder (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS (folder)->get_parent_folder (folder, ex); + return CF_CLASS (folder)->get_parent_folder (folder); } static CamelStore * -get_parent_store (CamelFolder *folder, CamelException *ex) +get_parent_store (CamelFolder *folder) { return folder->parent_store; } @@ -491,21 +477,20 @@ get_parent_store (CamelFolder *folder, CamelException *ex) /** * camel_folder_get_parent_store: * @folder: folder to get the parent of - * @ex: a CamelException * * Return value: the parent store of the folder. **/ CamelStore * -camel_folder_get_parent_store (CamelFolder *folder, CamelException *ex) +camel_folder_get_parent_store (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS (folder)->get_parent_store (folder, ex); + return CF_CLASS (folder)->get_parent_store (folder); } static GPtrArray * -get_subfolder_names (CamelFolder *folder, CamelException *ex) +get_subfolder_names (CamelFolder *folder) { g_warning ("CamelFolder::get_subfolder_names not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -515,18 +500,17 @@ get_subfolder_names (CamelFolder *folder, CamelException *ex) /** * camel_folder_get_subfolder_names: * @folder: the folder - * @ex: a CamelException * * Return value: an array containing the names of the folder's * subfolders. The array should not be modified and must be freed with * camel_folder_free_subfolder_names(). **/ GPtrArray * -camel_folder_get_subfolder_names (CamelFolder *folder, CamelException *ex) +camel_folder_get_subfolder_names (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS (folder)->get_subfolder_names (folder, ex); + return CF_CLASS (folder)->get_subfolder_names (folder); } @@ -578,7 +562,7 @@ camel_folder_expunge (CamelFolder *folder, CamelException *ex) static gint -get_message_count (CamelFolder *folder, CamelException *ex) +get_message_count (CamelFolder *folder) { g_warning ("CamelFolder::get_message_count not implemented " "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -588,20 +572,19 @@ get_message_count (CamelFolder *folder, CamelException *ex) /** * camel_folder_get_message_count: * @folder: A CamelFolder object - * @ex: a CamelException * * Return value: the number of messages in the folder, or -1 if unknown. **/ gint -camel_folder_get_message_count (CamelFolder *folder, CamelException *ex) +camel_folder_get_message_count (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1); - return CF_CLASS (folder)->get_message_count (folder, ex); + return CF_CLASS (folder)->get_message_count (folder); } static gint -get_unread_message_count (CamelFolder *folder, CamelException *ex) +get_unread_message_count (CamelFolder *folder) { g_warning ("CamelFolder::get_unread_message_count not implemented " "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -611,16 +594,15 @@ get_unread_message_count (CamelFolder *folder, CamelException *ex) /** * camel_folder_unread_get_message_count: * @folder: A CamelFolder object - * @ex: a CamelException * * Return value: the number of unread messages in the folder, or -1 if unknown. **/ gint -camel_folder_get_unread_message_count (CamelFolder *folder, CamelException *ex) +camel_folder_get_unread_message_count (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1); - return CF_CLASS (folder)->get_message_count (folder, ex); + return CF_CLASS (folder)->get_unread_message_count (folder); } @@ -655,7 +637,7 @@ camel_folder_append_message (CamelFolder *folder, static guint32 -get_permanent_flags (CamelFolder *folder, CamelException *ex) +get_permanent_flags (CamelFolder *folder) { return folder->permanent_flags; } @@ -663,23 +645,22 @@ get_permanent_flags (CamelFolder *folder, CamelException *ex) /** * camel_folder_get_permanent_flags: * @folder: a CamelFolder - * @ex: a CamelException * * Return value: the set of CamelMessageFlags that can be permanently * stored on a message between sessions. If it includes %CAMEL_FLAG_USER, * then user-defined flags will be remembered. **/ guint32 -camel_folder_get_permanent_flags (CamelFolder *folder, CamelException *ex) +camel_folder_get_permanent_flags (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); - return CF_CLASS (folder)->get_permanent_flags (folder, ex); + return CF_CLASS (folder)->get_permanent_flags (folder); } static guint32 -get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex) +get_message_flags (CamelFolder *folder, const char *uid) { g_warning ("CamelFolder::get_message_flags not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -690,24 +671,22 @@ get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex) * camel_folder_get_message_flags: * @folder: a CamelFolder * @uid: the UID of a message in @folder - * @ex: a CamelException * * Return value: the CamelMessageFlags that are set on the indicated * message. **/ guint32 -camel_folder_get_message_flags (CamelFolder *folder, const char *uid, - CamelException *ex) +camel_folder_get_message_flags (CamelFolder *folder, const char *uid) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); - return CF_CLASS (folder)->get_message_flags (folder, uid, ex); + return CF_CLASS (folder)->get_message_flags (folder, uid); } static void set_message_flags (CamelFolder *folder, const char *uid, - guint32 flags, guint32 set, CamelException *ex) + guint32 flags, guint32 set) { g_warning ("CamelFolder::set_message_flags not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -719,7 +698,6 @@ set_message_flags (CamelFolder *folder, const char *uid, * @uid: the UID of a message in @folder * @flags: a set of CamelMessageFlag values to set * @set: the mask of values in @flags to use. - * @ex: a CamelException * * Sets those flags specified by @set to the values specified by @flags * on the indicated message. (This may or may not persist after the @@ -727,18 +705,17 @@ set_message_flags (CamelFolder *folder, const char *uid, **/ void camel_folder_set_message_flags (CamelFolder *folder, const char *uid, - guint32 flags, guint32 set, - CamelException *ex) + guint32 flags, guint32 set) { g_return_if_fail (CAMEL_IS_FOLDER (folder)); - CF_CLASS (folder)->set_message_flags (folder, uid, flags, set, ex); + CF_CLASS (folder)->set_message_flags (folder, uid, flags, set); } static gboolean get_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, CamelException *ex) + const char *name) { g_warning ("CamelFolder::get_message_user_flag not implemented " "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -750,24 +727,22 @@ get_message_user_flag (CamelFolder *folder, const char *uid, * @folder: a CamelFolder * @uid: the UID of a message in @folder * @name: the name of a user flag - * @ex: a CamelException * * Return value: whether or not the given user flag is set on the message. **/ gboolean camel_folder_get_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, CamelException *ex) + const char *name) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); - return CF_CLASS (folder)->get_message_user_flag (folder, uid, - name, ex); + return CF_CLASS (folder)->get_message_user_flag (folder, uid, name); } static void set_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, gboolean value, CamelException *ex) + const char *name, gboolean value) { g_warning ("CamelFolder::set_message_user_flag not implemented " "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -779,7 +754,6 @@ set_message_user_flag (CamelFolder *folder, const char *uid, * @uid: the UID of a message in @folder * @name: the name of the user flag to set * @value: the value to set it to - * @ex: a CamelException * * Sets the user flag specified by @name to the value specified by @value * on the indicated message. (This may or may not persist after the @@ -787,13 +761,11 @@ set_message_user_flag (CamelFolder *folder, const char *uid, **/ void camel_folder_set_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, gboolean value, - CamelException *ex) + const char *name, gboolean value) { g_return_if_fail (CAMEL_IS_FOLDER (folder)); - CF_CLASS (folder)->set_message_user_flag (folder, uid, name, - value, ex); + CF_CLASS (folder)->set_message_user_flag (folder, uid, name, value); } @@ -864,34 +836,8 @@ camel_folder_get_message (CamelFolder *folder, const gchar *uid, } -static void -delete_message (CamelFolder *folder, const gchar *uid, - CamelException *ex) -{ - g_warning ("CamelFolder::delete_message not implemented " - "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); -} - -/** - * camel_folder_delete_message: - * @folder: the folder object - * @uid: the UID - * @ex: a CamelException - * - * Delete a message from a folder given its UID. - **/ -void -camel_folder_delete_message (CamelFolder *folder, const gchar *uid, - CamelException *ex) -{ - g_return_if_fail (CAMEL_IS_FOLDER (folder)); - - return CF_CLASS (folder)->delete_message (folder, uid, ex); -} - - static GPtrArray * -get_uids (CamelFolder *folder, CamelException *ex) +get_uids (CamelFolder *folder) { g_warning ("CamelFolder::get_uids not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -901,7 +847,6 @@ get_uids (CamelFolder *folder, CamelException *ex) /** * camel_folder_get_uids: * @folder: folder object - * @ex: a CamelException * * Get the list of UIDs available in a folder. This routine is useful * for finding what messages are available when the folder does not @@ -912,15 +857,14 @@ get_uids (CamelFolder *folder, CamelException *ex) * available in the folder. **/ GPtrArray * -camel_folder_get_uids (CamelFolder *folder, CamelException *ex) +camel_folder_get_uids (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS (folder)->get_uids (folder, ex); + return CF_CLASS (folder)->get_uids (folder); } -/* This is also the default implementation of free_subfolder_names. */ static void free_uids (CamelFolder *folder, GPtrArray *array) { @@ -945,7 +889,7 @@ camel_folder_free_uids (CamelFolder *folder, GPtrArray *array) static GPtrArray * -get_summary (CamelFolder *folder, CamelException *ex) +get_summary (CamelFolder *folder) { g_warning ("CamelFolder::get_summary not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); @@ -955,7 +899,6 @@ get_summary (CamelFolder *folder, CamelException *ex) /** * camel_folder_get_summary: * @folder: a folder object - * @ex: a CamelException * * This returns the summary information for the folder. This array * should not be modified, and must be freed with @@ -964,11 +907,11 @@ get_summary (CamelFolder *folder, CamelException *ex) * Return value: an array of CamelMessageInfo **/ GPtrArray * -camel_folder_get_summary (CamelFolder *folder, CamelException *ex) +camel_folder_get_summary (CamelFolder *folder) { g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS (folder)->get_summary (folder, ex); + return CF_CLASS (folder)->get_summary (folder); } @@ -1105,7 +1048,7 @@ move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, gtk_object_unref (GTK_OBJECT (msg)); if (camel_exception_is_set (ex)) return; - camel_folder_delete_message (source, uid, ex); + camel_folder_delete_message (source, uid); } /** diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 02808ee6e1..bdaebfd242 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -94,45 +94,36 @@ typedef struct { gboolean create, CamelException *ex); - CamelFolder * (*get_parent_folder) (CamelFolder *folder, - CamelException *ex); + CamelFolder * (*get_parent_folder) (CamelFolder *folder); - CamelStore * (*get_parent_store) (CamelFolder *folder, - CamelException *ex); + CamelStore * (*get_parent_store) (CamelFolder *folder); void (*expunge) (CamelFolder *folder, CamelException *ex); - gint (*get_message_count) (CamelFolder *folder, - CamelException *ex); + gint (*get_message_count) (CamelFolder *folder); - gint (*get_unread_message_count) (CamelFolder *folder, - CamelException *ex); + gint (*get_unread_message_count) (CamelFolder *folder); void (*append_message) (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, CamelException *ex); - guint32 (*get_permanent_flags) (CamelFolder *folder, - CamelException *ex); + guint32 (*get_permanent_flags) (CamelFolder *folder); guint32 (*get_message_flags) (CamelFolder *folder, - const char *uid, - CamelException *ex); + const char *uid); void (*set_message_flags) (CamelFolder *folder, const char *uid, - guint32 flags, guint32 set, - CamelException *ex); + guint32 flags, guint32 set); gboolean (*get_message_user_flag) (CamelFolder *folder, const char *uid, - const char *name, - CamelException *ex); + const char *name); void (*set_message_user_flag) (CamelFolder *folder, const char *uid, const char *name, - gboolean value, - CamelException *ex); + gboolean value); CamelMimeMessage * (*get_message) (CamelFolder *folder, const gchar *uid, @@ -142,18 +133,15 @@ typedef struct { const gchar *uid, CamelException *ex); - GPtrArray * (*get_uids) (CamelFolder *folder, - CamelException *ex); + GPtrArray * (*get_uids) (CamelFolder *folder); void (*free_uids) (CamelFolder *folder, GPtrArray *array); - GPtrArray * (*get_summary) (CamelFolder *folder, - CamelException *ex); + GPtrArray * (*get_summary) (CamelFolder *folder); void (*free_summary) (CamelFolder *folder, GPtrArray *summary); - GPtrArray * (*get_subfolder_names) (CamelFolder *folder, - CamelException *ex); + GPtrArray * (*get_subfolder_names) (CamelFolder *folder); void (*free_subfolder_names) (CamelFolder *folder, GPtrArray *subfolders); @@ -199,10 +187,8 @@ void camel_folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); -CamelFolder * camel_folder_get_parent_folder (CamelFolder *folder, - CamelException *ex); -CamelStore * camel_folder_get_parent_store (CamelFolder *folder, - CamelException *ex); +CamelFolder * camel_folder_get_parent_folder (CamelFolder *folder); +CamelStore * camel_folder_get_parent_store (CamelFolder *folder); /* delete operations */ @@ -216,29 +202,24 @@ const gchar * camel_folder_get_full_name (CamelFolder *folder); /* various properties accessors */ -guint32 camel_folder_get_permanent_flags (CamelFolder *folder, - CamelException *ex); +guint32 camel_folder_get_permanent_flags (CamelFolder *folder); guint32 camel_folder_get_message_flags (CamelFolder *folder, - const char *uid, - CamelException *ex); + const char *uid); void camel_folder_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, - guint32 set, - CamelException *ex); + guint32 set); gboolean camel_folder_get_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, - CamelException *ex); + const char *name); void camel_folder_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, - gboolean value, - CamelException *ex); + gboolean value); @@ -253,19 +234,15 @@ void camel_folder_append_message (CamelFolder *folder, gboolean camel_folder_has_summary_capability (CamelFolder *folder); -gint camel_folder_get_message_count (CamelFolder *folder, - CamelException *ex); +gint camel_folder_get_message_count (CamelFolder *folder); -gint camel_folder_get_unread_message_count (CamelFolder *folder, - CamelException *ex); +gint camel_folder_get_unread_message_count (CamelFolder *folder); -GPtrArray * camel_folder_get_summary (CamelFolder *folder, - CamelException *ex); +GPtrArray * camel_folder_get_summary (CamelFolder *folder); void camel_folder_free_summary (CamelFolder *folder, GPtrArray *array); -GPtrArray * camel_folder_get_subfolder_names (CamelFolder *folder, - CamelException *ex); +GPtrArray * camel_folder_get_subfolder_names (CamelFolder *folder); void camel_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *array); @@ -274,11 +251,10 @@ void camel_folder_free_subfolder_names (CamelFolder *folder, CamelMimeMessage * camel_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex); -void camel_folder_delete_message (CamelFolder *folder, - const gchar *uid, - CamelException *ex); -GPtrArray * camel_folder_get_uids (CamelFolder *folder, - CamelException *ex); +#define camel_folder_delete_message(folder, uid) \ + camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED) + +GPtrArray * camel_folder_get_uids (CamelFolder *folder); void camel_folder_free_uids (CamelFolder *folder, GPtrArray *array); diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 3dab6179cb..a8e4a7d602 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -69,35 +69,31 @@ static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex static void imap_expunge (CamelFolder *folder, CamelException *ex); static gint imap_get_message_count_internal (CamelFolder *folder, CamelException *ex); -static gint imap_get_message_count (CamelFolder *folder, CamelException *ex); -static gint imap_get_unread_message_count (CamelFolder *folder, CamelException *ex); +static gint imap_get_message_count (CamelFolder *folder); +static gint imap_get_unread_message_count (CamelFolder *folder); static CamelMimeMessage *imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex); static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, CamelException *ex); static void imap_copy_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex); static void imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex); -static void imap_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex); static gboolean imap_parse_subfolder_line (gchar *buf, gchar *namespace, gchar **flags, gchar **sep, gchar **folder); static GPtrArray *imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex); -static GPtrArray *imap_get_subfolder_names (CamelFolder *folder, CamelException *ex); +static GPtrArray *imap_get_subfolder_names (CamelFolder *folder); -static GPtrArray *imap_get_uids (CamelFolder *folder, CamelException *ex); +static GPtrArray *imap_get_uids (CamelFolder *folder); static GPtrArray *imap_get_summary_internal (CamelFolder *folder, CamelException *ex); -static GPtrArray *imap_get_summary (CamelFolder *folder, CamelException *ex); +static GPtrArray *imap_get_summary (CamelFolder *folder); static const CamelMessageInfo *imap_get_message_info (CamelFolder *folder, const char *uid); static GPtrArray *imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex); /* flag methods */ -static guint32 imap_get_permanent_flags (CamelFolder *folder, CamelException *ex); -static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex); -static void imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, - CamelException *ex); -static gboolean imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, - CamelException *ex); +static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid); +static void imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name); static void imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, - gboolean value, CamelException *ex); + gboolean value); static void @@ -118,13 +114,12 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class) camel_folder_class->get_uids = imap_get_uids; camel_folder_class->free_uids = camel_folder_free_nop; camel_folder_class->get_subfolder_names = imap_get_subfolder_names; - camel_folder_class->free_subfolder_names = camel_folder_free_deep; + camel_folder_class->free_subfolder_names = camel_folder_free_nop; camel_folder_class->get_message_count = imap_get_message_count; camel_folder_class->get_unread_message_count = imap_get_unread_message_count; camel_folder_class->get_message = imap_get_message; camel_folder_class->append_message = imap_append_message; - camel_folder_class->delete_message = imap_delete_message; camel_folder_class->copy_message_to = imap_copy_message_to; camel_folder_class->move_message_to = imap_move_message_to; @@ -134,7 +129,6 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class) camel_folder_class->search_by_expression = imap_search_by_expression; - camel_folder_class->get_permanent_flags = imap_get_permanent_flags; camel_folder_class->get_message_flags = imap_get_message_flags; camel_folder_class->set_message_flags = imap_set_message_flags; camel_folder_class->get_message_user_flag = imap_get_message_user_flag; @@ -416,7 +410,7 @@ imap_get_message_count_internal (CamelFolder *folder, CamelException *ex) } static gint -imap_get_message_count (CamelFolder *folder, CamelException *ex) +imap_get_message_count (CamelFolder *folder) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); @@ -427,7 +421,7 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex) } static gint -imap_get_unread_message_count (CamelFolder *folder, CamelException *ex) +imap_get_unread_message_count (CamelFolder *folder) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); CamelMessageInfo *info; @@ -440,7 +434,7 @@ imap_get_unread_message_count (CamelFolder *folder, CamelException *ex) if (!imap_folder->summary) return 0; - infolist = imap_get_summary (folder, ex); + infolist = imap_get_summary (folder); for (i = 0; i < infolist->len; i++) { info = (CamelMessageInfo *) g_ptr_array_index (infolist, i); @@ -600,19 +594,19 @@ imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destina return; } - imap_set_message_flags (source, uid, CAMEL_MESSAGE_DELETED, ~(info->flags), ex); + imap_set_message_flags (source, uid, CAMEL_MESSAGE_DELETED, ~(info->flags)); camel_imap_folder_changed (destination, ex); } static GPtrArray * -imap_get_uids (CamelFolder *folder, CamelException *ex) +imap_get_uids (CamelFolder *folder) { CamelMessageInfo *info; GPtrArray *array, *infolist; gint i, count; - infolist = imap_get_summary (folder, ex); + infolist = imap_get_summary (folder); count = infolist->len; array = g_ptr_array_new (); @@ -763,30 +757,13 @@ imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex) } static GPtrArray * -imap_get_subfolder_names (CamelFolder *folder, CamelException *ex) +imap_get_subfolder_names (CamelFolder *folder) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); return imap_folder->lsub; } -static void -imap_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - CamelMessageInfo *info; - - if (!(info = (CamelMessageInfo *)imap_get_message_info (folder, uid))) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not set flags for message %s on IMAP server %s: %s", - uid, service->url->host, "Unknown error"); - return; - } - - imap_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED, ~(info->flags), ex); -} - static CamelMimeMessage * imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex) { @@ -1181,7 +1158,7 @@ imap_get_summary_internal (CamelFolder *folder, CamelException *ex) } static GPtrArray * -imap_get_summary (CamelFolder *folder, CamelException *ex) +imap_get_summary (CamelFolder *folder) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); @@ -1204,6 +1181,7 @@ imap_get_message_info (CamelFolder *folder, const char *uid) if (imap_folder->summary) { int max, i; + /* FIXME: use a hash table like the mbox provider does */ max = imap_folder->summary->len; for (i = 0; i < max; i++) { info = g_ptr_array_index (imap_folder->summary, i); @@ -1417,42 +1395,23 @@ imap_search_by_expression (CamelFolder *folder, const char *expression, CamelExc } static guint32 -imap_get_permanent_flags (CamelFolder *folder, CamelException *ex) -{ - /* return permamnant flags */ - return folder->permanent_flags; -} - -static guint32 -imap_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex) +imap_get_message_flags (CamelFolder *folder, const char *uid) { - CamelMessageInfo *info; + const CamelMessageInfo *info; - if (!(info = (CamelMessageInfo *)imap_get_message_info (folder, uid))) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not get flags for message %s on IMAP server %s: %s", - uid, service->url->host, "Unknown error"); - return 0; - } + info = imap_get_message_info (folder, uid); + g_return_val_if_fail (info != NULL, 0); return info->flags; } static void -imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex) +imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set) { CamelMessageInfo *info; - if (!(info = (CamelMessageInfo *)imap_get_message_info (folder, uid))) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not set flags for message %s on IMAP server %s: %s", - uid, service->url->host, "Unknown error"); - return; - } + info = (CamelMessageInfo*)imap_get_message_info (folder, uid); + g_return_if_fail (info != NULL); info->flags = (info->flags & ~flags) | (set & flags) | CAMEL_MESSAGE_FOLDER_FLAGGED; @@ -1460,13 +1419,13 @@ imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, gui } static gboolean -imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, CamelException *ex) +imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name) { return FALSE; } static void -imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value, CamelException *ex) +imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value) { gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid); } diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c index 6e94456b8b..deb47f6dcf 100644 --- a/camel/providers/mbox/camel-mbox-folder.c +++ b/camel/providers/mbox/camel-mbox-folder.c @@ -63,26 +63,24 @@ static void mbox_init (CamelFolder *folder, CamelStore *parent_store, CamelException *ex); static void mbox_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); -static gint mbox_get_message_count (CamelFolder *folder, CamelException *ex); -static gint mbox_get_unread_message_count (CamelFolder *folder, CamelException *ex); +static gint mbox_get_message_count (CamelFolder *folder); +static gint mbox_get_unread_message_count (CamelFolder *folder); static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, CamelException *ex); -static GPtrArray *mbox_get_uids (CamelFolder *folder, CamelException *ex); -static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex); -static GPtrArray *mbox_get_summary (CamelFolder *folder, CamelException *ex); +static GPtrArray *mbox_get_uids (CamelFolder *folder); +static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder); +static GPtrArray *mbox_get_summary (CamelFolder *folder); static CamelMimeMessage *mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex); static void mbox_expunge (CamelFolder *folder, CamelException *ex); -static void mbox_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex); - static const CamelMessageInfo *mbox_get_message_info (CamelFolder *folder, const char *uid); static GPtrArray *mbox_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex); -static guint32 mbox_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex); -static void mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex); -static gboolean mbox_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, CamelException *ex); -static void mbox_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value, CamelException *ex); +static guint32 mbox_get_message_flags (CamelFolder *folder, const char *uid); +static void mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean mbox_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name); +static void mbox_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value); static void mbox_finalize (GtkObject *object); @@ -112,7 +110,6 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class) camel_folder_class->expunge = mbox_expunge; camel_folder_class->get_message = mbox_get_message; - camel_folder_class->delete_message = mbox_delete_message; camel_folder_class->search_by_expression = mbox_search_by_expression; @@ -263,31 +260,30 @@ mbox_expunge (CamelFolder *folder, CamelException *ex) } static gint -mbox_get_message_count (CamelFolder *folder, CamelException *ex) +mbox_get_message_count (CamelFolder *folder) { CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - g_assert (folder); - g_assert (mbox_folder->summary); + g_return_val_if_fail (mbox_folder->summary != NULL, -1); return camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); } static gint -mbox_get_unread_message_count (CamelFolder *folder, CamelException *ex) +mbox_get_unread_message_count (CamelFolder *folder) { CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); CamelMessageInfo *info; GPtrArray *infolist; gint i, max, count = 0; - g_return_val_if_fail (folder != NULL, -1); + g_return_val_if_fail (mbox_folder->summary != NULL, -1); max = camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); if (max == -1) return -1; - infolist = mbox_get_summary (folder, ex); + infolist = mbox_get_summary (folder); for (i = 0; i < infolist->len; i++) { info = (CamelMessageInfo *) g_ptr_array_index (infolist, i); @@ -335,7 +331,6 @@ mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 fla uid = camel_folder_summary_next_uid (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); xev = g_strdup_printf ("%08x-%04x", uid, flags); camel_medium_add_header (CAMEL_MEDIUM (message), "X-Evolution", xev); - g_print ("%s -- %s\n", __FUNCTION__, xev); g_free (xev); /* we must write this to the non-filtered stream ... */ @@ -394,7 +389,7 @@ fail: } static GPtrArray * -mbox_get_uids (CamelFolder *folder, CamelException *ex) +mbox_get_uids (CamelFolder *folder) { GPtrArray *array; CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); @@ -413,25 +408,12 @@ mbox_get_uids (CamelFolder *folder, CamelException *ex) } static GPtrArray * -mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex) +mbox_get_subfolder_names (CamelFolder *folder) { /* No subfolders. */ return g_ptr_array_new (); } -static void -mbox_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - const CamelMessageInfo *info; - CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); - - info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); - if (info) { - mbox_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED, ~(info->flags), ex); - camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary)); - } -} - static CamelMimeMessage * mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex) { @@ -503,7 +485,7 @@ fail: } GPtrArray * -mbox_get_summary (CamelFolder *folder, CamelException *ex) +mbox_get_summary (CamelFolder *folder) { CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); @@ -541,77 +523,59 @@ mbox_search_by_expression (CamelFolder *folder, const char *expression, CamelExc } static guint32 -mbox_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex) +mbox_get_message_flags (CamelFolder *folder, const char *uid) { CamelMessageInfo *info; CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); - if (info) { - return info->flags; - } else { - camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "No such message %s in %s.", uid, - folder->name); - return 0; - } + g_return_val_if_fail (info != NULL, 0); + + return info->flags; } static void mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, - guint32 set, CamelException *ex) + guint32 set) { CamelMessageInfo *info; CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); - if (info) { - info->flags = (info->flags & ~flags) | (set & flags) | - CAMEL_MESSAGE_FOLDER_FLAGGED; - camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary)); - - gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid); - } else { - camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "No such message %s in %s.", uid, - folder->name); - } + g_return_if_fail (info != NULL); + + info->flags = (info->flags & ~flags) | (set & flags) | + CAMEL_MESSAGE_FOLDER_FLAGGED; + camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary)); + + gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid); } static gboolean mbox_get_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, CamelException *ex) + const char *name) { CamelMessageInfo *info; CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); - if (info) - return camel_flag_get (&info->user_flags, name); - else { - camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "No such message %s in %s.", uid, - folder->name); - return FALSE; - } + g_return_val_if_fail (info != NULL, FALSE); + + return camel_flag_get (&info->user_flags, name); } -static void mbox_set_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, gboolean value, - CamelException *ex) +static void +mbox_set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value) { CamelMessageInfo *info; CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); - if (info) { - camel_flag_set (&info->user_flags, name, value); - info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED; - camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary)); - gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid); - } else { - camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "No such message %s in %s.", uid, - folder->name); - } + g_return_if_fail (info != NULL); + + camel_flag_set (&info->user_flags, name, value); + info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED; + camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary)); + gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid); } diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c index 8384327cd9..b1d0a919d5 100644 --- a/camel/providers/nntp/camel-nntp-folder.c +++ b/camel/providers/nntp/camel-nntp-folder.c @@ -70,7 +70,7 @@ nntp_folder_init (CamelFolder *folder, CamelStore *parent_store, parent_class->init (folder, parent_store, parent_folder, name, separator, path_begins_with_sep, ex); - if (camel_exception_get_id (ex)) return; + if (camel_exception_is_set (ex)) return; /* set flags */ @@ -130,9 +130,8 @@ nntp_folder_sync (CamelFolder *folder, gboolean expunge, camel_folder_summary_save (CAMEL_NNTP_FOLDER(folder)->summary); - store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder, ex)); - if (!camel_exception_is_set (ex)) - camel_nntp_newsrc_write (store->newsrc); + store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder)); + camel_nntp_newsrc_write (store->newsrc); } static const gchar * @@ -160,7 +159,7 @@ nntp_folder_get_subfolder (CamelFolder *folder, } static gint -nntp_folder_get_message_count (CamelFolder *folder, CamelException *ex) +nntp_folder_get_message_count (CamelFolder *folder) { CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER(folder); @@ -171,7 +170,7 @@ nntp_folder_get_message_count (CamelFolder *folder, CamelException *ex) } static guint32 -nntp_folder_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex) +nntp_folder_get_message_flags (CamelFolder *folder, const char *uid) { CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); CamelMessageInfo *info = camel_folder_summary_uid (nntp_folder->summary, uid); @@ -181,7 +180,7 @@ nntp_folder_get_message_flags (CamelFolder *folder, const char *uid, CamelExcept static void nntp_folder_set_message_flags (CamelFolder *folder, const char *uid, - guint32 flags, guint32 set, CamelException *ex) + guint32 flags, guint32 set) { CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); CamelMessageInfo *info = camel_folder_summary_uid (nntp_folder->summary, uid); @@ -191,16 +190,14 @@ nntp_folder_set_message_flags (CamelFolder *folder, const char *uid, if (set & CAMEL_MESSAGE_SEEN) { CamelNNTPStore *store; int article_num; - CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder, ex)); + CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder)); - if (!camel_exception_is_set (ex)) { - sscanf (uid, "%d", &article_num); + sscanf (uid, "%d", &article_num); - camel_nntp_newsrc_mark_article_read (nntp_store->newsrc, - nntp_folder->group_name, - article_num); - } - } + camel_nntp_newsrc_mark_article_read (nntp_store->newsrc, + nntp_folder->group_name, + article_num); + } camel_folder_summary_touch (nntp_folder->summary); } @@ -220,10 +217,7 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException * char *message_id; /* get the parent store */ - parent_store = camel_folder_get_parent_store (folder, ex); - if (camel_exception_get_id (ex)) { - return NULL; - } + parent_store = camel_folder_get_parent_store (folder); message_id = strchr (uid, ',') + 1; status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %s", message_id); @@ -297,17 +291,8 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException * return message; } -static void -nntp_folder_delete_message (CamelFolder *folder, - const gchar *uid, - CamelException *ex) -{ - g_assert (0); -} - static GPtrArray * -nntp_folder_get_uids (CamelFolder *folder, - CamelException *ex) +nntp_folder_get_uids (CamelFolder *folder) { CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); GPtrArray *out; @@ -327,8 +312,7 @@ nntp_folder_get_uids (CamelFolder *folder, } static GPtrArray * -nntp_folder_get_summary (CamelFolder *folder, - CamelException *ex) +nntp_folder_get_summary (CamelFolder *folder) { CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); @@ -336,10 +320,10 @@ nntp_folder_get_summary (CamelFolder *folder, } static GPtrArray * -nntp_folder_get_subfolder_names (CamelFolder *folder, CamelException *ex) +nntp_folder_get_subfolder_names (CamelFolder *folder) { if (!strcmp (folder->name, "/")) { - CamelStore *store = camel_folder_get_parent_store (folder, ex); + CamelStore *store = camel_folder_get_parent_store (folder); GPtrArray *array = camel_nntp_newsrc_get_subscribed_group_names (CAMEL_NNTP_STORE (store)->newsrc); return array; } @@ -352,10 +336,8 @@ static void nntp_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *subfolders) { if (subfolders) { - CamelException *ex = camel_exception_new (); - CamelStore *store = camel_folder_get_parent_store (folder, ex); + CamelStore *store = camel_folder_get_parent_store (folder); camel_nntp_newsrc_free_group_names (CAMEL_NNTP_STORE (store)->newsrc, subfolders); - camel_exception_free (ex); } } @@ -404,7 +386,6 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class) camel_folder_class->set_message_flags = nntp_folder_set_message_flags; camel_folder_class->get_message_flags = nntp_folder_get_message_flags; camel_folder_class->get_message = nntp_folder_get_message; - camel_folder_class->delete_message = nntp_folder_delete_message; camel_folder_class->get_uids = nntp_folder_get_uids; camel_folder_class->free_uids = camel_folder_free_deep; camel_folder_class->get_summary = nntp_folder_get_summary; diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c index 713cb646d5..415ec4cd71 100644 --- a/camel/providers/pop3/camel-pop3-folder.c +++ b/camel/providers/pop3/camel-pop3-folder.c @@ -41,14 +41,15 @@ static void pop3_finalize (GtkObject *object); static void pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); -static gint pop3_get_message_count (CamelFolder *folder, CamelException *ex); -static GPtrArray *pop3_get_uids (CamelFolder *folder, CamelException *ex); +static gint pop3_get_message_count (CamelFolder *folder); +static GPtrArray *pop3_get_uids (CamelFolder *folder); static CamelMimeMessage *pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex); -static void pop3_delete_message (CamelFolder *folder, const char *uid, - CamelException *ex); +static void pop3_set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set); +static GPtrArray *parse_listing (int count, char *data); static void camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class) @@ -68,7 +69,7 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class) camel_folder_class->free_uids = camel_folder_free_nop; camel_folder_class->get_message = pop3_get_message; - camel_folder_class->delete_message = pop3_delete_message; + camel_folder_class->set_message_flags = pop3_set_message_flags; object_class->finalize = pop3_finalize; } @@ -76,15 +77,12 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class) static void camel_pop3_folder_init (gpointer object, gpointer klass) { - CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object); CamelFolder *folder = CAMEL_FOLDER (object); folder->can_hold_messages = TRUE; folder->can_hold_folders = FALSE; folder->has_summary_capability = FALSE; folder->has_search_capability = FALSE; - - pop3_folder->uids = NULL; } GtkType @@ -116,27 +114,105 @@ pop3_finalize (GtkObject *object) { CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object); - g_ptr_array_free (pop3_folder->uids, TRUE); + camel_folder_free_deep (NULL, pop3_folder->uids); + g_free (pop3_folder->flags); } CamelFolder * camel_pop3_folder_new (CamelStore *parent, CamelException *ex) { - CamelFolder *folder = - CAMEL_FOLDER (gtk_object_new (camel_pop3_folder_get_type (), - NULL)); + CamelPop3Store *pop3_store = CAMEL_POP3_STORE (parent); + CamelPop3Folder *pop3_folder; + GPtrArray *uids; + int status, count; + char *data; + + status = camel_pop3_command (pop3_store, &data, "STAT"); + if (status != CAMEL_POP3_OK) { + CamelService *service = CAMEL_SERVICE (parent); + camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, + "Could not get message count from POP " + "server %s: %s.", service->url->host, + data ? data : "Unknown error"); + g_free (data); + return NULL; + } + + count = atoi (data); + g_free (data); + + if (pop3_store->supports_uidl != FALSE) { + status = camel_pop3_command (pop3_store, NULL, "UIDL"); + if (status != CAMEL_POP3_OK) + pop3_store->supports_uidl = FALSE; + } - CF_CLASS (folder)->init (folder, parent, NULL, "inbox", "/", TRUE, ex); - return folder; + if (pop3_store->supports_uidl == FALSE) { + int i; + + uids = g_ptr_array_new (); + g_ptr_array_set_size (uids, count); + + for (i = 0; i < count; i++) + uids->pdata[i] = g_strdup_printf ("%d", i + 1); + } else { + data = camel_pop3_command_get_additional_data (pop3_store, ex); + if (camel_exception_is_set (ex)) + return NULL; + + uids = parse_listing (count, data); + g_free (data); + + if (!uids) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not open folder: message " + "listing was incomplete."); + return NULL; + } + } + + pop3_folder = gtk_type_new (CAMEL_POP3_FOLDER_TYPE); + CF_CLASS (pop3_folder)->init ((CamelFolder *)pop3_folder, parent, + NULL, "inbox", "/", TRUE, ex); + pop3_folder->uids = uids; + pop3_folder->flags = g_new0 (guint32, uids->len); + + return (CamelFolder *)pop3_folder; } static void pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) { - if (expunge) - camel_pop3_store_expunge (CAMEL_POP3_STORE (folder->parent_store), ex); + CamelPop3Folder *pop3_folder; + CamelPop3Store *pop3_store; + int i, status; + char *resp; + + if (!expunge) + return; + + pop3_folder = CAMEL_POP3_FOLDER (folder); + pop3_store = CAMEL_POP3_STORE (folder->parent_store); + + for (i = 0; i < pop3_folder->uids->len; i++) { + if (pop3_folder->flags[i] & CAMEL_MESSAGE_DELETED) { + status = camel_pop3_command (pop3_store, &resp, + "DELE %d", i); + if (status != CAMEL_POP3_OK) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Unable to sync folder" + "%s%s", resp ? ": " : "", + resp ? resp : ""); + g_free (resp); + return; + } + } + } + + camel_pop3_store_expunge (pop3_store, ex); } + static GPtrArray * parse_listing (int count, char *data) { @@ -169,14 +245,10 @@ parse_listing (int count, char *data) } static int -uid_to_number (CamelFolder *folder, const char *uid, CamelException *ex) +uid_to_number (CamelPop3Folder *pop3_folder, const char *uid) { - CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); int i; - if (!pop3_get_uids (folder, ex)) - return -1; - for (i = 0; i < pop3_folder->uids->len; i++) { if (!strcmp (uid, pop3_folder->uids->pdata[i])) return i + 1; @@ -194,9 +266,12 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex) CamelStream *msgstream; CamelMimeMessage *msg; - num = uid_to_number (folder, uid, ex); - if (num == -1) + num = uid_to_number (CAMEL_POP3_FOLDER (folder), uid); + if (num == -1) { + camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, + "No message with uid %s", uid); return NULL; + } status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store), &result, "RETR %d", num); @@ -226,7 +301,8 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex) g_free (body); msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), CAMEL_STREAM (msgstream)); + camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), + CAMEL_STREAM (msgstream)); gtk_object_unref (GTK_OBJECT (msgstream)); @@ -234,95 +310,32 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex) } static void -pop3_delete_message (CamelFolder *folder, const char *uid, - CamelException *ex) +pop3_set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set) { - int status, num; - char *resp; + CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); + int num; - num = uid_to_number (folder, uid, ex); + num = uid_to_number (pop3_folder, uid); if (num == -1) return; - status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store), - &resp, "DELE %d", num); - if (status != CAMEL_POP3_OK) { - camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "Unable to delete message %s%s%s", - uid, resp ? ": " : "", - resp ? resp : ""); - } - g_free (resp); + pop3_folder->flags[num] = + (pop3_folder->flags[num] & ~flags) | (set & flags); } static gint -pop3_get_message_count (CamelFolder *folder, CamelException *ex) +pop3_get_message_count (CamelFolder *folder) { CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); - if (!pop3_get_uids (folder, ex)) - return -1; - return pop3_folder->uids->len; } static GPtrArray * -pop3_get_uids (CamelFolder *folder, CamelException *ex) +pop3_get_uids (CamelFolder *folder) { - CamelPop3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store); CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); - int count, status; - char *data; - - if (pop3_folder->uids) - return pop3_folder->uids; - - status = camel_pop3_command (pop3_store, &data, "STAT"); - if (status != CAMEL_POP3_OK) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not get message count from POP " - "server %s: %s.", service->url->host, - data ? data : "Unknown error"); - g_free (data); - return NULL; - } - - count = atoi (data); - g_free (data); - - if (pop3_store->supports_uidl != FALSE) { - status = camel_pop3_command (pop3_store, NULL, "UIDL"); - if (status != CAMEL_POP3_OK) - pop3_store->supports_uidl = FALSE; - } - - if (pop3_store->supports_uidl == FALSE) { - int i; - - pop3_folder->uids = g_ptr_array_new (); - g_ptr_array_set_size (pop3_folder->uids, count); - - for (i = 0; i < count; i++) { - pop3_folder->uids->pdata[i] = - g_strdup_printf ("%d", i + 1); - } - - return pop3_folder->uids; - } - - data = camel_pop3_command_get_additional_data (pop3_store, ex); - if (camel_exception_is_set (ex)) - return NULL; - - pop3_folder->uids = parse_listing (count, data); - g_free (data); - - if (!pop3_folder->uids) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "UID listing from server was " - "incomplete."); - } return pop3_folder->uids; } diff --git a/camel/providers/pop3/camel-pop3-folder.h b/camel/providers/pop3/camel-pop3-folder.h index 874c7a3a04..89c16c4c89 100644 --- a/camel/providers/pop3/camel-pop3-folder.h +++ b/camel/providers/pop3/camel-pop3-folder.h @@ -46,6 +46,7 @@ typedef struct { CamelFolder parent_object; GPtrArray *uids; + guint32 *flags; } CamelPop3Folder; diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c index 54417bac64..8c9109db91 100644 --- a/camel/providers/vee/camel-vee-folder.c +++ b/camel/providers/vee/camel-vee-folder.c @@ -45,20 +45,20 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store, CamelException *ex); static void vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); -static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex); -GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex); +static GPtrArray *vee_get_uids (CamelFolder *folder); +GPtrArray *vee_get_summary (CamelFolder *folder); -static gint vee_get_message_count (CamelFolder *folder, CamelException *ex); -static gint vee_get_unread_message_count (CamelFolder *folder, CamelException *ex); +static gint vee_get_message_count (CamelFolder *folder); +static gint vee_get_unread_message_count (CamelFolder *folder); static CamelMimeMessage *vee_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex); static const CamelMessageInfo *vee_get_message_info (CamelFolder *folder, const char *uid); static GPtrArray *vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex); -static guint32 vee_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex); -static void vee_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex); -static gboolean vee_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, CamelException *ex); -static void vee_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value, CamelException *ex); +static guint32 vee_get_message_flags (CamelFolder *folder, const char *uid); +static void vee_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean vee_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name); +static void vee_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value); static void camel_vee_folder_class_init (CamelVeeFolderClass *klass); @@ -278,7 +278,7 @@ vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) ; } -static gint vee_get_message_count (CamelFolder *folder, CamelException *ex) +static gint vee_get_message_count (CamelFolder *folder) { CamelVeeFolder *vf = (CamelVeeFolder *)folder; @@ -286,7 +286,7 @@ static gint vee_get_message_count (CamelFolder *folder, CamelException *ex) } static gint -vee_get_unread_message_count (CamelFolder *folder, CamelException *ex) +vee_get_unread_message_count (CamelFolder *folder) { CamelVeeFolder *vee_folder = CAMEL_VEE_FOLDER (folder); CamelMessageInfo *info; @@ -308,18 +308,12 @@ vee_get_unread_message_count (CamelFolder *folder, CamelException *ex) static gboolean get_real_message (CamelFolder *folder, const char *uid, - CamelFolder **out_folder, const char **out_uid, - CamelException *ex) + CamelFolder **out_folder, const char **out_uid) { CamelVeeMessageInfo *mi; mi = (CamelVeeMessageInfo *)vee_get_message_info(folder, uid); - if (mi == NULL) { - camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "No such message %s in %s", uid, - folder->name); - return FALSE; - } + g_return_val_if_fail (mi != NULL, FALSE); *out_folder = mi->folder; *out_uid = strchr(mi->info.uid, ':')+1; @@ -331,13 +325,17 @@ static CamelMimeMessage *vee_get_message (CamelFolder *folder, const gchar *uid, const char *real_uid; CamelFolder *real_folder; - if (!get_real_message (folder, uid, &real_folder, &real_uid, ex)) + if (!get_real_message (folder, uid, &real_folder, &real_uid)) { + camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, + "No such message %s in %s", uid, + folder->name); return NULL; + } return camel_folder_get_message (real_folder, real_uid, ex); } -GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex) +GPtrArray *vee_get_summary (CamelFolder *folder) { CamelVeeFolder *vf = (CamelVeeFolder *)folder; @@ -351,7 +349,7 @@ static const CamelMessageInfo *vee_get_message_info (CamelFolder *f, const char return g_hash_table_lookup(vf->messages_uid, uid); } -static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex) +static GPtrArray *vee_get_uids (CamelFolder *folder) { GPtrArray *result; int i; @@ -395,55 +393,54 @@ vee_search_by_expression(CamelFolder *folder, const char *expression, CamelExcep } static guint32 -vee_get_message_flags(CamelFolder *folder, const char *uid, CamelException *ex) +vee_get_message_flags(CamelFolder *folder, const char *uid) { const char *real_uid; CamelFolder *real_folder; - if (!get_real_message (folder, uid, &real_folder, &real_uid, ex)) + if (!get_real_message (folder, uid, &real_folder, &real_uid)) return 0; - return camel_folder_get_message_flags(real_folder, real_uid, ex); + return camel_folder_get_message_flags(real_folder, real_uid); } static void vee_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, - guint32 set, CamelException *ex) + guint32 set) { const char *real_uid; CamelFolder *real_folder; - if (!get_real_message (folder, uid, &real_folder, &real_uid, ex)) + if (!get_real_message (folder, uid, &real_folder, &real_uid)) return; - camel_folder_set_message_flags(real_folder, real_uid, flags, set, ex); + camel_folder_set_message_flags(real_folder, real_uid, flags, set); } static gboolean vee_get_message_user_flag(CamelFolder *folder, const char *uid, - const char *name, CamelException *ex) + const char *name) { const char *real_uid; CamelFolder *real_folder; - if (!get_real_message (folder, uid, &real_folder, &real_uid, ex)) + if (!get_real_message (folder, uid, &real_folder, &real_uid)) return FALSE; - return camel_folder_get_message_user_flag(real_folder, real_uid, name, ex); + return camel_folder_get_message_user_flag(real_folder, real_uid, name); } static void vee_set_message_user_flag(CamelFolder *folder, const char *uid, - const char *name, gboolean value, - CamelException *ex) + const char *name, gboolean value) { const char *real_uid; CamelFolder *real_folder; - if (!get_real_message (folder, uid, &real_folder, &real_uid, ex)) + if (!get_real_message (folder, uid, &real_folder, &real_uid)) return; - return camel_folder_set_message_user_flag(real_folder, real_uid, name, value, ex); + return camel_folder_set_message_user_flag(real_folder, real_uid, name, value); } |