X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fmessage-property.cc;h=210a15cca81e99d36ae8f5f7635971b3e21083c0;hb=4a6371f1d80aec5947b41d7c4e1fdb60cca3c55d;hp=f32d555062d2bce0decf7cd5f9b33894655e7924;hpb=0aba694c11846f76cfa64470d10a50cec8e43bd5;p=notmuch diff --git a/lib/message-property.cc b/lib/message-property.cc index f32d5550..210a15cc 100644 --- a/lib/message-property.cc +++ b/lib/message-property.cc @@ -16,7 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: David Bremner */ @@ -38,13 +38,13 @@ notmuch_message_get_property (notmuch_message_t *message, const char *key, const static notmuch_status_t _notmuch_message_modify_property (notmuch_message_t *message, const char *key, const char *value, - notmuch_bool_t delete_it) + bool delete_it) { notmuch_private_status_t private_status; notmuch_status_t status; char *term = NULL; - status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); + status = _notmuch_database_ensure_writable (notmuch_message_get_database (message)); if (status) return status; @@ -76,28 +76,30 @@ _notmuch_message_modify_property (notmuch_message_t *message, const char *key, c notmuch_status_t notmuch_message_add_property (notmuch_message_t *message, const char *key, const char *value) { - return _notmuch_message_modify_property (message, key, value, FALSE); + return _notmuch_message_modify_property (message, key, value, false); } notmuch_status_t notmuch_message_remove_property (notmuch_message_t *message, const char *key, const char *value) { - return _notmuch_message_modify_property (message, key, value, TRUE); + return _notmuch_message_modify_property (message, key, value, true); } +static notmuch_status_t -notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key) +_notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key, bool prefix) { notmuch_status_t status; const char * term_prefix; - status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); + status = _notmuch_database_ensure_writable (notmuch_message_get_database (message)); if (status) return status; _notmuch_message_invalidate_metadata (message, "property"); if (key) - term_prefix = talloc_asprintf (message, "%s%s=", _find_prefix ("property"), key); + term_prefix = talloc_asprintf (message, "%s%s%s", _find_prefix ("property"), key, + prefix ? "" : "="); else term_prefix = _find_prefix ("property"); @@ -107,6 +109,18 @@ notmuch_message_remove_all_properties (notmuch_message_t *message, const char *k return NOTMUCH_STATUS_SUCCESS; } +notmuch_status_t +notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key) +{ + return _notmuch_message_remove_all_properties (message, key, false); +} + +notmuch_status_t +notmuch_message_remove_all_properties_with_prefix (notmuch_message_t *message, const char *prefix) +{ + return _notmuch_message_remove_all_properties (message, prefix, true); +} + notmuch_message_properties_t * notmuch_message_get_properties (notmuch_message_t *message, const char *key, notmuch_bool_t exact) {