Author: norman
Date: Tue Dec 27 20:26:59 2011
New Revision: 1225003
URL: http://svn.apache.org/viewvc?rev=1225003&view=rev
Log:
Add missing methods to IMAPSession and start to implment a custom
ImapRequestLineReader. See PROTOCOLS-73
Added:
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequestLineReader.java
(with props)
Modified:
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPSession.java
Added:
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequestLineReader.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequestLineReader.java?rev=1225003&view=auto
==============================================================================
---
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequestLineReader.java
(added)
+++
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequestLineReader.java
Tue Dec 27 20:26:59 2011
@@ -0,0 +1,85 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.protocols.imap;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.decode.DecodingException;
+import org.apache.james.imap.decode.ImapRequestLineReader;
+import org.apache.james.imap.decode.base.EolInputStream;
+import org.apache.james.imap.decode.base.FixedLengthInputStream;
+
+public class IMAPRequestLineReader extends ImapRequestLineReader{
+
+ private final Iterator<ByteBuffer> args;
+ private final byte[] prefix;
+ private int pos = 0;
+ private ByteBuffer curBuf;
+
+ public IMAPRequestLineReader(IMAPRequest request) throws
UnsupportedEncodingException {
+ this.args = request.getArguments();
+ prefix = (request.getTag() + " " + request.getCommand() + "
").getBytes("US-ASCII");
+ }
+
+ @Override
+ public char nextChar() throws DecodingException {
+ if (pos >= prefix.length) {
+ if (curBuf == null || curBuf.remaining() == 0) {
+ if (args.hasNext()) {
+ curBuf = args.next();
+ } else {
+ throw new
DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Unexpected end of
stream.");
+ }
+ }
+ return (char) curBuf.get();
+ }
+ return (char) prefix[pos++];
+ }
+
+ @Override
+ public InputStream read(int size, boolean extraCRLF) throws
DecodingException {
+ // Unset the next char.
+ nextSeen = false;
+ nextChar = 0;
+ FixedLengthInputStream in = new FixedLengthInputStream(new
InputStream() {
+
+ @Override
+ public int read() throws IOException {
+ return consume();
+ }
+ }, size);
+ if (extraCRLF) {
+ return new EolInputStream(this, in);
+ } else {
+ return in;
+ }
+ }
+
+ @Override
+ protected void commandContinuationRequest() throws DecodingException {
+ // TODO FIX ME!
+
+ }
+
+}
Propchange:
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequestLineReader.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPSession.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPSession.java?rev=1225003&r1=1225002&r2=1225003&view=diff
==============================================================================
---
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPSession.java
(original)
+++
james/protocols/trunk/imap/src/main/java/org/apache/james/protocols/imap/IMAPSession.java
Tue Dec 27 20:26:59 2011
@@ -18,6 +18,8 @@
****************************************************************/
package org.apache.james.protocols.imap;
+import org.apache.james.imap.api.ImapSessionState;
+import org.apache.james.imap.api.process.SelectedMailbox;
import org.apache.james.protocols.api.ProtocolSession;
import org.apache.james.protocols.api.handler.LineHandler;
@@ -39,4 +41,82 @@ public interface IMAPSession extends Pro
* @return size of the pushed line handler
*/
int getPushedLineHandlerCount();
+
+ /**
+ * Logs out the session. Marks the connection for closure;
+ */
+ void logout();
+
+ /**
+ * Gets the current client state.
+ *
+ * @return Returns the current state of this session.
+ */
+ ImapSessionState getSessionState();
+
+ /**
+ * Moves the session into {@link ImapSessionState#AUTHENTICATED} state.
+ */
+ void authenticated();
+
+ /**
+ * Moves this session into {@link ImapSessionState#SELECTED} state and sets
+ * the supplied mailbox to be the currently selected mailbox.
+ *
+ * @param mailbox
+ * The selected mailbox.
+ */
+ void selected(SelectedMailbox mailbox);
+
+ /**
+ * Moves the session out of {@link ImapSessionState#SELECTED} state and
back
+ * into {@link ImapSessionState#AUTHENTICATED} state. The selected mailbox
+ * is cleared.
+ */
+ void deselect();
+
+ /**
+ * Provides the selected mailbox for this session, or <code>null</code> if
+ * this session is not in {@link ImapSessionState#SELECTED} state.
+ *
+ * @return the currently selected mailbox.
+ */
+ SelectedMailbox getSelected();
+
+ /**
+ * Return true if compression is active
+ *
+ * @return compActive
+ */
+ public boolean isCompressionActive();
+
+ /**
+ * Return true if compression is supported. This is related to COMPRESS
extension.
+ * See http://www.ietf.org/rfc/rfc4978.txt
+ *
+ * @return compressSupport
+ */
+ public boolean isCompressionSupported();
+
+ /**
+ * Start the compression
+ *
+ * @return success
+ */
+ public boolean startCompression();
+
+ /**
+ * Return true if multiple namespaces are supported
+ *
+ * @return multipleNamespaces
+ */
+ public boolean supportMultipleNamespaces();
+
+ /**
+ * Return true if the login / authentication via plain username / password
is
+ * disallowed
+ *
+ * @return plainDisallowed
+ */
+ public boolean isPlainAuthDisallowed();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]