From 82f3c67ff0ac0a4da02aa21e51e933905eaa8580 Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 26 Jan 2017 22:33:42 +0100 Subject: [PATCH] Remove MessagingListener methods that are never used --- .../k9/controller/MessagingController.java | 29 --------------- .../fsck/k9/controller/MessagingListener.java | 19 ---------- .../controller/SimpleMessagingListener.java | 36 ------------------- .../java/com/fsck/k9/service/PollService.java | 5 --- .../k9/activity/ActivityListenerTest.java | 10 ------ .../controller/MessagingControllerTest.java | 33 ----------------- 6 files changed, 132 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java index 93de4449f..92a43495a 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -223,10 +223,6 @@ public class MessagingController { if (K9.DEBUG) { Log.i(K9.LOG_TAG, " Command '" + command.description + "' completed"); } - - for (MessagingListener l : getListeners(command.listener)) { - l.controllerCommandCompleted(!queuedCommands.isEmpty()); - } } } catch (Exception e) { Log.e(K9.LOG_TAG, "Error running command '" + commandDescription + "'", e); @@ -544,24 +540,12 @@ public class MessagingController { } }; - // alert everyone the search has started - if (listener != null) { - listener.listLocalMessagesStarted(account, null); - } - // build and do the query in the localstore try { LocalStore localStore = account.getLocalStore(); localStore.searchForMessages(retrievalListener, search); } catch (Exception e) { - if (listener != null) { - listener.listLocalMessagesFailed(account, null, e.getMessage()); - } addErrorMessage(account, null, e); - } finally { - if (listener != null) { - listener.listLocalMessagesFinished(account, null); - } } } @@ -713,10 +697,6 @@ public class MessagingController { localFolder.appendMessages(Collections.singletonList(message)); localMsg = localFolder.getMessage(message.getUid()); } - - if (listener != null) { - listener.remoteSearchAddMessage(remoteFolder.getName(), localMsg, i, messages.size()); - } } } @@ -1316,7 +1296,6 @@ public class MessagingController { localMessage.setFlag(Flag.X_DOWNLOADED_PARTIAL, message.isSet(Flag.X_DOWNLOADED_PARTIAL)); for (MessagingListener l : getListeners()) { - l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); if (!localMessage.isSet(Flag.SEEN)) { l.synchronizeMailboxNewMessage(account, folder, localMessage); } @@ -1470,7 +1449,6 @@ public class MessagingController { // Update the listener with what we've found for (MessagingListener l : getListeners()) { - l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); l.synchronizeMailboxProgress(account, folder, progress.get(), todo); if (!localMessage.isSet(Flag.SEEN)) { l.synchronizeMailboxNewMessage(account, folder, localMessage); @@ -1543,7 +1521,6 @@ public class MessagingController { newMessages.incrementAndGet(); } for (MessagingListener l : getListeners()) { - l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); l.synchronizeMailboxProgress(account, folder, progress.get(), todo); if (!localMessage.isSet(Flag.SEEN)) { l.synchronizeMailboxNewMessage(account, folder, localMessage); @@ -1670,9 +1647,6 @@ public class MessagingController { l.synchronizeMailboxRemovedMessage(account, folder, localMessage); } } else { - for (MessagingListener l : getListeners()) { - l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); - } if (shouldNotifyForMessage(account, localFolder, localMessage)) { shouldBeNotifiedOf = true; } @@ -2194,9 +2168,6 @@ public class MessagingController { for (Message message : messages) { if (!message.isSet(Flag.SEEN)) { message.setFlag(Flag.SEEN, true); - for (MessagingListener l : getListeners()) { - l.listLocalMessagesUpdateMessage(account, folder, message); - } } } diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingListener.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingListener.java index ac6376686..8cc15e70a 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingListener.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingListener.java @@ -26,12 +26,7 @@ public interface MessagingListener { void listFoldersFinished(Account account); void listFoldersFailed(Account account, String message); - void listLocalMessagesStarted(Account account, String folder); void listLocalMessagesAddMessages(Account account, String folder, List messages); - void listLocalMessagesUpdateMessage(Account account, String folder, Message message); - void listLocalMessagesRemoveMessage(Account account, String folder, Message message); - void listLocalMessagesFinished(Account account, String folder); - void listLocalMessagesFailed(Account account, String folder, String message); void synchronizeMailboxStarted(Account account, String folder); void synchronizeMailboxHeadersStarted(Account account, String folder); @@ -40,7 +35,6 @@ public interface MessagingListener { int numNewMessages); void synchronizeMailboxProgress(Account account, String folder, int completed, int total); void synchronizeMailboxNewMessage(Account account, String folder, Message message); - void synchronizeMailboxAddOrUpdateMessage(Account account, String folder, Message message); void synchronizeMailboxRemovedMessage(Account account, String folder, Message message); void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages); void synchronizeMailboxFailed(Account account, String folder, String message); @@ -50,7 +44,6 @@ public interface MessagingListener { void checkMailStarted(Context context, Account account); void checkMailFinished(Context context, Account account); - void checkMailFailed(Context context, Account account, String reason); void sendPendingMessagesStarted(Account account); void sendPendingMessagesCompleted(Account account); @@ -76,20 +69,8 @@ public interface MessagingListener { void remoteSearchStarted(String folder); void remoteSearchServerQueryComplete(String folderName, int numResults, int maxResults); - void remoteSearchAddMessage(String folder, Message message, int numDone, int numTotal); void remoteSearchFinished(String folder, int numResults, int maxResults, List extraResults); void remoteSearchFailed(String folder, String err); - /** - * General notification messages subclasses can override to be notified that the controller - * has completed a command. This is useful for turning off progress indicators that may have - * been left over from previous commands. - * - * @param moreCommandsToRun - * {@code true} if the controller will continue on to another command immediately. - * {@code false} otherwise. - */ - void controllerCommandCompleted(boolean moreCommandsToRun); - void enableProgressIndicator(boolean enable); } diff --git a/k9mail/src/main/java/com/fsck/k9/controller/SimpleMessagingListener.java b/k9mail/src/main/java/com/fsck/k9/controller/SimpleMessagingListener.java index a6f0ce6e4..785191b84 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/SimpleMessagingListener.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/SimpleMessagingListener.java @@ -44,30 +44,10 @@ public abstract class SimpleMessagingListener implements MessagingListener { public void listFoldersFailed(Account account, String message) { } - @Override - public void listLocalMessagesStarted(Account account, String folder) { - } - @Override public void listLocalMessagesAddMessages(Account account, String folder, List messages) { } - @Override - public void listLocalMessagesUpdateMessage(Account account, String folder, Message message) { - } - - @Override - public void listLocalMessagesRemoveMessage(Account account, String folder, Message message) { - } - - @Override - public void listLocalMessagesFinished(Account account, String folder) { - } - - @Override - public void listLocalMessagesFailed(Account account, String folder, String message) { - } - @Override public void synchronizeMailboxStarted(Account account, String folder) { } @@ -93,10 +73,6 @@ public abstract class SimpleMessagingListener implements MessagingListener { public void synchronizeMailboxNewMessage(Account account, String folder, Message message) { } - @Override - public void synchronizeMailboxAddOrUpdateMessage(Account account, String folder, Message message) { - } - @Override public void synchronizeMailboxRemovedMessage(Account account, String folder, Message message) { } @@ -126,10 +102,6 @@ public abstract class SimpleMessagingListener implements MessagingListener { public void checkMailFinished(Context context, Account account) { } - @Override - public void checkMailFailed(Context context, Account account, String reason) { - } - @Override public void sendPendingMessagesStarted(Account account) { } @@ -198,10 +170,6 @@ public abstract class SimpleMessagingListener implements MessagingListener { public void remoteSearchServerQueryComplete(String folderName, int numResults, int maxResults) { } - @Override - public void remoteSearchAddMessage(String folder, Message message, int numDone, int numTotal) { - } - @Override public void remoteSearchFinished(String folder, int numResults, int maxResults, List extraResults) { } @@ -210,10 +178,6 @@ public abstract class SimpleMessagingListener implements MessagingListener { public void remoteSearchFailed(String folder, String err) { } - @Override - public void controllerCommandCompleted(boolean moreCommandsToRun) { - } - @Override public void enableProgressIndicator(boolean enable) { } diff --git a/k9mail/src/main/java/com/fsck/k9/service/PollService.java b/k9mail/src/main/java/com/fsck/k9/service/PollService.java index 7ee27276f..4ff0d331c 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/PollService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/PollService.java @@ -108,11 +108,6 @@ public class PollService extends CoreService { accountsChecked.clear(); } - @Override - public void checkMailFailed(Context context, Account account, String reason) { - release(); - } - @Override public void synchronizeMailboxFinished( Account account, diff --git a/k9mail/src/test/java/com/fsck/k9/activity/ActivityListenerTest.java b/k9mail/src/test/java/com/fsck/k9/activity/ActivityListenerTest.java index 90ba052a5..660fa1ea4 100644 --- a/k9mail/src/test/java/com/fsck/k9/activity/ActivityListenerTest.java +++ b/k9mail/src/test/java/com/fsck/k9/activity/ActivityListenerTest.java @@ -140,16 +140,6 @@ public class ActivityListenerTest { assertEquals("", operation); } - @Test - public void getOperation__whenSynchronizeMailboxAddOrUpdateMessage() { - activityListener.synchronizeMailboxStarted(account, FOLDER); - activityListener.synchronizeMailboxAddOrUpdateMessage(account, FOLDER, message); - - String operation = activityListener.getOperation(context); - - assertEquals("Poll account:folder", operation); - } - @Test public void getOperation__whenSynchronizeMailboxNewMessage() { activityListener.synchronizeMailboxStarted(account, FOLDER); diff --git a/k9mail/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java b/k9mail/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java index 1dbf3cdfa..bfdcf8d26 100644 --- a/k9mail/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java +++ b/k9mail/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java @@ -360,17 +360,6 @@ public class MessagingControllerTest { verify(listener, never()).listFoldersFinished(account); } - @Test - public void searchLocalMessagesSynchronous_shouldNotifyStartedListingLocalMessages() - throws Exception { - setAccountsInPreferences(Collections.singletonMap("1", account)); - when(search.getAccountUuids()).thenReturn(new String[]{"allAccounts"}); - - controller.searchLocalMessagesSynchronous(search, listener); - - verify(listener).listLocalMessagesStarted(account, null); - } - @Test public void searchLocalMessagesSynchronous_shouldCallSearchForMessagesOnLocalStore() throws Exception { @@ -382,18 +371,6 @@ public class MessagingControllerTest { verify(localStore).searchForMessages(any(MessageRetrievalListener.class), eq(search)); } - @Test - public void searchLocalMessagesSynchronous_shouldNotifyFailureIfStoreThrowsException() throws Exception { - setAccountsInPreferences(Collections.singletonMap("1", account)); - when(search.getAccountUuids()).thenReturn(new String[]{"allAccounts"}); - when(localStore.searchForMessages(any(MessageRetrievalListener.class), eq(search))) - .thenThrow(new MessagingException("Test")); - - controller.searchLocalMessagesSynchronous(search, listener); - - verify(listener).listLocalMessagesFailed(account, null, "Test"); - } - @Test public void searchLocalMessagesSynchronous_shouldNotifyWhenStoreFinishesRetrievingAMessage() throws Exception { @@ -522,16 +499,6 @@ public class MessagingControllerTest { fetchProfileCaptor.capture(), Matchers.eq(null)); } - @Test - public void searchRemoteMessagesSynchronous_shouldNotifyListenerOfNewMessages() throws Exception { - setupRemoteSearch(); - - controller.searchRemoteMessagesSynchronous("1", FOLDER_NAME, "query", reqFlags, forbiddenFlags, listener); - - verify(listener).remoteSearchAddMessage(FOLDER_NAME, localNewMessage1, 1, 2); - verify(listener).remoteSearchAddMessage(FOLDER_NAME, localNewMessage2, 2, 2); - } - @Test public void searchRemoteMessagesSynchronous_shouldNotifyOnFailure() throws Exception { setupRemoteSearch();