Remove unused code

This commit is contained in:
cketti 2019-03-09 19:08:48 +01:00
parent 34c20ce317
commit 3ccabbf95f
11 changed files with 0 additions and 164 deletions

View file

@ -99,13 +99,6 @@ public abstract class Folder<T extends Message> {
return null; return null;
} }
public void delete(List<? extends Message> msgs, String trashFolder) throws MessagingException {
for (Message message : msgs) {
Message myMessage = getMessage(message.getUid());
myMessage.delete(trashFolder);
}
}
public abstract void setFlags(List<? extends Message> messages, Set<Flag> flags, boolean value) public abstract void setFlags(List<? extends Message> messages, Set<Flag> flags, boolean value)
throws MessagingException; throws MessagingException;

View file

@ -137,8 +137,6 @@ public abstract class Message implements Part, Body {
public abstract long getSize(); public abstract long getSize();
public void delete(String trashFolder) throws MessagingException {}
/* /*
* TODO Refactor Flags at some point to be able to store user defined flags. * TODO Refactor Flags at some point to be able to store user defined flags.
*/ */

View file

@ -390,36 +390,6 @@ public class ImapFolder extends Folder<ImapMessage> {
return uidMapping; return uidMapping;
} }
@Override
public void delete(List<? extends Message> messages, String trashFolder) throws MessagingException {
if (messages.isEmpty()) {
return;
}
if (trashFolder == null || getServerId().equals(trashFolder)) {
setFlags(messages, Collections.singleton(Flag.DELETED), true);
} else {
ImapFolder remoteTrashFolder = getStore().getFolder(trashFolder);
String encodedTrashFolderName = folderNameCodec.encode(remoteTrashFolder.getPrefixedName());
String escapedTrashFolderName = ImapUtility.encodeString(encodedTrashFolderName);
if (!exists(escapedTrashFolderName)) {
if (K9MailLib.isDebug()) {
Timber.i("ImapFolder.delete: couldn't find remote trash folder '%s' for %s",
trashFolder, getLogId());
}
throw new FolderNotFoundException(remoteTrashFolder.getServerId());
}
if (K9MailLib.isDebug()) {
Timber.d("IMAPMessage.delete: copying remote %d messages to '%s' for %s",
messages.size(), trashFolder, getLogId());
}
moveMessages(messages, remoteTrashFolder);
}
}
@Override @Override
public int getMessageCount() { public int getMessageCount() {
return messageCount; return messageCount;

View file

@ -28,9 +28,4 @@ public class ImapMessage extends MimeMessage {
super.setFlag(flag, set); super.setFlag(flag, set);
mFolder.setFlags(Collections.singletonList(this), Collections.singleton(flag), set); mFolder.setFlags(Collections.singletonList(this), Collections.singleton(flag), set);
} }
@Override
public void delete(String trashFolder) throws MessagingException {
getFolder().delete(Collections.singletonList(this), trashFolder);
}
} }

View file

