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 {
|
public MessageList getAllMessageUidAndSize(String folderName) throws IOException {
|
||||||
return searchMessages(folderName, "");
|
return searchMessages(folderName, "\"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageList searchMessages(String folderName, String conditions) throws IOException {
|
public MessageList searchMessages(String folderName, String conditions) throws IOException {
|
||||||
String folderUrl = getFolderPath(folderName);
|
return searchMessages(folderName, "\"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"" +
|
||||||
MessageList messages = new MessageList();
|
|
||||||
String searchRequest = "Select \"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"" +
|
|
||||||
" ,\"http://schemas.microsoft.com/mapi/proptag/x0e230003\"" +
|
" ,\"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/x10830003\", \"http://schemas.microsoft.com/mapi/proptag/x10900003\"" +
|
||||||
" ,\"http://schemas.microsoft.com/mapi/proptag/x0E070003\", \"http://schemas.microsoft.com/mapi/proptag/x10810003\"" +
|
" ,\"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" +
|
" FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUrl + "\"')\n" +
|
||||||
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n";
|
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n";
|
||||||
if (conditions != null) {
|
if (conditions != null) {
|
||||||
|
@ -980,7 +984,7 @@ public class ExchangeSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMessages() throws IOException {
|
public void loadMessages() throws IOException {
|
||||||
messages = getAllMessages(folderUrl);
|
messages = searchMessages(folderUrl, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
|
|
|
@ -108,7 +108,6 @@ public class PopConnection extends AbstractConnection {
|
||||||
password = line.substring("PASS".length() + 1);
|
password = line.substring("PASS".length() + 1);
|
||||||
try {
|
try {
|
||||||
session = ExchangeSessionFactory.getInstance(userName, password);
|
session = ExchangeSessionFactory.getInstance(userName, password);
|
||||||
messages = session.getAllMessages("INBOX");
|
|
||||||
sendOK("PASS");
|
sendOK("PASS");
|
||||||
state = State.AUTHENTICATED;
|
state = State.AUTHENTICATED;
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
|
@ -125,6 +124,10 @@ public class PopConnection extends AbstractConnection {
|
||||||
} else if (state != State.AUTHENTICATED) {
|
} else if (state != State.AUTHENTICATED) {
|
||||||
sendERR("Invalid state not authenticated");
|
sendERR("Invalid state not authenticated");
|
||||||
} else {
|
} else {
|
||||||
|
// load messages (once)
|
||||||
|
if (messages == null) {
|
||||||
|
messages = session.getAllMessageUidAndSize("INBOX");
|
||||||
|
}
|
||||||
if ("STAT".equalsIgnoreCase(command)) {
|
if ("STAT".equalsIgnoreCase(command)) {
|
||||||
sendOK(messages.size() + " " +
|
sendOK(messages.size() + " " +
|
||||||
getTotalMessagesLength());
|
getTotalMessagesLength());
|
||||||
|
|
|
@ -2,7 +2,6 @@ package davmail.exchange;
|
||||||
|
|
||||||
import davmail.Settings;
|
import davmail.Settings;
|
||||||
import davmail.http.DavGatewaySSLProtocolSocketFactory;
|
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++]);
|
ExchangeSession.Folder folder = session.getFolder(argv[currentArg++]);
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
ExchangeSession.MessageList messageList = session.getAllMessages(folder.folderUrl);
|
ExchangeSession.MessageList messageList = session.getAllMessageUidAndSize(folder.folderUrl);
|
||||||
System.out.println("******");
|
System.out.println("******");
|
||||||
for (ExchangeSession.Message message : messageList) {
|
for (ExchangeSession.Message message : messageList) {
|
||||||
message.write(System.out);
|
message.write(System.out);
|
||||||
|
|
Loading…
Reference in New Issue