virtual-sync.c revision 3e1d94509fd76c56f2eb54f98ea02ade9ac2d44a
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2008-2014 Dovecot authors, see the included COPYING file */
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen const char *const *kw_all;
3ddbbe03fe74b3ee7b1dff4e08ec706d7880d052Timo Sirainen /* messages expunged within this sync */
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainenstatic void virtual_sync_set_uidvalidity(struct virtual_sync_context *ctx)
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen offsetof(struct mail_index_header, uid_validity),
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainenstatic void virtual_sync_external_flags(struct virtual_sync_context *ctx,
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen const char *const *kw_names;
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen if (!mail_set_uid(bbox->sync_mail, real_uid)) {
8039af9679af6fb56116b353fe44f7dd4c08f031Timo Sirainen /* copy flags */
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen mail_index_update_flags(ctx->trans, vseq, MODIFY_REPLACE, flags);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen /* copy keywords */
ca9b4bd99287f7aef3065c9973f8d440bf5bbbc5Timo Sirainen kw_names = mail_get_keywords(bbox->sync_mail);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen keywords = mail_index_keywords_create(ctx->index, kw_names);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen mail_index_update_keywords(ctx->trans, vseq, MODIFY_REPLACE, keywords);
2ba4e9bedb0fa778dfbccec5370018b4d0040d9cTimo Sirainenstatic int virtual_sync_mail_cmp(const void *p1, const void *p2)
923eb3dde28e4d8841c14fd6b4a69635b7070c3eTimo Sirainen const struct virtual_sync_mail *m1 = p1, *m2 = p2;
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen if (m1->vrec.mailbox_id < m2->vrec.mailbox_id)
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen if (m1->vrec.mailbox_id > m2->vrec.mailbox_id)
2cfe9983ce7a6280636ee12beccc2e865111967bTimo Sirainenvirtual_backend_box_sync_mail_set(struct virtual_backend_box *bbox)
2cfe9983ce7a6280636ee12beccc2e865111967bTimo Sirainen trans = mailbox_transaction_begin(bbox->box, 0);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenvirtual_backend_box_sync_mail_unset(struct virtual_backend_box *bbox)
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenstatic int bbox_mailbox_id_cmp(struct virtual_backend_box *const *b1,
16834f18f903048c772112838c015051642a0e77Timo Sirainenvirtual_sync_get_backend_box(struct virtual_sync_context *ctx, const char *name,
const void *ext_data;
ext_name_offset = 0;
ext_mailbox_count = 0;
box_path);
ext_mailbox_count = 0;
ret = 0;
prev_mailbox_id = 0;
for (i = 0; i < ext_mailbox_count; i++) {
box_path);
box_path);
box_path);
T_BEGIN {
const unsigned char *nameptr;
const char *name;
} T_END;
if (ret < 0)
ret = 0;
if (i < ext_mailbox_count) {
ret = 0;
for (i = 0; i < count; i++) {
ret = 0;
return ret;
const void *ext_data;
for (i = 0; i < count; i++) {
i_assert(i == 0 ||
sizeof(struct virtual_mail_index_record),
sizeof(uint32_t));
const void *data;
if (flags != 0) {
if (flags != 0) {
kw_names);
int ret;
0, NULL);
return ret;
if (uid_count == 0)
i_unreached();
for (i = 0; i < uid_count; i++) {
&vseq))
if (uid_count == 0)
if (rec_count == 0 ||
&dest))
i_unreached();
for (i = 0; i < uid_count; i++) {
unsigned int i, count;
for (i = 0; i < count; i++) {
const void *data;
old_msg_count = 0;
&removed_uids);
unsigned int i, n = 0, count;
if (i == count)
for (; i < count; ) {
unsigned int i, n = 0, count;
for (; i < count; ) {
if (!iter_done) {
&added_uids);
&temp_uids);
&removed_uids);
&removed_uids);
unsigned int *idx1_r,
unsigned int *idx2_r)
&idx);
return FALSE;
return TRUE;
&idx1);
case MAILBOX_SYNC_TYPE_FLAGS:
case MAILBOX_SYNC_TYPE_MODSEQ:
const unsigned int uidval_pos =
unsigned int mailbox_offset;
int ret;
if (bbox_index_opened) {
&status) < 0)
if (!bbox_index_opened) {
} T_END;
return ret;
const void *data;
unsigned int j = 0, uidmap_count = 0;
if (messages == 0)
for (i = 0; i < messages; i++) {
for (; j < uidmap_count; j++) {
&uidmap_count);
for (; j < uidmap_count; j++) {
for (; j < uidmap_count; j++) {
for (i = 0; i < count; i++) {
for (j = 0; j < uidmap_count; j++) {
unsigned int i, count;
i_unreached();
if (count == 0) {
&idx))
i_unreached();
const void *data;
const void *data;
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int i, count;
for (i = 0; i < count; i++)
if (success) {
return ret;
int ret;
if (ret <= 0) {
if (ret < 0)
return ret;
if (ret < 0)
if (ret == 0)
struct mailbox_sync_context *
int ret = 0;
return sync_ctx;