mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Don't show parts we can't (yet) decrypt as attachments
This commit is contained in:
parent
e5e4c29736
commit
b40749547c
@ -5,8 +5,10 @@ import java.util.Stack;
|
|||||||
|
|
||||||
import com.fsck.k9.mail.Body;
|
import com.fsck.k9.mail.Body;
|
||||||
import com.fsck.k9.mail.BodyPart;
|
import com.fsck.k9.mail.BodyPart;
|
||||||
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.Multipart;
|
import com.fsck.k9.mail.Multipart;
|
||||||
import com.fsck.k9.mail.Part;
|
import com.fsck.k9.mail.Part;
|
||||||
|
import com.fsck.k9.mail.internet.MimeBodyPart;
|
||||||
|
|
||||||
|
|
||||||
public class MessageHelper {
|
public class MessageHelper {
|
||||||
@ -34,4 +36,12 @@ public class MessageHelper {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MimeBodyPart createEmptyPart() {
|
||||||
|
try {
|
||||||
|
return new MimeBodyPart(null);
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection.OnBound;
|
|||||||
public class MessageCryptoHelper {
|
public class MessageCryptoHelper {
|
||||||
private static final int REQUEST_CODE_CRYPTO = 1000;
|
private static final int REQUEST_CODE_CRYPTO = 1000;
|
||||||
private static final int INVALID_OPENPGP_RESULT_CODE = -1;
|
private static final int INVALID_OPENPGP_RESULT_CODE = -1;
|
||||||
|
private static final MimeBodyPart NO_REPLACEMENT_PART = null;
|
||||||
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@ -83,10 +84,11 @@ public class MessageCryptoHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
|
List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
|
||||||
processFoundParts(encryptedParts, CryptoPartType.ENCRYPTED, CryptoError.ENCRYPTED_BUT_INCOMPLETE);
|
processFoundParts(encryptedParts, CryptoPartType.ENCRYPTED, CryptoError.ENCRYPTED_BUT_INCOMPLETE,
|
||||||
|
MessageHelper.createEmptyPart());
|
||||||
|
|
||||||
List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message);
|
List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message);
|
||||||
processFoundParts(signedParts, CryptoPartType.SIGNED, CryptoError.SIGNED_BUT_INCOMPLETE);
|
processFoundParts(signedParts, CryptoPartType.SIGNED, CryptoError.SIGNED_BUT_INCOMPLETE, NO_REPLACEMENT_PART);
|
||||||
|
|
||||||
List<Part> inlineParts = MessageDecryptVerifier.findPgpInlineParts(message);
|
List<Part> inlineParts = MessageDecryptVerifier.findPgpInlineParts(message);
|
||||||
addFoundInlinePgpParts(inlineParts);
|
addFoundInlinePgpParts(inlineParts);
|
||||||
@ -94,22 +96,22 @@ public class MessageCryptoHelper {
|
|||||||
decryptOrVerifyNextPart();
|
decryptOrVerifyNextPart();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processFoundParts(List<Part> foundParts, CryptoPartType cryptoPartType,
|
private void processFoundParts(List<Part> foundParts, CryptoPartType cryptoPartType, CryptoError errorIfIncomplete,
|
||||||
CryptoError errorIfIncomplete) {
|
MimeBodyPart replacementPart) {
|
||||||
|
|
||||||
for (Part part : foundParts) {
|
for (Part part : foundParts) {
|
||||||
if (MessageHelper.isCompletePartAvailable(part)) {
|
if (MessageHelper.isCompletePartAvailable(part)) {
|
||||||
CryptoPart cryptoPart = new CryptoPart(cryptoPartType, part);
|
CryptoPart cryptoPart = new CryptoPart(cryptoPartType, part);
|
||||||
partsToDecryptOrVerify.add(cryptoPart);
|
partsToDecryptOrVerify.add(cryptoPart);
|
||||||
} else {
|
} else {
|
||||||
addErrorAnnotation(part, errorIfIncomplete);
|
addErrorAnnotation(part, errorIfIncomplete, replacementPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addErrorAnnotation(Part part, CryptoError error) {
|
private void addErrorAnnotation(Part part, CryptoError error, MimeBodyPart outputData) {
|
||||||
OpenPgpResultAnnotation annotation = new OpenPgpResultAnnotation();
|
OpenPgpResultAnnotation annotation = new OpenPgpResultAnnotation();
|
||||||
annotation.setErrorType(error);
|
annotation.setErrorType(error);
|
||||||
|
annotation.setOutputData(outputData);
|
||||||
messageAnnotations.put(part, annotation);
|
messageAnnotations.put(part, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user