Browse Source

JNI-158 - JNI-159 - Remove all keyserver functions

JNI-158
heck 4 months ago
parent
commit
5e2a042197
4 changed files with 0 additions and 139 deletions
  1. +0
    -114
      src/cxx/foundation_pEp_jniadapter_AbstractEngine.cc
  2. +0
    -17
      src/java/foundation/pEp/jniadapter/AbstractEngine.java
  3. +0
    -4
      src/java/foundation/pEp/jniadapter/interfaces/AbstractEngineInterface.java
  4. +0
    -4
      test/java/foundation/pEp/jniadapter/test/regression/TestMain.java

+ 0
- 114
src/cxx/foundation_pEp_jniadapter_AbstractEngine.cc View File

@ -1,5 +1,4 @@
#include "foundation_pEp_jniadapter_AbstractEngine.h"
#include <unistd.h>
#include <pEp/keymanagement.h>
#include <pEp/message_api.h>
#include <pEp/sync_api.h>
@ -326,119 +325,6 @@ int examine_identity(pEp_identity *ident,
return 0;
}
pEp_identity *retrieve_next_identity(void *arg)
{
pEpLog("called");
locked_queue < pEp_identity * > *queue = static_cast<locked_queue < pEp_identity * > * > (arg);
while (!queue->size()) {
usleep(100000);
}
pEp_identity *ident = queue->front();
queue->pop_front();
return ident;
}
static void *keyserver_thread_routine(void *arg)
{
PEP_STATUS status = do_keymanagement(retrieve_next_identity, arg);
locked_queue < pEp_identity * > *queue = static_cast<locked_queue < pEp_identity * > * > (arg);
while (queue->size()) {
pEp_identity *ident = queue->front();
queue->pop_front();
free_identity(ident);
}
delete queue;
return reinterpret_cast<void *>(status);
}
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine__1startKeyserverLookup(JNIEnv *env,
jobject obj)
{
std::mutex *mutex_local = nullptr;
{
std::lock_guard<std::mutex> l(global_mutex);
pEpLog("called with lock_guard");
mutex_local = get_engine_java_object_mutex(env, obj);
}
std::lock_guard<std::mutex> l(*mutex_local);
pthread_t *thread = nullptr;
locked_queue< pEp_identity * > *queue = nullptr;
jfieldID thread_handle;
jfieldID queue_handle;
try {
thread_handle = getFieldID(env, "foundation/pEp/jniadapter/Engine", "keyserverThread", "J");
queue_handle = getFieldID(env, "foundation/pEp/jniadapter/Engine", "keyserverQueue", "J");
}
catch (std::exception& ex) {
assert(0);
return;
}
thread = reinterpret_cast<pthread_t*>(env->GetLongField(obj, thread_handle));
if (thread)
return;
thread = static_cast<pthread_t*>(calloc(1, sizeof(pthread_t)));
assert(thread);
env->SetLongField(obj, thread_handle, reinterpret_cast<jlong>(thread));
queue = new locked_queue< pEp_identity * >();
env->SetLongField(obj, queue_handle, reinterpret_cast<jlong>(queue));
register_examine_function(Adapter::session(), examine_identity,static_cast<void*>(queue));
pthread_create(thread, nullptr, keyserver_thread_routine, static_cast<void*>(queue));
}
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine__1stopKeyserverLookup(JNIEnv *env,
jobject obj)
{
std::mutex *mutex_local = nullptr;
{
std::lock_guard<std::mutex> l(global_mutex);
pEpLog("called with lock_guard");
mutex_local = get_engine_java_object_mutex(env, obj);
}
std::lock_guard<std::mutex> l(*mutex_local);
pthread_t *thread = nullptr;
locked_queue< pEp_identity * > *queue = nullptr;
jfieldID thread_handle;
jfieldID queue_handle;
try {
thread_handle = getFieldID(env, "foundation/pEp/jniadapter/Engine", "keyserverThread", "J");
queue_handle = getFieldID(env, "foundation/pEp/jniadapter/Engine", "keyserverQueue", "J");
}
catch (std::exception& ex) {
assert(0);
return;
}
thread = reinterpret_cast<pthread_t*>(env->GetLongField(obj, thread_handle));
if (!thread)
return;
queue = reinterpret_cast<locked_queue<pEp_identity*>*>(env->GetLongField(obj, queue_handle));
env->SetLongField(obj, queue_handle, 0);
env->SetLongField(obj, thread_handle, 0);
register_examine_function(Adapter::session(), nullptr, nullptr);
queue->push_front(nullptr);
pthread_join(*thread, nullptr);
free(thread);
}
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine__1startSync(JNIEnv *env,
jobject obj)
{


+ 0
- 17
src/java/foundation/pEp/jniadapter/AbstractEngine.java View File

@ -23,9 +23,6 @@ abstract class AbstractEngine extends UniquelyIdentifiable implements AbstractEn
private native void init();
private native void release();
private long keyserverThread;
private long keyserverQueue;
public AbstractEngine() throws pEpException {
synchronized (AbstractEngine.class) {
init();
@ -67,20 +64,6 @@ abstract class AbstractEngine extends UniquelyIdentifiable implements AbstractEn
private native String _getProtocolVersion();
public void startKeyserverLookup() {
_startKeyserverLookup();
}
private native void _startKeyserverLookup();
public void stopKeyserverLookup() {
_startKeyserverLookup();
}
private native void _stopKeyserverLookup();
public void startSync() {
_startSync();
}


+ 0
- 4
src/java/foundation/pEp/jniadapter/interfaces/AbstractEngineInterface.java View File

@ -8,10 +8,6 @@ public interface AbstractEngineInterface extends AutoCloseable {
public String getProtocolVersion();
public void startKeyserverLookup();
public void stopKeyserverLookup();
public void startSync();
public void stopSync();


+ 0
- 4
test/java/foundation/pEp/jniadapter/test/regression/TestMain.java View File

@ -276,10 +276,6 @@ class TestMain {
ctx.engine.getProtocolVersion();
});
new TestUnit<CTXBase>("Engine.startKeyserverLookup", new CTXBase(), ctx -> {
ctx.engine.startKeyserverLookup();
});
new TestUnit<CTXBase>("Engine.startSync", new CTXBase(), ctx -> {
ctx.engine.startSync();
});


Loading…
Cancel
Save