use of androidx.annotation.Nullable in project k-9 by k9mail.
the class AttachmentInfoExtractor method getDecryptedFileProviderUri.
@Nullable
@VisibleForTesting
protected Uri getDecryptedFileProviderUri(DeferredFileBody decryptedTempFileBody, String mimeType) {
Uri uri;
try {
File file = decryptedTempFileBody.getFile();
uri = DecryptedFileProvider.getUriForProvidedFile(context, file, decryptedTempFileBody.getEncoding(), mimeType);
} catch (IOException e) {
Timber.e(e, "Decrypted temp file (no longer?) exists!");
uri = null;
}
return uri;
}
use of androidx.annotation.Nullable 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 androidx.annotation.Nullable in project k-9 by k9mail.
the class MessageCryptoHelper method getMultipartSignedContentPartIfAvailable.
@Nullable
private static MimeBodyPart getMultipartSignedContentPartIfAvailable(Part part) {
MimeBodyPart replacementPart = NO_REPLACEMENT_PART;
Body body = part.getBody();
if (body instanceof MimeMultipart) {
MimeMultipart multipart = ((MimeMultipart) part.getBody());
if (multipart.getCount() >= 1) {
replacementPart = (MimeBodyPart) multipart.getBodyPart(0);
}
}
return replacementPart;
}
use of androidx.annotation.Nullable in project k-9 by k9mail.
the class AutocryptOperations method createGossipUpdateBundle.
@Nullable
private Bundle createGossipUpdateBundle(Message message, MimeBodyPart decryptedPart) {
List<String> gossipAcceptedAddresses = getGossipAcceptedAddresses(message);
if (gossipAcceptedAddresses.isEmpty()) {
return null;
}
List<AutocryptGossipHeader> autocryptGossipHeaders = autocryptGossipHeaderParser.getAllAutocryptGossipHeaders(decryptedPart);
if (autocryptGossipHeaders.isEmpty()) {
return null;
}
Date messageDate = message.getSentDate();
Date internalDate = message.getInternalDate();
Date effectiveDate = messageDate.before(internalDate) ? messageDate : internalDate;
return createGossipUpdateBundle(gossipAcceptedAddresses, autocryptGossipHeaders, effectiveDate);
}
use of androidx.annotation.Nullable in project k-9 by k9mail.
the class AutocryptGossipHeaderParser method parseAutocryptGossipHeader.
@Nullable
@VisibleForTesting
AutocryptGossipHeader parseAutocryptGossipHeader(String headerValue) {
Map<String, String> parameters = MimeUtility.getAllHeaderParameters(headerValue);
String type = parameters.remove(AutocryptHeader.AUTOCRYPT_PARAM_TYPE);
if (type != null && !type.equals(AutocryptHeader.AUTOCRYPT_TYPE_1)) {
Timber.e("autocrypt: unsupported type parameter %s", type);
return null;
}
String base64KeyData = parameters.remove(AutocryptHeader.AUTOCRYPT_PARAM_KEY_DATA);
if (base64KeyData == null) {
Timber.e("autocrypt: missing key parameter");
return null;
}
ByteString byteString = ByteString.decodeBase64(base64KeyData);
if (byteString == null) {
Timber.e("autocrypt: error parsing base64 data");
return null;
}
String addr = parameters.remove(AutocryptHeader.AUTOCRYPT_PARAM_ADDR);
if (addr == null) {
Timber.e("autocrypt: no to header!");
return null;
}
if (hasCriticalParameters(parameters)) {
return null;
}
return new AutocryptGossipHeader(addr, byteString.toByteArray());
}
Aggregations