Browse Source

Merge with default

JNI-88
Hussein Kasem 7 years ago
parent
commit
d9baafb2f2
  1. 2
      android/build.gradle
  2. 2
      android/src/org/pEp/jniadapter/AndroidHelper.java
  3. 2
      src/Makefile
  4. 4
      src/gen_java_Message.ysl2
  5. 39
      test/Testing.java

2
android/build.gradle

@ -31,7 +31,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '28.0.2'
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 18

2
android/src/org/pEp/jniadapter/AndroidHelper.java

@ -29,7 +29,7 @@ public class AndroidHelper {
private static File tmpDir;
// TODO : Increment when needed.
public static int ENGINE_VERSION_CODE = 3063;
public static int ENGINE_VERSION_CODE = 3104;
private static File shareDir;

2
src/Makefile

@ -3,7 +3,7 @@ SHARED=libpEpJNI.so
JAR=jniadapter.jar
include Makefile.conf
CXXFLAGS+=-std=c++14
CXXFLAGS+=-std=c++14 -fPIC
all: $(JAR) $(SHARED)

4
src/gen_java_Message.ysl2

@ -16,8 +16,10 @@ tstylesheet {
import java.util.Vector;
import java.util.Date;
import java.util.HashMap;
import java.io.Serializable;
public class «$cname» implements AutoCloseable {
public class «$cname» implements AutoCloseable, Serializable {
private static final long serialVersionUID = 2119420428331150924L;
private long handle;
native long init();

39
test/Testing.java

@ -15,6 +15,18 @@ class Testing {
}
System.out.println("Test loaded");
// Keygen
System.out.println("Generating keys: ");
Identity user = new Identity();
user.user_id = "pEp_own_userId";
user.me = true;
user.username = "Test User";
user.address = "jniTestUser@peptest.ch";
user = e.myself(user);
System.out.print("Keys generated: ");
System.out.println(user.fpr);
// trustwords
Identity vb = new Identity();
vb.fpr = "DB4713183660A12ABAFA7714EBE90D44146F62F4";
@ -25,52 +37,51 @@ class Testing {
// message
Message msg = new Message();
Identity from = new Identity();
from.username = "Volker Birk";
from.address = "vb@dingens.org";
from.user_id = "23";
from.me = true;
msg.setFrom(from);
msg.setFrom(user);
Vector<Identity> to = new Vector<Identity>();
Identity to1 = new Identity();
to1.username = "Volker Birk";
to1.address = "vb@pep-project.org";
to1.user_id = "42";
to.add(to1);
//to1.username = "Volker Birk";
//to1.address = "vb@pep-project.org";
//to1.user_id = "42";
to.add(user);
msg.setTo(to);
msg.setShortmsg("hello, world");
msg.setLongmsg("this is a test");
msg.setDir(Message.Direction.Outgoing);
Message enc = null;
try {
enc = e.encrypt_message(msg, null);
enc = e.encrypt_message(msg, null, Message.EncFormat.PEP);
System.out.println("encrypted");
}
catch (pEpException ex) {
System.out.println("cannot encrypt");
ex.printStackTrace();
}
System.out.println(enc.getLongmsg());
Vector<Blob> attachments = enc.getAttachments();
System.out.println(e.toUTF16(attachments.get(1).data));
msg.setDir(Message.Direction.Outgoing);
try {
System.out.println(e.outgoing_message_color(msg));
System.out.println(e.outgoing_message_rating(msg));
}
catch (pEpException ex) {
System.out.println("cannot measure outgoing message color");
System.out.println("cannot measure outgoing message rating");
}
Engine.decrypt_message_Return result = null;
try {
result = e.decrypt_message(enc);
result = e.decrypt_message(enc, new Vector<>(), 0);
System.out.println("decrypted");
}
catch (pEpException ex) {
System.out.println("cannot decrypt");
ex.printStackTrace();
}
System.out.println(result.dst.getShortmsg());

Loading…
Cancel
Save