Remove unused callbacks from MessageRetrievalListener

This commit is contained in:
cketti 2022-02-24 19:32:29 +01:00
parent 065f98cfdd
commit e59f57f602
11 changed files with 4 additions and 97 deletions

View file

@ -418,14 +418,6 @@ public class MessagingController {
// Collecting statistics of the search result
MessageRetrievalListener<LocalMessage> retrievalListener = new MessageRetrievalListener<LocalMessage>() {
@Override
public void messageStarted(String message, int number, int ofTotal) {
}
@Override
public void messagesFinished(int number) {
}
@Override
public void messageFinished(LocalMessage message, int number, int ofTotal) {
if (!isMessageSuppressed(message)) {

View file

@ -395,9 +395,9 @@ public class LocalStore {
final String queryString, final String[] placeHolders
) throws MessagingException {
final List<LocalMessage> messages = new ArrayList<>();
final int j = database.execute(false, new DbCallback<Integer>() {
database.execute(false, new DbCallback<Void>() {
@Override
public Integer doDbWork(final SQLiteDatabase db) {
public Void doDbWork(final SQLiteDatabase db) {
Cursor cursor = null;
int i = 0;
try {
@ -431,12 +431,10 @@ public class LocalStore {
} finally {
Utility.closeQuietly(cursor);
}
return i;
return null;
}
});
if (listener != null) {
listener.messagesFinished(j);
}
return Collections.unmodifiableList(messages);

View file

@ -509,9 +509,6 @@ internal class ImapSync(
Timber.e(e, "Error while storing downloaded message.")
}
}
override fun messageStarted(uid: String, number: Int, ofTotal: Int) = Unit
override fun messagesFinished(total: Int) = Unit
},
syncConfig.maximumAutoDownloadMessageSize
)
@ -562,9 +559,6 @@ internal class ImapSync(
Timber.e(e, "SYNC: fetch small messages")
}
}
override fun messageStarted(uid: String, number: Int, ofTotal: Int) = Unit
override fun messagesFinished(total: Int) = Unit
},
-1
)

View file

@ -447,16 +447,6 @@ class Pop3Sync {
Timber.e(e, "Error while storing downloaded message.");
}
}
@Override
public void messageStarted(String uid, int number, int ofTotal) {
}
@Override
public void messagesFinished(int total) {
// FIXME this method is almost never invoked by various Stores! Don't rely on it unless fixed!!
}
},
syncConfig.getMaximumAutoDownloadMessageSize());
}
@ -503,14 +493,6 @@ class Pop3Sync {
Timber.e(e, "SYNC: fetch small messages");
}
}
@Override
public void messageStarted(String uid, int number, int ofTotal) {
}
@Override
public void messagesFinished(int total) {
}
},
-1);

View file

@ -433,16 +433,6 @@ class WebDavSync {
Timber.e(e, "Error while storing downloaded message.");
}
}
@Override
public void messageStarted(String uid, int number, int ofTotal) {
}
@Override
public void messagesFinished(int total) {
// FIXME this method is almost never invoked by various Stores! Don't rely on it unless fixed!!
}
},
syncConfig.getMaximumAutoDownloadMessageSize());
}
@ -488,14 +478,6 @@ class WebDavSync {
Timber.e(e, "SYNC: fetch small messages");
}
}
@Override
public void messageStarted(String uid, int number, int ofTotal) {
}
@Override
public void messagesFinished(int total) {
}
},
-1);

View file

@ -3,12 +3,5 @@ package com.fsck.k9.mail;
public interface MessageRetrievalListener<T extends Message> {
void messageStarted(String uid, int number, int ofTotal);
void messageFinished(T message, int number, int ofTotal);
/**
* FIXME <strong>this method is almost never invoked by various Stores! Don't rely on it unless fixed!!</strong>
*/
void messagesFinished(int total);
}

View file

