diff options
author | Dan Winship <danw@src.gnome.org> | 2000-06-17 07:09:43 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-06-17 07:09:43 +0800 |
commit | 174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f (patch) | |
tree | edcbfcf1e6244d1f30e28e7dca2c14c7715ace38 /camel/camel-folder.c | |
parent | f0600c2ccbfbd5378cdf980e2d53210c0101639d (diff) | |
download | gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar.gz gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar.zst gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.zip |
Move flag handling from CamelMimeMessage to CamelFolder. This
simplifies several flag-handling pieces of code in the mailer, and
lets you change a message's flags without having to fetch the
message body. It also means that fully-constructed
CamelMimeMessages are now essentially constant, which will help
simplify locking issues later since it means two threads
interested in the same message can just work with separate copies
of it.
* camel-mime-message.h (struct _CamelMimeMessage): Removed flags
and user_flags (moved to summary). Removed expunged and
message_number which were unused. Removed message_uid and folder
which are no longer needed in the new scheme.
(struct CamelMimeMessageClass): Removed message_changed signal and
get/set_message_number methods.
* camel-mime-message.c: Updates for CamelMimeMessage changes.
(camel_mime_message_get/set_flags,
camel_mime_message_get/set_user_flag): Replaced with methods in
CamelFolder.
(camel_flag_get, camel_flag_set, camel_flag_list_size,
camel_flag_list_free): Moved verbatim to camel-folder-summary.c
* camel-folder.c (camel_folder_get/set_message_flags,
camel_folder_get/set_message_user_flag): New methods (and
corresponding useless default implementations)
(camel_folder_class_init): add a message_changed signal
* camel-folder-summary.c (camel_flag_get, camel_flag_set,
camel_flag_list_size, camel_flag_list_free): Moved here from
camel-mime-message.c
* providers/mbox/camel-mbox-folder.c (message_changed): Removed.
(mbox_get_message_flags, mbox_set_message_flags,
mbox_get_message_user_flag, mbox_set_message_user_flag): Tweak
summary bits as appropriate. (Functionality moved here from
message_changed.)
(mbox_get_message_by_uid): Update for CamelMimeMessage changes
(less stuff to initialize).
* providers/imap/camel-imap-folder.c (message_changed): Remove
this. It was just copied from the mbox provider and doesn't deal
with the real IMAP flag stuff anyway. (So there's currently no
flag support in the IMAP provider.)
(imap_get_message_by_uid): Update for CamelMimeMessage changes.
* providers/vee/camel-vee-folder.c: (message_changed): Remove old
one. Add a new one to listen for message_changed on each folder
and re-emit message_changed signals that correspond to messages in
the vfolder.
(vee_get/set_message_flags, vee_get/set_message_user_flag): Proxy
flag setting to the underlying real messages.
(vee_append_message): Removed for now; there's no way to translate
this into the new CamelMimeMessage/CamelFolder scheme, but (a)
there's also no code which would ever call it and (b) we're
probably going want a better interface than append_message for
message drag and drop to work anyway. To be revisited.
svn path=/trunk/; revision=3598
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r-- | camel/camel-folder.c | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c index a5ccc24070..f3cea51af2 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -39,6 +39,7 @@ static CamelObjectClass *parent_class = NULL; enum SIGNALS { FOLDER_CHANGED, + MESSAGE_CHANGED, LAST_SIGNAL }; @@ -63,6 +64,15 @@ 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 void set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set, CamelException *ex); +static gboolean get_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, CamelException *ex); +static void set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value, + CamelException *ex); static GPtrArray *get_subfolder_names (CamelFolder *folder, @@ -136,6 +146,10 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) camel_folder_class->get_message_count = get_message_count; camel_folder_class->append_message = append_message; camel_folder_class->get_permanent_flags = get_permanent_flags; + camel_folder_class->get_message_flags = get_message_flags; + camel_folder_class->set_message_flags = set_message_flags; + 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_uid = get_message_uid; camel_folder_class->get_message_by_uid = get_message_by_uid; camel_folder_class->delete_message_by_uid = delete_message_by_uid; @@ -158,6 +172,15 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + signals[MESSAGE_CHANGED] = + gtk_signal_new ("message_changed", + GTK_RUN_LAST, + gtk_object_class->type, + GTK_SIGNAL_OFFSET (CamelFolderClass, + message_changed), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + gtk_object_class_add_signals (gtk_object_class, signals, LAST_SIGNAL); } @@ -571,6 +594,15 @@ get_permanent_flags (CamelFolder *folder, CamelException *ex) return folder->permanent_flags; } +/** + * 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) { @@ -580,6 +612,125 @@ camel_folder_get_permanent_flags (CamelFolder *folder, CamelException *ex) } +static guint32 +get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex) +{ + g_warning ("CamelFolder::get_message_flags not implemented for `%s'", + gtk_type_name (GTK_OBJECT_TYPE (folder))); + return 0; +} + +/** + * 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) +{ + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); + + return CF_CLASS (folder)->get_message_flags (folder, uid, ex); +} + + +static void +set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set, CamelException *ex) +{ + g_warning ("CamelFolder::set_message_flags not implemented for `%s'", + gtk_type_name (GTK_OBJECT_TYPE (folder))); +} + +/** + * camel_folder_set_message_flags: + * @folder: a CamelFolder + * @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 + * folder or store is closed. See camel_folder_get_permanent_flags().) + **/ +void +camel_folder_set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set, + CamelException *ex) +{ + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + + CF_CLASS (folder)->set_message_flags (folder, uid, flags, set, ex); +} + + +static gboolean +get_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, CamelException *ex) +{ + g_warning ("CamelFolder::get_message_user_flag not implemented " + "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); + return FALSE; +} + +/** + * camel_folder_get_message_user_flag: + * @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) +{ + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); + + return CF_CLASS (folder)->get_message_user_flag (folder, uid, + name, ex); +} + + +static void +set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value, CamelException *ex) +{ + g_warning ("CamelFolder::set_message_user_flag not implemented " + "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder))); +} + +/** + * camel_folder_set_message_user_flag: + * @folder: a CamelFolder + * @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 + * folder or store is closed. See camel_folder_get_permanent_flags().) + **/ +void +camel_folder_set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value, + CamelException *ex) +{ + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + + CF_CLASS (folder)->set_message_user_flag (folder, uid, name, + value, ex); +} + + static const CamelMessageInfo * summary_get_by_uid (CamelFolder *folder, const char *uid) { |