Browse Source

Add disable sync switch for keyrest and so on...

JNI-88
Hussein Kasem 7 years ago
parent
commit
a204c0565b
  1. 2
      src/AdapterTest.java
  2. 2
      src/Makefile.conf
  3. 1
      src/gen_cpp_Engine.ysl2
  4. 7
      src/gen_java_Engine.ysl2
  5. 11
      src/org_pEp_jniadapter_AbstractEngine.cc
  6. 7
      src/pEp.yml2
  7. 1
      test/Makefile
  8. 14
      test/SyncCallbacks.java
  9. 28
      test/Testing.java

2
src/AdapterTest.java

@ -20,7 +20,7 @@ class AdapterTest {
pEp = new Engine();
System.out.println("Setting callbacks");
SyncCallbacks callbacks = new SyncCallbacks();
pEp.setnotifyHandshakeCallback(callbacks);
pEp.setNotifyHandshakeCallback(callbacks);
pEp.setMessageToSendCallback(callbacks);
System.out.println("Calling myself");

2
src/Makefile.conf

@ -1,3 +1,3 @@
CXXFLAGS=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -I$(HOME)/include -fpermissive
CXXFLAGS=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -I$(HOME)/include -fpermissive -DDISABLE_SYNC
LDFLAGS=-L$(HOME)/lib
SHARED=libpEpJNI.dylib

1
src/gen_cpp_Engine.ysl2

@ -13,6 +13,7 @@ tstylesheet {
#include <pEp/message_api.h>
#include <pEp/blacklist.h>
#include <pEp/openpgp_compat.h>
#include <pEp/key_reset.h>
#include <pEp/Adapter.hh>
#include "org_pEp_jniadapter_«@name».h"
#include "throw_pEp_exception.hh"

7
src/gen_java_Engine.ysl2

@ -278,7 +278,12 @@ tstylesheet {
when "$type = 'string' or $type = 'stringlist'"
| ¡$type _«$name» = AbstractEngine.toUTF8(«$name»);
when "$type = 'identity'"
| _Identity _«$name» = new _Identity(«$name»);
||
_Identity _«$name» = null;
if («$name» != null) {
_«$name» = new _Identity(«$name»);
}
||
}
}

11
src/org_pEp_jniadapter_AbstractEngine.cc

@ -194,7 +194,16 @@ extern "C" {
assert(notifyHandShakeMethodID);
}
startup<JNISync>(messageToSend, notifyHandshake, o, &JNISync::startup_sync, &JNISync::shutdown_sync);
thread_local static PEP_SESSION _session = nullptr;
PEP_STATUS status = PEP_STATUS_OK;
#ifdef DISABLE_SYNC
_messageToSend = messageToSend;
session();
#else
startup<JNISync>(messageToSend, notifyHandshake, o, &JNISync::startup_sync, &JNISync::shutdown_sync);
#endif
}
JNIEXPORT void JNICALL Java_org_pEp_jniadapter_AbstractEngine_release(

7
src/pEp.yml2

@ -262,7 +262,12 @@ namespace pEp {
returns string languagelist
);
basic string trustwords(identity ident);
method key_reset(
in string fpr,
in identity ident
);
basic string trustwords(identity ident);
basic identity myself(identity ident);
basic identity updateIdentity(identity ident);
basic identity setOwnKey(identity ident, string fpr);

1
test/Makefile

@ -1,4 +1,5 @@
CLASSPATH=.:../src
#VM=java -Xcheck:jni -Djava.library.path=../src
VM=java -Djava.library.path=../src
test: Testing.class SyncCallbacks.class

14
test/SyncCallbacks.java

@ -3,12 +3,22 @@ import org.pEp.jniadapter.*;
class SyncCallbacks implements Sync.MessageToSendCallback, Sync.NotifyHandshakeCallback {
public void messageToSend(Message message)
{
System.out.println(message.getFrom());
System.out.println("================================");
System.out.println("Message to send called");
System.out.println("From: " + message.getFrom());
System.out.println("To: " + message.getTo());
System.out.println("Subject: " + message.getShortmsg());
System.out.println("================================");
}
public void notifyHandshake(Identity myself, Identity partner, SyncHandshakeSignal signal)
{
System.out.println("================================");
System.out.println("Notify handshake called");
System.out.println("Myself: " + myself);
System.out.println("Partner: " + partner);
System.out.println("Signal: " + signal);
System.out.println("================================");
}
}

28
test/Testing.java

@ -1,7 +1,18 @@
import org.pEp.jniadapter.*;
import java.util.Vector;
import java.net.URL;
import java.net.URLClassLoader;
class Testing {
public void printClassPath() {
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(URL url: urls){
System.out.println(url.getFile());
}
}
public static void main(String[] args) {
Engine e;
@ -46,7 +57,9 @@ class Testing {
Identity to1 = new Identity();
//to1.username = "Volker Birk";
//to1.address = "vb@pep-project.org";
//to1.address = "android01@peptest.ch";
//to1.user_id = "42";
//to.add(to1);
to.add(user);
msg.setTo(to);
@ -89,8 +102,17 @@ class Testing {
System.out.println(result.dst.getShortmsg());
System.out.println(result.dst.getLongmsg());
System.out.println("TEST DONE - FINISHED");
System.exit(0);
System.out.println("TEST DONE - FINISHED");
try {
e.startSync();
e.key_reset(null, null);
}
catch (pEpException ex) {
System.out.println("cannot reset all own keys");
ex.printStackTrace();
}
System.exit(0);
}

Loading…
Cancel
Save