private MessageManager.MetaData selectMailbox(MailboxPath mailboxPath, ImapSession session) throws MailboxException { final MailboxManager mailboxManager = getMailboxManager(); final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); final MessageManager mailbox = mailboxManager.getMailbox(mailboxPath, mailboxSession); final SelectedMailbox sessionMailbox; final SelectedMailbox currentMailbox = session.getSelected(); if (currentMailbox == null || !currentMailbox.getPath().equals(mailboxPath)) { // QRESYNC EXTENSION // // Response with the CLOSE return-code when the currently selected mailbox is closed implicitly using the SELECT/EXAMINE command on another mailbox // // See rfc5162 3.7. CLOSED Response Code if (currentMailbox != null) { getStatusResponseFactory().untaggedOk(HumanReadableText.QRESYNC_CLOSED, ResponseCode.closed()); } session.selected(new SelectedMailboxImpl(getMailboxManager(), session, mailboxPath)); sessionMailbox = session.getSelected(); } else { // TODO: Check if we need to handle CONDSTORE there too sessionMailbox = currentMailbox; } final MessageManager.MetaData metaData = mailbox.getMetaData(!openReadOnly, mailboxSession, MessageManager.MetaData.FetchGroup.FIRST_UNSEEN); addRecent(metaData, sessionMailbox); return metaData; }
private MessageManager.MetaData selectMailbox(MailboxPath mailboxPath, ImapSession session) throws MailboxException { final MailboxManager mailboxManager = getMailboxManager(); final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); final MessageManager mailbox = mailboxManager.getMailbox(mailboxPath, mailboxSession); final SelectedMailbox sessionMailbox; final SelectedMailbox currentMailbox = session.getSelected(); if (currentMailbox == null || !currentMailbox.getPath().equals(mailboxPath)) { // QRESYNC EXTENSION // // Response with the CLOSE return-code when the currently selected mailbox is closed implicitly using the SELECT/EXAMINE command on another mailbox // // See rfc5162 3.7. CLOSED Response Code if (currentMailbox != null) { getStatusResponseFactory().untaggedOk(HumanReadableText.QRESYNC_CLOSED, ResponseCode.closed()); } session.selected(new SelectedMailboxImpl(getMailboxManager(), session, mailboxPath)); sessionMailbox = session.getSelected(); } else { // TODO: Check if we need to handle CONDSTORE there too sessionMailbox = currentMailbox; } final MessageManager.MetaData metaData = mailbox.getMetaData(!openReadOnly, mailboxSession, MessageManager.MetaData.FetchGroup.FIRST_UNSEEN); addRecent(metaData, sessionMailbox); return metaData; }