use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class LocalFolder method addChildrenToStack.
private void addChildrenToStack(Stack<PartContainer> stack, Part part, long parentMessageId) {
Body body = part.getBody();
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
for (int i = multipart.getCount() - 1; i >= 0; i--) {
BodyPart childPart = multipart.getBodyPart(i);
stack.push(new PartContainer(parentMessageId, childPart));
}
} else if (body instanceof Message) {
Message innerMessage = (Message) body;
stack.push(new PartContainer(parentMessageId, innerMessage));
}
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class LocalFolder method saveMessagePart.
private long saveMessagePart(SQLiteDatabase db, PartContainer partContainer, long rootMessagePartId, int order) throws IOException, MessagingException {
Part part = partContainer.part;
ContentValues cv = new ContentValues();
if (rootMessagePartId != -1) {
cv.put("root", rootMessagePartId);
}
cv.put("parent", partContainer.parent);
cv.put("seq", order);
cv.put("server_extra", part.getServerExtra());
return updateOrInsertMessagePart(db, cv, part, INVALID_MESSAGE_PART_ID);
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class MessageFulltextCreator method extractText.
private String extractText(Message message) {
Part textPart = textPartFinder.findFirstTextPart(message);
if (textPart == null || hasEmptyBody(textPart)) {
return null;
}
String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_FTS);
String mimeType = textPart.getMimeType();
if (!MimeUtility.isSameMimeType(mimeType, "text/html")) {
return text;
}
return HtmlConverter.htmlToText(text);
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class TextPartFinder method findFirstTextPart.
@Nullable
public Part findFirstTextPart(@NonNull Part part) {
String mimeType = part.getMimeType();
Body body = part.getBody();
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
if (isSameMimeType(mimeType, "multipart/alternative")) {
return findTextPartInMultipartAlternative(multipart);
} else {
return findTextPartInMultipart(multipart);
}
} else if (isSameMimeType(mimeType, "text/plain") || isSameMimeType(mimeType, "text/html")) {
return part;
}
return null;
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class TextPartFinder method findTextPartInMultipart.
private Part findTextPartInMultipart(Multipart multipart) {
for (BodyPart bodyPart : multipart.getBodyParts()) {
String mimeType = bodyPart.getMimeType();
Body body = bodyPart.getBody();
if (body instanceof Multipart) {
Part candidatePart = findFirstTextPart(bodyPart);
if (candidatePart != null) {
return candidatePart;
}
} else if (isSameMimeType(mimeType, "text/plain") || isSameMimeType(mimeType, "text/html")) {
return bodyPart;
}
}
return null;
}
Aggregations