Don't pass Folder instance to PushReceiver

This commit is contained in:
cketti 2019-12-18 01:05:28 +01:00
parent c61d9925d2
commit aa13a46e3e
3 changed files with 21 additions and 21 deletions

View file

@ -32,21 +32,21 @@ public class MessagingControllerPushReceiver implements PushReceiver {
this.context = context;
}
public void messagesFlagsChanged(Folder folder, List<Message> messages) {
syncFolder(folder);
public void messagesFlagsChanged(String folderServerId, List<Message> messages) {
syncFolder(folderServerId);
}
public void messagesArrived(Folder folder, List<Message> messages) {
syncFolder(folder);
public void messagesArrived(String folderServerId, List<Message> messages) {
syncFolder(folderServerId);
}
public void messagesRemoved(Folder folder, List<Message> messages) {
syncFolder(folder);
public void messagesRemoved(String folderServerId, List<Message> messages) {
syncFolder(folderServerId);
}
public void syncFolder(Folder folder) {
Timber.v("syncFolder(%s)", folder.getServerId());
public void syncFolder(String folderServerId) {
Timber.v("syncFolder(%s)", folderServerId);
final CountDownLatch latch = new CountDownLatch(1);
controller.synchronizeMailbox(account, folder.getServerId(), new SimpleMessagingListener() {
controller.synchronizeMailbox(account, folderServerId, new SimpleMessagingListener() {
@Override
public void synchronizeMailboxFinished(Account account, String folderServerId,
int totalMessagesInMailbox, int numNewMessages) {
@ -58,13 +58,13 @@ public class MessagingControllerPushReceiver implements PushReceiver {
String message) {
latch.countDown();
}
}, folder);
}, null);
Timber.v("syncFolder(%s) about to await latch release", folder.getServerId());
Timber.v("syncFolder(%s) about to await latch release", folderServerId);
try {
latch.await();
Timber.v("syncFolder(%s) got latch release", folder.getServerId());
Timber.v("syncFolder(%s) got latch release", folderServerId);
} catch (Exception e) {
Timber.e(e, "Interrupted while awaiting latch release");
}

View file

@ -7,10 +7,10 @@ import com.fsck.k9.mail.power.WakeLock;
public interface PushReceiver {
void syncFolder(Folder folder);
void messagesArrived(Folder folder, List<Message> mess);
void messagesFlagsChanged(Folder folder, List<Message> mess);
void messagesRemoved(Folder folder, List<Message> mess);
void syncFolder(String folderServerId);
void messagesArrived(String folderServerId, List<Message> mess);
void messagesFlagsChanged(String folderServerId, List<Message> mess);
void messagesRemoved(String folderServerId, List<Message> mess);
String getPushState(String folderServerId);
void pushError(String errorMessage, Exception e);
void authenticationFailed();

View file

@ -592,7 +592,7 @@ class ImapFolderPusher extends ImapFolder {
}
if (!messages.isEmpty()) {
pushReceiver.messagesArrived(ImapFolderPusher.this, messages);
pushReceiver.messagesArrived(getServerId(), messages);
}
}
}
@ -604,7 +604,7 @@ class ImapFolderPusher extends ImapFolder {
List<? extends Message> messageList = getMessages(messageSeqSet, true, null);
List<Message> messages = new ArrayList<>(messageList);
pushReceiver.messagesFlagsChanged(ImapFolderPusher.this, messages);
pushReceiver.messagesFlagsChanged(getServerId(), messages);
} catch (Exception e) {
pushReceiver.pushError("Exception while processing Push untagged responses", e);
}
@ -637,7 +637,7 @@ class ImapFolderPusher extends ImapFolder {
messages.add(message);
}
pushReceiver.messagesRemoved(ImapFolderPusher.this, messages);
pushReceiver.messagesRemoved(getServerId(), messages);
} catch (Exception e) {
Timber.e("Cannot remove EXPUNGEd messages");
}
@ -650,7 +650,7 @@ class ImapFolderPusher extends ImapFolder {
throw new MessagingException("Message count = -1 for idling");
}
pushReceiver.syncFolder(ImapFolderPusher.this);
pushReceiver.syncFolder(getServerId());
}
private void notifyMessagesArrived(long startUid, long uidNext) {
@ -666,7 +666,7 @@ class ImapFolderPusher extends ImapFolder {
messages.add(message);
}
pushReceiver.messagesArrived(ImapFolderPusher.this, messages);
pushReceiver.messagesArrived(getServerId(), messages);
}
private long getOldUidNext() {