23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "lib.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "mailbox-list-private.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "mailbox-list-notify.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint mailbox_list_notify_init(struct mailbox_list *list,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen enum mailbox_list_notify_event mask,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen struct mailbox_list_notify **notify_r)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen{
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (list->v.notify_init == NULL)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return -1;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return list->v.notify_init(list, mask, notify_r);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenvoid mailbox_list_notify_deinit(struct mailbox_list_notify **_notify)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen{
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen struct mailbox_list_notify *notify = *_notify;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen *_notify = NULL;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen notify->list->v.notify_deinit(notify);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint mailbox_list_notify_next(struct mailbox_list_notify *notify,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const struct mailbox_list_notify_rec **rec_r)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen{
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return notify->list->v.notify_next(notify, rec_r);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#undef mailbox_list_notify_wait
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenvoid mailbox_list_notify_wait(struct mailbox_list_notify *notify,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void (*callback)(void *context), void *context)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen{
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen notify->list->v.notify_wait(notify, callback, context);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenvoid mailbox_list_notify_flush(struct mailbox_list_notify *notify)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen{
04c0136989b7eb896bfb0fb176e11233d69e1453Lennart Poettering if (notify->list->v.notify_flush != NULL)
0b9315719154fa7ea1a075e1b3785713f5acc3a1David Herrmann notify->list->v.notify_flush(notify);
bff686e2a981ccd0888cdf1981977d24320f1770David Herrmann}
bff686e2a981ccd0888cdf1981977d24320f1770David Herrmann