[PATCH 3/4] Make maildir synchronization configurable
This adds group [maildir] and key 'sync_level' to the configuration file. The value of sync_level is used to control how the synchronization happens. The default value is no synchronization. --- lib/database-private.h |2 +- lib/database.cc|9 + lib/message.cc |2 +- lib/notmuch.h | 19 +++ notmuch-client.h |7 +++ notmuch-config.c | 48 notmuch-new.c |8 ++-- notmuch-restore.c |2 ++ notmuch-setup.c| 17 + notmuch-tag.c |2 ++ 10 files changed, 112 insertions(+), 4 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index bd72f67..3c80f99 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -49,7 +49,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; - +enum notmuch_maildir_sync maildir_sync; }; /* Convert tags from Xapian internal format to notmuch format. diff --git a/lib/database.cc b/lib/database.cc index 9652013..d6b6f47 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -689,6 +689,8 @@ notmuch_database_open (const char *path, notmuch = NULL; } +notmuch_database_set_maildir_sync (notmuch, NOTMUCH_MAILDIR_SYNC_NONE); + DONE: if (notmuch_path) free (notmuch_path); @@ -718,6 +720,13 @@ notmuch_database_close (notmuch_database_t *notmuch) talloc_free (notmuch); } +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync) +{ +database->maildir_sync = maildir_sync; +} + const char * notmuch_database_get_path (notmuch_database_t *notmuch) { diff --git a/lib/message.cc b/lib/message.cc index 96c402c..1b945c6 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -626,7 +626,7 @@ _notmuch_message_sync (notmuch_message_t *message) if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; -if (// todo_sync_enabled && +if (message->notmuch->maildir_sync == NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED && !notmuch_message_get_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID)) { status = _notmuch_message_tags_to_maildir (message); if (status != NOTMUCH_PRIVATE_STATUS_SUCCESS) { diff --git a/lib/notmuch.h b/lib/notmuch.h index 408d633..34b3bcf 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -108,6 +108,19 @@ typedef enum _notmuch_status { const char * notmuch_status_to_string (notmuch_status_t status); +/* Level of synchronization between notmuch tags and maildir flags. */ +enum notmuch_maildir_sync { +NOTMUCH_MAILDIR_SYNC_INVALID = 0, +/* No synchronization */ +NOTMUCH_MAILDIR_SYNC_NONE, +/* Tag new messages accoring to maildir flags */ +NOTMUCH_MAILDIR_SYNC_NEW, +/* The above + update tags for renamed messages */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED, +/* The above + update flags when tags are added/removed. */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED, +}; + /* Various opaque data types. For each notmuch__t see the various * notmuch_ functions below. */ typedef struct _notmuch_database notmuch_database_t; @@ -176,6 +189,12 @@ notmuch_database_open (const char *path, void notmuch_database_close (notmuch_database_t *database); +/* Sets the level of synchronization between maildir flags and notmuch + * tags. */ +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync); + /* Return the database path of the given database. * * The return value is a string owned by notmuch so should not be diff --git a/notmuch-client.h b/notmuch-client.h index 20be43b..50be95c 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -191,6 +191,13 @@ notmuch_config_set_new_tags (notmuch_config_t *config, const char *new_tags[], size_t length); +enum notmuch_maildir_sync +notmuch_config_get_maildir_sync (notmuch_config_t *config); + +void +notmuch_config_set_maildir_sync (notmuch_config_t *config, +enum notmuch_maildir_sync maildir_sync); + notmuch_bool_t debugger_is_active (void); diff --git a/notmuch-config.c b/notmuch-config.c index cf30603..60d5730 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -61,6 +61,21 @@ static const char user_config_comment[] = " recipient list of replies, and will set the From address based on the\n" " address to which the original email was addressed.\n"; +static const char maildir_config_comment[] = +" Maildir compatibility configuration\n" +"\n" +" Here you can configure whether and how will notmuch synchronize its\n" +" tags with maildir flags." +"\n" +"\tsync_level Integer in the
[PATCH 3/4] Make maildir synchronization configurable
This adds group [maildir] and key 'sync_level' to the configuration file. The value of sync_level is used to control how the synchronization happens. The default value is no synchronization. --- lib/database-private.h |2 +- lib/database.cc|9 + lib/message.cc |2 +- lib/notmuch.h | 19 +++ notmuch-client.h |7 +++ notmuch-config.c | 48 notmuch-new.c |8 ++-- notmuch-restore.c |2 ++ notmuch-setup.c| 17 + notmuch-tag.c |2 ++ 10 files changed, 112 insertions(+), 4 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index bd72f67..3c80f99 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -49,7 +49,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; - +enum notmuch_maildir_sync maildir_sync; }; /* Convert tags from Xapian internal format to notmuch format. diff --git a/lib/database.cc b/lib/database.cc index 9652013..d6b6f47 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -689,6 +689,8 @@ notmuch_database_open (const char *path, notmuch = NULL; } +notmuch_database_set_maildir_sync (notmuch, NOTMUCH_MAILDIR_SYNC_NONE); + DONE: if (notmuch_path) free (notmuch_path); @@ -718,6 +720,13 @@ notmuch_database_close (notmuch_database_t *notmuch) talloc_free (notmuch); } +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync) +{ +database-maildir_sync = maildir_sync; +} + const char * notmuch_database_get_path (notmuch_database_t *notmuch) { diff --git a/lib/message.cc b/lib/message.cc index 96c402c..1b945c6 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -626,7 +626,7 @@ _notmuch_message_sync (notmuch_message_t *message) if (message-notmuch-mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; -if (// todo_sync_enabled +if (message-notmuch-maildir_sync == NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED !notmuch_message_get_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID)) { status = _notmuch_message_tags_to_maildir (message); if (status != NOTMUCH_PRIVATE_STATUS_SUCCESS) { diff --git a/lib/notmuch.h b/lib/notmuch.h index 408d633..34b3bcf 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -108,6 +108,19 @@ typedef enum _notmuch_status { const char * notmuch_status_to_string (notmuch_status_t status); +/* Level of synchronization between notmuch tags and maildir flags. */ +enum notmuch_maildir_sync { +NOTMUCH_MAILDIR_SYNC_INVALID = 0, +/* No synchronization */ +NOTMUCH_MAILDIR_SYNC_NONE, +/* Tag new messages accoring to maildir flags */ +NOTMUCH_MAILDIR_SYNC_NEW, +/* The above + update tags for renamed messages */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED, +/* The above + update flags when tags are added/removed. */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED, +}; + /* Various opaque data types. For each notmuch_foo_t see the various * notmuch_foo functions below. */ typedef struct _notmuch_database notmuch_database_t; @@ -176,6 +189,12 @@ notmuch_database_open (const char *path, void notmuch_database_close (notmuch_database_t *database); +/* Sets the level of synchronization between maildir flags and notmuch + * tags. */ +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync); + /* Return the database path of the given database. * * The return value is a string owned by notmuch so should not be diff --git a/notmuch-client.h b/notmuch-client.h index 20be43b..50be95c 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -191,6 +191,13 @@ notmuch_config_set_new_tags (notmuch_config_t *config, const char *new_tags[], size_t length); +enum notmuch_maildir_sync +notmuch_config_get_maildir_sync (notmuch_config_t *config); + +void +notmuch_config_set_maildir_sync (notmuch_config_t *config, +enum notmuch_maildir_sync maildir_sync); + notmuch_bool_t debugger_is_active (void); diff --git a/notmuch-config.c b/notmuch-config.c index cf30603..60d5730 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -61,6 +61,21 @@ static const char user_config_comment[] = recipient list of replies, and will set the From address based on the\n address to which the original email was addressed.\n; +static const char maildir_config_comment[] = + Maildir compatibility configuration\n +\n + Here you can configure whether and how will notmuch synchronize its\n + tags with maildir flags. +\n +\tsync_level Integer in the range 1 - 4
[PATCH 3/4] Make maildir synchronization configurable
This adds group [maildir] and key 'sync_level' to the configuration file. The value of sync_level is used to control how the synchronization happens. The default value is no synchronization. --- lib/database-private.h |2 +- lib/database.cc|9 + lib/message.cc |2 +- lib/notmuch.h | 19 +++ notmuch-client.h |7 +++ notmuch-config.c | 48 notmuch-new.c |8 ++-- notmuch-restore.c |2 ++ notmuch-setup.c| 17 + notmuch-tag.c |2 ++ 10 files changed, 112 insertions(+), 4 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 41918d7..370d779 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -48,7 +48,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; - +enum notmuch_maildir_sync maildir_sync; }; /* Convert tags from Xapian internal format to notmuch format. diff --git a/lib/database.cc b/lib/database.cc index 908bbaa..bf645d0 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -662,6 +662,8 @@ notmuch_database_open (const char *path, notmuch = NULL; } +notmuch_database_set_maildir_sync (notmuch, NOTMUCH_MAILDIR_SYNC_NONE); + DONE: if (notmuch_path) free (notmuch_path); @@ -691,6 +693,13 @@ notmuch_database_close (notmuch_database_t *notmuch) talloc_free (notmuch); } +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync) +{ +database->maildir_sync = maildir_sync; +} + const char * notmuch_database_get_path (notmuch_database_t *notmuch) { diff --git a/lib/message.cc b/lib/message.cc index 0de3f01..758e6fa 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -599,7 +599,7 @@ _notmuch_message_sync (notmuch_message_t *message) if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; -if (// todo_sync_enabled && +if (message->notmuch->maildir_sync == NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED && !notmuch_message_get_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID)) { status = _notmuch_message_tags_to_maildir (message); if (status != NOTMUCH_PRIVATE_STATUS_SUCCESS) { diff --git a/lib/notmuch.h b/lib/notmuch.h index 408d633..34b3bcf 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -108,6 +108,19 @@ typedef enum _notmuch_status { const char * notmuch_status_to_string (notmuch_status_t status); +/* Level of synchronization between notmuch tags and maildir flags. */ +enum notmuch_maildir_sync { +NOTMUCH_MAILDIR_SYNC_INVALID = 0, +/* No synchronization */ +NOTMUCH_MAILDIR_SYNC_NONE, +/* Tag new messages accoring to maildir flags */ +NOTMUCH_MAILDIR_SYNC_NEW, +/* The above + update tags for renamed messages */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED, +/* The above + update flags when tags are added/removed. */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED, +}; + /* Various opaque data types. For each notmuch__t see the various * notmuch_ functions below. */ typedef struct _notmuch_database notmuch_database_t; @@ -176,6 +189,12 @@ notmuch_database_open (const char *path, void notmuch_database_close (notmuch_database_t *database); +/* Sets the level of synchronization between maildir flags and notmuch + * tags. */ +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync); + /* Return the database path of the given database. * * The return value is a string owned by notmuch so should not be diff --git a/notmuch-client.h b/notmuch-client.h index 20be43b..50be95c 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -191,6 +191,13 @@ notmuch_config_set_new_tags (notmuch_config_t *config, const char *new_tags[], size_t length); +enum notmuch_maildir_sync +notmuch_config_get_maildir_sync (notmuch_config_t *config); + +void +notmuch_config_set_maildir_sync (notmuch_config_t *config, +enum notmuch_maildir_sync maildir_sync); + notmuch_bool_t debugger_is_active (void); diff --git a/notmuch-config.c b/notmuch-config.c index 58f83b0..5ac5f7b 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -61,6 +61,21 @@ static const char user_config_comment[] = " recipient list of replies, and will set the From address based on the\n" " address to which the original email was addressed.\n"; +static const char maildir_config_comment[] = +" Maildir compatibility configuration\n" +"\n" +" Here you can configure whether and how will notmuch synchronize its\n" +" tags with maildir flags." +"\n" +"\tsync_level Integer in the
[PATCH 3/4] Make maildir synchronization configurable
This adds group [maildir] and key 'sync_level' to the configuration file. The value of sync_level is used to control how the synchronization happens. The default value is no synchronization. --- lib/database-private.h |2 +- lib/database.cc|9 + lib/message.cc |2 +- lib/notmuch.h | 19 +++ notmuch-client.h |7 +++ notmuch-config.c | 48 notmuch-new.c |8 ++-- notmuch-restore.c |2 ++ notmuch-setup.c| 17 + notmuch-tag.c |2 ++ 10 files changed, 112 insertions(+), 4 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 41918d7..370d779 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -48,7 +48,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; - +enum notmuch_maildir_sync maildir_sync; }; /* Convert tags from Xapian internal format to notmuch format. diff --git a/lib/database.cc b/lib/database.cc index 908bbaa..bf645d0 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -662,6 +662,8 @@ notmuch_database_open (const char *path, notmuch = NULL; } +notmuch_database_set_maildir_sync (notmuch, NOTMUCH_MAILDIR_SYNC_NONE); + DONE: if (notmuch_path) free (notmuch_path); @@ -691,6 +693,13 @@ notmuch_database_close (notmuch_database_t *notmuch) talloc_free (notmuch); } +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync) +{ +database-maildir_sync = maildir_sync; +} + const char * notmuch_database_get_path (notmuch_database_t *notmuch) { diff --git a/lib/message.cc b/lib/message.cc index 0de3f01..758e6fa 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -599,7 +599,7 @@ _notmuch_message_sync (notmuch_message_t *message) if (message-notmuch-mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; -if (// todo_sync_enabled +if (message-notmuch-maildir_sync == NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED !notmuch_message_get_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID)) { status = _notmuch_message_tags_to_maildir (message); if (status != NOTMUCH_PRIVATE_STATUS_SUCCESS) { diff --git a/lib/notmuch.h b/lib/notmuch.h index 408d633..34b3bcf 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -108,6 +108,19 @@ typedef enum _notmuch_status { const char * notmuch_status_to_string (notmuch_status_t status); +/* Level of synchronization between notmuch tags and maildir flags. */ +enum notmuch_maildir_sync { +NOTMUCH_MAILDIR_SYNC_INVALID = 0, +/* No synchronization */ +NOTMUCH_MAILDIR_SYNC_NONE, +/* Tag new messages accoring to maildir flags */ +NOTMUCH_MAILDIR_SYNC_NEW, +/* The above + update tags for renamed messages */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED, +/* The above + update flags when tags are added/removed. */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED, +}; + /* Various opaque data types. For each notmuch_foo_t see the various * notmuch_foo functions below. */ typedef struct _notmuch_database notmuch_database_t; @@ -176,6 +189,12 @@ notmuch_database_open (const char *path, void notmuch_database_close (notmuch_database_t *database); +/* Sets the level of synchronization between maildir flags and notmuch + * tags. */ +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync); + /* Return the database path of the given database. * * The return value is a string owned by notmuch so should not be diff --git a/notmuch-client.h b/notmuch-client.h index 20be43b..50be95c 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -191,6 +191,13 @@ notmuch_config_set_new_tags (notmuch_config_t *config, const char *new_tags[], size_t length); +enum notmuch_maildir_sync +notmuch_config_get_maildir_sync (notmuch_config_t *config); + +void +notmuch_config_set_maildir_sync (notmuch_config_t *config, +enum notmuch_maildir_sync maildir_sync); + notmuch_bool_t debugger_is_active (void); diff --git a/notmuch-config.c b/notmuch-config.c index 58f83b0..5ac5f7b 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -61,6 +61,21 @@ static const char user_config_comment[] = recipient list of replies, and will set the From address based on the\n address to which the original email was addressed.\n; +static const char maildir_config_comment[] = + Maildir compatibility configuration\n +\n + Here you can configure whether and how will notmuch synchronize its\n + tags with maildir flags. +\n +\tsync_level Integer in the range 1 - 4