# HG changeset patch # User Timo Sirainen # Date 1316690516 -10800 # Node ID 645a56f9d8ee4ef309d843256a955e4e3da18aec # Parent 00b6848a5a63523c0a84ed6f87a976c59f2f21e8 iampc: Small code cleanup. diff -r 00b6848a5a63 -r 645a56f9d8ee src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Thu Sep 22 13:09:18 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Thu Sep 22 14:21:56 2011 +0300 @@ -116,7 +116,7 @@ if (view == NULL) view = imapc_mailbox_get_sync_view(mbox); - if (mbox->opening) { + if (mbox->selecting) { /* We don't know the latest flags, refresh them. */ mbox->sync_fetch_first_uid = 1; } else if (mbox->sync_fetch_first_uid != 1) { diff -r 00b6848a5a63 -r 645a56f9d8ee src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Thu Sep 22 13:09:18 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Thu Sep 22 14:21:56 2011 +0300 @@ -382,11 +382,30 @@ imapc_client_stop(ctx->mbox->storage->client); } +static int imapc_mailbox_select(struct imapc_mailbox *mbox) +{ + struct imapc_open_context ctx; + bool examine; + + examine = (mbox->box.flags & MAILBOX_FLAG_READONLY) != 0 && + (mbox->box.flags & MAILBOX_FLAG_DROP_RECENT) == 0; + + mbox->selecting = TRUE; + ctx.mbox = mbox; + ctx.ret = -2; + mbox->client_box = + imapc_client_mailbox_open(mbox->storage->client, mbox->box.name, + examine, imapc_mailbox_open_callback, + &ctx, mbox); + while (ctx.ret == -2) + imapc_storage_run(mbox->storage); + mbox->selecting = FALSE; + return ctx.ret; +} + static int imapc_mailbox_open(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; - struct imapc_open_context ctx; - bool examine; if (index_storage_mailbox_open(box, FALSE) < 0) return -1; @@ -395,8 +414,6 @@ /* We don't actually want to SELECT the mailbox. */ return 0; } - examine = (box->flags & MAILBOX_FLAG_READONLY) != 0 && - (box->flags & MAILBOX_FLAG_DROP_RECENT) == 0; if (*box->name == '\0' && (box->list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) { @@ -408,17 +425,7 @@ return -1; } - mbox->opening = TRUE; - ctx.mbox = mbox; - ctx.ret = -2; - mbox->client_box = - imapc_client_mailbox_open(mbox->storage->client, box->name, - examine, imapc_mailbox_open_callback, - &ctx, mbox); - while (ctx.ret == -2) - imapc_storage_run(mbox->storage); - mbox->opening = FALSE; - if (ctx.ret < 0) { + if (imapc_mailbox_select(mbox) < 0) { mailbox_close(box); return -1; } diff -r 00b6848a5a63 -r 645a56f9d8ee src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Thu Sep 22 13:09:18 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Thu Sep 22 14:21:56 2011 +0300 @@ -68,7 +68,7 @@ uint32_t prev_skipped_rseq, prev_skipped_uid; - unsigned int opening:1; + unsigned int selecting:1; unsigned int syncing:1; unsigned int initial_sync_done:1; };