use of com.fsck.k9.mail.store.pop3.Pop3Message in project k-9 by k9mail.
the class Pop3Folder method setFlags.
public void setFlags(List<Pop3Message> messages, final Set<Flag> flags, boolean value) throws MessagingException {
if (!value || !flags.contains(Flag.DELETED)) {
/*
* The only flagging we support is setting the Deleted flag.
*/
return;
}
List<String> uids = new ArrayList<>();
try {
for (Pop3Message message : messages) {
uids.add(message.getUid());
}
indexUids(uids);
} catch (IOException ioe) {
throw new MessagingException("Could not get message number for uid " + uids, ioe);
}
for (Pop3Message message : messages) {
Integer msgNum = uidToMsgNumMap.get(message.getUid());
if (msgNum == null) {
throw new MessagingException("Could not delete message " + message.getUid() + " because no msgNum found; permanent error", true);
}
open();
connection.executeSimpleCommand(String.format(DELE_COMMAND + " %s", msgNum));
}
}
use of com.fsck.k9.mail.store.pop3.Pop3Message in project k-9 by k9mail.
the class Pop3FolderTest method fetch_withBodyProfile_setsContentOfMessage.
@Test
public void fetch_withBodyProfile_setsContentOfMessage() throws MessagingException, IOException {
InputStream messageInputStream = new ByteArrayInputStream(("From: <adam@example.org>\r\n" + "To: <eva@example.org>\r\n" + "Subject: Testmail\r\n" + "MIME-Version: 1.0\r\n" + "Content-type: text/plain\r\n" + "Content-Transfer-Encoding: 7bit\r\n" + "\r\n" + "this is some test text.").getBytes());
folder.open();
List<Pop3Message> messageList = setupMessageFromServer();
FetchProfile fetchProfile = new FetchProfile();
fetchProfile.add(Item.BODY);
when(mockConnection.readLine()).thenReturn("1 100").thenReturn(".");
when(mockConnection.getInputStream()).thenReturn(messageInputStream);
folder.fetch(messageList, fetchProfile, mockListener, MAX_DOWNLOAD_SIZE);
ByteArrayOutputStream bodyData = new ByteArrayOutputStream();
messageList.get(0).getBody().writeTo(bodyData);
assertEquals("this is some test text.", new String(bodyData.toByteArray(), "UTF-8"));
}
Aggregations