mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-02 00:25:10 -04:00
Provide for doing a full poll/sync of a folder whenever the IMAP IDLE
connection is established. Turned off for now, but just get rid of the false && on line 2641 in order to enable it.
This commit is contained in:
parent
02f4d08396
commit
78a101547c
@ -14,6 +14,7 @@ import com.fsck.k9.mail.store.LocalStore.LocalFolder;
|
||||
import com.fsck.k9.service.SleepService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class MessagingControllerPushReceiver implements PushReceiver
|
||||
{
|
||||
@ -74,6 +75,37 @@ public class MessagingControllerPushReceiver implements PushReceiver
|
||||
{
|
||||
controller.messagesArrived(account, folder, messages, false);
|
||||
}
|
||||
|
||||
public void syncFolder(Folder folder)
|
||||
{
|
||||
Log.i(K9.LOG_TAG, "syncFolder(" + folder.getName() + ")");
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
controller.synchronizeMailbox(account, folder.getName(), new MessagingListener()
|
||||
{
|
||||
public void synchronizeMailboxFinished(Account account, String folder,
|
||||
int totalMessagesInMailbox, int numNewMessages)
|
||||
{
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
public void synchronizeMailboxFailed(Account account, String folder,
|
||||
String message)
|
||||
{
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
Log.i(K9.LOG_TAG, "syncFolder(" + folder.getName() + ") about to await latch release");
|
||||
try
|
||||
{
|
||||
latch.await();
|
||||
Log.i(K9.LOG_TAG, "syncFolder(" + folder.getName() + ") got latch release");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "Interrupted while awaiting latch release", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void sleep(long millis)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ public interface PushReceiver
|
||||
{
|
||||
public void acquireWakeLock();
|
||||
public void releaseWakeLock();
|
||||
public void syncFolder(Folder folder);
|
||||
public void messagesArrived(Folder folder, List<Message> mess);
|
||||
public void messagesFlagsChanged(Folder folder, List<Message> mess);
|
||||
public String getPushState(String folderName);
|
||||
|
@ -1094,14 +1094,18 @@ public class ImapStore extends Store
|
||||
if (o != null && o instanceof Part)
|
||||
{
|
||||
Part part = (Part) o;
|
||||
String partId = part.getHeader(MimeHeader.HEADER_ANDROID_ATTACHMENT_STORE_DATA)[0];
|
||||
if ("TEXT".equals(partId))
|
||||
String[] parts = part.getHeader(MimeHeader.HEADER_ANDROID_ATTACHMENT_STORE_DATA);
|
||||
if (parts != null)
|
||||
{
|
||||
fetchFields.add(String.format("BODY.PEEK[TEXT]<0.%d>", FETCH_BODY_SANE_SUGGESTED_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
fetchFields.add("BODY.PEEK[" + partId + "]");
|
||||
String partId = parts[0];
|
||||
if ("TEXT".equals(partId))
|
||||
{
|
||||
fetchFields.add(String.format("BODY.PEEK[TEXT]<0.%d>", FETCH_BODY_SANE_SUGGESTED_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
fetchFields.add("BODY.PEEK[" + partId + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2615,7 +2619,7 @@ public class ImapStore extends Store
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "Unable to get oldUidNext for " + getLogId(), e);
|
||||
}
|
||||
|
||||
ImapConnection oldConnection = mConnection;
|
||||
List<ImapResponse> responses = internalOpen(OpenMode.READ_ONLY);
|
||||
if (mConnection == null)
|
||||
{
|
||||
@ -2634,6 +2638,10 @@ public class ImapStore extends Store
|
||||
{
|
||||
handleUntaggedResponses(responses);
|
||||
}
|
||||
if (false && mConnection != oldConnection)
|
||||
{
|
||||
receiver.syncFolder(ImapFolderPusher.this);
|
||||
}
|
||||
int startUid = oldUidNext;
|
||||
if (startUid < uidNext - mAccount.getDisplayCount())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user