james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From darr...@apache.org
Subject cvs commit: james-server/proposals/imap2/test/org/apache/james/imapserver SelectAppend.test AppendExpunge.test Copy.test ExamineEmpty.test ExamineInbox.test FetchMultipleMessages.test SelectEmpty.test SelectInbox.test SelectedStateCleanup.test SelectedStateSetup.test TestCompound.java TestSelectedCommandsInSelectedState.java Uid.test
Date Sun, 13 Jul 2003 06:04:57 GMT
darrell     2003/07/12 23:04:57

  Modified:    proposals/imap2 build-test.xml build.xml
               proposals/imap2/java/org/apache/james/imapserver
                        ImapHost.java ImapResponse.java ImapSession.java
                        ImapSessionImpl.java JamesImapHost.java
               proposals/imap2/java/org/apache/james/imapserver/commands
                        CloseCommand.java CopyCommand.java
                        ExpungeCommand.java FetchCommand.java
                        SearchCommand.java SelectCommand.java
               proposals/imap2/java/org/apache/james/imapserver/store
                        ImapMailbox.java InMemoryStore.java
               proposals/imap2/test/org/apache/james/imapserver
                        AppendExpunge.test Copy.test ExamineEmpty.test
                        ExamineInbox.test FetchMultipleMessages.test
                        SelectEmpty.test SelectInbox.test
                        SelectedStateCleanup.test SelectedStateSetup.test
                        TestCompound.java
                        TestSelectedCommandsInSelectedState.java Uid.test
  Added:       proposals/imap2/java/org/apache/james/imapserver
                        ImapSessionMailbox.java
               proposals/imap2/java/org/apache/james/imapserver/store
                        MailboxListener.java
               proposals/imap2/test/org/apache/james/imapserver
                        SelectAppend.test
  Log:
  Imap2 proposal:
  - Split out session-specific Mailbox info, for handling expunge or addition by a different
  session. The RECENT and FETCH responses are not yet handled for external chang:es.
  - Moved expunge(), copy() and search() off the ImapHost, and onto the Mailbox.
  
  Revision  Changes    Path
  1.5       +1 -1      james-server/proposals/imap2/build-test.xml
  
  Index: build-test.xml
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/build-test.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- build-test.xml	3 Dec 2002 14:00:11 -0000	1.4
  +++ build-test.xml	13 Jul 2003 06:04:55 -0000	1.5
  @@ -65,7 +65,7 @@
           <pathelement location="${xerces.jar}"/>
           <pathelement path="${java.class.path}"/>
           <fileset dir="${lib.dir}">
  -            <include name="*.jar"/>
  +            <include name="**/*.jar"/>
               <exclude name="xerces.jar"/>
           </fileset>
           <fileset dir="${phoenix.dir}/lib">
  
  
  
  1.9       +11 -0     james-server/proposals/imap2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/build.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- build.xml	17 Feb 2003 13:09:32 -0000	1.8
  +++ build.xml	13 Jul 2003 06:04:55 -0000	1.9
  @@ -20,4 +20,15 @@
               <property name="version" value="3.0a1-imap2"/>
           </ant>
       </target>
  +
  +    <target name="clean">
  +        <ant antfile="build.xml" target="clean">
  +            <property name="build.dir" value="${proposal.dir}/build"/>
  +            <property name="dist.base" value="${proposal.dir}/dist"/>
  +            <property name="conf.dir" value="${conf.proposal.dir}"/>
  +            <property name="version" value="3.0a1-imap2"/>
  +        </ant>
  +    </target>
  +    
  +    <target name="rebuild" depends="clean,main"/>
   </project>
  
  
  
  1.7       +1 -9      james-server/proposals/imap2/java/org/apache/james/imapserver/ImapHost.java
  
  Index: ImapHost.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/ImapHost.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ImapHost.java	8 Mar 2003 21:13:54 -0000	1.6
  +++ ImapHost.java	13 Jul 2003 06:04:55 -0000	1.7
  @@ -296,13 +296,5 @@
       void unsubscribe( User user, String mailbox )
               throws MailboxException;
   
  -    int[] expunge( ImapMailbox mailbox ) throws MailboxException;
  -
  -    long[] search( SearchTerm searchTerm, ImapMailbox mailbox );
  -
  -    void copyMessage( long uid, ImapMailbox currentMailbox, ImapMailbox toMailbox )
  -            throws MailboxException;
  -
  -
   }
   
  
  
  
  1.5       +6 -0      james-server/proposals/imap2/java/org/apache/james/imapserver/ImapResponse.java
  
  Index: ImapResponse.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/ImapResponse.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ImapResponse.java	8 Mar 2003 21:13:54 -0000	1.4
  +++ ImapResponse.java	13 Jul 2003 06:04:56 -0000	1.5
  @@ -315,4 +315,10 @@
           writer.flush();
       }
   
  +    public void permanentFlagsResponse(MessageFlags flags) {
  +        untagged();
  +        message(OK);
  +        responseCode("PERMANENTFLAGS " + flags.format());
  +        end();
  +    }
   }
  
  
  
  1.6       +2 -9      james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSession.java
  
  Index: ImapSession.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSession.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ImapSession.java	8 Mar 2003 21:13:54 -0000	1.5
  +++ ImapSession.java	13 Jul 2003 06:04:56 -0000	1.6
  @@ -150,13 +150,6 @@
        * session is not in {@link ImapSessionState#SELECTED} state.
        * @return the currently selected mailbox.
        */
  -    ImapMailbox getSelected();
  -
  -    /**
  -     * TODO? return a read-only wrapper for read-only selections, and put the
  -     * isReadOnly() on the mailbox itself?
  -     * @return if the currently selected mailbox is open read only.
  -     */
  -    boolean selectedIsReadOnly();
  +    ImapSessionMailbox getSelected();
   
   }
  
  
  
  1.5       +25 -13    james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSessionImpl.java
  
  Index: ImapSessionImpl.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSessionImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ImapSessionImpl.java	8 Mar 2003 21:13:54 -0000	1.4
  +++ ImapSessionImpl.java	13 Jul 2003 06:04:56 -0000	1.5
  @@ -58,11 +58,9 @@
   
   package org.apache.james.imapserver;
   
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.logger.Logger;
  +import org.apache.james.imapserver.store.ImapMailbox;
   import org.apache.mailet.User;
   import org.apache.mailet.UsersRepository;
  -import org.apache.james.imapserver.store.ImapMailbox;
   
   /**
    *
  @@ -74,11 +72,7 @@
   {
       private ImapSessionState state = ImapSessionState.NON_AUTHENTICATED;
       private User user = null;
  -    private ImapMailbox selectedMailbox = null;
  -    // TODO: Use a session-specific wrapper for user's view of mailbox
  -    // this wrapper would provide access control and track if the mailbox
  -    // is opened read-only.
  -    private boolean selectedIsReadOnly = false;
  +    private ImapSessionMailbox selectedMailbox = null;
   
       private String clientHostName;
       private String clientAddress;
  @@ -108,6 +102,23 @@
   
       public void unsolicitedResponses( ImapResponse request )
       {
  +        ImapSessionMailbox selected = getSelected();
  +        if (selected != null) {
  +            
  +            // Expunge response
  +            int[] expunged = selected.getExpunged();
  +            for (int i = 0; i < expunged.length; i++) {
  +                int msn = expunged[i];
  +                request.expungeResponse(msn);
  +            }
  +            
  +            // New message response 
  +            // TODO: need RECENT...
  +            if (selected._sizeChanged) {
  +                request.existsResponse(selected.getMessageCount());
  +                selected._sizeChanged = false;
  +            }
  +        }
       }
   
       public void closeConnection()
  @@ -148,23 +159,24 @@
   
       public void setSelected( ImapMailbox mailbox, boolean readOnly )
       {
  +        ImapSessionMailbox sessionMailbox = new ImapSessionMailbox(mailbox, readOnly);
           this.state = ImapSessionState.SELECTED;
  -        this.selectedMailbox = mailbox;
  -        this.selectedIsReadOnly = readOnly;
  +        this.selectedMailbox = sessionMailbox;
       }
   
  -    public ImapMailbox getSelected()
  +    public ImapSessionMailbox getSelected()
       {
           return this.selectedMailbox;
       }
   
       public boolean selectedIsReadOnly()
       {
  -        return this.selectedIsReadOnly;
  +        return selectedMailbox.isReadonly();
       }
   
       public ImapSessionState getState()
       {
           return this.state;
       }
  +
   }
  
  
  
  1.9       +7 -80     james-server/proposals/imap2/java/org/apache/james/imapserver/JamesImapHost.java
  
  Index: JamesImapHost.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/JamesImapHost.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JamesImapHost.java	8 Mar 2003 21:13:54 -0000	1.8
  +++ JamesImapHost.java	13 Jul 2003 06:04:56 -0000	1.9
  @@ -58,26 +58,21 @@
   
   package org.apache.james.imapserver;
   
  -import org.apache.mailet.User;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.ConsoleLogger;
  +import org.apache.james.imapserver.store.ImapMailbox;
   import org.apache.james.imapserver.store.ImapStore;
   import org.apache.james.imapserver.store.InMemoryStore;
  -import org.apache.james.imapserver.store.ImapMailbox;
   import org.apache.james.imapserver.store.MailboxException;
   import org.apache.james.imapserver.store.SimpleImapMessage;
  -import org.apache.james.imapserver.store.MessageFlags;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.logger.ConsoleLogger;
  +import org.apache.mailet.User;
   
  -import javax.mail.search.SearchTerm;
  -import javax.mail.internet.MimeMessage;
  -import javax.mail.MessagingException;
   import java.util.ArrayList;
   import java.util.Collection;
  +import java.util.HashMap;
   import java.util.Iterator;
  -import java.util.StringTokenizer;
   import java.util.Map;
  -import java.util.HashMap;
  -import java.util.Date;
  +import java.util.StringTokenizer;
   
   /**
    * An initial implementation of an ImapHost. By default, uses,
  @@ -315,74 +310,6 @@
       {
           ImapMailbox mailbox = getMailbox( user, mailboxName, true );
           subscriptions.unsubscribe( user, mailbox );
  -    }
  -
  -    public int[] expunge( ImapMailbox mailbox )
  -            throws MailboxException
  -    {
  -        ArrayList deletedMessages = new ArrayList();
  -
  -        long[] uids = mailbox.getMessageUids();
  -        for ( int i = 0; i < uids.length; i++ ) {
  -            long uid = uids[i];
  -            SimpleImapMessage message = mailbox.getMessage( uid );
  -            if ( message.getFlags().isDeleted() ) {
  -                deletedMessages.add( message );
  -            }
  -        }
  -
  -        int[] ids = new int[ deletedMessages.size() ];
  -        for ( int i = 0; i < ids.length; i++ ) {
  -            SimpleImapMessage imapMessage = ( SimpleImapMessage ) deletedMessages.get( i );
  -            long uid = imapMessage.getUid();
  -            int msn = mailbox.getMsn( uid );
  -            ids[i] = msn;
  -            mailbox.deleteMessage( uid );
  -        }
  -
  -        return ids;
  -    }
  -
  -    public long[] search( SearchTerm searchTerm, ImapMailbox mailbox )
  -    {
  -        ArrayList matchedMessages = new ArrayList();
  -
  -        long[] allUids = mailbox.getMessageUids();
  -        for ( int i = 0; i < allUids.length; i++ ) {
  -            long uid = allUids[i];
  -            SimpleImapMessage message = mailbox.getMessage( uid );
  -            if ( searchTerm.match( message.getMimeMessage() ) ) {
  -                matchedMessages.add( message );
  -            }
  -        }
  -
  -        long[] matchedUids = new long[ matchedMessages.size() ];
  -        for ( int i = 0; i < matchedUids.length; i++ ) {
  -            SimpleImapMessage imapMessage = ( SimpleImapMessage ) matchedMessages.get( i );
  -            long uid = imapMessage.getUid();
  -            matchedUids[i] = uid;
  -        }
  -        return matchedUids;
  -    }
  -
  -    /** @see {@link ImapHost#copyMessage } */
  -    public void copyMessage( long uid, ImapMailbox currentMailbox, ImapMailbox toMailbox )
  -            throws MailboxException
  -    {
  -        SimpleImapMessage originalMessage = currentMailbox.getMessage( uid );
  -        MimeMessage newMime = null;
  -        try {
  -            newMime = new MimeMessage( originalMessage.getMimeMessage() );
  -        }
  -        catch ( MessagingException e ) {
  -            // TODO chain.
  -            throw new MailboxException( "Messaging exception: " + e.getMessage() );
  -        }
  -        MessageFlags newFlags = new MessageFlags();
  -        newFlags.setAll( originalMessage.getFlags() );
  -        Date newDate = originalMessage.getInternalDate();
  -
  -        toMailbox.createMessage( newMime, newFlags, newDate);
       }
   
       /**
  
  
  
  1.1                  james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSessionMailbox.java
  
  Index: ImapSessionMailbox.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache", "Jakarta", "JAMES" and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * Portions of this software are based upon public domain software
   * originally written at the National Center for Supercomputing Applications,
   * University of Illinois, Urbana-Champaign.
   */
  package org.apache.james.imapserver;
  
  import org.apache.james.imapserver.store.ImapMailbox;
  import org.apache.james.imapserver.store.MailboxListener;
  import org.apache.james.imapserver.store.MailboxException;
  import org.apache.james.imapserver.store.MessageFlags;
  import org.apache.james.imapserver.store.SimpleImapMessage;
  import org.apache.james.core.MailImpl;
  
  import javax.mail.search.SearchTerm;
  import javax.mail.internet.MimeMessage;
  import java.util.List;
  import java.util.Collections;
  import java.util.LinkedList;
  import java.util.Date;
  
  public class ImapSessionMailbox implements ImapMailbox, MailboxListener {
      private ImapMailbox _mailbox;
      private boolean _readonly;
      // TODO encapsulate
      public boolean _sizeChanged;
      private List _expungedMsns = Collections.synchronizedList(new LinkedList());
  
      public ImapSessionMailbox(ImapMailbox mailbox, boolean readonly) {
          _mailbox = mailbox;
          _readonly = readonly;
          // TODO make this a weak reference (or make sure deselect() is *always* called).
          _mailbox.addExpungeListener(this);
      }
  
      public void deselect() {
          _mailbox.removeExpungeListener(this);
          _mailbox = null;
      }
  
      public int getMsn( long uid ) throws MailboxException
      {
          long[] uids = _mailbox.getMessageUids();
          for (int i = 0; i < uids.length; i++) {
              long messageUid = uids[i];
              if (uid == messageUid) {
                  return i+1;
              }
          }
          throw new MailboxException( "No such message." );
      }
  
      public boolean isReadonly() {
          return _readonly;
      }
  
      public int[] getExpunged() {
          synchronized (_expungedMsns) {
              int[] expungedMsns = new int[_expungedMsns.size()];
              for (int i = 0; i < expungedMsns.length; i++) {
                  Integer msn = (Integer) _expungedMsns.get(i);
                  expungedMsns[i] = msn.intValue();
              }
              _expungedMsns.clear();
              return expungedMsns;
          }
      }
  
      public void expunged(long uid) throws MailboxException {
          synchronized (_expungedMsns) {
              int msn = getMsn(uid);
              _expungedMsns.add(new Integer(msn));
          }
      }
  
      public void added(long uid) {
          _sizeChanged = true;
      }
  
      public String getName() {
          return _mailbox.getName();
      }
  
      public String getFullName() {
          return _mailbox.getFullName();
      }
  
      public MessageFlags getAllowedFlags() {
          return _mailbox.getAllowedFlags();
      }
  
      public MessageFlags getPermanentFlags() {
          return _mailbox.getPermanentFlags();
      }
  
      public int getMessageCount() {
          return _mailbox.getMessageCount();
      }
  
      public int getRecentCount() {
          return _mailbox.getRecentCount();
      }
  
      public long getUidValidity() {
          return _mailbox.getUidValidity();
      }
  
      public long getFirstUnseen() {
          return _mailbox.getFirstUnseen();
      }
  
      public boolean isSelectable() {
          return _mailbox.isSelectable();
      }
  
      public long getUidNext() {
          return _mailbox.getUidNext();
      }
  
      public int getUnseenCount() {
          return _mailbox.getUnseenCount();
      }
  
      public SimpleImapMessage createMessage( MimeMessage message, MessageFlags flags, Date internalDate ) {
          return _mailbox.createMessage(message, flags, internalDate);
      }
  
      public void updateMessage( SimpleImapMessage message ) throws MailboxException {
          _mailbox.updateMessage(message);
      }
  
      public void store( MailImpl mail) throws Exception {
          _mailbox.store(mail);
      }
  
      public SimpleImapMessage getMessage( long uid ) {
          return _mailbox.getMessage(uid);
      }
  
      public long[] getMessageUids() {
          return _mailbox.getMessageUids();
      }
  
      public void deleteMessage( long uid ) {
          _mailbox.deleteMessage(uid);
      }
  
      public void expunge() throws MailboxException {
          _mailbox.expunge();
      }
  
      public long[] search( SearchTerm searchTerm ) {
          return _mailbox.search( searchTerm);
      }
  
      public void copyMessage(long uid, ImapMailbox toMailbox) throws MailboxException {
          _mailbox.copyMessage(uid, toMailbox);
      }
  
      public void addExpungeListener(MailboxListener listener) {
          _mailbox.addExpungeListener(listener);
      }
  
      public void removeExpungeListener(MailboxListener listener) {
          _mailbox.removeExpungeListener(listener);
      }
  
  }
  
  
  
  1.4       +3 -5      james-server/proposals/imap2/java/org/apache/james/imapserver/commands/CloseCommand.java
  
  Index: CloseCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/CloseCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CloseCommand.java	8 Mar 2003 21:13:55 -0000	1.3
  +++ CloseCommand.java	13 Jul 2003 06:04:56 -0000	1.4
  @@ -62,7 +62,6 @@
   import org.apache.james.imapserver.ImapResponse;
   import org.apache.james.imapserver.ImapSession;
   import org.apache.james.imapserver.ProtocolException;
  -import org.apache.james.imapserver.ImapHost;
   import org.apache.james.imapserver.store.ImapMailbox;
   import org.apache.james.imapserver.store.MailboxException;
   
  @@ -86,10 +85,9 @@
       {
           parser.endLine( request );
   
  -        if ( ! session.selectedIsReadOnly() ) {
  +        if ( ! session.getSelected().isReadonly() ) {
               ImapMailbox mailbox = session.getSelected();
  -            ImapHost host = session.getHost();
  -            host.expunge( mailbox );
  +            mailbox.expunge();
           }
           session.deselect();
   
  
  
  
  1.4       +4 -3      james-server/proposals/imap2/java/org/apache/james/imapserver/commands/CopyCommand.java
  
  Index: CopyCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/CopyCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CopyCommand.java	8 Mar 2003 21:13:55 -0000	1.3
  +++ CopyCommand.java	13 Jul 2003 06:04:56 -0000	1.4
  @@ -62,6 +62,7 @@
   import org.apache.james.imapserver.ImapResponse;
   import org.apache.james.imapserver.ImapSession;
   import org.apache.james.imapserver.ProtocolException;
  +import org.apache.james.imapserver.ImapSessionMailbox;
   import org.apache.james.imapserver.store.ImapMailbox;
   import org.apache.james.imapserver.store.MailboxException;
   import org.apache.james.imapserver.store.SimpleImapMessage;
  @@ -97,7 +98,7 @@
           String mailboxName = parser.mailbox( request );
           parser.endLine( request );
   
  -        ImapMailbox currentMailbox = session.getSelected();
  +        ImapSessionMailbox currentMailbox = session.getSelected();
           ImapMailbox toMailbox;
           try {
               toMailbox = getMailbox( mailboxName, session, true );
  @@ -120,7 +121,7 @@
               }
   
               if ( inSet ) {
  -                session.getHost().copyMessage( uid, currentMailbox, toMailbox );
  +                currentMailbox.copyMessage(uid, toMailbox);
               }
           }
   
  
  
  
  1.4       +3 -8      james-server/proposals/imap2/java/org/apache/james/imapserver/commands/ExpungeCommand.java
  
  Index: ExpungeCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/ExpungeCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExpungeCommand.java	8 Mar 2003 21:13:55 -0000	1.3
  +++ ExpungeCommand.java	13 Jul 2003 06:04:56 -0000	1.4
  @@ -86,17 +86,12 @@
       {
           parser.endLine( request );
   
  -        if ( session.selectedIsReadOnly() ) {
  +        if (session.getSelected().isReadonly()) {
               response.commandFailed( this, "Mailbox selected read only." );
           }
   
           ImapMailbox mailbox = session.getSelected();
  -        ImapHost host = session.getHost();
  -        int[] msns = host.expunge( mailbox );
  -        for ( int i = 0; i < msns.length; i++ ) {
  -            int msn = msns[i];
  -            response.expungeResponse( msn );
  -        }
  +        mailbox.expunge();
   
           session.unsolicitedResponses( response );
           response.commandComplete( this );
  
  
  
  1.4       +22 -5     james-server/proposals/imap2/java/org/apache/james/imapserver/commands/FetchCommand.java
  
  Index: FetchCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/FetchCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FetchCommand.java	8 Mar 2003 21:13:55 -0000	1.3
  +++ FetchCommand.java	13 Jul 2003 06:04:56 -0000	1.4
  @@ -58,16 +58,15 @@
   
   package org.apache.james.imapserver.commands;
   
  -import org.apache.excalibur.util.StringUtil;
   import org.apache.james.core.MimeMessageWrapper;
   import org.apache.james.imapserver.ImapRequestLineReader;
   import org.apache.james.imapserver.ImapResponse;
   import org.apache.james.imapserver.ImapSession;
   import org.apache.james.imapserver.ProtocolException;
  +import org.apache.james.imapserver.store.ImapMailbox;
   import org.apache.james.imapserver.store.MailboxException;
   import org.apache.james.imapserver.store.MessageFlags;
   import org.apache.james.imapserver.store.SimpleImapMessage;
  -import org.apache.james.imapserver.store.ImapMailbox;
   
   import javax.mail.MessagingException;
   import javax.mail.internet.MimeMessage;
  @@ -78,7 +77,6 @@
   import java.util.Enumeration;
   import java.util.Iterator;
   import java.util.List;
  -import java.util.Collection;
   
   /**
    * Handles processeing for the FETCH imap command.
  @@ -125,6 +123,10 @@
                   SimpleImapMessage imapMessage = mailbox.getMessage( uid );
                   String msgData = outputMessage( fetch, imapMessage );
                   response.fetchResponse( msn, msgData );
  +                if (imapMessage.getFlags().isRecent()) {
  +                    imapMessage.getFlags().setRecent(false);
  +                    mailbox.updateMessage(imapMessage);
  +                }
               }
           }
   
  @@ -292,8 +294,23 @@
       {
           // Remove the trailing and leading ')('
           String tmp = headerList.substring( prefixLen + 1, headerList.length() - 1 );
  -        String[] headerNames = StringUtil.split( tmp, " " );
  +        String[] headerNames = split( tmp, " " );
           return headerNames;
  +    }
  +    
  +    private String[] split(String value, String delimiter) {
  +        ArrayList strings = new ArrayList();
  +        int startPos = 0;
  +        int delimPos;
  +        while ( (delimPos = value.indexOf(delimiter, startPos) ) != -1) {
  +            String sub = value.substring(startPos, delimPos);
  +            strings.add(sub);
  +            startPos = delimPos + 1;
  +        }
  +        String sub = value.substring(startPos);
  +        strings.add(sub);
  +        
  +        return (String[]) strings.toArray(new String[0]);
       }
   
       private void addHeaders( Enumeration enum, StringBuffer response )
  
  
  
  1.4       +2 -2      james-server/proposals/imap2/java/org/apache/james/imapserver/commands/SearchCommand.java
  
  Index: SearchCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/SearchCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SearchCommand.java	8 Mar 2003 21:13:55 -0000	1.3
  +++ SearchCommand.java	13 Jul 2003 06:04:56 -0000	1.4
  @@ -102,7 +102,7 @@
           parser.endLine( request );
   
           ImapMailbox mailbox = session.getSelected();
  -        long[] uids = session.getHost().search( searchTerm, mailbox );
  +        long[] uids = mailbox.search( searchTerm);
           StringBuffer idList = new StringBuffer();
           for ( int i = 0; i < uids.length; i++ ) {
               if ( i > 0 ) {
  
  
  
  1.7       +21 -13    james-server/proposals/imap2/java/org/apache/james/imapserver/commands/SelectCommand.java
  
  Index: SelectCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/SelectCommand.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SelectCommand.java	8 Mar 2003 21:13:55 -0000	1.6
  +++ SelectCommand.java	13 Jul 2003 06:04:56 -0000	1.7
  @@ -64,6 +64,7 @@
   import org.apache.james.imapserver.ImapSession;
   import org.apache.james.imapserver.store.MailboxException;
   import org.apache.james.imapserver.ProtocolException;
  +import org.apache.james.imapserver.ImapSessionMailbox;
   
   /**
    * Handles processeing for the SELECT imap command.
  @@ -88,22 +89,16 @@
   
           session.deselect();
   
  -        ImapMailbox mailbox = getMailbox( mailboxName, session, true );
  -
  -        if ( !mailbox.isSelectable() ) {
  -            throw new MailboxException( "Nonselectable mailbox." );
  -        }
  -
  -        boolean readOnly = ( this instanceof ExamineCommand );
  -        session.setSelected( mailbox, readOnly );
  +        selectMailbox(mailboxName, session);
   
  +        ImapSessionMailbox mailbox = session.getSelected();
           response.flagsResponse( mailbox.getAllowedFlags() );
           response.existsResponse( mailbox.getMessageCount() );
           response.recentResponse( mailbox.getRecentCount() );
           response.okResponse( "UIDVALIDITY " + mailbox.getUidValidity(), null );
   
  -        int firstUnseen = mailbox.getFirstUnseen();
  -        if ( firstUnseen != 0 ) {
  +        long firstUnseen = mailbox.getFirstUnseen();
  +        if ( firstUnseen > 0 ) {
               int msnUnseen = mailbox.getMsn( firstUnseen );
               response.okResponse( "UNSEEN " + msnUnseen,
                                    "Message " + msnUnseen + " is the first unseen" );
  @@ -111,14 +106,27 @@
           else {
               response.okResponse( null, "No messages unseen" );
           }
  +        
  +        response.permanentFlagsResponse(mailbox.getAllowedFlags());
   
  -
  -        if ( readOnly ) {
  +        if ( mailbox.isReadonly() ) {
               response.commandComplete( this, "READ-ONLY" );
           }
           else {
               response.commandComplete( this, "READ-WRITE" );
           }
  +    }
  +
  +    private boolean selectMailbox(String mailboxName, ImapSession session) throws MailboxException {
  +        ImapMailbox mailbox = getMailbox( mailboxName, session, true );
  +
  +        if ( !mailbox.isSelectable() ) {
  +            throw new MailboxException( "Nonselectable mailbox." );
  +        }
  +
  +        boolean readOnly = ( this instanceof ExamineCommand );
  +        session.setSelected( mailbox, readOnly );
  +        return readOnly;
       }
   
       /** @see ImapCommand#getName */
  
  
  
  1.8       +16 -2     james-server/proposals/imap2/java/org/apache/james/imapserver/store/ImapMailbox.java
  
  Index: ImapMailbox.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/store/ImapMailbox.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ImapMailbox.java	8 Mar 2003 21:13:56 -0000	1.7
  +++ ImapMailbox.java	13 Jul 2003 06:04:56 -0000	1.8
  @@ -84,6 +84,8 @@
       String getFullName();
   
       MessageFlags getAllowedFlags();
  +    
  +    MessageFlags getPermanentFlags();
   
       int getMessageCount();
   
  @@ -91,7 +93,7 @@
   
       long getUidValidity();
   
  -    int getFirstUnseen();
  +    long getFirstUnseen();
   
       int getMsn( long uid ) throws MailboxException;
   
  @@ -112,4 +114,16 @@
       long[] getMessageUids();
   
       void deleteMessage( long uid );
  +    
  +    void expunge() throws MailboxException;
  +
  +    void addExpungeListener(MailboxListener listener);
  +
  +    void removeExpungeListener(MailboxListener listener);
  +
  +    long[] search(SearchTerm searchTerm);
  +
  +    void copyMessage( long uid, ImapMailbox toMailbox )
  +            throws MailboxException;
  +
   }
  
  
  
  1.7       +117 -10   james-server/proposals/imap2/java/org/apache/james/imapserver/store/InMemoryStore.java
  
  Index: InMemoryStore.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/store/InMemoryStore.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InMemoryStore.java	8 Mar 2003 21:13:56 -0000	1.6
  +++ InMemoryStore.java	13 Jul 2003 06:04:56 -0000	1.7
  @@ -58,15 +58,13 @@
   
   package org.apache.james.imapserver.store;
   
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.james.core.MailImpl;
   import org.apache.james.imapserver.ImapConstants;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.logger.LogKitLogger;
  -import org.apache.avalon.framework.logger.ConsoleLogger;
  -import org.apache.log.Logger;
   
   import javax.mail.internet.MimeMessage;
   import javax.mail.search.SearchTerm;
  +import javax.mail.MessagingException;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Collections;
  @@ -75,6 +73,8 @@
   import java.util.Map;
   import java.util.StringTokenizer;
   import java.util.TreeMap;
  +import java.util.List;
  +import java.util.LinkedList;
   
   /**
    * A simple in-memory implementation of {@link ImapStore}, used for testing
  @@ -250,9 +250,11 @@
           private boolean isSelectable = false;
   
           private Map mailMessages = new TreeMap();
  -        private long nextUid = 10;
  +        private long nextUid = 1;
           private long uidValidity;
   
  +        private List _mailboxListeners = new LinkedList();
  +
           public HierarchicalMailbox( HierarchicalMailbox parent,
                                       String name )
           {
  @@ -304,6 +306,10 @@
               return mailboxFlags;
           }
   
  +        public MessageFlags getPermanentFlags() {
  +            return getAllowedFlags();
  +        }
  +
           public int getMessageCount()
           {
               return mailMessages.size();
  @@ -321,12 +327,27 @@
   
           public int getUnseenCount()
           {
  -            return 0;
  +            int count = 0;
  +            Iterator iter = mailMessages.values().iterator();
  +            while (iter.hasNext()) {
  +                SimpleImapMessage message = (SimpleImapMessage) iter.next();
  +                if (! message.getFlags().isSeen()) {
  +                    count++;
  +                }
  +            }
  +            return count;
           }
   
  -        public int getFirstUnseen()
  +        public long getFirstUnseen()
           {
  -            return 0;
  +            Iterator iter = mailMessages.values().iterator();
  +            while (iter.hasNext()) {
  +                SimpleImapMessage message = (SimpleImapMessage) iter.next();
  +                if (! message.getFlags().isSeen()) {
  +                    return message.getUid();
  +                }
  +            }
  +            return -1;
           }
   
           public int getRecentCount()
  @@ -362,13 +383,23 @@
                                             Date internalDate )
           {
               long uid = nextUid;
  -            nextUid+=10;
  +            nextUid++;
   
  +//            flags.setRecent(true);
               SimpleImapMessage imapMessage = new SimpleImapMessage( message, flags,
                                                          internalDate, uid );
               setupLogger( imapMessage );
   
               mailMessages.put( new Long( uid ), imapMessage );
  +            
  +            // Notify all the listeners of the pending delete
  +            synchronized (_mailboxListeners) {
  +                for (int j = 0; j < _mailboxListeners.size(); j++) {
  +                    MailboxListener listener = (MailboxListener) _mailboxListeners.get(j);
  +                    listener.added(uid);
  +                }
  +            }
  +            
               return imapMessage;
           }
   
  @@ -414,5 +445,81 @@
               mailMessages.remove( new Long( uid ) );
           }
   
  +        public long[] search(SearchTerm searchTerm) {
  +            ArrayList matchedMessages = new ArrayList();
  +
  +            long[] allUids = getMessageUids();
  +            for ( int i = 0; i < allUids.length; i++ ) {
  +                long uid = allUids[i];
  +                SimpleImapMessage message = getMessage( uid );
  +                if ( searchTerm.match( message.getMimeMessage() ) ) {
  +                    matchedMessages.add( message );
  +                }
  +            }
  +
  +            long[] matchedUids = new long[ matchedMessages.size() ];
  +            for ( int i = 0; i < matchedUids.length; i++ ) {
  +                SimpleImapMessage imapMessage = ( SimpleImapMessage ) matchedMessages.get( i );
  +                long uid = imapMessage.getUid();
  +                matchedUids[i] = uid;
  +            }
  +            return matchedUids;
  +        }
  +
  +        public void copyMessage( long uid, ImapMailbox toMailbox )
  +                throws MailboxException
  +        {
  +            SimpleImapMessage originalMessage = getMessage( uid );
  +            MimeMessage newMime = null;
  +            try {
  +                newMime = new MimeMessage( originalMessage.getMimeMessage() );
  +            }
  +            catch ( MessagingException e ) {
  +                // TODO chain.
  +                throw new MailboxException( "Messaging exception: " + e.getMessage() );
  +            }
  +            MessageFlags newFlags = new MessageFlags();
  +            newFlags.setAll( originalMessage.getFlags() );
  +            Date newDate = originalMessage.getInternalDate();
  +
  +            toMailbox.createMessage( newMime, newFlags, newDate);
  +        }
  +
  +        public void expunge() throws MailboxException {
  +
  +            long[] allUids = getMessageUids();
  +            for (int i = 0; i < allUids.length; i++) {
  +                long uid = allUids[i];
  +                SimpleImapMessage message = getMessage(uid);
  +                if (message.getFlags().isDeleted()) {
  +                    expungeMessage(uid);
  +
  +                }
  +            }
  +        }
  +
  +        private void expungeMessage(long uid) throws MailboxException {
  +            // Notify all the listeners of the pending delete
  +            synchronized (_mailboxListeners) {
  +                for (int j = 0; j < _mailboxListeners.size(); j++) {
  +                    MailboxListener expungeListener = (MailboxListener) _mailboxListeners.get(j);
  +                    expungeListener.expunged(uid);
  +                }
  +            }
  +
  +            deleteMessage(uid);
  +        }
  +
  +        public void addExpungeListener(MailboxListener listener) {
  +            synchronized(_mailboxListeners) {
  +                _mailboxListeners.add(listener);
  +            }
  +        }
  +
  +        public void removeExpungeListener(MailboxListener listener) {
  +            synchronized (_mailboxListeners) {
  +                _mailboxListeners.remove(listener);
  +            }
  +        }
       }
   }
  
  
  
  1.1                  james-server/proposals/imap2/java/org/apache/james/imapserver/store/MailboxListener.java
  
  Index: MailboxListener.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache", "Jakarta", "JAMES" and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * Portions of this software are based upon public domain software
   * originally written at the National Center for Supercomputing Applications,
   * University of Illinois, Urbana-Champaign.
   */
  package org.apache.james.imapserver.store;
  
  public interface MailboxListener {
      // TODO shouldn't have exceptions here
      void expunged(long uid) throws MailboxException;
      
      void added(long uid);
  }
  
  
  1.2       +31 -7     james-server/proposals/imap2/test/org/apache/james/imapserver/AppendExpunge.test
  
  Index: AppendExpunge.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/AppendExpunge.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AppendExpunge.test	3 Dec 2002 14:00:13 -0000	1.1
  +++ AppendExpunge.test	13 Jul 2003 06:04:57 -0000	1.2
  @@ -5,7 +5,7 @@
   S: \* STATUS appendexpunge \(MESSAGES 0\)
   S: a001 OK STATUS completed
   
  -C: A003 APPEND appendexpunge (\Deleted) {310+}
  +C: A002 APPEND appendexpunge (\Deleted) {310+}
   C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
   C: From: Fred Foobar <foobar@Blurdybloop.COM>
   C: Subject: afternoon meeting
  @@ -16,9 +16,9 @@
   C:
   C: Hello Joe, do you think we can meet at 3:30 tomorrow?
   C:
  -S: A003 OK APPEND completed
  +S: A002 OK APPEND completed
   
  -C: A003 APPEND appendexpunge (\Deleted) {310+}
  +C: A003 APPEND appendexpunge {310+}
   C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
   C: From: Fred Foobar <foobar@Blurdybloop.COM>
   C: Subject: afternoon meeting 2
  @@ -31,21 +31,45 @@
   C:
   S: A003 OK APPEND completed
   
  +C: A004 APPEND appendexpunge (\Deleted) {310+}
  +C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  +C: From: Fred Foobar <foobar@Blurdybloop.COM>
  +C: Subject: afternoon meeting 2
  +C: To: mooch@owatagu.siam.edu
  +C: Message-Id: <B27397-0100000@Blurdybloop.COM>
  +C: MIME-Version: 1.0
  +C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  +C:
  +C: Hello Joe, could we change that to 4:30pm tomorrow?
  +C:
  +S: A004 OK APPEND completed
  +
   C: a1 STATUS appendexpunge (MESSAGES)
  -S: \* STATUS appendexpunge \(MESSAGES 2\)
  +S: \* STATUS appendexpunge \(MESSAGES 3\)
   S: a1 OK STATUS completed
   
   C: a1 SELECT appendexpunge
   S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  -S: \* 2 EXISTS
  +S: \* 3 EXISTS
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
  -S: \* OK No messages unseen
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: a1 OK \[READ-WRITE\] SELECT completed
   
   C: a1 EXPUNGE
   S: \* 1 EXPUNGE
  +S: \* 2 EXPUNGE
  +S: a1 OK EXPUNGE completed
  +
  +C: a1 STATUS appendexpunge (MESSAGES)
  +S: \* STATUS appendexpunge \(MESSAGES 1\)
  +S: a1 OK STATUS completed
  +
  +C: f2 STORE 1 FLAGS.SILENT (\Deleted)
  +S: f2 OK STORE completed
  +
  +C: a1 EXPUNGE
   S: \* 1 EXPUNGE
   S: a1 OK EXPUNGE completed
   
  
  
  
  1.3       +2 -2      james-server/proposals/imap2/test/org/apache/james/imapserver/Copy.test
  
  Index: Copy.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/Copy.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Copy.test	4 Dec 2002 06:06:45 -0000	1.2
  +++ Copy.test	13 Jul 2003 06:04:57 -0000	1.3
  @@ -29,8 +29,8 @@
   S: \* 3 EXISTS
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
  -S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: (\* OK \[UNSEEN \d+\] Message \d+ is the first unseen)|(\* OK No messages unseen)
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: a1 OK \[READ-WRITE\] SELECT completed
   
   C: a1 FETCH 1:4 (FLAGS)
  
  
  
  1.3       +3 -3      james-server/proposals/imap2/test/org/apache/james/imapserver/ExamineEmpty.test
  
  Index: ExamineEmpty.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/ExamineEmpty.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExamineEmpty.test	3 Dec 2002 14:00:13 -0000	1.2
  +++ ExamineEmpty.test	13 Jul 2003 06:04:57 -0000	1.3
  @@ -14,7 +14,7 @@
   S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK No messages unseen
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-ONLY\] EXAMINE completed
   
   C: abcd EXAMINE test.subfolder
  @@ -23,7 +23,7 @@
   S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK No messages unseen
  -#S: * OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-ONLY\] EXAMINE completed
   
   C: abcd EXAMINE test1
  @@ -32,7 +32,7 @@
   S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK No messages unseen
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-ONLY\] EXAMINE completed
   
   C: abcd EXAMINE subfolder1
  
  
  
  1.2       +2 -2      james-server/proposals/imap2/test/org/apache/james/imapserver/ExamineInbox.test
  
  Index: ExamineInbox.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/ExamineInbox.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExamineInbox.test	22 Nov 2002 02:09:52 -0000	1.1
  +++ ExamineInbox.test	13 Jul 2003 06:04:57 -0000	1.2
  @@ -4,7 +4,7 @@
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-ONLY\] EXAMINE completed
   
   # Try again to ensure that no changes to flags were made.
  @@ -14,5 +14,5 @@
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-ONLY\] EXAMINE completed
  
  
  
  1.2       +14 -14    james-server/proposals/imap2/test/org/apache/james/imapserver/FetchMultipleMessages.test
  
  Index: FetchMultipleMessages.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/FetchMultipleMessages.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FetchMultipleMessages.test	22 Nov 2002 02:09:52 -0000	1.1
  +++ FetchMultipleMessages.test	13 Jul 2003 06:04:57 -0000	1.2
  @@ -1,22 +1,22 @@
  -// Fetch 3 messages with UID
  +# Fetch 3 messages with UID
   C: f1 FETCH 1:3 (UID)
  -S: * 1 FETCH (UID ${ignore})
  -S: * 2 FETCH (UID ${ignore})
  -S: * 3 FETCH (UID ${ignore})
  +S: \* 1 FETCH \(UID .*\)
  +S: \* 2 FETCH \(UID .*\)
  +S: \* 3 FETCH \(UID .*\)
   S: f1 OK FETCH completed
   
  -// Fetch 3 messages with BODY
  +# Fetch 3 messages with BODY
   C: f1 FETCH 1:3 (BODY[HEADER.FIELDS (Subject)])
  -S: * 1 FETCH (BODY[HEADER.FIELDS (Subject)] {22}
  -S: Subject: Message 1
  +S: \* 1 FETCH \(BODY\[HEADER\.FIELDS \(Subject\)\] \{20\}
  +S: Subject\: Test 01
   S: 
  -S: )
  -S: * 2 FETCH (BODY[HEADER.FIELDS (Subject)] {22}
  -S: Subject: Message 2
  +S: \)
  +S: \* 2 FETCH \(BODY\[HEADER\.FIELDS \(Subject\)\] \{20\}
  +S: Subject\: Test 02
   S: 
  -S: )
  -S: * 3 FETCH (BODY[HEADER.FIELDS (Subject)] {22}
  -S: Subject: Message 3
  +S: \)
  +S: \* 3 FETCH \(BODY\[HEADER\.FIELDS \(Subject\)\] \{20\}
  +S: Subject\: Test 03
   S: 
  -S: )
  +S: \)
   S: f1 OK FETCH completed
  
  
  
  1.3       +3 -3      james-server/proposals/imap2/test/org/apache/james/imapserver/SelectEmpty.test
  
  Index: SelectEmpty.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectEmpty.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SelectEmpty.test	3 Dec 2002 14:00:13 -0000	1.2
  +++ SelectEmpty.test	13 Jul 2003 06:04:57 -0000	1.3
  @@ -14,7 +14,7 @@
   S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK No messages unseen
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-WRITE\] SELECT completed
   
   C: abcd SELECT test.subfolder
  @@ -25,7 +25,7 @@
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK No messages unseen
   }
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-WRITE\] SELECT completed
   
   C: abcd SELECT test1
  @@ -34,7 +34,7 @@
   S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK No messages unseen
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-WRITE\] SELECT completed
   
   C: abcd SELECT subfolder1
  
  
  
  1.2       +3 -3      james-server/proposals/imap2/test/org/apache/james/imapserver/SelectInbox.test
  
  Index: SelectInbox.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectInbox.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectInbox.test	22 Nov 2002 02:09:52 -0000	1.1
  +++ SelectInbox.test	13 Jul 2003 06:04:57 -0000	1.2
  @@ -4,7 +4,7 @@
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-WRITE\] SELECT completed
   
   # Try again to ensure that no changes to flags were made.
  @@ -14,5 +14,5 @@
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  -S: abcd OK \[READ-WRITE\] SELECT completed
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  +S: abcd OK \[READ-WRITE\] SELECT completed
  \ No newline at end of file
  
  
  
  1.2       +1 -1      james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateCleanup.test
  
  Index: SelectedStateCleanup.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateCleanup.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectedStateCleanup.test	3 Dec 2002 14:00:13 -0000	1.1
  +++ SelectedStateCleanup.test	13 Jul 2003 06:04:57 -0000	1.2
  @@ -4,7 +4,7 @@
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-WRITE\] SELECT completed
   
   C: a1 DELETE selected
  
  
  
  1.2       +3 -3      james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateSetup.test
  
  Index: SelectedStateSetup.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateSetup.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectedStateSetup.test	3 Dec 2002 14:00:13 -0000	1.1
  +++ SelectedStateSetup.test	13 Jul 2003 06:04:57 -0000	1.2
  @@ -56,9 +56,9 @@
   C: a1 SELECT selected
   S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
   S: \* 4 EXISTS
  -S: \* \d+ RECENT
  +S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
  -S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -#S: \* OK \[PERMANENTFLAGS \(\)\]
  +S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: a1 OK \[READ-WRITE\] SELECT completed
   
  
  
  
  1.4       +2 -1      james-server/proposals/imap2/test/org/apache/james/imapserver/TestCompound.java
  
  Index: TestCompound.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/TestCompound.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestCompound.java	8 Mar 2003 21:13:57 -0000	1.3
  +++ TestCompound.java	13 Jul 2003 06:04:57 -0000	1.4
  @@ -82,6 +82,7 @@
       {
           TestSuite suite = new TestSuite();
           suite.addTest( new TestCommandsInAuthenticatedState( "AppendExpunge" ) );
  +        suite.addTest( new TestCommandsInAuthenticatedState( "SelectAppend" ) );
           suite.addTest( new TestCommandsInAuthenticatedState( "StringArgs" ) );
           // TODO various mailbox names (eg with spaces...)
           return suite;
  
  
  
  1.4       +1 -1      james-server/proposals/imap2/test/org/apache/james/imapserver/TestSelectedCommandsInSelectedState.java
  
  Index: TestSelectedCommandsInSelectedState.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/TestSelectedCommandsInSelectedState.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestSelectedCommandsInSelectedState.java	8 Mar 2003 21:13:57 -0000	1.3
  +++ TestSelectedCommandsInSelectedState.java	13 Jul 2003 06:04:57 -0000	1.4
  @@ -98,7 +98,7 @@
           suite.addTest( new TestSelectedCommandsInSelectedState( "Expunge" ) );
           suite.addTest( new TestSelectedCommandsInSelectedState( "Search" ) );
           suite.addTest( new TestSelectedCommandsInSelectedState( "FetchSingleMessage" ) );
  -//        suite.addTest( new TestSelectedCommandsInSelectedState( "FetchMultipleMessages" ) );
  +        suite.addTest( new TestSelectedCommandsInSelectedState( "FetchMultipleMessages" ) );
           suite.addTest( new TestSelectedCommandsInSelectedState( "Store" ) );
           suite.addTest( new TestSelectedCommandsInSelectedState( "Copy" ) );
           suite.addTest( new TestSelectedCommandsInSelectedState( "Uid" ) );
  
  
  
  1.2       +15 -15    james-server/proposals/imap2/test/org/apache/james/imapserver/Uid.test
  
  Index: Uid.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/Uid.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Uid.test	3 Dec 2002 14:00:13 -0000	1.1
  +++ Uid.test	13 Jul 2003 06:04:57 -0000	1.2
  @@ -1,46 +1,46 @@
   #Regular fetch
   C: a FETCH 1:10 (UID)
  -S: \* 1 FETCH \(UID 10\)
  -S: \* 2 FETCH \(UID 20\)
  -S: \* 3 FETCH \(UID 30\)
  -S: \* 4 FETCH \(UID 40\)
  +S: \* 1 FETCH \(UID 1\)
  +S: \* 2 FETCH \(UID 2\)
  +S: \* 3 FETCH \(UID 3\)
  +S: \* 4 FETCH \(UID 4\)
   S: a OK FETCH completed
   
   #UID fetch
  -C: a UID FETCH 1:20 (UID)
  -S: \* 1 FETCH \(UID 10\)
  -S: \* 2 FETCH \(UID 20\)
  +C: a UID FETCH 1:3 (UID)
  +S: \* 1 FETCH \(UID 1\)
  +S: \* 2 FETCH \(UID 2\)
  +S: \* 3 FETCH \(UID 3\)
   S: a OK FETCH completed
   
   #UID store
  -C: a UID STORE 15:35 +FLAGS (\Deleted)
  +C: a UID STORE 2:3 +FLAGS (\Deleted)
   S: \* 2 FETCH \(FLAGS \(\\Deleted\)\)
   S: \* 3 FETCH \(FLAGS \(\\Deleted\)\)
   S: a OK STORE completed
   
   # Regular fetch
   C: a FETCH 1:100 (FLAGS UID)
  -S: \* 1 FETCH \(FLAGS \(\) UID 10\)
  -S: \* 2 FETCH \(FLAGS \(\\Deleted\) UID 20\)
  -S: \* 3 FETCH \(FLAGS \(\\Deleted\) UID 30\)
  -S: \* 4 FETCH \(FLAGS \(\) UID 40\)
  +S: \* 1 FETCH \(FLAGS \(\) UID 1\)
  +S: \* 2 FETCH \(FLAGS \(\\Deleted\) UID 2\)
  +S: \* 3 FETCH \(FLAGS \(\\Deleted\) UID 3\)
  +S: \* 4 FETCH \(FLAGS \(\) UID 4\)
   S: a OK FETCH completed
   
   # CREATE and do a UID COPY
   C: a CREATE copied
   S: a OK CREATE completed
   
  -C: a UID COPY 20 copied
  +C: a UID COPY 2 copied
   S: a OK COPY completed
   
   C: a STATUS copied (MESSAGES)
   S: \* STATUS copied \(MESSAGES 1\)
   S: a OK STATUS completed
   
  -
   # Do a UID SEARCH
   C: a UID SEARCH FLAGGED
  -S: \* SEARCH 10 20 30 40
  +S: \* SEARCH 1 2 3 4
   S: a OK SEARCH completed
   
   # Cleanup
  
  
  
  1.1                  james-server/proposals/imap2/test/org/apache/james/imapserver/SelectAppend.test
  
  Index: SelectAppend.test
  ===================================================================
  C: 10 CREATE selectappend
  S: 10 OK CREATE completed
  
  C: 10 SELECT selectappend
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 0 EXISTS
  S: \* \d+ RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: \* OK No messages unseen
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: 10 OK \[READ-WRITE\] SELECT completed
  
  C: A003 APPEND selectappend {310}
  # Use command continuation request
  S: \+
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <foobar@Blurdybloop.COM>
  C: Subject: afternoon meeting 2
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B27397-0100000@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Hello Joe, could we change that to 4:00pm tomorrow?
  C:
  S: \* 1 EXISTS
  S: A003 OK APPEND completed
  
  C: A003 APPEND selectappend {310}
  # Use command continuation request
  S: \+
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <foobar@Blurdybloop.COM>
  C: Subject: afternoon meeting 2
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B27397-0100000@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Hello Joe, could we change that to 4:00pm tomorrow?
  C:
  S: \* 2 EXISTS
  S: A003 OK APPEND completed
  
  C: a1 DELETE selectappend
  S: a1 OK DELETE completed
  
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message