mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 11:42:23 -05:00
IMAP: Fix bug 2835529, implement SEARCH ALL SINCE for Palm Pre
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@664 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
5cb2c3e9b7
commit
986bfd0be8
@ -49,7 +49,11 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
|
|
||||||
ExchangeSession.Folder currentFolder;
|
ExchangeSession.Folder currentFolder;
|
||||||
|
|
||||||
// Initialize the streams and start the thread
|
/**
|
||||||
|
* Initialize the streams and start the thread.
|
||||||
|
*
|
||||||
|
* @param clientSocket IMAP client socket
|
||||||
|
*/
|
||||||
public ImapConnection(Socket clientSocket) {
|
public ImapConnection(Socket clientSocket) {
|
||||||
super(ImapConnection.class.getSimpleName(), clientSocket, null);
|
super(ImapConnection.class.getSimpleName(), clientSocket, null);
|
||||||
}
|
}
|
||||||
@ -705,7 +709,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
conditions.append(operator).append("\"http://schemas.microsoft.com/mapi/proptag/x0e080003\" >= ").append(Long.parseLong(tokens.nextToken())).append("");
|
conditions.append(operator).append("\"http://schemas.microsoft.com/mapi/proptag/x0e080003\" >= ").append(Long.parseLong(tokens.nextToken())).append("");
|
||||||
} else if ("SMALLER".equals(token)) {
|
} else if ("SMALLER".equals(token)) {
|
||||||
conditions.append(operator).append("\"http://schemas.microsoft.com/mapi/proptag/x0e080003\" < ").append(Long.parseLong(tokens.nextToken())).append("");
|
conditions.append(operator).append("\"http://schemas.microsoft.com/mapi/proptag/x0e080003\" < ").append(Long.parseLong(tokens.nextToken())).append("");
|
||||||
} else if (token.startsWith("SENT")) {
|
} else if (token.startsWith("SENT") || "SINCE".equals(token) || "BEFORE".equals(token)) {
|
||||||
conditions.append(operator);
|
conditions.append(operator);
|
||||||
appendDateSearchParam(tokens, token, conditions);
|
appendDateSearchParam(tokens, token, conditions);
|
||||||
} else if ("SEEN".equals(token)) {
|
} else if ("SEEN".equals(token)) {
|
||||||
@ -740,18 +744,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
} else {
|
} else {
|
||||||
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", range);
|
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", range);
|
||||||
}
|
}
|
||||||
} else if ("BEFORE".equals(token)) {
|
} else if ("OLD".equals(token) || "RECENT".equals(token) || "ALL".equals(token)) {
|
||||||
SimpleDateFormat parser = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
|
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
||||||
dateFormatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
|
|
||||||
String dateToken = tokens.nextToken();
|
|
||||||
try {
|
|
||||||
Date date = parser.parse(dateToken);
|
|
||||||
conditions.append(operator).append("\"urn:schemas:httpmail:datereceived\"<'").append(dateFormatter.format(date)).append('\'');
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", dateToken);
|
|
||||||
}
|
|
||||||
} else if ("OLD".equals(token) || "RECENT".equals(token)) {
|
|
||||||
// ignore
|
// ignore
|
||||||
} else if (token.indexOf(':') >= 0) {
|
} else if (token.indexOf(':') >= 0) {
|
||||||
// range search
|
// range search
|
||||||
@ -782,18 +775,25 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", dateToken);
|
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", dateToken);
|
||||||
}
|
}
|
||||||
if ("SENTON".equals(token)) {
|
String searchAttribute;
|
||||||
conditions.append("(\"urn:schemas:httpmail:date\" > '")
|
if (token.startsWith("SENT")) {
|
||||||
|
searchAttribute = "urn:schemas:httpmail:date";
|
||||||
|
} else {
|
||||||
|
searchAttribute = "DAV:getlastmodified";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.endsWith("ON")) {
|
||||||
|
conditions.append("(\"").append(searchAttribute).append("\" > '")
|
||||||
.append(dateFormatter.format(startDate))
|
.append(dateFormatter.format(startDate))
|
||||||
.append("' AND \"urn:schemas:httpmail:date\" < '")
|
.append("' AND \"").append(searchAttribute).append("\" < '")
|
||||||
.append(dateFormatter.format(endDate))
|
.append(dateFormatter.format(endDate))
|
||||||
.append("')");
|
.append("')");
|
||||||
} else if ("SENTBEFORE".equals(token)) {
|
} else if (token.endsWith("BEFORE")) {
|
||||||
conditions.append("\"urn:schemas:httpmail:date\" < '")
|
conditions.append("\"").append(searchAttribute).append("\" < '")
|
||||||
.append(dateFormatter.format(startDate))
|
.append(dateFormatter.format(startDate))
|
||||||
.append('\'');
|
.append('\'');
|
||||||
} else if ("SENTSINCE".equals(token)) {
|
} else if (token.endsWith("SINCE")) {
|
||||||
conditions.append("\"urn:schemas:httpmail:date\" >= '")
|
conditions.append("\"").append(searchAttribute).append("\" >= '")
|
||||||
.append(dateFormatter.format(startDate))
|
.append(dateFormatter.format(startDate))
|
||||||
.append('\'');
|
.append('\'');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user