bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M SlusarzHASH_TABLE_DEFINE_TYPE(push_notification_config, const char *, const char *);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M SlusarzHASH_TABLE_DEFINE_TYPE(push_notification_msgs, void *,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Init driver. Config (from plugin configuration) is parsed once (no
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz * user variable substitutions). Return 0 on success, or -1 if this
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz * driver should be disabled (or on error). */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz int (*init)(struct push_notification_driver_config *config,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct mail_user *user, pool_t pool, void **context,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz const char **error_r);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Called at the beginning of a notification transaction. Return TRUE on
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz * success, or FALSE if this driver should be ignored for this
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz * transaction. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz bool (*begin_txn)(struct push_notification_driver_txn *dtxn);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Called once for every mailbox processed. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz void (*process_mbox)(struct push_notification_driver_txn *dtxn,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Called once for every message processed. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz void (*process_msg)(struct push_notification_driver_txn *dtxn,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Called at the end of a successful notification transaction. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz void (*end_txn)(struct push_notification_driver_txn *dtxn, bool success);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Called when plugin is deinitialized. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz void (*deinit)(struct push_notification_driver_user *duser);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Called to cleanup any global resources used in plugin. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz HASH_TABLE_TYPE(push_notification_config) config;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz const struct push_notification_driver *driver;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz const struct push_notification_driver_user *duser;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Transaction context. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz ARRAY(struct push_notification_driver_user *) drivers;
e7e9ca33af09b6ab77633bcafe27d751adf09c93Michael Slusarz struct push_notification_driver_list *driverlist;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz enum push_notification_event_trigger trigger;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_trigger_ctx *trigger_ctx;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz ARRAY(struct push_notification_driver_txn *) drivers;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz ARRAY(struct push_notification_event_config *) events;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Used with mailbox events. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_txn_mbox *mbox_txn;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Used with mailbox events. */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz HASH_TABLE_TYPE(push_notification_msgs) messages;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* Private (used with message events). */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzpush_notification_driver_init(struct mail_user *user, const char *config_in,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_driver_user **duser_r);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzvoid push_notification_driver_cleanup_all(void);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzpush_notification_driver_debug(const char *label, struct mail_user *user,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz const char *fmt, ...);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz(const struct push_notification_driver *driver);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz(const struct push_notification_driver *driver);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz#endif /* PUSH_NOTIFICATION_DRIVERS_H */