1 /* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
2 
3 #include "lib.h"
4 #include "mail-storage.h"
5 
6 #include "push-notification-drivers.h"
7 #include "push-notification-events.h"
8 #include "push-notification-event-mailboxsubscribe.h"
9 #include "push-notification-txn-mbox.h"
10 
11 #define EVENT_NAME "MailboxSubscribe"
12 
13 static void
push_notification_event_mailboxsubscribe_debug_mbox(struct push_notification_txn_event * event ATTR_UNUSED)14 push_notification_event_mailboxsubscribe_debug_mbox(
15 	struct push_notification_txn_event *event ATTR_UNUSED)
16 {
17 	i_debug("%s: Mailbox was subscribed to", EVENT_NAME);
18 }
19 
20 static void
push_notification_event_mailboxsubscribe_event(struct push_notification_txn * ptxn,struct push_notification_event_config * ec,struct push_notification_txn_mbox * mbox)21 push_notification_event_mailboxsubscribe_event(
22 	struct push_notification_txn *ptxn,
23 	struct push_notification_event_config *ec,
24 	struct push_notification_txn_mbox *mbox)
25 {
26 	struct push_notification_event_mailboxsubscribe_data *data;
27 
28 	data = p_new(ptxn->pool,
29 		     struct push_notification_event_mailboxsubscribe_data, 1);
30 	data->subscribe = TRUE;
31 
32 	push_notification_txn_mbox_set_eventdata(ptxn, mbox, ec, data);
33 }
34 
35 /* Event definition */
36 
37 extern struct push_notification_event push_notification_event_mailboxsubscribe;
38 
39 struct push_notification_event push_notification_event_mailboxsubscribe = {
40 	.name = EVENT_NAME,
41 	.mbox = {
42 		.debug_mbox =
43 			push_notification_event_mailboxsubscribe_debug_mbox,
44 	},
45 	.mbox_triggers = {
46 		.subscribe = push_notification_event_mailboxsubscribe_event,
47 	},
48 };
49