Remove unused MessagingListener callbacks for sending messages

This commit is contained in:
cketti 2020-01-22 16:48:03 +01:00
parent 6916ea8ce5
commit 2dc75163a0
5 changed files with 1 additions and 86 deletions

View file

@ -30,7 +30,6 @@ class MemorizingMessagingListener extends SimpleMessagingListener {
if (other != null) {
Memory syncStarted = null;
Memory sendStarted = null;
for (Memory memory : memories.values()) {
@ -49,20 +48,6 @@ class MemorizingMessagingListener extends SimpleMessagingListener {
break;
}
}
if (memory.sendingState != null) {
switch (memory.sendingState) {
case STARTED:
sendStarted = memory;
break;
case FINISHED:
other.sendPendingMessagesCompleted(memory.account);
break;
case FAILED:
other.sendPendingMessagesFailed(memory.account);
break;
}
}
}
Memory somethingStarted = null;
if (syncStarted != null) {
@ -70,10 +55,6 @@ class MemorizingMessagingListener extends SimpleMessagingListener {
syncStarted.folderName);
somethingStarted = syncStarted;
}
if (sendStarted != null) {
other.sendPendingMessagesStarted(sendStarted.account);
somethingStarted = sendStarted;
}
if (somethingStarted != null && somethingStarted.folderTotal > 0) {
other.synchronizeMailboxProgress(somethingStarted.account, somethingStarted.folderServerId,
somethingStarted.folderCompleted, somethingStarted.folderTotal);
@ -110,27 +91,6 @@ class MemorizingMessagingListener extends SimpleMessagingListener {
memory.failureMessage = message;
}
@Override
public synchronized void sendPendingMessagesStarted(Account account) {
Memory memory = getMemory(account, null);
memory.sendingState = MemorizingState.STARTED;
memory.folderCompleted = 0;
memory.folderTotal = 0;
}
@Override
public synchronized void sendPendingMessagesCompleted(Account account) {
Memory memory = getMemory(account, null);
memory.sendingState = MemorizingState.FINISHED;
}
@Override
public synchronized void sendPendingMessagesFailed(Account account) {
Memory memory = getMemory(account, null);
memory.sendingState = MemorizingState.FAILED;
}
@Override
public synchronized void synchronizeMailboxProgress(Account account, String folderServerId, int completed,
int total) {
@ -159,7 +119,6 @@ class MemorizingMessagingListener extends SimpleMessagingListener {
String folderServerId;
String folderName;
MemorizingState syncingState = null;
MemorizingState sendingState = null;
String failureMessage = null;
int syncingTotalMessagesInMailbox;

View file

@ -1499,9 +1499,7 @@ public class MessagingController {
Timber.v("Outbox does not exist");
return;
}
for (MessagingListener l : getListeners()) {
l.sendPendingMessagesStarted(account);
}
localFolder.open();
List<LocalMessage> localMessages = localFolder.getMessages(null);
@ -1608,10 +1606,6 @@ public class MessagingController {
}
}
for (MessagingListener l : getListeners()) {
l.sendPendingMessagesCompleted(account);
}
if (lastFailure != null) {
if (wasPermanentFailure) {
notificationController.showSendFailedNotification(account, lastFailure);
@ -1624,10 +1618,6 @@ public class MessagingController {
throw new UnavailableAccountException(e);
} catch (Exception e) {
Timber.v(e, "Failed to send pending messages");
for (MessagingListener l : getListeners()) {
l.sendPendingMessagesFailed(account);
}
} finally {
if (lastFailure == null) {
notificationController.clearSendFailedNotification(account);

View file

@ -35,10 +35,6 @@ public interface MessagingListener {
void checkMailStarted(Context context, Account account);
void checkMailFinished(Context context, Account account);
void sendPendingMessagesStarted(Account account);
void sendPendingMessagesCompleted(Account account);
void sendPendingMessagesFailed(Account account);
void folderStatusChanged(Account account, String folderServerId, int unreadMessageCount);
void messageUidChanged(Account account, String folderServerId, String oldUid, String newUid);

View file

@ -79,18 +79,6 @@ public abstract class SimpleMessagingListener implements MessagingListener {
public void checkMailFinished(Context context, Account account) {
}
@Override
public void sendPendingMessagesStarted(Account account) {
}
@Override
public void sendPendingMessagesCompleted(Account account) {
}
@Override
public void sendPendingMessagesFailed(Account account) {
}
@Override
public void folderStatusChanged(Account account, String folderServerId, int unreadMessageCount) {
}

View file

@ -370,15 +370,6 @@ public class MessagingControllerTest extends K9RobolectricTest {
verifyZeroInteractions(listener);
}
@Test
public void sendPendingMessagesSynchronous_shouldCallListenerOnStart() throws MessagingException {
setupAccountWithMessageToSend();
controller.sendPendingMessagesSynchronous(account);
verify(listener).sendPendingMessagesStarted(account);
}
@Test
public void sendPendingMessagesSynchronous_shouldSetProgress() throws MessagingException {
setupAccountWithMessageToSend();
@ -456,15 +447,6 @@ public class MessagingControllerTest extends K9RobolectricTest {
verify(notificationController).showCertificateErrorNotification(account, false);
}
@Test
public void sendPendingMessagesSynchronous_shouldCallListenerOnCompletion() throws MessagingException {
setupAccountWithMessageToSend();
controller.sendPendingMessagesSynchronous(account);
verify(listener).sendPendingMessagesCompleted(account);
}
private void setupAccountWithMessageToSend() throws MessagingException {
when(account.getOutboxFolder()).thenReturn(FOLDER_NAME);
account.setSentFolder(SENT_FOLDER_NAME, SpecialFolderSelection.AUTOMATIC);