push-notification-txn-msg.c revision 2d7ad82a356217c7d763c7075aa3526129373bd8
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2015-2016 Dovecot authors, see the included COPYING file */
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainenpush_notification_txn_msg_create(struct push_notification_txn *txn,
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen hash_table_create_direct(&txn->messages, txn->pool, 4);
948b838c8e9896132e3a2d802fb5dad37e8dc716Timo Sirainen msg = p_new(txn->pool, struct push_notification_txn_msg, 1);
948b838c8e9896132e3a2d802fb5dad37e8dc716Timo Sirainen /* Save sequence number - used to determine UID later. */
e2ce8d4a6ac5d82a906178148453e7613fab9ba0Timo Sirainen hash_table_insert(txn->messages, POINTER_CAST(txn->t->save_count + 1),
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainenpush_notification_txn_msg_end(struct push_notification_txn *ptxn,
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen struct mail_transaction_commit_changes *changes)
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen hiter = hash_table_iterate_init(ptxn->messages);
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen seq_range_array_iter_init(&siter, &changes->saved_uids);
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen /* uid_validity is only set in changes if message is new. */
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen mailbox_get_open_status(ptxn->mbox, STATUS_UIDVALIDITY, &status);
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen while (hash_table_iterate(hiter, ptxn->messages, &key, &value)) {
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen if (seq_range_array_iter_nth(&siter, value->seq, &uid)) {
beffc30d933c5e134c45cc871852a8427eba7e70Timo Sirainen array_foreach_modifiable(&ptxn->drivers, dtxn) {
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen if ((*dtxn)->duser->driver->v.process_msg != NULL) {
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainen (*dtxn)->duser->driver->v.process_msg(*dtxn, value);
5c92436a61569c0b56a9374e60e779fa4455edefTimo Sirainen push_notification_txn_msg_deinit_eventdata(value);
f89cb43088c8b46d12d66ac924724b53ab14ce66Timo Sirainenpush_notification_txn_msg_get_eventdata(struct push_notification_txn_msg *msg,
64055bc6d2ed9e25b3b1db3b5b90d0bdb77cd715Timo Sirainen array_foreach_modifiable(&msg->eventdata, mevent) {
64055bc6d2ed9e25b3b1db3b5b90d0bdb77cd715Timo Sirainen if (strcmp((*mevent)->event->event->name, event_name) == 0) {
0c3ec2538c366bb5583f0b4ca2ce60804756b51cTimo Sirainenpush_notification_txn_msg_set_eventdata(struct push_notification_txn *txn,
beffc30d933c5e134c45cc871852a8427eba7e70Timo Sirainen mevent = p_new(txn->pool, struct push_notification_txn_event, 1);
beffc30d933c5e134c45cc871852a8427eba7e70Timo Sirainenpush_notification_txn_msg_deinit_eventdata(struct push_notification_txn_msg *msg)
4afd5082f38342fd688acb5796912329f57dd02cTimo Sirainen array_foreach_modifiable(&msg->eventdata, mevent) {
4afd5082f38342fd688acb5796912329f57dd02cTimo Sirainen ((*mevent)->event->event->msg.free_msg != NULL)) {