本文整理汇总了Java中com.fsck.k9.mail.Part.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java Part.getBody方法的具体用法?Java Part.getBody怎么用?Java Part.getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fsck.k9.mail.Part
的用法示例。
在下文中一共展示了Part.getBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findFirstTextPart
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
@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;
}
示例2: findMultipartEncryptedParts
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
public static List<Part> findMultipartEncryptedParts(Part startPart) {
List<Part> encryptedParts = new ArrayList<>();
Stack<Part> partsToCheck = new Stack<>();
partsToCheck.push(startPart);
while (!partsToCheck.isEmpty()) {
Part part = partsToCheck.pop();
Body body = part.getBody();
if (isPartMultipartEncrypted(part)) {
encryptedParts.add(part);
continue;
}
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
for (int i = multipart.getCount() - 1; i >= 0; i--) {
BodyPart bodyPart = multipart.getBodyPart(i);
partsToCheck.push(bodyPart);
}
}
}
return encryptedParts;
}
示例3: writeRawBodyToStream
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
private void writeRawBodyToStream(Cursor cursor, SQLiteDatabase db, OutputStream outputStream)
throws IOException, MessagingException {
long partId = cursor.getLong(ATTACH_PART_ID_INDEX);
String rootPart = cursor.getString(ATTACH_ROOT_INDEX);
LocalMessage message = loadLocalMessageByRootPartId(db, rootPart);
if (message == null) {
throw new MessagingException("Unable to find message for attachment!");
}
Part part = findPartById(message, partId);
if (part == null) {
throw new MessagingException("Unable to find attachment part in associated message (db integrity error?)");
}
Body body = part.getBody();
if (body == null) {
throw new MessagingException("Attachment part isn't available!");
}
body.writeTo(outputStream);
}
示例4: findPrimaryPartInAlternative
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
private static Part findPrimaryPartInAlternative(Part part) {
Body body = part.getBody();
if (part.isMimeType("multipart/alternative") && body instanceof Multipart) {
Multipart multipart = (Multipart) body;
if (multipart.getCount() == 0) {
return null;
}
BodyPart firstBodyPart = multipart.getBodyPart(0);
if (isPartPgpInlineEncryptedOrSigned(firstBodyPart)) {
return firstBodyPart;
}
}
return null;
}
示例5: findEncryptedParts
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
public static List<Part> findEncryptedParts(Part startPart) {
List<Part> encryptedParts = new ArrayList<>();
Stack<Part> partsToCheck = new Stack<>();
partsToCheck.push(startPart);
while (!partsToCheck.isEmpty()) {
Part part = partsToCheck.pop();
Body body = part.getBody();
if (isPartMultipartEncrypted(part)) {
encryptedParts.add(part);
continue;
}
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
for (int i = multipart.getCount() - 1; i >= 0; i--) {
BodyPart bodyPart = multipart.getBodyPart(i);
partsToCheck.push(bodyPart);
}
}
}
return encryptedParts;
}
示例6: isPartMultipartSigned
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
private static boolean isPartMultipartSigned(Part part) {
if (!isSameMimeType(part.getMimeType(), MULTIPART_SIGNED)) {
return false;
}
if (! (part.getBody() instanceof MimeMultipart)) {
return false;
}
MimeMultipart mimeMultipart = (MimeMultipart) part.getBody();
if (mimeMultipart.getCount() != 2) {
return false;
}
String protocolParameter = MimeUtility.getHeaderParameter(part.getContentType(), PROTOCOL_PARAMETER);
// for partially downloaded messages the protocol parameter isn't yet available, so we'll just assume it's ok
boolean dataUnavailable = protocolParameter == null && mimeMultipart.getBodyPart(0).getBody() == null;
boolean protocolMatches = isSameMimeType(protocolParameter, mimeMultipart.getBodyPart(1).getMimeType());
return dataUnavailable || protocolMatches;
}
示例7: findFirstPartByMimeType
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
public static Part findFirstPartByMimeType(Part part, String mimeType) {
if (part.getBody() instanceof Multipart) {
Multipart multipart = (Multipart)part.getBody();
for (BodyPart bodyPart : multipart.getBodyParts()) {
Part ret = MimeUtility.findFirstPartByMimeType(bodyPart, mimeType);
if (ret != null) {
return ret;
}
}
} else if (isSameMimeType(part.getMimeType(), mimeType)) {
return part;
}
return null;
}
示例8: getDataSourceForOpenPgpSignedData
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
private OpenPgpDataSource getDataSourceForOpenPgpSignedData(final Part signedPart) throws IOException {
return new OpenPgpDataSource() {
@Override
public void writeTo(OutputStream os) throws IOException {
try {
Multipart multipartSignedMultipart = (Multipart) signedPart.getBody();
BodyPart signatureBodyPart = multipartSignedMultipart.getBodyPart(0);
Timber.d("signed data type: %s", signatureBodyPart.getMimeType());
signatureBodyPart.writeTo(os);
} catch (MessagingException e) {
Timber.e(e, "Exception while writing message to crypto provider");
}
}
};
}
示例9: writeBodyToDiskIfNecessary
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
private File writeBodyToDiskIfNecessary(Part part) throws MessagingException, IOException {
Body body = part.getBody();
if (body instanceof BinaryTempFileBody) {
return ((BinaryTempFileBody) body).getFile();
} else {
return writeBodyToDisk(body);
}
}
示例10: addChildrenToStack
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
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));
}
}
示例11: setEncoding
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
public static void setEncoding(Part part, String encoding) throws MessagingException {
Body body = part.getBody();
if (body != null) {
body.setEncoding(encoding);
}
part.setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, encoding);
}
示例12: getSignatureData
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
public static byte[] getSignatureData(Part part) throws IOException, MessagingException {
if (isPartMultipartSigned(part)) {
Body body = part.getBody();
if (body instanceof Multipart) {
Multipart multi = (Multipart) body;
BodyPart signatureBody = multi.getBodyPart(1);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
signatureBody.getBody().writeTo(bos);
return bos.toByteArray();
}
}
return null;
}
示例13: findTextPart
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
/**
* Search the children of a {@link Multipart} for {@code text/plain} parts.
*
* @param multipart The {@code Multipart} to search through.
* @param directChild If {@code true}, this method will return after the first {@code text/plain} was
* found.
*
* @return A list of {@link Text} viewables.
*
* @throws MessagingException
* In case of an error.
*/
private static List<Viewable> findTextPart(Multipart multipart, boolean directChild)
throws MessagingException {
List<Viewable> viewables = new ArrayList<Viewable>();
for (Part part : multipart.getBodyParts()) {
Body body = part.getBody();
if (body instanceof Multipart) {
Multipart innerMultipart = (Multipart) body;
/*
* Recurse to find text parts. Since this is a multipart that is a child of a
* multipart/alternative we don't want to stop after the first text/plain part
* we find. This will allow to get all text parts for constructions like this:
*
* 1. multipart/alternative
* 1.1. multipart/mixed
* 1.1.1. text/plain
* 1.1.2. text/plain
* 1.2. text/html
*/
List<Viewable> textViewables = findTextPart(innerMultipart, false);
if (!textViewables.isEmpty()) {
viewables.addAll(textViewables);
if (directChild) {
break;
}
}
} else if (isPartTextualBody(part) && isSameMimeType(part.getMimeType(), "text/plain")) {
Text text = new Text(part);
viewables.add(text);
if (directChild) {
break;
}
}
}
return viewables;
}
示例14: hasMissingParts
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
public static boolean hasMissingParts(Part part) {
Body body = part.getBody();
if (body == null) {
return true;
}
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
for (Part subPart : multipart.getBodyParts()) {
if (hasMissingParts(subPart)) {
return true;
}
}
}
return false;
}
示例15: findSignedParts
import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) {
List<Part> signedParts = new ArrayList<>();
Stack<Part> partsToCheck = new Stack<>();
partsToCheck.push(startPart);
while (!partsToCheck.isEmpty()) {
Part part = partsToCheck.pop();
if (messageCryptoAnnotations.has(part)) {
CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part);
MimeBodyPart replacementData = resultAnnotation.getReplacementData();
if (replacementData != null) {
part = replacementData;
}
}
Body body = part.getBody();
if (isPartMultipartSigned(part)) {
signedParts.add(part);
continue;
}
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
for (int i = multipart.getCount() - 1; i >= 0; i--) {
BodyPart bodyPart = multipart.getBodyPart(i);
partsToCheck.push(bodyPart);
}
}
}
return signedParts;
}