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


Java Part.getHeader方法代码示例

本文整理汇总了Java中com.fsck.k9.mail.Part.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java Part.getHeader方法的具体用法?Java Part.getHeader怎么用?Java Part.getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fsck.k9.mail.Part的用法示例。


在下文中一共展示了Part.getHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJisVariantFromReceivedHeaders

import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
private static String getJisVariantFromReceivedHeaders(Part message) throws MessagingException {
    String[] receivedHeaders = message.getHeader("Received");
    if (receivedHeaders.length == 0) {
        return null;
    }

    for (String receivedHeader : receivedHeaders) {
        String address = getAddressFromReceivedHeader(receivedHeader);
        if (address == null) {
            continue;
        }
        String variant = getJisVariantFromAddress(address);
        if (variant != null) {
            return variant;
        }
    }
    return null;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:JisSupport.java

示例2: extractAttachmentInfo

import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
@WorkerThread
private AttachmentViewInfo extractAttachmentInfo(Part part, Uri uri, long size, boolean isContentAvailable)
        throws MessagingException {
    boolean inlineAttachment = false;

    String mimeType = part.getMimeType();
    String contentTypeHeader = MimeUtility.unfoldAndDecode(part.getContentType());
    String contentDisposition = MimeUtility.unfoldAndDecode(part.getDisposition());

    String name = MimeUtility.getHeaderParameter(contentDisposition, "filename");
    if (name == null) {
        name = MimeUtility.getHeaderParameter(contentTypeHeader, "name");
    }

    if (name == null) {
        String extension = null;
        if (mimeType != null) {
            extension = MimeUtility.getExtensionByMimeType(mimeType);
        }
        name = "noname" + ((extension != null) ? "." + extension : "");
    }

    // Inline parts with a content-id are almost certainly components of an HTML message
    // not attachments. Only show them if the user pressed the button to show more
    // attachments.
    if (contentDisposition != null &&
            MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)") &&
            part.getHeader(MimeHeader.HEADER_CONTENT_ID).length > 0) {
        inlineAttachment = true;
    }

    long attachmentSize = extractAttachmentSize(contentDisposition, size);

    return new AttachmentViewInfo(mimeType, name, attachmentSize, uri, inlineAttachment, part, isContentAvailable);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:36,代码来源:AttachmentInfoExtractor.java

示例3: getTransferEncoding

import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
private String getTransferEncoding(Part part) {
    String[] contentTransferEncoding = part.getHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING);
    if (contentTransferEncoding.length > 0) {
        return contentTransferEncoding[0].toLowerCase(Locale.US);
    }

    return MimeUtil.ENC_7BIT;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:9,代码来源:LocalFolder.java

示例4: fetchPart

import com.fsck.k9.mail.Part; //导入方法依赖的package包/类
@Override
public void fetchPart(Message message, Part part, MessageRetrievalListener<Message> listener,
        BodyFactory bodyFactory) throws MessagingException {
    checkOpen();

    String partId = part.getServerExtra();

    String fetch;
    if ("TEXT".equalsIgnoreCase(partId)) {
        int maximumAutoDownloadMessageSize = store.getStoreConfig().getMaximumAutoDownloadMessageSize();
        fetch = String.format(Locale.US, "BODY.PEEK[TEXT]<0.%d>", maximumAutoDownloadMessageSize);
    } else {
        fetch = String.format("BODY.PEEK[%s]", partId);
    }

    try {
        String command = String.format("UID FETCH %s (UID %s)", message.getUid(), fetch);
        connection.sendCommand(command, false);

        ImapResponse response;
        int messageNumber = 0;

        ImapResponseCallback callback = new FetchPartCallback(part, bodyFactory);

        do {
            response = connection.readResponse(callback);

            if (response.getTag() == null && ImapResponseParser.equalsIgnoreCase(response.get(1), "FETCH")) {
                ImapList fetchList = (ImapList) response.getKeyedValue("FETCH");
                String uid = fetchList.getKeyedString("UID");

                if (!message.getUid().equals(uid)) {
                    if (K9MailLib.isDebug()) {
                        Timber.d("Did not ask for UID %s for %s", uid, getLogId());
                    }

                    handleUntaggedResponse(response);
                    continue;
                }

                if (listener != null) {
                    listener.messageStarted(uid, messageNumber++, 1);
                }

                ImapMessage imapMessage = (ImapMessage) message;

                Object literal = handleFetchResponse(imapMessage, fetchList);

                if (literal != null) {
                    if (literal instanceof Body) {
                        // Most of the work was done in FetchAttachmentCallback.foundLiteral()
                        MimeMessageHelper.setBody(part, (Body) literal);
                    } else if (literal instanceof String) {
                        String bodyString = (String) literal;
                        InputStream bodyStream = new ByteArrayInputStream(bodyString.getBytes());

                        String contentTransferEncoding =
                                part.getHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING)[0];
                        String contentType = part.getHeader(MimeHeader.HEADER_CONTENT_TYPE)[0];
                        Body body = bodyFactory.createBody(contentTransferEncoding, contentType, bodyStream);
                        MimeMessageHelper.setBody(part, body);
                    } else {
                        // This shouldn't happen
                        throw new MessagingException("Got FETCH response with bogus parameters");
                    }
                }

                if (listener != null) {
                    listener.messageFinished(message, messageNumber, 1);
                }
            } else {
                handleUntaggedResponse(response);
            }

        } while (response.getTag() == null);
    } catch (IOException ioe) {
        throw ioExceptionHandler(connection, ioe);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:80,代码来源:ImapFolder.java


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