bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen struct mailbox_transaction_context *parent_mailbox_txn;
bd63b5b860658b01b1f46f26d406e1e4a9dc019aTimo Sirainenconst char *notify_plugin_version = DOVECOT_ABI_VERSION;
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainennotify_context_find_mail_txn(struct notify_context *ctx,
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen struct notify_mail_txn *mail_txn = ctx->mail_txn_list;
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (; mail_txn != NULL; mail_txn = mail_txn->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_transaction_begin(struct mailbox_transaction_context *t)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen mail_txn->txn = ctx->v.mail_transaction_begin == NULL ? NULL :
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen DLLIST_PREPEND(&ctx->mail_txn_list, mail_txn);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_save(struct mail *mail)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen mail_txn = notify_context_find_mail_txn(ctx, mail->transaction);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_copy(struct mail *src, struct mail *dst)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen mail_txn = notify_context_find_mail_txn(ctx, dst->transaction);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_expunge(struct mail *mail)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen mail_txn = notify_context_find_mail_txn(ctx, mail->transaction);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_update_flags(struct mail *mail,
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen mail_txn = notify_context_find_mail_txn(ctx, mail->transaction);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen ctx->v.mail_update_flags(mail_txn->txn, mail, old_flags);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_update_keywords(struct mail *mail,
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen const char *const *old_keywords)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen mail_txn = notify_context_find_mail_txn(ctx, mail->transaction);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen ctx->v.mail_update_keywords(mail_txn->txn, mail, old_keywords);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_transaction_commit(struct mailbox_transaction_context *t,
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen struct mail_transaction_commit_changes *changes)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen mail_txn = notify_context_find_mail_txn(ctx, t);
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen ctx->v.mail_transaction_commit(mail_txn->txn, changes);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mail_transaction_rollback(struct mailbox_transaction_context *t)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen mail_txn = notify_context_find_mail_txn(ctx, t);
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen ctx->v.mail_transaction_rollback(mail_txn->txn);
132bfe8fcb7a1be790dc8b5bf9d155c9f060808dTimo Sirainenvoid notify_contexts_mailbox_create(struct mailbox *box)
132bfe8fcb7a1be790dc8b5bf9d155c9f060808dTimo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
95c4f06cba717df14358ec883b1bd1aec6cbf0a1Timo Sirainenvoid notify_contexts_mailbox_update(struct mailbox *box)
95c4f06cba717df14358ec883b1bd1aec6cbf0a1Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
61b0637759146621cbb7edcbd0b03a71cfd66dfeTimo Sirainenvoid notify_contexts_mailbox_delete_begin(struct mailbox *box)
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
61b0637759146621cbb7edcbd0b03a71cfd66dfeTimo Sirainenvoid notify_contexts_mailbox_delete_commit(struct mailbox *box)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen ctx->v.mailbox_delete_commit(ctx->mailbox_delete_txn,
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_contexts_mailbox_delete_rollback(void)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen ctx->v.mailbox_delete_rollback(ctx->mailbox_delete_txn);
71e88fae3be360e9a93b3398e743f99a6f05d2edTimo Sirainenvoid notify_contexts_mailbox_rename(struct mailbox *src, struct mailbox *dest)
87346782e83fdb1f316d6cf1d8fa51466c3f0e3aTimo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
95c4f06cba717df14358ec883b1bd1aec6cbf0a1Timo Sirainenvoid notify_contexts_mailbox_set_subscribed(struct mailbox *box,
95c4f06cba717df14358ec883b1bd1aec6cbf0a1Timo Sirainen for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
95c4f06cba717df14358ec883b1bd1aec6cbf0a1Timo Sirainen ctx->v.mailbox_set_subscribed(box, subscribed);
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainenvoid notify_unregister(struct notify_context *ctx)
56c35c844320b0a157d1aaa6b3e62b7f3851b235Timo Sirainen struct notify_mail_txn *mail_txn = ctx->mail_txn_list;
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen for (; mail_txn != NULL; mail_txn = mail_txn->next) {
2f779122ee7263be9c8fc7ffd6fa7405e888d755Timo Sirainen ctx->v.mail_transaction_rollback(mail_txn->txn);