mirror of
https://github.com/moparisthebest/davmail
synced 2024-08-13 16:53:51 -04: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() {
|
public void run() {
|
||||||
String line;
|
String line;
|
||||||
String commandId = null;
|
String commandId = null;
|
||||||
StringTokenizer tokens;
|
IMAPTokenizer tokens;
|
||||||
try {
|
try {
|
||||||
ExchangeSessionFactory.checkConfig();
|
ExchangeSessionFactory.checkConfig();
|
||||||
sendClient("* OK [CAPABILITY IMAP4REV1 AUTH=LOGIN] IMAP4rev1 DavMail server ready");
|
sendClient("* OK [CAPABILITY IMAP4REV1 AUTH=LOGIN] IMAP4rev1 DavMail server ready");
|
||||||
@ -288,8 +288,26 @@ 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 flags = tokens.nextToken();
|
|
||||||
HashMap<String, String> properties = new HashMap<String, String>();
|
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);
|
StringTokenizer flagtokenizer = new StringTokenizer(flags);
|
||||||
while (flagtokenizer.hasMoreTokens()) {
|
while (flagtokenizer.hasMoreTokens()) {
|
||||||
String flag = flagtokenizer.nextToken();
|
String flag = flagtokenizer.nextToken();
|
||||||
@ -307,18 +325,17 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
properties.put("junk", "1");
|
properties.put("junk", "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// handle optional date
|
// handle optional date
|
||||||
String dateOrSize = tokens.nextToken();
|
if (date != null) {
|
||||||
if (tokens.hasMoreTokens()) {
|
|
||||||
SimpleDateFormat dateParser = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z", Locale.ENGLISH);
|
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'");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||||
dateFormatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
|
dateFormatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
|
||||||
|
|
||||||
properties.put("datereceived", dateFormatter.format(dateReceived));
|
properties.put("datereceived", dateFormatter.format(dateReceived));
|
||||||
dateOrSize = tokens.nextToken();
|
|
||||||
}
|
}
|
||||||
int size = Integer.parseInt(dateOrSize);
|
int size = Integer.parseInt(nextToken);
|
||||||
sendClient("+ send literal data");
|
sendClient("+ send literal data");
|
||||||
char[] buffer = new char[size];
|
char[] buffer = new char[size];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -1032,6 +1049,10 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String nextToken() {
|
public String nextToken() {
|
||||||
|
return removeQuotes(nextQuotedToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String nextQuotedToken() {
|
||||||
StringBuilder nextToken = new StringBuilder();
|
StringBuilder nextToken = new StringBuilder();
|
||||||
nextToken.append(super.nextToken());
|
nextToken.append(super.nextToken());
|
||||||
while (hasMoreTokens() && nextToken.length() > 0 && nextToken.charAt(0) == '"'
|
while (hasMoreTokens() && nextToken.length() > 0 && nextToken.charAt(0) == '"'
|
||||||
@ -1042,7 +1063,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
&& nextToken.charAt(nextToken.length() - 1) != ')') {
|
&& nextToken.charAt(nextToken.length() - 1) != ')') {
|
||||||
nextToken.append(' ').append(super.nextToken());
|
nextToken.append(' ').append(super.nextToken());
|
||||||
}
|
}
|
||||||
return removeQuotes(nextToken.toString());
|
return nextToken.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user