dovecot-2.1: notify plugin: Added mailbox_update and mailbox_set...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Jan 20 21:11:15 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/eaf3152a33d6
changeset: 13973:eaf3152a33d6
user: Timo Sirainen <tss at iki.fi>
date: Fri Jan 20 21:11:09 2012 +0200
description:
notify plugin: Added mailbox_update and mailbox_set_subscribed notifications.
diffstat:
src/plugins/notify/notify-plugin-private.h | 3 +++
src/plugins/notify/notify-plugin.c | 21 +++++++++++++++++++++
src/plugins/notify/notify-plugin.h | 3 ++-
src/plugins/notify/notify-storage.c | 26 ++++++++++++++++++++++++++
4 files changed, 52 insertions(+), 1 deletions(-)
diffs (128 lines):
diff -r e1f21a4ef417 -r eaf3152a33d6 src/plugins/notify/notify-plugin-private.h
--- a/src/plugins/notify/notify-plugin-private.h Fri Jan 20 18:59:16 2012 +0200
+++ b/src/plugins/notify/notify-plugin-private.h Fri Jan 20 21:11:09 2012 +0200
@@ -15,11 +15,14 @@
struct mail_transaction_commit_changes *changes);
void notify_contexts_mail_transaction_rollback(struct mailbox_transaction_context *t);
void notify_contexts_mailbox_create(struct mailbox *box);
+void notify_contexts_mailbox_update(struct mailbox *box);
void notify_contexts_mailbox_delete_begin(struct mailbox *box);
void notify_contexts_mailbox_delete_commit(struct mailbox *box);
void notify_contexts_mailbox_delete_rollback(void);
void notify_contexts_mailbox_rename(struct mailbox *src, struct mailbox *dest,
bool rename_children);
+void notify_contexts_mailbox_set_subscribed(struct mailbox *box,
+ bool subscribed);
void notify_plugin_init_storage(struct module *module);
void notify_plugin_deinit_storage(void);
diff -r e1f21a4ef417 -r eaf3152a33d6 src/plugins/notify/notify-plugin.c
--- a/src/plugins/notify/notify-plugin.c Fri Jan 20 18:59:16 2012 +0200
+++ b/src/plugins/notify/notify-plugin.c Fri Jan 20 21:11:09 2012 +0200
@@ -157,6 +157,16 @@
}
}
+void notify_contexts_mailbox_update(struct mailbox *box)
+{
+ struct notify_context *ctx;
+
+ for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
+ if (ctx->v.mailbox_update != NULL)
+ ctx->v.mailbox_update(box);
+ }
+}
+
void notify_contexts_mailbox_delete_begin(struct mailbox *box)
{
struct notify_context *ctx;
@@ -201,6 +211,17 @@
ctx->v.mailbox_rename(src, dest, rename_children);
}
+void notify_contexts_mailbox_set_subscribed(struct mailbox *box,
+ bool subscribed)
+{
+ struct notify_context *ctx;
+
+ for (ctx = ctx_list; ctx != NULL; ctx = ctx->next) {
+ if (ctx->v.mailbox_set_subscribed != NULL)
+ ctx->v.mailbox_set_subscribed(box, subscribed);
+ }
+}
+
struct notify_context *
notify_register(const struct notify_vfuncs *v)
{
diff -r e1f21a4ef417 -r eaf3152a33d6 src/plugins/notify/notify-plugin.h
--- a/src/plugins/notify/notify-plugin.h Fri Jan 20 18:59:16 2012 +0200
+++ b/src/plugins/notify/notify-plugin.h Fri Jan 20 21:11:09 2012 +0200
@@ -24,14 +24,15 @@
struct mail_transaction_commit_changes *changes);
void (*mail_transaction_rollback)(void *txn);
void (*mailbox_create)(struct mailbox *box);
+ void (*mailbox_update)(struct mailbox *box);
void *(*mailbox_delete_begin)(struct mailbox *box);
void (*mailbox_delete_commit)(void *txn, struct mailbox *box);
void (*mailbox_delete_rollback)(void *txn);
void (*mailbox_rename)(struct mailbox *src, struct mailbox *dest,
bool rename_children);
+ void (*mailbox_set_subscribed)(struct mailbox *box, bool subscribed);
};
-void notify_noop_mailbox_create(struct mailbox *box);
struct notify_context *
notify_register(const struct notify_vfuncs *vfuncs);
void notify_unregister(struct notify_context *ctx);
diff -r e1f21a4ef417 -r eaf3152a33d6 src/plugins/notify/notify-storage.c
--- a/src/plugins/notify/notify-storage.c Fri Jan 20 18:59:16 2012 +0200
+++ b/src/plugins/notify/notify-storage.c Fri Jan 20 21:11:09 2012 +0200
@@ -202,6 +202,18 @@
}
static int
+notify_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
+{
+ union mailbox_module_context *lbox = NOTIFY_CONTEXT(box);
+
+ if (lbox->super.update(box, update) < 0)
+ return -1;
+
+ notify_contexts_mailbox_update(box);
+ return 0;
+}
+
+static int
notify_mailbox_delete(struct mailbox *box)
{
union mailbox_module_context *lbox = NOTIFY_CONTEXT(box);
@@ -228,6 +240,18 @@
return 0;
}
+static int
+notify_mailbox_set_subscribed(struct mailbox *box, bool set)
+{
+ union mailbox_module_context *lbox = NOTIFY_CONTEXT(box);
+
+ if (lbox->super.set_subscribed(box, set) < 0)
+ return -1;
+
+ notify_contexts_mailbox_set_subscribed(box, set);
+ return 0;
+}
+
static void notify_mailbox_allocated(struct mailbox *box)
{
struct mailbox_vfuncs *v = box->vlast;
@@ -244,8 +268,10 @@
v->transaction_commit = notify_transaction_commit;
v->transaction_rollback = notify_transaction_rollback;
v->create = notify_mailbox_create;
+ v->update = notify_mailbox_update;
v->delete = notify_mailbox_delete;
v->rename = notify_mailbox_rename;
+ v->set_subscribed = notify_mailbox_set_subscribed;
MODULE_CONTEXT_SET_SELF(box, notify_storage_module, lbox);
}
More information about the dovecot-cvs
mailing list