mirror of
https://github.com/moparisthebest/davmail
synced 2025-02-28 17:31:52 -05:00
IMAP: make APPEND flags and date parameters optional
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@445 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
2c7add2af3
commit
56befe6e77
@ -38,7 +38,7 @@ public class ImapConnection extends AbstractConnection {
|
||||
public void run() {
|
||||
String line;
|
||||
String commandId = null;
|
||||
StringTokenizer tokens;
|
||||
IMAPTokenizer tokens;
|
||||
try {
|
||||
ExchangeSessionFactory.checkConfig();
|
||||
sendClient("* OK [CAPABILITY IMAP4REV1 AUTH=LOGIN] IMAP4rev1 DavMail server ready");
|
||||
@ -288,8 +288,26 @@ public class ImapConnection extends AbstractConnection {
|
||||
|
||||
} else if ("append".equalsIgnoreCase(command)) {
|
||||
String folderName = BASE64MailboxDecoder.decode(tokens.nextToken());
|
||||
String flags = tokens.nextToken();
|
||||
HashMap<String, String> properties = new HashMap<String, String>();
|
||||
String flags = null;
|
||||
String date = null;
|
||||
// handle optional flags
|
||||
String nextToken = tokens.nextQuotedToken();
|
||||
if (nextToken.startsWith("(")) {
|
||||
flags = removeQuotes(nextToken);
|
||||
if (tokens.hasMoreTokens()) {
|
||||
nextToken = tokens.nextToken();
|
||||
if (tokens.hasMoreTokens()) {
|
||||
date = nextToken;
|
||||
nextToken = tokens.nextToken();
|
||||
}
|
||||
}
|
||||
} else if (tokens.hasMoreTokens()) {
|
||||
date = removeQuotes(nextToken);
|
||||
nextToken = tokens.nextToken();
|
||||
}
|
||||
|
||||
if (flags != null) {
|
||||
StringTokenizer flagtokenizer = new StringTokenizer(flags);
|
||||
while (flagtokenizer.hasMoreTokens()) {
|
||||
String flag = flagtokenizer.nextToken();
|
||||
@ -307,18 +325,17 @@ public class ImapConnection extends AbstractConnection {
|
||||
properties.put("junk", "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
// handle optional date
|
||||
String dateOrSize = tokens.nextToken();
|
||||
if (tokens.hasMoreTokens()) {
|
||||
if (date != null) {
|
||||
SimpleDateFormat dateParser = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z", Locale.ENGLISH);
|
||||
Date dateReceived = dateParser.parse(dateOrSize);
|
||||
Date dateReceived = dateParser.parse(date);
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
dateFormatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
|
||||
|
||||
properties.put("datereceived", dateFormatter.format(dateReceived));
|
||||
dateOrSize = tokens.nextToken();
|
||||
}
|
||||
int size = Integer.parseInt(dateOrSize);
|
||||
int size = Integer.parseInt(nextToken);
|
||||
sendClient("+ send literal data");
|
||||
char[] buffer = new char[size];
|
||||
int index = 0;
|
||||
@ -1032,6 +1049,10 @@ public class ImapConnection extends AbstractConnection {
|
||||
|
||||
@Override
|
||||
public String nextToken() {
|
||||
return removeQuotes(nextQuotedToken());
|
||||
}
|
||||
|
||||
public String nextQuotedToken() {
|
||||
StringBuilder nextToken = new StringBuilder();
|
||||
nextToken.append(super.nextToken());
|
||||
while (hasMoreTokens() && nextToken.length() > 0 && nextToken.charAt(0) == '"'
|
||||
@ -1042,7 +1063,7 @@ public class ImapConnection extends AbstractConnection {
|
||||
&& nextToken.charAt(nextToken.length() - 1) != ')') {
|
||||
nextToken.append(' ').append(super.nextToken());
|
||||
}
|
||||
return removeQuotes(nextToken.toString());
|
||||
return nextToken.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user