mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 03:02:22 -05:00
IMAP: improve error handling and support optional append date parameter
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@322 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
5e0a589542
commit
4b1f7b9cbb
@ -14,6 +14,7 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.net.SocketException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@ -37,6 +38,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
String line;
|
String line;
|
||||||
|
String commandId = null;
|
||||||
StringTokenizer tokens;
|
StringTokenizer tokens;
|
||||||
try {
|
try {
|
||||||
sendClient("* OK [CAPABILITY IMAP4REV1 AUTH=LOGIN] IMAP4rev1 DavMail server ready");
|
sendClient("* OK [CAPABILITY IMAP4REV1 AUTH=LOGIN] IMAP4rev1 DavMail server ready");
|
||||||
@ -63,7 +65,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (tokens.hasMoreTokens()) {
|
if (tokens.hasMoreTokens()) {
|
||||||
String commandId = tokens.nextToken();
|
commandId = tokens.nextToken();
|
||||||
if (tokens.hasMoreTokens()) {
|
if (tokens.hasMoreTokens()) {
|
||||||
String command = tokens.nextToken();
|
String command = tokens.nextToken();
|
||||||
|
|
||||||
@ -383,8 +385,14 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
} else if ("append".equalsIgnoreCase(command)) {
|
} else if ("append".equalsIgnoreCase(command)) {
|
||||||
String folderName = BASE64MailboxDecoder.decode(tokens.nextToken());
|
String folderName = BASE64MailboxDecoder.decode(tokens.nextToken());
|
||||||
String parameters = tokens.nextToken();
|
// TODO handle flags
|
||||||
int size = Integer.parseInt(tokens.nextToken());
|
String flags = tokens.nextToken();
|
||||||
|
// skip optional date
|
||||||
|
String dateOrSize = tokens.nextToken();
|
||||||
|
if (tokens.hasMoreTokens()) {
|
||||||
|
dateOrSize = tokens.nextToken();
|
||||||
|
}
|
||||||
|
int size = Integer.parseInt(dateOrSize);
|
||||||
sendClient("+ send literal data");
|
sendClient("+ send literal data");
|
||||||
char[] buffer = new char[size];
|
char[] buffer = new char[size];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -433,7 +441,18 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
DavGatewayTray.debug("Exception closing connection on timeout");
|
DavGatewayTray.debug("Exception closing connection on timeout");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (SocketException e) {
|
||||||
|
DavGatewayTray.debug("Connection closed");
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
if (commandId != null) {
|
||||||
|
sendClient(commandId + " BAD unable to handle request: " + e.getMessage());
|
||||||
|
} else {
|
||||||
|
sendClient("* BAD unable to handle request: " + e.getMessage());
|
||||||
|
}
|
||||||
|
} catch (IOException e2) {
|
||||||
|
DavGatewayTray.warn("Exception sending error to client", e2);
|
||||||
|
}
|
||||||
DavGatewayTray.error("Exception handling client", e);
|
DavGatewayTray.error("Exception handling client", e);
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
|
Loading…
Reference in New Issue
Block a user