mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-12 22:18:11 -05:00
POP: Defer message list after login phase and load only uid and size attributes
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@557 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
587c6b44a7
commit
2abfa2ce46
@ -634,18 +634,22 @@ public class ExchangeSession {
|
||||
}
|
||||
}
|
||||
|
||||
public MessageList getAllMessages(String folderName) throws IOException {
|
||||
return searchMessages(folderName, "");
|
||||
public MessageList getAllMessageUidAndSize(String folderName) throws IOException {
|
||||
return searchMessages(folderName, "\"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"", "");
|
||||
}
|
||||
|
||||
public MessageList searchMessages(String folderName, String conditions) throws IOException {
|
||||
String folderUrl = getFolderPath(folderName);
|
||||
MessageList messages = new MessageList();
|
||||
String searchRequest = "Select \"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"" +
|
||||
return searchMessages(folderName, "\"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"" +
|
||||
" ,\"http://schemas.microsoft.com/mapi/proptag/x0e230003\"" +
|
||||
" ,\"http://schemas.microsoft.com/mapi/proptag/x10830003\", \"http://schemas.microsoft.com/mapi/proptag/x10900003\"" +
|
||||
" ,\"http://schemas.microsoft.com/mapi/proptag/x0E070003\", \"http://schemas.microsoft.com/mapi/proptag/x10810003\"" +
|
||||
" ,\"urn:schemas:mailheader:message-id\", \"urn:schemas:httpmail:read\", \"DAV:isdeleted\", \"urn:schemas:mailheader:date\"" +
|
||||
" ,\"urn:schemas:mailheader:message-id\", \"urn:schemas:httpmail:read\", \"DAV:isdeleted\", \"urn:schemas:mailheader:date\"", conditions);
|
||||
}
|
||||
|
||||
public MessageList searchMessages(String folderName, String attributes, String conditions) throws IOException {
|
||||
String folderUrl = getFolderPath(folderName);
|
||||
MessageList messages = new MessageList();
|
||||
String searchRequest = "Select "+ attributes +
|
||||
" FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUrl + "\"')\n" +
|
||||
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n";
|
||||
if (conditions != null) {
|
||||
@ -980,7 +984,7 @@ public class ExchangeSession {
|
||||
}
|
||||
|
||||
public void loadMessages() throws IOException {
|
||||
messages = getAllMessages(folderUrl);
|
||||
messages = searchMessages(folderUrl, "");
|
||||
}
|
||||
|
||||
public int size() {
|
||||
|
@ -108,7 +108,6 @@ public class PopConnection extends AbstractConnection {
|
||||
password = line.substring("PASS".length() + 1);
|
||||
try {
|
||||
session = ExchangeSessionFactory.getInstance(userName, password);
|
||||
messages = session.getAllMessages("INBOX");
|
||||
sendOK("PASS");
|
||||
state = State.AUTHENTICATED;
|
||||
} catch (SocketException e) {
|
||||
@ -125,6 +124,10 @@ public class PopConnection extends AbstractConnection {
|
||||
} else if (state != State.AUTHENTICATED) {
|
||||
sendERR("Invalid state not authenticated");
|
||||
} else {
|
||||
// load messages (once)
|
||||
if (messages == null) {
|
||||
messages = session.getAllMessageUidAndSize("INBOX");
|
||||
}
|
||||
if ("STAT".equalsIgnoreCase(command)) {
|
||||
sendOK(messages.size() + " " +
|
||||
getTotalMessagesLength());
|
||||
|
@ -2,7 +2,6 @@ package davmail.exchange;
|
||||
|
||||
import davmail.Settings;
|
||||
import davmail.http.DavGatewaySSLProtocolSocketFactory;
|
||||
import org.apache.commons.httpclient.util.URIUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,7 +28,7 @@ public class TestExchangeSession {
|
||||
ExchangeSession.Folder folder = session.getFolder(argv[currentArg++]);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
ExchangeSession.MessageList messageList = session.getAllMessages(folder.folderUrl);
|
||||
ExchangeSession.MessageList messageList = session.getAllMessageUidAndSize(folder.folderUrl);
|
||||
System.out.println("******");
|
||||
for (ExchangeSession.Message message : messageList) {
|
||||
message.write(System.out);
|
||||
|
Loading…
Reference in New Issue
Block a user