push-notification-events.h revision bcb4e51a409d94ae670de96afb8483a4f7855294
2N/A/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
2N/A
2N/A#ifndef PUSH_NOTIFICATION_EVENTS_H
2N/A#define PUSH_NOTIFICATION_EVENTS_H
2N/A
2N/A#include "mail-types.h"
2N/A
2N/Astruct mail;
2N/Astruct mailbox;
2N/Astruct push_notification_event_config;
2N/Astruct push_notification_driver_txn;
2N/Astruct push_notification_txn;
2N/Astruct push_notification_txn_event;
2N/Astruct push_notification_txn_mbox;
2N/Astruct push_notification_txn_msg;
2N/A
2N/Astruct push_notification_event_vfuncs_init {
2N/A /* Return the default config for an event (or NULL if config is
2N/A * required). */
2N/A void *(*default_config)(void);
2N/A};
2N/A
2N/Astruct push_notification_event_vfuncs_mbox {
2N/A /* Output debug information about a message event. */
2N/A void (*debug_mbox)(struct push_notification_txn_event *event);
2N/A /* Called when message data is about to be free'd. */
2N/A void (*free_mbox)(struct push_notification_txn_event *event);
2N/A};
2N/A
2N/Astruct push_notification_event_vfuncs_mbox_triggers {
2N/A /* Mailbox event: create mailbox. */
2N/A void (*create)(struct push_notification_txn *ptxn,
2N/A struct push_notification_event_config *ec,
2N/A struct push_notification_txn_mbox *mbox);
2N/A /* Mailbox event: delete mailbox. */
2N/A void (*delete)(struct push_notification_txn *ptxn,
2N/A struct push_notification_event_config *ec,
2N/A struct push_notification_txn_mbox *mbox);
2N/A /* Mailbox event: rename mailbox. */
2N/A void (*rename)(struct push_notification_txn *ptxn,
2N/A struct push_notification_event_config *ec,
2N/A struct push_notification_txn_mbox *mbox,
2N/A struct mailbox *old);
2N/A /* Mailbox event: subscribe mailbox. */
2N/A void (*subscribe)(struct push_notification_txn *ptxn,
struct push_notification_event_config *ec,
struct push_notification_txn_mbox *mbox);
/* Mailbox event: unsubscribe mailbox. */
void (*unsubscribe)(struct push_notification_txn *ptxn,
struct push_notification_event_config *ec,
struct push_notification_txn_mbox *mbox);
};
struct push_notification_event_vfuncs_msg {
/* Output debug information about a message event. */
void (*debug_msg)(struct push_notification_txn_event *event);
/* Called when message data is about to be free'd. */
void (*free_msg)(struct push_notification_txn_event *event);
};
struct push_notification_event_vfuncs_msg_triggers {
/* Message event: save message (from MTA). */
void (*save)(struct push_notification_txn *ptxn,
struct push_notification_event_config *ec,
struct push_notification_txn_msg *msg,
struct mail *mail);
/* Message event: append message (from MUA). */
void (*append)(struct push_notification_txn *ptxn,
struct push_notification_event_config *ec,
struct push_notification_txn_msg *msg,
struct mail *mail);
/* Message event: expunge message. */
void (*expunge)(struct push_notification_txn *ptxn,
struct push_notification_event_config *ec,
struct push_notification_txn_msg *msg);
/* Message event: flag change. */
void (*flagchange)(struct push_notification_txn *ptxn,
struct push_notification_event_config *ec,
struct push_notification_txn_msg *msg,
struct mail *mail,
enum mail_flags old_flags);
/* Message event: keyword change. */
void (*keywordchange)(struct push_notification_txn *ptxn,
struct push_notification_event_config *ec,
struct push_notification_txn_msg *msg,
struct mail *mail,
const char *const *old_keywords);
};
struct push_notification_event_config {
const struct push_notification_event *event;
void *config;
};
struct push_notification_event {
const char *name;
struct push_notification_event_vfuncs_init init;
struct push_notification_event_vfuncs_mbox mbox;
struct push_notification_event_vfuncs_mbox_triggers mbox_triggers;
struct push_notification_event_vfuncs_msg msg;
struct push_notification_event_vfuncs_msg_triggers msg_triggers;
};
struct push_notification_txn_event {
struct push_notification_event_config *event;
void *data;
};
ARRAY_DEFINE_TYPE(push_notification_event,
const struct push_notification_event *);
extern ARRAY_TYPE(push_notification_event) push_notification_events;
void
push_notification_event_init(struct push_notification_driver_txn *dtxn,
const char *event_name, void *config);
void push_notification_event_register
(const struct push_notification_event *event);
void push_notification_event_unregister
(const struct push_notification_event *event);
#endif /* PUSH_NOTIFICATION_EVENTS_H */