notify-status-plugin.c revision 5c449ac9f4b353cb75b1a27f0fc96da3940829b8
/* Copyright (c) 2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "json-parser.h"
#include "str.h"
#include "var-expand.h"
#include "mail-user.h"
#include "mail-storage.h"
#include "mail-storage-private.h"
#include "mail-namespace.h"
#include "mail-storage-hooks.h"
#include "imap-match.h"
#include "dict.h"
#include "notify-plugin.h"
#define NOTIFY_STATUS_SETTING_DICT_URI "notify_status_dict"
#define NOTIFY_STATUS_SETTING_MAILBOX_PREFIX "notify_status_mailbox"
#define NOTIFY_STATUS_SETTING_VALUE_TEMPLATE "notify_status_value"
#define NOTIFY_STATUS_SETTING_VALUE_TEMPLATE_DEFAULT "{\"messages\":%{messages},\"unseen\":%{unseen}}"
#define NOTIFY_STATUS_KEY "priv/%s/status"
#define NOTIFY_STATUS_USER_CONTEXT(obj) \
void notify_status_plugin_deinit(void);
const char *notify_status_plugin_version = DOVECOT_ABI_VERSION;
struct notify_status_mail_txn {
bool changed:1;
};
struct notify_status_user {
const char *value_template;
struct notify_context *context;
};
{
struct dict_settings set = {
};
return -1;
}
return 0;
}
{
const char *value;
unsigned int i;
for(i=1;;i++) {
struct imap_match_glob **glob;
const char *key = NOTIFY_STATUS_SETTING_MAILBOX_PREFIX;
if (i > 1)
return;
}
}
{
struct imap_match_glob **glob;
/* not enabled */
return FALSE;
/* if no patterns defined, anything goes */
return TRUE;
return TRUE;
}
return FALSE;
}
void *context ATTR_UNUSED)
{
return;
i_error("notify-status: dict_transaction_commit failed: %s",
}
{
struct dict_transaction_context *t;
struct mailbox_status status;
if (user->mail_debug)
i_debug("notify-status: Updating mailbox %s status",
if (mailbox_open(box) < 0) {
i_error("notify-status: mailbox_open(%s) failed: %s",
i_error("notify-status: mailbox_sync(%s) failed: %s",
&status) < 0) {
i_error("notify-status: mailbox_get_status(%s) failed: %s",
} else {
const struct var_expand_table values[] = {
};
const char *error;
const char *key =
i_error("notify-status: var_expand(%s) failed: %s",
} else {
}
}
mailbox_free(&box);
}
{
struct dict_transaction_context *t;
if (user->mail_debug)
i_debug("notify-status: Removing mailbox %s status",
const char *key =
dict_unset(t, key);
}
static void *notify_status_mail_transaction_begin(struct mailbox_transaction_context *t)
{
return txn;
}
static void
{
}
static void notify_status_mail_transaction_rollback(void *t)
{
i_free(t);
}
{
}
{
}
{
}
{
}
{
}
{
}
enum mail_flags old_flags)
{
}
static const struct notify_vfuncs notify_vfuncs =
{
};
{
}
{
struct notify_status_user *nuser;
const char *error;
if (user->autocreated)
return;
if (user->mail_debug)
i_debug("notify-status: Disabled - Missing plugin/"
NOTIFY_STATUS_SETTING_DICT_URI" setting");
return;
}
return;
}
/* either static value or lifetime is user object's lifetime */
}
static void
{
return;
}
static const struct mail_storage_hooks notify_storage_hooks =
{
};
{
}
void notify_status_plugin_deinit(void)
{
}