コード例 #1
0
  /**
   * @see
   *     org.apache.james.imap.processor.PermitEnableCapabilityProcessor#enable(org.apache.james.imap.api.ImapMessage,
   *     org.apache.james.imap.api.process.ImapProcessor.Responder,
   *     org.apache.james.imap.api.process.ImapSession, java.lang.String)
   */
  public void enable(
      ImapMessage message, Responder responder, ImapSession session, String capability)
      throws EnableException {

    if (EnableProcessor.getEnabledCapabilities(session).contains(capability) == false) {
      SelectedMailbox sm = session.getSelected();
      // Send a HIGHESTMODSEQ response if the there was a select mailbox before and the client just
      // enabled
      // QRESYNC or CONDSTORE
      //
      // See http://www.dovecot.org/list/dovecot/2008-March/029561.html
      if (capability.equalsIgnoreCase(ImapConstants.SUPPORTS_CONDSTORE)
          || capability.equalsIgnoreCase(ImapConstants.SUPPORTS_QRESYNC)) {
        try {
          MetaData metaData = null;
          boolean send = false;
          if (sm != null) {
            MessageManager mailbox = getSelectedMailbox(session);
            metaData =
                mailbox.getMetaData(
                    false, ImapSessionUtils.getMailboxSession(session), FetchGroup.NO_COUNT);
            send = true;
          }
          condstoreEnablingCommand(session, responder, metaData, send);
        } catch (MailboxException e) {
          throw new EnableException("Unable to enable " + capability, e);
        }
      }
    }
  }
コード例 #2
0
  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;
  }