static int restore_add_message(const struct backup_message *message, const struct backup_mailbox_list *message_mailboxes, const struct restore_options *options, struct backup_mailbox_list *mailbox_list, struct sync_folder_list *reserve_folder_list, struct sync_reserve_list *reserve_list) { struct sync_msgid_list *msgid_list = NULL; if (options->override_mboxname) { /* create a mailbox... */ struct backup_mailbox *mailbox = xzmalloc(sizeof *mailbox); apply_mailbox_options(mailbox, options); if (!mailbox->partition) mailbox->partition = xstrdup(message->partition); /* ... containing this message */ struct backup_mailbox_message *mailbox_message = xzmalloc(sizeof *mailbox_message); mailbox_message->guid = *message->guid; mailbox_message->size = message->length; mailbox->records = xzmalloc(sizeof *mailbox->records); mailbox->records->head = mailbox->records->tail = mailbox_message; mailbox->records->count = 1; /* add to reserve list */ msgid_list = sync_reserve_partlist(reserve_list, mailbox->partition); sync_msgid_insert(msgid_list, message->guid); /* add to reserve folder list */ const struct synccrcs synccrcs = {0, 0}; sync_folder_list_add(reserve_folder_list, NULL, mailbox->mboxname, 0, NULL, NULL, 0, 0, 0, 0, synccrcs, 0, 0, 0, 0, NULL, 0, 0, 0); /* add to mailbox list */ my_mailbox_list_add(mailbox_list, mailbox); } else if (message_mailboxes) { struct backup_mailbox *iter; for (iter = message_mailboxes->head; iter; iter = iter->next) { struct backup_mailbox *clone = backup_mailbox_clone(iter); apply_mailbox_options(clone, options); /* add to reserve list */ msgid_list = sync_reserve_partlist(reserve_list, clone->partition); sync_msgid_insert(msgid_list, message->guid); /* add to mailbox list */ my_mailbox_list_add(mailbox_list, clone); } } return 0; }
static int restore_add_mailbox(const struct backup_mailbox *mailbox, const struct restore_options *options, struct backup_mailbox_list *mailbox_list, struct sync_folder_list *reserve_folder_list, struct sync_reserve_list *reserve_list) { struct backup_mailbox *clone = backup_mailbox_clone(mailbox); apply_mailbox_options(clone, options); /* populate reserve list */ if (clone->records) { struct sync_msgid_list *msgid_list = NULL; struct backup_mailbox_message *record = NULL; msgid_list = sync_reserve_partlist(reserve_list, clone->partition); for (record = clone->records->head; record; record = record->next) { sync_msgid_insert(msgid_list, &record->guid); } } /* add to folder list if not already-extant folder */ if (options->override_mboxname) { const struct synccrcs synccrcs = {0, 0}; sync_folder_list_add(reserve_folder_list, NULL, clone->mboxname, 0, NULL, NULL, 0, 0, 0, 0, synccrcs, 0, 0, 0, 0, NULL, 0, 0, 0); } /* populate mailbox list */ my_mailbox_list_add(mailbox_list, clone); return 0; }
static int _keep_message_guids_cb(const struct backup_message *message, void *rock) { struct sync_msgid_list *list = (struct sync_msgid_list *) rock; sync_msgid_insert(list, message->guid); return 0; }