@ -379,66 +379,6 @@ public class ImapFolderTest {
assertNull(uidMapping); assertNull(uidMapping);
} }
@Test
public void delete_withEmptyMessageList_shouldNotInteractWithImapConnection() throws Exception {
ImapFolder folder = createFolder("Source");
List<ImapMessage> messages = Collections.emptyList();
folder.delete(messages, "Trash");
verifyNoMoreInteractions(imapConnection);
}
@Test
public void delete_fromTrashFolder_shouldIssueUidStoreFlagsCommand() throws Exception {
ImapFolder folder = createFolder("Folder");
prepareImapFolderForOpen(OPEN_MODE_RW);
List<ImapMessage> messages = singletonList(createImapMessage("23"));
folder.open(OPEN_MODE_RW);
folder.delete(messages, "Folder");
assertCommandWithIdsIssued("UID STORE 23 +FLAGS.SILENT (\\Deleted)");
}
@Test
public void delete_shouldMoveMessagesToTrashFolder() throws Exception {
ImapFolder folder = createFolder("Folder");
prepareImapFolderForOpen(OPEN_MODE_RW);
ImapFolder trashFolder = createFolder("Trash");
when(imapStore.getFolder("Trash")).thenReturn(trashFolder);
List<ImapMessage> messages = singletonList(createImapMessage("2"));
setupCopyResponse("x OK [COPYUID 23 2 102] Success");
folder.open(OPEN_MODE_RW);
folder.delete(messages, "Trash");
assertCommandWithIdsIssued("UID STORE 2 +FLAGS.SILENT (\\Deleted)");
}
@Test
public void delete_withoutTrashFolderExisting_shouldThrow() throws Exception {
ImapFolder folder = createFolder("Folder");
prepareImapFolderForOpen(OPEN_MODE_RW);
ImapFolder trashFolder = createFolder("Trash");
when(imapStore.getFolder("Trash")).thenReturn(trashFolder);
List<ImapMessage> messages = singletonList(createImapMessage("2"));
List<ImapResponse> copyResponses = singletonList(
createImapResponse("x OK [COPYUID 23 2 102] Success")
);
when(imapConnection.executeSimpleCommand("UID COPY 2 \"Trash\"")).thenReturn(copyResponses);
folder.open(OPEN_MODE_RW);
doThrow(NegativeImapResponseException.class).doReturn(Collections.emptyList())
.when(imapConnection).executeSimpleCommand("STATUS \"Trash\" (RECENT)");
try {
folder.delete(messages, "Trash");
fail("Expected exception");
} catch (FolderNotFoundException e) {
assertEquals("Trash", e.getFolderServerId());
}
}
@Test @Test
public void getUnreadMessageCount_withClosedFolder_shouldThrow() throws Exception { public void getUnreadMessageCount_withClosedFolder_shouldThrow() throws Exception {
ImapFolder folder = createFolder("Folder"); ImapFolder folder = createFolder("Folder");

View file

@ -3,7 +3,6 @@ package com.fsck.k9.mail.store.pop3;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -523,11 +522,6 @@ public class Pop3Folder extends Folder<Pop3Message> {
return null; return null;
} }
@Override
public void delete(List<? extends Message> msgs, String trashFolder) throws MessagingException {
setFlags(msgs, Collections.singleton(Flag.DELETED), true);
}
@Override @Override
public String getUidFromMessageId(String messageId) throws MessagingException { public String getUidFromMessageId(String messageId) throws MessagingException {
return null; return null;

View file

@ -24,17 +24,4 @@ public class Pop3Message extends MimeMessage {
super.setFlag(flag, set); super.setFlag(flag, set);
mFolder.setFlags(Collections.singletonList(this), Collections.singleton(flag), set); mFolder.setFlags(Collections.singletonList(this), Collections.singleton(flag), set);
} }
@Override
public void delete(String trashFolder) throws MessagingException {
// try
// {
// Poor POP3 users, we can't copy the message to the Trash folder, but they still want a delete
setFlag(Flag.DELETED, true);
// }
// catch (MessagingException me)
// {
// Log.w(LOG_TAG, "Could not delete non-existent message", me);
// }
}
} }

View file

@ -1,21 +0,0 @@
package com.fsck.k9.mail.store.pop3;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.MessagingException;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
public class Pop3MessageTest {
@Test
public void delete_setsDeletedFlag() throws MessagingException {
Pop3Message message = new Pop3Message("001", mock(Pop3Folder.class));
message.delete("Trash");
assertTrue(message.getFlags().contains(Flag.DELETED));
}
}

View file

@ -104,11 +104,6 @@ public class WebDavFolder extends Folder<WebDavMessage> {
return null; return null;
} }
@Override
public void delete(List<? extends Message> msgs, String trashFolder) throws MessagingException {
moveOrCopyMessages(msgs, trashFolder, true);
}
private void moveOrCopyMessages(List<? extends Message> messages, String folderName, boolean isMove) private void moveOrCopyMessages(List<? extends Message> messages, String folderName, boolean isMove)
throws MessagingException { throws MessagingException {
String[] uids = new String[messages.size()]; String[] uids = new String[messages.size()];

View file

@ -95,13 +95,6 @@ public class WebDavMessage extends MimeMessage {
} }
} }
@Override
public void delete(String trashFolder) throws MessagingException {
WebDavFolder wdFolder = (WebDavFolder) getFolder();
Timber.i("Deleting message by moving to %s", trashFolder);
wdFolder.moveMessages(Collections.singletonList(this), wdFolder.getStore().getFolder(trashFolder));
}
@Override @Override
public void setFlag(Flag flag, boolean set) throws MessagingException { public void setFlag(Flag flag, boolean set) throws MessagingException {
super.setFlag(flag, set); super.setFlag(flag, set);

View file

@ -48,14 +48,6 @@ public class WebDavMessageTest {
assertEquals("http://example.org/Inbox/sub%20folder/mes%20sage.eml", message.getUrl()); assertEquals("http://example.org/Inbox/sub%20folder/mes%20sage.eml", message.getUrl());
} }
@Test
public void delete_asks_folder_to_delete_message() throws MessagingException {
when(mockFolder.getStore()).thenReturn(mockStore);
when(mockStore.getFolder("Trash")).thenReturn(mockTrashFolder);
message.delete("Trash");
verify(mockFolder).moveMessages(Collections.singletonList(message), mockTrashFolder);
}
@Test @Test
public void setNewHeaders_updates_size() throws MessagingException { public void setNewHeaders_updates_size() throws MessagingException {
ParsedMessageEnvelope parsedMessageEnvelope = new ParsedMessageEnvelope(); ParsedMessageEnvelope parsedMessageEnvelope = new ParsedMessageEnvelope();