diff --git a/src/basic_api.cc b/src/basic_api.cc index fcf4ba6..72a140a 100644 --- a/src/basic_api.cc +++ b/src/basic_api.cc @@ -1,4 +1,5 @@ #include +#include #include "throw_pEp_exception.hh" #include "jniutils.hh" @@ -178,5 +179,73 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_config_1passive_1mode( ::config_passive_mode(session, (bool)enable); } +JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_blacklist_1add( + JNIEnv *env, + jobject obj, + jbyteArray fpr + ) +{ + PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle"); + char *_fpr = to_string(env, fpr); + + if(_fpr == NULL){ + throw_pEp_Exception(env, PEP_OUT_OF_MEMORY); + return; + } + + PEP_STATUS status = ::blacklist_add(session, _fpr); + if (status != PEP_STATUS_OK) { + throw_pEp_Exception(env, status); + return; + } + +} + +JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_blacklist_1delete( + JNIEnv *env, + jobject obj, + jbyteArray fpr + ) +{ + PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle"); + char *_fpr = to_string(env, fpr); + + if(_fpr == NULL){ + throw_pEp_Exception(env, PEP_OUT_OF_MEMORY); + return; + } + + PEP_STATUS status = ::blacklist_add(session, _fpr); + if (status != PEP_STATUS_OK) { + throw_pEp_Exception(env, status); + return; + } + +} + +JNIEXPORT jboolean JNICALL Java_org_pEp_jniadapter_Engine_blacklist_1is_1listed( + JNIEnv *env, + jobject obj, + jbyteArray fpr + ) +{ + PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle"); + char *_fpr = to_string(env, fpr); + bool _listed = 0; + + if(_fpr == NULL){ + throw_pEp_Exception(env, PEP_OUT_OF_MEMORY); + return 0; + } + + PEP_STATUS status = ::blacklist_is_listed(session, _fpr, &_listed); + if (status != PEP_STATUS_OK) { + throw_pEp_Exception(env, status); + return 0; + } + + return (jboolean)_listed; +} + } // extern "C" diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 index 0b82b3e..2cd5165 100644 --- a/src/gen_java_Engine.ysl2 +++ b/src/gen_java_Engine.ysl2 @@ -50,7 +50,7 @@ tstylesheet { |> «@name»(_«$pname»); when "@type = 'identity'" |> return new Identity(«@name»(_«$pname»)); - when "@type = 'identity'" + when "@type = 'bool'" |> return new Boolean(«@name»(_«$pname»)); otherwise |> return AbstractEngine.toUTF16(«@name»(_«$pname»)); diff --git a/src/pEp.yml2 b/src/pEp.yml2 index aae8cad..81d12ec 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -111,9 +111,9 @@ namespace pEp { basic void keyResetTrust(identity ident); basic void trustPersonalKey(identity ident); basic void importKey(string key); - // basic void blacklist_add(string fpr); - // basic void blacklist_delete(string fpr); - // basic bool blacklist_is_listed(string fpr); + basic void blacklist_add(string fpr); + basic void blacklist_delete(string fpr); + basic bool blacklist_is_listed(string fpr); basic void config_passive_mode(bool enable); };