1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

Drop icon activity switches under 250ms to avoid fast flickering on OSX, add new switch icon in IMAP fetch iterations

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@750 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-09-24 09:18:57 +00:00
parent 3f742edce9
commit 6eb3da9916
2 changed files with 14 additions and 5 deletions

View File

@ -230,6 +230,7 @@ public class ImapConnection extends AbstractConnection {
sendClient(commandId + " NO No message found");
} else {
while (uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon();
ExchangeSession.Message message = uidRangeIterator.next();
handleFetch(message, uidRangeIterator.currentIndex, parameters);
}
@ -287,6 +288,7 @@ public class ImapConnection extends AbstractConnection {
String action = tokens.nextToken();
String flags = tokens.nextToken();
while (uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon();
ExchangeSession.Message message = uidRangeIterator.next();
updateFlags(message, action, flags);
sendClient("* " + (uidRangeIterator.currentIndex) + " FETCH (UID " + message.getImapUid() + " FLAGS (" + (message.getImapFlags()) + "))");
@ -297,6 +299,7 @@ public class ImapConnection extends AbstractConnection {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(tokens.nextToken());
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
while (uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon();
ExchangeSession.Message message = uidRangeIterator.next();
session.copyMessage(message, targetName);
}
@ -318,6 +321,7 @@ public class ImapConnection extends AbstractConnection {
parameters = tokens.nextToken();
}
while (rangeIterator.hasNext()) {
DavGatewayTray.switchIcon();
ExchangeSession.Message message = rangeIterator.next();
handleFetch(message, rangeIterator.currentIndex, parameters);
}

View File

@ -34,7 +34,9 @@ import java.net.URL;
* Tray icon handler
*/
public final class DavGatewayTray {
protected static final Logger LOGGER = Logger.getLogger("davmail");
private static final Logger LOGGER = Logger.getLogger("davmail");
private static final long ICON_SWITCH_MINIMUM_DELAY = 250;
private static long lastIconSwitch;
private DavGatewayTray() {
}
@ -59,7 +61,10 @@ public final class DavGatewayTray {
*/
public static void switchIcon() {
if (davGatewayTray != null) {
if (System.currentTimeMillis() - lastIconSwitch > ICON_SWITCH_MINIMUM_DELAY) {
davGatewayTray.switchIcon();
lastIconSwitch = System.currentTimeMillis();
}
}
}
@ -87,7 +92,7 @@ public final class DavGatewayTray {
* @param message text message
* @param level log level
*/
protected static void displayMessage(BundleMessage message, Level level) {
private static void displayMessage(BundleMessage message, Level level) {
LOGGER.log(level, message.formatLog());
if (davGatewayTray != null) {
davGatewayTray.displayMessage(message.format(), level);
@ -101,7 +106,7 @@ public final class DavGatewayTray {
* @param e exception
* @param level log level
*/
protected static void displayMessage(BundleMessage message, Exception e, Level level) {
private static void displayMessage(BundleMessage message, Exception e, Level level) {
if (e instanceof NetworkDownException) {
LOGGER.log(level, BundleMessage.getExceptionLogMessage(message, e));
} else {
@ -263,7 +268,7 @@ public final class DavGatewayTray {
*
* @return true on Mac OS X
*/
protected static boolean isOSX() {
private static boolean isOSX() {
return System.getProperty("os.name").toLowerCase().startsWith("mac os x");
}