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; }
List<AutocryptGossipHeader> getAllAutocryptGossipHeaders(Part part) { String[] headers = part.getHeader(AutocryptGossipHeader.AUTOCRYPT_GOSSIP_HEADER); List<AutocryptGossipHeader> autocryptHeaders = parseAllAutocryptGossipHeaders(headers); return Collections.unmodifiableList(autocryptHeaders); }
@Nullable private String extractProtectedSubject(MessageViewInfo messageViewInfo) { String protectedHeadersParam = MimeUtility.getHeaderParameter( messageViewInfo.rootPart.getContentType(), "protected-headers"); String[] protectedSubjectHeader = messageViewInfo.rootPart.getHeader("Subject"); boolean hasProtectedSubject = "v1".equalsIgnoreCase(protectedHeadersParam) && protectedSubjectHeader.length > 0; if (hasProtectedSubject) { return protectedSubjectHeader[0]; } return null; }
@Override public Object foundLiteral(ImapResponse response, FixedLengthInputStream literal) throws IOException { if (response.getTag() == null && ImapResponseParser.equalsIgnoreCase(response.get(1), "FETCH")) { //TODO: check for correct UID String contentTransferEncoding = part.getHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING)[0]; String contentType = part.getHeader(MimeHeader.HEADER_CONTENT_TYPE)[0]; return bodyFactory.createBody(contentTransferEncoding, contentType, literal); } return null; } }
private Part createPlainTextPart(String serverExtra) { Part part = createPart(serverExtra); when(part.getHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING)).thenReturn( new String[] { MimeUtil.ENC_7BIT } ); when(part.getHeader(MimeHeader.HEADER_CONTENT_TYPE)).thenReturn( new String[] { "text/plain" } ); return part; }
private static String getJisVariantFromReceivedHeaders(Part message) { 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; }
@WorkerThread private AttachmentViewInfo extractAttachmentInfo(Part part, Uri uri, long size, boolean isContentAvailable) { boolean inlineAttachment = false; String mimeType = part.getMimeType(); String contentTypeHeader = part.getContentType(); String contentDisposition = 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 header and a MIME type of image/* are probably components of an HTML message, // not attachments. if (contentDisposition != null && MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)") && part.getHeader(MimeHeader.HEADER_CONTENT_ID).length > 0 && mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("image/")) { inlineAttachment = true; } long attachmentSize = extractAttachmentSize(contentDisposition, size); return new AttachmentViewInfo(mimeType, name, attachmentSize, uri, inlineAttachment, part, isContentAvailable); }
String[] identityHeaders = message.getHeader(K9.IDENTITY_HEADER); if (identityHeaders.length == 0) { identityHeaders = messageViewInfo.rootPart.getHeader(K9.IDENTITY_HEADER);