From acf3cfadd47da518d095c611ec8300debace92f0 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 14 Oct 2018 08:59:39 +0000 Subject: [PATCH] Folder NOOP --- .idea/misc.xml | 2 +- .../eu/faircode/email/ServiceSynchronize.java | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 99202cc2..c0f68edd 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index c92b79c5..0817f7a9 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -52,10 +52,12 @@ import android.text.TextUtils; import android.util.Log; import com.sun.mail.iap.ConnectionException; +import com.sun.mail.iap.ProtocolException; import com.sun.mail.imap.AppendUID; import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPMessage; import com.sun.mail.imap.IMAPStore; +import com.sun.mail.imap.protocol.IMAPProtocol; import com.sun.mail.util.FolderClosedIOException; import com.sun.mail.util.MailConnectException; @@ -1024,12 +1026,24 @@ public class ServiceSynchronize extends LifecycleService { if (!istore.isConnected()) throw new StoreClosedException(istore); - for (EntityFolder folder : folders.keySet()) + for (final EntityFolder folder : folders.keySet()) { + IMAPFolder ifolder = folders.get(folder); if (capIdle) { - if (!folders.get(folder).isOpen()) - throw new FolderClosedException(folders.get(folder)); + try { + ifolder.doCommand(new IMAPFolder.ProtocolCommand() { + public Object doCommand(IMAPProtocol p) + throws ProtocolException { + Log.i(Helper.TAG, folder.name + " do noop"); + p.simpleCommand("NOOP", null); + return null; + } + }); + } catch (MessagingException ex) { + throw new FolderClosedException(ifolder, "NOOP", ex); + } } else - synchronizeMessages(account, folder, folders.get(folder), state); + synchronizeMessages(account, folder, ifolder, state); + } } }