当前位置: 首页>>代码示例>>Java>>正文


Java Part.getBody方法代码示例

本文整理汇总了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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:TextPartFinder.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:26,代码来源:MessageCryptoStructureDetector.java

示例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);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:23,代码来源:LocalStore.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:17,代码来源:MessageDecryptVerifier.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:26,代码来源:MessageDecryptVerifier.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:MessageCryptoStructureDetector.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:15,代码来源:MimeUtility.java

示例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");
            }
        }
    };
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:16,代码来源:MessageCryptoHelper.java

示例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);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:9,代码来源:LocalFolder.java

示例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));
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:14,代码来源:LocalFolder.java

示例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);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:8,代码来源:MimeMessageHelper.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:15,代码来源:MessageCryptoStructureDetector.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:51,代码来源:MessageExtractor.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:16,代码来源:MessageExtractor.java

示例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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:33,代码来源:MessageDecryptVerifier.java


注:本文中的com.fsck.k9.mail.Part.getBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。