push-notification-event-flagsset.c revision 51ed197520dd9ea534fbc3bc1790ebe3cb5421e2
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (c) 2015 Dovecot authors, see the included COPYING file */
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainenstatic struct push_notification_event_flagsset_config default_config;
bb2471ff14f01390b47cce63b407820b5547df1aTimo Sirainenstatic void *push_notification_event_flagsset_default_config(void)
bb2471ff14f01390b47cce63b407820b5547df1aTimo Sirainen memset(&default_config, 0, sizeof(default_config));
83d0c8152f694ae5b5d1798abda5728dc886102aTimo Sirainenstatic void push_notification_event_flagsset_debug_msg
83d0c8152f694ae5b5d1798abda5728dc886102aTimo Sirainen struct push_notification_event_flagsset_data *data = event->data;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen const char *const *keyword;
29543188462c9348f365ec29115d777ffe4769d3Timo Sirainen i_debug("%s: Keyword set [%s]", EVENT_NAME, *keyword);
917498e6f84969d2b93410c1e479735abe8e0ed7Timo Sirainenstatic struct push_notification_event_flagsset_data *
29543188462c9348f365ec29115d777ffe4769d3Timo Sirainenpush_notification_event_flagsset_get_data(struct push_notification_txn *ptxn,
29543188462c9348f365ec29115d777ffe4769d3Timo Sirainen struct push_notification_event_flagsset_data *data;
917498e6f84969d2b93410c1e479735abe8e0ed7Timo Sirainen data = push_notification_txn_msg_get_eventdata(msg, EVENT_NAME);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct push_notification_event_flagsset_data, 1);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen p_array_init(&data->keywords_set, ptxn->pool, 4);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen push_notification_txn_msg_set_eventdata(ptxn, msg, ec, data);
8528048c7b82c745bcfa5a6b1394251b3aaeb129Josef 'Jeff' Sipekstatic void push_notification_event_flagsset_flags_event(
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen struct push_notification_event_flagsset_config *config =
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen (struct push_notification_event_flagsset_config *)ec->config;
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen struct push_notification_event_flagsset_data *data;
b056d19b7a07400b897104b146c8768280d24009Timo Sirainen unsigned int i;
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen for (i = 0; i < N_ELEMENTS(flag_check_always); i++) {
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen /* Only create data element if at least one flag was set. */
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen data = push_notification_event_flagsset_get_data(ptxn, msg, ec);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainenstatic void push_notification_event_flagsset_keywords_event(
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen const char *const *old_keywords)
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct push_notification_event_flagsset_data *data;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen data = push_notification_event_flagsset_get_data(ptxn, msg, ec);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainenstatic void push_notification_event_flagsset_free_msg(
bb2471ff14f01390b47cce63b407820b5547df1aTimo Sirainen struct push_notification_event_flagsset_data *data = event->data;
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen/* Event definition */
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainenextern struct push_notification_event push_notification_event_flagsset;
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainenstruct push_notification_event push_notification_event_flagsset = {
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen .default_config = push_notification_event_flagsset_default_config
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen .debug_msg = push_notification_event_flagsset_debug_msg,
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen .free_msg = push_notification_event_flagsset_free_msg
f663bdd9d345a86e6a7924d83319bd04b2fcb600Timo Sirainen .flagchange = push_notification_event_flagsset_flags_event,