@ -505,7 +505,6 @@ internal class RealImapFolder(
val count = uids.size
return uids.mapIndexed { index, uidLong ->
val uid = uidLong.toString()
listener?.messageStarted(uid, index, count)
val message = ImapMessage(uid)
listener?.messageFinished(message, index, count)
@ -596,8 +595,6 @@ internal class RealImapFolder(
continue
}
listener?.messageStarted(uid, messageNumber++, messageMap.size)
val literal = handleFetchResponse(message, fetchList)
if (literal != null) {
when (literal) {
@ -668,8 +665,6 @@ internal class RealImapFolder(
continue
}
listener?.messageStarted(uid, messageNumber++, 1)
val literal = handleFetchResponse(message, fetchList)
if (literal != null) {
when (literal) {

View file

@ -475,7 +475,6 @@ class RealImapFolderTest {
val messages = folder.getMessages(1, 10, null, listener)
verify(listener).messageStarted("99", 0, 1)
verify(listener).messageFinished(messages[0], 0, 1)
verifyNoMoreInteractions(listener)
}
@ -563,7 +562,6 @@ class RealImapFolderTest {
val messages = folder.getMessages(setOf(1L), true, listener)
verify(listener).messageStarted("99", 0, 1)
verify(listener).messageFinished(messages[0], 0, 1)
verifyNoMoreInteractions(listener)
}

View file

@ -133,9 +133,6 @@ public class Pop3Folder {
continue;
}
if (listener != null) {
listener.messageStarted(message.getUid(), i++, (end - start) + 1);
}
messages.add(message);
if (listener != null) {
listener.messageFinished(message, i++, (end - start) + 1);
@ -320,9 +317,6 @@ public class Pop3Folder {
for (int i = 0, count = messages.size(); i < count; i++) {
Pop3Message pop3Message = messages.get(i);
try {
if (listener != null && !fp.contains(FetchProfile.Item.ENVELOPE)) {
listener.messageStarted(pop3Message.getUid(), i, count);
}
if (fp.contains(FetchProfile.Item.BODY)) {
fetchBody(pop3Message, -1);
} else if (fp.contains(FetchProfile.Item.BODY_SANE)) {
@ -369,9 +363,6 @@ public class Pop3Folder {
*/
for (int i = 0, count = messages.size(); i < count; i++) {
Pop3Message message = messages.get(i);
if (listener != null) {
listener.messageStarted(message.getUid(), i, count);
}
String response = connection.executeSimpleCommand(
String.format(Locale.US, LIST_COMMAND + " %d",
uidToMsgNumMap.get(message.getUid())));
@ -400,9 +391,6 @@ public class Pop3Folder {
int msgSize = Integer.parseInt(listParts[1]);
Pop3Message pop3Message = msgNumToMsgMap.get(msgNum);
if (pop3Message != null && msgUidIndex.contains(pop3Message.getUid())) {
if (listener != null) {
listener.messageStarted(pop3Message.getUid(), i, count);
}
pop3Message.setSize(msgSize);
if (listener != null) {
listener.messageFinished(pop3Message, i, count);

View file

@ -235,9 +235,6 @@ public class WebDavFolder {
uidsLength = uids.length;
for (int i = 0; i < uidsLength; i++) {
if (listener != null) {
listener.messageStarted(uids[i], i, uidsLength);
}
WebDavMessage message = new WebDavMessage(uids[i], this);
message.setUrl(uidToUrl.get(uids[i]));
messages.add(message);
@ -313,10 +310,6 @@ public class WebDavFolder {
WebDavMessage wdMessage = messages.get(i);
int statusCode = 0;
if (listener != null) {
listener.messageStarted(wdMessage.getUid(), i, count);
}
/**
* If fetch is called outside of the initial list (ie, a locally stored message), it may not have a URL
* associated. Verify and fix that
@ -514,9 +507,6 @@ public class WebDavFolder {
int count = messages.size();
for (int i = messages.size() - 1; i >= 0; i--) {
WebDavMessage message = messages.get(i);
if (listener != null) {
listener.messageStarted(messages.get(i).getUid(), i, count);
}
ParsedMessageEnvelope envelope = envelopes.get(message.getUid());
if (envelope != null) {

View file

@ -221,7 +221,6 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageStarted(any(String.class), anyInt(), eq(25));
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), eq(25));
}
@ -252,7 +251,6 @@ public class WebDavFolderTest {
profile.add(FetchProfile.Item.FLAGS);
profile.add(FetchProfile.Item.BODY);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageStarted(any(String.class), anyInt(), anyInt());
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), anyInt());
}
@ -293,7 +291,6 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageStarted(any(String.class), anyInt(), eq(25));
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), eq(25));
}
@ -324,7 +321,6 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageStarted(any(String.class), anyInt(), eq(25));
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), eq(25));
}
@ -391,7 +387,6 @@ public class WebDavFolderTest {
folder.getMessages(messageStart, messageEnd, listener);
verify(listener, times(5)).messageStarted(anyString(), anyInt(), eq(5));
verify(listener, times(5)).messageFinished(any(WebDavMessage.class), anyInt(), eq(5));
}