From 4bc21c82b2b8ed6feb4435e5f81049973900d873 Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 7 May 2020 00:46:44 +0200 Subject: [PATCH] first draft of incomingMessageFromPGPText() --- .../pEp/jniadapter/AbstractEngine.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) 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; + } }