IMAP: apply flag to keyword conversion in SEARCH, refresh folder before search
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2026 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
e1002affac
commit
cdfad5a8ba
|
@ -1470,6 +1470,43 @@ public abstract class ExchangeSession {
|
|||
|
||||
protected abstract void moveToTrash(Message message) throws IOException;
|
||||
|
||||
/**
|
||||
* Convert keyword value to IMAP flag.
|
||||
* @param value keyword value
|
||||
* @return IMAP flag
|
||||
*/
|
||||
public String convertKeywordToFlag(String value) {
|
||||
String result = value;
|
||||
// convert flags to Thunderbird flags
|
||||
ResourceBundle flagBundle = ResourceBundle.getBundle("imapflags");
|
||||
Enumeration<String> flagEnumeration = flagBundle.getKeys();
|
||||
while (flagEnumeration.hasMoreElements()) {
|
||||
String key = flagEnumeration.nextElement();
|
||||
if (value.equalsIgnoreCase(flagBundle.getString(key))) {
|
||||
result = key;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert IMAP flag to keyword value.
|
||||
* @param value IMAP flag
|
||||
* @return keyword value
|
||||
*/
|
||||
public String convertFlagToKeyword(String value) {
|
||||
String result = value;
|
||||
// convert flags to Thunderbird flags
|
||||
ResourceBundle flagBundle = ResourceBundle.getBundle("imapflags");
|
||||
try {
|
||||
result = flagBundle.getString(value);
|
||||
} catch (MissingResourceException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchange folder with IMAP properties
|
||||
*/
|
||||
|
@ -2000,33 +2037,6 @@ public abstract class ExchangeSession {
|
|||
return (int) (imapUid ^ (imapUid >>> 32));
|
||||
}
|
||||
|
||||
protected String convertKeywordToFlag(String value) {
|
||||
String result = value;
|
||||
// convert flags to Thunderbird flags
|
||||
ResourceBundle flagBundle = ResourceBundle.getBundle("imapflags");
|
||||
Enumeration<String> flagEnumeration = flagBundle.getKeys();
|
||||
while (flagEnumeration.hasMoreElements()) {
|
||||
String key = flagEnumeration.nextElement();
|
||||
if (value.equalsIgnoreCase(flagBundle.getString(key))) {
|
||||
result = key;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String convertFlagToKeyword(String value) {
|
||||
String result = value;
|
||||
// convert flags to Thunderbird flags
|
||||
ResourceBundle flagBundle = ResourceBundle.getBundle("imapflags");
|
||||
try {
|
||||
result = flagBundle.getString(value);
|
||||
} catch (MissingResourceException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String removeFlag(String flag) {
|
||||
if (keywords != null) {
|
||||
final String exchangeFlag = convertFlagToKeyword(flag);
|
||||
|
|
|
@ -934,6 +934,7 @@ public class ImapConnection extends AbstractConnection {
|
|||
List<Long> localMessagesUidList = null;
|
||||
SearchConditions conditions = new SearchConditions();
|
||||
ExchangeSession.Condition condition = buildConditions(conditions, tokens);
|
||||
session.refreshFolder(currentFolder);
|
||||
ExchangeSession.MessageList localMessages = currentFolder.searchMessages(condition);
|
||||
Iterator<ExchangeSession.Message> iterator;
|
||||
if (conditions.uidRange != null) {
|
||||
|
@ -1272,7 +1273,7 @@ public class ImapConnection extends AbstractConnection {
|
|||
session.contains("to", value),
|
||||
session.contains("cc", value));
|
||||
} else if ("KEYWORD".equals(token)) {
|
||||
return session.contains("keywords", tokens.nextToken());
|
||||
return session.contains("keywords", session.convertFlagToKeyword(tokens.nextToken()));
|
||||
} else if ("FROM".equals(token)) {
|
||||
return session.contains("from", tokens.nextToken());
|
||||
} else if ("TO".equals(token)) {
|
||||
|
|
Loading…
Reference in New Issue