diff options
author | Not Zed <NotZed@Ximian.com> | 2004-02-06 14:31:02 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-02-06 14:31:02 +0800 |
commit | 734a27187b7c4495f377c8533f9affdcf860dbbc (patch) | |
tree | d4e7496e6844564a592706e0fd3f74e5d4d0e4c6 | |
parent | 9fe2942fe8ed2a561c9a3098f8a3655ae2691fcd (diff) | |
download | gsoc2013-evolution-734a27187b7c4495f377c8533f9affdcf860dbbc.tar gsoc2013-evolution-734a27187b7c4495f377c8533f9affdcf860dbbc.tar.gz gsoc2013-evolution-734a27187b7c4495f377c8533f9affdcf860dbbc.tar.bz2 gsoc2013-evolution-734a27187b7c4495f377c8533f9affdcf860dbbc.tar.lz gsoc2013-evolution-734a27187b7c4495f377c8533f9affdcf860dbbc.tar.xz gsoc2013-evolution-734a27187b7c4495f377c8533f9affdcf860dbbc.tar.zst gsoc2013-evolution-734a27187b7c4495f377c8533f9affdcf860dbbc.zip |
changed to return a boolean to indicate if the flags were actually changed
2004-02-06 Not Zed <NotZed@Ximian.com>
* camel-folder.c (camel_folder_set_message_flags): changed to
return a boolean to indicate if the flags were actually changed or
not. Fixed all implementors.
svn path=/trunk/; revision=24643
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-folder.c | 40 | ||||
-rw-r--r-- | camel/camel-folder.h | 8 | ||||
-rw-r--r-- | camel/camel-vee-folder.c | 11 | ||||
-rw-r--r-- | camel/providers/local/camel-mbox-folder.c | 6 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-folder.c | 4 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-folder.c | 17 |
7 files changed, 55 insertions, 37 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 9de19c916f..6f6c891c6d 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2004-02-06 Not Zed <NotZed@Ximian.com> + + * camel-folder.c (camel_folder_set_message_flags): changed to + return a boolean to indicate if the flags were actually changed or + not. Fixed all implementors. + 2004-02-05 Not Zed <NotZed@Ximian.com> * providers/local/camel-mbox-store.c (rename_folder): rename diff --git a/camel/camel-folder.c b/camel/camel-folder.c index b3a7b93713..602f8afdd1 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -62,18 +62,16 @@ static const gchar *get_name (CamelFolder *folder); static const gchar *get_full_name (CamelFolder *folder); static CamelStore *get_parent_store (CamelFolder *folder); -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); -static gboolean get_message_user_flag (CamelFolder *folder, const char *uid, const char *name); -static void set_message_user_flag (CamelFolder *folder, const char *uid, - const char *name, gboolean value); +static guint32 get_permanent_flags(CamelFolder *folder); +static guint32 get_message_flags(CamelFolder *folder, const char *uid); +static gboolean set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean get_message_user_flag(CamelFolder *folder, const char *uid, const char *name); +static void set_message_user_flag(CamelFolder *folder, const char *uid, const char *name, gboolean value); static const char *get_message_user_tag(CamelFolder *folder, const char *uid, const char *name); static void set_message_user_tag(CamelFolder *folder, const char *uid, const char *name, const char *value); -static gint get_message_count (CamelFolder *folder); -static gint get_unread_message_count (CamelFolder *folder); +static gint get_message_count(CamelFolder *folder); +static gint get_unread_message_count(CamelFolder *folder); static void expunge (CamelFolder *folder, CamelException *ex); @@ -681,29 +679,31 @@ camel_folder_get_message_flags (CamelFolder *folder, const char *uid) return ret; } -static void +static gboolean set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set) { CamelMessageInfo *info; guint32 new; - g_return_if_fail(folder->summary != NULL); + g_return_val_if_fail(folder->summary != NULL, FALSE); info = camel_folder_summary_uid(folder->summary, uid); if (info == NULL) - return; + return FALSE; new = (info->flags & ~flags) | (set & flags); if (new == info->flags) { camel_folder_summary_info_free(folder->summary, info); - return; + return FALSE; } info->flags = new | CAMEL_MESSAGE_FOLDER_FLAGGED; camel_folder_summary_touch(folder->summary); camel_folder_summary_info_free(folder->summary, info); - camel_object_trigger_event (folder, "message_changed", (char *) uid); + camel_object_trigger_event(folder, "message_changed", (char *) uid); + + return TRUE; } /** @@ -716,17 +716,17 @@ set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 s * Sets those flags specified by @set to the values specified by @flags * on the indicated message. (This may or may not persist after the * folder or store is closed. See camel_folder_get_permanent_flags().) + * + * Return Value: TRUE if the flags were changed, false otherwise. **/ -void -camel_folder_set_message_flags (CamelFolder *folder, const char *uid, - guint32 flags, guint32 set) +gboolean +camel_folder_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set) { - g_return_if_fail (CAMEL_IS_FOLDER (folder)); + g_return_val_if_fail(CAMEL_IS_FOLDER(folder), FALSE); - CF_CLASS (folder)->set_message_flags (folder, uid, flags, set); + return CF_CLASS(folder)->set_message_flags(folder, uid, flags, set); } - static gboolean get_message_user_flag(CamelFolder *folder, const char *uid, const char *name) { diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 15e1aacb8b..74fc5aa205 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -136,9 +136,9 @@ typedef struct { guint32 (*get_permanent_flags) (CamelFolder *folder); guint32 (*get_message_flags) (CamelFolder *folder, const char *uid); - void (*set_message_flags) (CamelFolder *folder, - const char *uid, - guint32 flags, guint32 set); + gboolean (*set_message_flags) (CamelFolder *folder, + const char *uid, + guint32 flags, guint32 set); gboolean (*get_message_user_flag) (CamelFolder *folder, const char *uid, @@ -229,7 +229,7 @@ guint32 camel_folder_get_permanent_flags (CamelFolder *folder); guint32 camel_folder_get_message_flags (CamelFolder *folder, const char *uid); -void camel_folder_set_message_flags (CamelFolder *folder, +gboolean camel_folder_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index b63643e9d0..1c246b3816 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -65,7 +65,7 @@ static void vee_transfer_messages_to(CamelFolder *source, GPtrArray *uids, Camel static GPtrArray *vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex); static GPtrArray *vee_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, CamelException *ex); -static void vee_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean vee_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); static void vee_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value); static void vee_set_message_user_tag(CamelFolder *folder, const char *uid, const char *name, const char *value); static void vee_rename(CamelFolder *folder, const char *new); @@ -767,17 +767,20 @@ vee_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, return result; } -static void +static gboolean vee_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set) { CamelVeeMessageInfo *mi; + int res = FALSE; mi = (CamelVeeMessageInfo *)camel_folder_summary_uid(folder->summary, uid); if (mi) { - camel_folder_set_message_flags(mi->folder, camel_message_info_uid(mi) + 8, flags, set); + res = camel_folder_set_message_flags(mi->folder, camel_message_info_uid(mi) + 8, flags, set); camel_folder_summary_info_free(folder->summary, (CamelMessageInfo *)mi); - ((CamelFolderClass *)camel_vee_folder_parent)->set_message_flags(folder, uid, flags, set); + res = res || ((CamelFolderClass *)camel_vee_folder_parent)->set_message_flags(folder, uid, flags, set); } + + return res; } static void diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c index 9c3a7036f2..f06d4e31f5 100644 --- a/camel/providers/local/camel-mbox-folder.c +++ b/camel/providers/local/camel-mbox-folder.c @@ -59,7 +59,7 @@ static int mbox_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *e static void mbox_unlock(CamelLocalFolder *lf); #ifdef STATUS_PINE -static void mbox_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean mbox_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set); #endif static void mbox_set_message_user_flag(CamelFolder *folder, const char *uid, const char *name, gboolean value); @@ -496,7 +496,7 @@ fail: } #ifdef STATUS_PINE -static void +static gboolean mbox_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set) { /* Basically, if anything could change the Status line, presume it does */ @@ -506,7 +506,7 @@ mbox_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guin set |= CAMEL_MESSAGE_FOLDER_XEVCHANGE|CAMEL_MESSAGE_FOLDER_FLAGGED; } - ((CamelFolderClass *)parent_class)->set_message_flags(folder, uid, flags, set); + return ((CamelFolderClass *)parent_class)->set_message_flags(folder, uid, flags, set); } #endif diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c index c0d7093a1c..6a6851232f 100644 --- a/camel/providers/nntp/camel-nntp-folder.c +++ b/camel/providers/nntp/camel-nntp-folder.c @@ -99,10 +99,10 @@ nntp_folder_sync_offline (CamelFolder *folder, CamelException *ex) camel_folder_summary_save (folder->summary); } -static void +static gboolean nntp_folder_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set) { - ((CamelFolderClass *) folder_class)->set_message_flags (folder, uid, flags, set); + return ((CamelFolderClass *) folder_class)->set_message_flags (folder, uid, flags, set); } static CamelStream * diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c index db77ad8191..edb71802bc 100644 --- a/camel/providers/pop3/camel-pop3-folder.c +++ b/camel/providers/pop3/camel-pop3-folder.c @@ -54,7 +54,7 @@ static void pop3_sync (CamelFolder *folder, gboolean expunge, 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_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean pop3_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); static void camel_pop3_folder_class_init (CamelPOP3FolderClass *camel_pop3_folder_class) @@ -522,15 +522,24 @@ fail: return message; } -static void +static gboolean pop3_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set) { CamelPOP3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); CamelPOP3FolderInfo *fi; + gboolean res = FALSE; fi = g_hash_table_lookup(pop3_folder->uids_uid, uid); - if (fi) - fi->flags = (fi->flags & ~flags) | (set & flags); + if (fi) { + guint32 new = (fi->flags & ~flags) | (set & flags); + + if (fi->flags != new) { + fi->flags = new; + res = TRUE; + } + } + + return res; } static gint |