use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class MessageCompose method processMessageToForward.
private void processMessageToForward(MessageViewInfo messageViewInfo, boolean asAttachment) throws MessagingException {
Message message = messageViewInfo.message;
String subject = messageViewInfo.subject;
if (subject != null && !subject.toLowerCase(Locale.US).startsWith("fwd:")) {
subjectView.setText("Fwd: " + subject);
} else {
subjectView.setText(subject);
}
// even if there are multiple references.
if (!TextUtils.isEmpty(message.getMessageId())) {
repliedToMessageId = message.getMessageId();
referencedMessageIds = repliedToMessageId;
} else {
Timber.d("could not get Message-ID.");
}
// Quote the message and setup the UI.
if (asAttachment) {
attachmentPresenter.processMessageToForwardAsAttachment(messageViewInfo);
} else {
quotedMessagePresenter.processMessageToForward(messageViewInfo);
attachmentPresenter.processMessageToForward(messageViewInfo);
}
setIdentityFromMessage(message);
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class MessageCompose method processMessageToReplyTo.
private void processMessageToReplyTo(MessageViewInfo messageViewInfo) throws MessagingException {
Message message = messageViewInfo.message;
if (messageViewInfo.subject != null) {
final String subject = PREFIX.matcher(messageViewInfo.subject).replaceFirst("");
if (!subject.toLowerCase(Locale.US).startsWith("re:")) {
subjectView.setText("Re: " + subject);
} else {
subjectView.setText(subject);
}
} else {
subjectView.setText("");
}
/*
* If a reply-to was included with the message use that, otherwise use the from
* or sender address.
*/
boolean isReplyAll = action == Action.REPLY_ALL;
recipientPresenter.initFromReplyToMessage(message, isReplyAll);
if (message.getMessageId() != null && message.getMessageId().length() > 0) {
repliedToMessageId = message.getMessageId();
String[] refs = message.getReferences();
if (refs != null && refs.length > 0) {
referencedMessageIds = TextUtils.join("", refs) + " " + repliedToMessageId;
} else {
referencedMessageIds = repliedToMessageId;
}
} else {
Timber.d("could not get Message-ID.");
}
// Quote the message and setup the UI.
quotedMessagePresenter.initFromReplyToMessage(messageViewInfo, action);
if (action == Action.REPLY || action == Action.REPLY_ALL) {
setIdentityFromMessage(message);
}
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class RealImapConnectionTest method open_authPlainWithLoginDisabled_shouldThrow.
@Test
public void open_authPlainWithLoginDisabled_shouldThrow() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "LOGINDISABLED");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (MessagingException e) {
assertEquals("Server doesn't support unencrypted passwords using AUTH=PLAIN and LOGIN is disabled.", e.getMessage());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class RealImapConnectionTest method open_authCramMd5WithoutAuthCramMd5Capability_shouldThrow.
@Test
public void open_authCramMd5WithoutAuthCramMd5Capability_shouldThrow() throws Exception {
settings.setAuthType(AuthType.CRAM_MD5);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=PLAIN");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (MessagingException e) {
assertEquals("Server doesn't support encrypted passwords using CRAM-MD5.", e.getMessage());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class RealImapStore method listFolders.
private List<FolderListItem> listFolders(ImapConnection connection, boolean subscribedOnly) throws IOException, MessagingException {
String commandFormat;
if (subscribedOnly) {
commandFormat = "LSUB \"\" %s";
} else if (connection.hasCapability(Capabilities.SPECIAL_USE) && connection.hasCapability(Capabilities.LIST_EXTENDED)) {
commandFormat = "LIST \"\" %s RETURN (SPECIAL-USE)";
} else {
commandFormat = "LIST \"\" %s";
}
String encodedListPrefix = ImapUtility.encodeString(getCombinedPrefix() + "*");
List<ImapResponse> responses = connection.executeSimpleCommand(String.format(commandFormat, encodedListPrefix));
List<ListResponse> listResponses = (subscribedOnly) ? ListResponse.parseLsub(responses) : ListResponse.parseList(responses);
Map<String, FolderListItem> folderMap = new HashMap<>(listResponses.size());
for (ListResponse listResponse : listResponses) {
String serverId = listResponse.getName();
if (pathDelimiter == null) {
pathDelimiter = listResponse.getHierarchyDelimiter();
combinedPrefix = null;
}
if (RealImapFolder.INBOX.equalsIgnoreCase(serverId)) {
continue;
} else if (listResponse.hasAttribute("\\NoSelect")) {
continue;
}
String name = getFolderDisplayName(serverId);
String oldServerId = getOldServerId(serverId);
FolderType type;
if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) {
type = FolderType.ARCHIVE;
} else if (listResponse.hasAttribute("\\Drafts")) {
type = FolderType.DRAFTS;
} else if (listResponse.hasAttribute("\\Sent")) {
type = FolderType.SENT;
} else if (listResponse.hasAttribute("\\Junk")) {
type = FolderType.SPAM;
} else if (listResponse.hasAttribute("\\Trash")) {
type = FolderType.TRASH;
} else {
type = FolderType.REGULAR;
}
FolderListItem existingItem = folderMap.get(serverId);
if (existingItem == null || existingItem.getType() == FolderType.REGULAR) {
folderMap.put(serverId, new FolderListItem(serverId, name, type, oldServerId));
}
}
List<FolderListItem> folders = new ArrayList<>(folderMap.size() + 1);
folders.add(new FolderListItem(RealImapFolder.INBOX, RealImapFolder.INBOX, FolderType.INBOX, RealImapFolder.INBOX));
folders.addAll(folderMap.values());
return folders;
}
Aggregations