private void highestModSeq(Responder responder, MetaData metaData, SelectedMailbox selected) { final StatusResponse untaggedOk; if (metaData.isModSeqPermanent()) { final long highestModSeq = metaData.getHighestModSeq(); untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.HIGHEST_MOD_SEQ, ResponseCode.highestModSeq(highestModSeq)); } else { untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.NO_MOD_SEQ, ResponseCode.noModSeq()); } responder.respond(untaggedOk); }
private void highestModSeq(Responder responder, MetaData metaData, SelectedMailbox selected) { final StatusResponse untaggedOk; if (metaData.isModSeqPermanent()) { final long highestModSeq = metaData.getHighestModSeq(); untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.HIGHEST_MOD_SEQ, ResponseCode.highestModSeq(highestModSeq)); } else { untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.NO_MOD_SEQ, ResponseCode.noModSeq()); } responder.respond(untaggedOk); }
@Override public void run() { // check if we need to cancel the Runnable // See IMAP-275 if (session.getState() != ImapSessionState.LOGOUT && idleActive.get()) { // Send a heartbeat to the client to make sure we // reset the idle timeout. This is kind of the same // workaround as dovecot use. // // This is mostly needed because of the broken // outlook client, but can't harm for other clients // too. // See IMAP-272 StatusResponse response = getStatusResponseFactory().untaggedOk(HumanReadableText.HEARTBEAT); responder.respond(response); // schedule the heartbeat again for the next interval heartbeatExecutor.schedule(this, heartbeatInterval, heartbeatIntervalUnit); } } }, heartbeatInterval, heartbeatIntervalUnit);
private void uidValidity(Responder responder, MessageManager.MetaData metaData) throws MailboxException { final long uidValidity = metaData.getUidValidity(); final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.UID_VALIDITY, ResponseCode.uidValidity(uidValidity)); responder.respond(untaggedOk); }
public void run() { // check if we need to cancel the Runnable // See IMAP-275 if (session.getState() != ImapSessionState.LOGOUT && idleActive.get()) { // Send a heartbeat to the client to make sure we // reset the idle timeout. This is kind of the same // workaround as dovecot use. // // This is mostly needed because of the broken // outlook client, but can't harm for other clients // too. // See IMAP-272 StatusResponse response = getStatusResponseFactory().untaggedOk(HumanReadableText.HEARTBEAT); responder.respond(response); // schedule the heartbeat again for the next interval heartbeatExecutor.schedule(this, heartbeatInterval, heartbeatIntervalUnit); } } }, heartbeatInterval, heartbeatIntervalUnit);
private void uidValidity(Responder responder, MessageManager.MetaData metaData) throws MailboxException { final long uidValidity = metaData.getUidValidity(); final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.UID_VALIDITY, ResponseCode.uidValidity(uidValidity)); responder.respond(untaggedOk); }
private void uidNext(Responder responder, MessageManager.MetaData metaData) throws MailboxException { final MessageUid uid = metaData.getUidNext(); final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.UIDNEXT, ResponseCode.uidNext(uid)); responder.respond(untaggedOk); }
private void uidNext(final Responder responder, final MessageManager.MetaData metaData) throws MailboxException { final long uid = metaData.getUidNext(); final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.UIDNEXT, ResponseCode.uidNext(uid)); responder.respond(untaggedOk); }
protected void condstoreEnablingCommand(ImapSession session, Responder responder, MetaData metaData, boolean sendHighestModSeq) { Set<String> enabled = EnableProcessor.getEnabledCapabilities(session); if (!enabled.contains(ImapConstants.SUPPORTS_CONDSTORE)) { if (sendHighestModSeq) { if (metaData.isModSeqPermanent()) { final long highestModSeq = metaData.getHighestModSeq(); StatusResponse untaggedOk = getStatusResponseFactory().untaggedOk(HumanReadableText.HIGHEST_MOD_SEQ, ResponseCode.highestModSeq(highestModSeq)); responder.respond(untaggedOk); } } enabled.add(ImapConstants.SUPPORTS_CONDSTORE); } }
protected void condstoreEnablingCommand(ImapSession session, Responder responder, MetaData metaData, boolean sendHighestModSeq) { Set<String> enabled = EnableProcessor.getEnabledCapabilities(session); if (!enabled.contains(ImapConstants.SUPPORTS_CONDSTORE)) { if (sendHighestModSeq) { if (metaData.isModSeqPermanent()) { final long highestModSeq = metaData.getHighestModSeq(); StatusResponse untaggedOk = getStatusResponseFactory().untaggedOk(HumanReadableText.HIGHEST_MOD_SEQ, ResponseCode.highestModSeq(highestModSeq)); responder.respond(untaggedOk); } } enabled.add(ImapConstants.SUPPORTS_CONDSTORE); } }
private boolean unseen(Responder responder, MessageUid firstUnseen, SelectedMailbox selected, MailboxSession session) throws MailboxException { if (firstUnseen != null) { final MessageUid unseenUid = firstUnseen; int msn = selected.msn(unseenUid); if (msn == SelectedMailbox.NO_SUCH_MESSAGE) { LOGGER.debug("No message found with uid {} in mailbox {}", unseenUid, selected.getPath().getFullName(session.getPathDelimiter())); return false; } final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.unseen(msn), ResponseCode.unseen(msn)); responder.respond(untaggedOk); } return true; }
private boolean unseen(Responder responder, Long firstUnseen, final SelectedMailbox selected, MailboxSession session) throws MailboxException { if (firstUnseen != null) { final long unseenUid = firstUnseen; int msn = selected.msn(unseenUid); if (msn == SelectedMailbox.NO_SUCH_MESSAGE) { if (session.getLog().isDebugEnabled()) { session.getLog().debug("No message found with uid " + unseenUid + " in mailbox " + selected.getPath().getFullName(session.getPathDelimiter())); } return false; } final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.unseen(msn), ResponseCode.unseen(msn)); responder.respond(untaggedOk); } return true; }
@Test public void testUntaggedOk() { StatusResponse response = factory.untaggedOk(KEY); assertThat(response).isNotNull(); assertThat(response.getServerResponseType()).isEqualTo(StatusResponse.Type.OK); assertThat(response.getTag()).isNull(); assertThat(response.getTextKey()).isEqualTo(KEY); assertThat(response.getResponseCode()).isNull(); assertThat(response.getCommand()).isNull(); response = factory.untaggedOk(KEY, CODE); assertThat(response).isNotNull(); assertThat(response.getServerResponseType()).isEqualTo(StatusResponse.Type.OK); assertThat(response.getTag()).isNull(); assertThat(response.getTextKey()).isEqualTo(KEY); assertThat(response.getResponseCode()).isEqualTo(CODE); assertThat(response.getCommand()).isNull(); }
protected void permanentFlags(Responder responder, MessageManager.MetaData metaData, SelectedMailbox selected) { final Flags permanentFlags = metaData.getPermanentFlags(); if (permanentFlags.contains(Flags.Flag.USER)) { permanentFlags.add(selected.getApplicableFlags()); } final StatusResponse untaggedOk = factory.untaggedOk(HumanReadableText.permanentFlags(permanentFlags), ResponseCode.permanentFlags(permanentFlags)); responder.respond(untaggedOk); }
protected void permanentFlags(Responder responder, MessageManager.MetaData metaData, SelectedMailbox selected) { final Flags permanentFlags = metaData.getPermanentFlags(); if (permanentFlags.contains(Flags.Flag.USER)) { permanentFlags.add(selected.getApplicableFlags()); } final StatusResponse untaggedOk = factory.untaggedOk(HumanReadableText.permanentFlags(permanentFlags), ResponseCode.permanentFlags(permanentFlags)); responder.respond(untaggedOk); }
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; }