diff --git a/src/foundation/pEp/jniadapter/AbstractEngine.java b/src/foundation/pEp/jniadapter/AbstractEngine.java index f882fce..c12d584 100644 --- a/src/foundation/pEp/jniadapter/AbstractEngine.java +++ b/src/foundation/pEp/jniadapter/AbstractEngine.java @@ -194,5 +194,39 @@ abstract class AbstractEngine extends UniquelyIdentifiable implements AutoClosea } return 0; } + + public static Message incomingMessageFromPGPText(String pgpText, Message.EncFormat encFormat) { + Message msg = new Message(); + msg.setDir(Message.Direction.Incoming); + msg.setShortmsg("p≡p"); + msg.setLongmsg("this message was encrypted with p≡p https://pEp-project.org"); + msg.setEncFormat(encFormat); + + // Attachments + Blob att0 = new Blob(); + att0.mime_type = "application/pgp-encrypted"; + att0.filename = null; + att0.data = "Version: 1".getBytes(); + + Blob att1 = new Blob(); + att1.mime_type = "application/octet-stream"; + att1.filename = "file://msg.asc"; + att1.data = pgpText.getBytes(); + + Vector attachments = new Vector<>(); + attachments.add(att0); + attachments.add(att1); + msg.setAttachments(attachments); + + // Opts + ArrayList> opts = new ArrayList<>(); + Pair xpEp = new Pair<>(); + xpEp.first = "X-pEp-Version"; + xpEp.second = "2.1"; + opts.add(xpEp); + msg.setOptFields(opts); + + return msg; + } }