mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-08 04:08:12 -05:00
IMAP: send updated flags on folder refresh
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2038 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
547787cbce
commit
f397d73a6a
@ -1664,16 +1664,16 @@ public abstract class ExchangeSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current folder messages imap uids
|
* Get current folder messages imap uids and flags
|
||||||
*
|
*
|
||||||
* @return imap uid list
|
* @return imap uid list
|
||||||
*/
|
*/
|
||||||
public List<Long> getImapUidList() {
|
public TreeMap<Long,String> getImapFlagMap() {
|
||||||
ArrayList<Long> imapUidList = new ArrayList<Long>();
|
TreeMap<Long,String> imapFlagMap = new TreeMap<Long,String>();
|
||||||
for (ExchangeSession.Message message : messages) {
|
for (ExchangeSession.Message message : messages) {
|
||||||
imapUidList.add(message.getImapUid());
|
imapFlagMap.put(message.getImapUid(), message.getImapFlags());
|
||||||
}
|
}
|
||||||
return imapUidList;
|
return imapFlagMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -517,9 +517,9 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
while (in.available() == 0) {
|
while (in.available() == 0) {
|
||||||
if (++count >= imapIdleDelay) {
|
if (++count >= imapIdleDelay) {
|
||||||
count = 0;
|
count = 0;
|
||||||
List<Long> previousImapUidList = currentFolder.getImapUidList();
|
TreeMap<Long,String> previousImapFlagMap = currentFolder.getImapFlagMap();
|
||||||
if (session.refreshFolder(currentFolder)) {
|
if (session.refreshFolder(currentFolder)) {
|
||||||
handleRefresh(previousImapUidList, currentFolder.getImapUidList());
|
handleRefresh(previousImapFlagMap, currentFolder.getImapFlagMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sleep 1 second
|
// sleep 1 second
|
||||||
@ -542,9 +542,9 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
} else if ("noop".equalsIgnoreCase(command) || "check".equalsIgnoreCase(command)) {
|
} else if ("noop".equalsIgnoreCase(command) || "check".equalsIgnoreCase(command)) {
|
||||||
if (currentFolder != null) {
|
if (currentFolder != null) {
|
||||||
DavGatewayTray.debug(new BundleMessage("LOG_IMAP_COMMAND", command, currentFolder.folderPath));
|
DavGatewayTray.debug(new BundleMessage("LOG_IMAP_COMMAND", command, currentFolder.folderPath));
|
||||||
List<Long> previousImapUidList = currentFolder.getImapUidList();
|
TreeMap<Long,String> previousImapFlagMap = currentFolder.getImapFlagMap();
|
||||||
if (session.refreshFolder(currentFolder)) {
|
if (session.refreshFolder(currentFolder)) {
|
||||||
handleRefresh(previousImapUidList, currentFolder.getImapUidList());
|
handleRefresh(previousImapFlagMap, currentFolder.getImapFlagMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendClient(commandId + " OK " + command + " completed");
|
sendClient(commandId + " OK " + command + " completed");
|
||||||
@ -691,16 +691,21 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
* @param imapUidList uid list after refresh
|
* @param imapUidList uid list after refresh
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
private void handleRefresh(List<Long> previousImapUidList, List<Long> imapUidList) throws IOException {
|
private void handleRefresh(TreeMap<Long,String> previousImapFlagMap, TreeMap<Long,String> imapFlagMap) throws IOException {
|
||||||
//
|
// send deleted message expunge notification
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (long previousImapUid : previousImapUidList) {
|
for (long previousImapUid : previousImapFlagMap.keySet()) {
|
||||||
if (!imapUidList.contains(previousImapUid)) {
|
if (!imapFlagMap.keySet().contains(previousImapUid)) {
|
||||||
sendClient("* " + index + " EXPUNGE");
|
sendClient("* " + index + " EXPUNGE");
|
||||||
} else {
|
} else {
|
||||||
|
// send updated flags
|
||||||
|
if (!previousImapFlagMap.get(previousImapUid).equals(imapFlagMap.get(previousImapUid))) {
|
||||||
|
sendClient("* " + index + " FETCH (UID "+previousImapUid+" FLAGS ("+imapFlagMap.get(previousImapUid)+"))");
|
||||||
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendClient("* " + currentFolder.count() + " EXISTS");
|
sendClient("* " + currentFolder.count() + " EXISTS");
|
||||||
sendClient("* " + currentFolder.recent + " RECENT");
|
sendClient("* " + currentFolder.recent + " RECENT");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user