diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-11-20 16:30:31 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-11-20 16:52:03 +0200 |
commit | c08b926f664b27953483a0dffcbe381ddaa154e5 (patch) | |
tree | e4172eba5a8d5a7e43b771b8342b3550334380e3 /mh/mh.h | |
parent | 77d2867d07ba9d1c5b8b0af1ba8b0543cf57f384 (diff) | |
download | mailutils-c08b926f664b27953483a0dffcbe381ddaa154e5.tar.gz mailutils-c08b926f664b27953483a0dffcbe381ddaa154e5.tar.bz2 |
Re-implement MH sequences via mailbox properties.
* libmailutils/mailbox/header.c (mu_header_clear): New function.
(mu_header_sget_value_n): Tolerate pval == NULL.
* libmailutils/property/assocprop.c (_assoc_prop_setval): Bugfix.
(_assoc_prop_clear): New method.
(mu_assoc_property_init): Reference the stream.
(mu_assoc_property_init): Initialize _prop_clear.
* libmailutils/property/create.c (_mu_property_init): Now extern.
* libmailutils/property/propset.c (mu_property_set_value): Null value
means unset.
* libmailutils/tests/prop.at: Test property clear and invalidate.
* libmailutils/tests/prop.c: New commands: 0 for property clear and ! for
invalidate.
* libmailutils/property/mhprop.c: New file.
* libmailutils/property/propclr.c: New file.
* libmailutils/property/propinv.c: New file.
* libmailutils/property/Makefile.am (noinst_LTLIBRARIES): Add new files.
* include/mailutils/header.h (mu_header_clear): New proto.
* include/mailutils/property.h (mu_property_clear)
(mu_property_invalidate): New protos.
(mu_mh_prop): New struct.
(mu_mh_property_init): New proto.
* include/mailutils/sys/property.h (_mu_property) <_prop_clear>: New member.
(_mu_property_init): New proto.
* include/mailutils/mh.h: New file.
* include/mailutils/Makefile.am (pkginclude_HEADERS): Add mh.h
* libproto/mh/profile.c: New file.
* libproto/mh/Makefile.am (libmu_mh_la_SOURCES): Add new files.
* libproto/mh/mbox.c (mh_get_property): New static function.
(_mailbox_mh_init): Set _get_property.
* mh/mh_global.c (current_message, sequences): Remove. Use mbox
properties instead.
(mh_global_sequences_get)
(mh_global_sequences_set)
(mh_global_sequences_iterate)
(mh_global_sequences_drop): Take mbox as first argument. All callers
updated.
* mh/mh_init.c (mh_init2): Remove call to mh_global_sequences_get.
* mh/mh_msgset.c (msgset_cur): Use mh_mailbox_get_cur.
* mh/mh_sequence.c (mh_seq_read, write_sequence)
(delete_sequence, mh_seq_add, mh_seq_delete): Take mbox as first argument.
All callers updated.
* mh/mh.h: Include mailutils/property.h.
(current_message): Remove.
(mh_mailbox_cur_default): New extern.
(mh_global_sequences_get)
(mh_global_sequences_set)
(mh_global_sequences_iterate)
(mh_global_sequences_drop): Take mbox as first argument. All callers
updated.
* mh/mh_format.c (builtin_cur): Rewrite using mh_message_number.
* mh/mboxprop.c: New file.
* mh/Makefile.am (libmh_a_SOURCES): Add new file.
* mh/folder.c: Update calls to sequence management functions.
* mh/mark.c: Likewise.
* mh/pick.c: Likewise.
* mh/inc.c (main): Set mh_mailbox_cur_default to 1.
Invalidate properties if changecur is not set.
* mh/prompter.c (main): Destroy the iterator.
* mh/rmf.c: Rewrite using mu_mailbox_remove.
* mh/scan.c: Always close the mailbox.
* mh/tests/folder.at: Update.
* mh/tests/inc.at: Update. Inc now sets cur to 1 if it was not
originally set. This is what others MHs do.
Diffstat (limited to 'mh/mh.h')
-rw-r--r-- | mh/mh.h | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -55,6 +55,7 @@ #include <mailutils/envelope.h> #include <mailutils/mime.h> #include <mailutils/io.h> +#include <mailutils/property.h> #include <mu_umaxtostr.h> @@ -233,9 +234,9 @@ typedef int (*mh_context_iterator) (const char *field, const char *value, #define SEQ_PRIVATE 1 #define SEQ_ZERO 2 -extern size_t current_message; extern char mh_list_format[]; extern int rcpt_mask; +extern int mh_mailbox_cur_default; void mh_init (void); void mh_init2 (void); @@ -251,13 +252,19 @@ const char *mh_global_context_get (const char *name, const char *defval); int mh_global_context_set (const char *name, const char *value); const char *mh_set_current_folder (const char *val); const char *mh_current_folder (void); -const char *mh_global_sequences_get (const char *name, const char *defval); -int mh_global_sequences_set (const char *name, const char *value); + +mu_property_t mh_mailbox_get_property (mu_mailbox_t mbox); +const char *mh_global_sequences_get (mu_mailbox_t mbox, + const char *name, const char *defval); +void mh_global_sequences_set (mu_mailbox_t mbox, + const char *name, const char *value); +void mh_global_sequences_iterate (mu_mailbox_t mbox, + mh_context_iterator fp, void *data); +void mh_global_sequences_drop (mu_mailbox_t mbox); + void mh_global_save_state (void); int mh_global_profile_iterate (mh_context_iterator fp, void *data); int mh_global_context_iterate (mh_context_iterator fp, void *data); -int mh_global_sequences_iterate (mh_context_iterator fp, void *data); -void mh_global_sequences_drop (void); int mh_interactive_mode_p (void); int mh_getyn (const char *fmt, ...) MU_PRINTFLIKE(1,2); @@ -300,7 +307,7 @@ int mh_msgset_parse (mu_mailbox_t mbox, mh_msgset_t *msgset, int mh_msgset_member (mh_msgset_t *msgset, size_t num); void mh_msgset_reverse (mh_msgset_t *msgset); void mh_msgset_negate (mu_mailbox_t mbox, mh_msgset_t *msgset); -int mh_msgset_current (mu_mailbox_t mbox, mh_msgset_t *msgset, int index); +void mh_msgset_current (mu_mailbox_t mbox, mh_msgset_t *msgset, int index); void mh_msgset_free (mh_msgset_t *msgset); void mh_msgset_uids (mu_mailbox_t mbox, mh_msgset_t *msgset); @@ -358,9 +365,11 @@ int mhl_format_run (mu_list_t fmt, int width, int length, int flags, mu_message_t msg, mu_stream_t output); void mhl_format_destroy (mu_list_t *fmt); -void mh_seq_add (const char *name, mh_msgset_t *mset, int flags); -int mh_seq_delete (const char *name, mh_msgset_t *mset, int flags); -const char *mh_seq_read (const char *name, int flags); +void mh_seq_add (mu_mailbox_t mbox, const char *name, mh_msgset_t *mset, + int flags); +int mh_seq_delete (mu_mailbox_t mbox, const char *name, mh_msgset_t *mset, + int flags); +const char *mh_seq_read (mu_mailbox_t mbox, const char *name, int flags); void mh_comp_draft (const char *formfile, const char *defformfile, const char *draftfile); @@ -371,3 +380,6 @@ void ali_verbatim (int enable); char *mh_safe_make_file_name (const char *dir, const char *file); +void mh_mailbox_get_cur (mu_mailbox_t mbox, size_t *pcur); +void mh_mailbox_set_cur (mu_mailbox_t mbox, size_t cur); + |