diff --git a/src/basic_api.cc b/src/basic_api.cc index 9aa8e63..b680e44 100644 --- a/src/basic_api.cc +++ b/src/basic_api.cc @@ -260,16 +260,55 @@ JNIEXPORT jboolean JNICALL Java_org_pEp_jniadapter_Engine_blacklist_1is_1listed( return (jboolean)_listed; } -JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_sync_1hanshake_1result( +JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_accept_1sync_1hanshake( JNIEnv *env, jobject obj, - jint result + jobject ident + ) + +{ + PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle"); + pEp_identity *_ident = to_identity(env, ident); + + PEP_STATUS status = + ::deliverHandshakeResult(session, _ident, SYNC_HANDSHAKE_ACCEPTED); + + if (status != PEP_STATUS_OK) { + throw_pEp_Exception(env, status); + return; + } +} + + +JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_reject_sync_1hanshake( + JNIEnv *env, + jobject obj, + jobject ident + ) +{ + PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle"); + pEp_identity *_ident = to_identity(env, ident); + + PEP_STATUS status = + ::deliverHandshakeResult(session, _ident, SYNC_HANDSHAKE_REJECTED); + + if (status != PEP_STATUS_OK) { + throw_pEp_Exception(env, status); + return; + } +} + +JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_cancel_sync_1hanshake( + JNIEnv *env, + jobject obj, + jobject ident ) { PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle"); + pEp_identity *_ident = to_identity(env, ident); PEP_STATUS status = - ::deliverHandshakeResult(session, (sync_handshake_result) result); + ::deliverHandshakeResult(session, _ident, SYNC_HANDSHAKE_CANCEL); if (status != PEP_STATUS_OK) { throw_pEp_Exception(env, status); diff --git a/src/gen_cpp_Engine.ysl2 b/src/gen_cpp_Engine.ysl2 index 85a1360..c5b37ae 100644 --- a/src/gen_cpp_Engine.ysl2 +++ b/src/gen_cpp_Engine.ysl2 @@ -12,6 +12,7 @@ tstylesheet { #include #include #include + #include #include "org_pEp_jniadapter_«@name».h" #include "throw_pEp_exception.hh" #include "jniutils.hh" @@ -89,6 +90,7 @@ tstylesheet { } when "$rettype = 'stringlist'" apply "parm[returns|creates]", mode=return; + when "$rettype = 'stringpairlist'" apply "parm[returns|creates]", mode=return; otherwise error | # not implemented: return type "«$rettype»"; } @@ -159,6 +161,14 @@ tstylesheet { «$name»_ = from_identity(env, _«$retname»); || + + when "$type = 'stringpairlist'" + || + jobject «$name»_ = NULL; + if (_«$retname») + «$name»_ = from_stringpairlist(env, _«$retname»); + + || when "ancestor::namespace/child::enum[@name=$jtype]" { const "ljtype" call "lcase" with "text","$jtype"; @@ -227,6 +237,8 @@ tstylesheet { choose { when "$type = 'message'" | message *_«$name» = (message *) callLongMethod(env, «$name», "getHandle"); + when "$type='bool'" + | bool _«$name» = (bool) «$name»; otherwise | √$type *_«$name» = to_«$type»(env, «$name»); } diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 index 9e3477b..7ae7546 100644 --- a/src/gen_java_Engine.ysl2 +++ b/src/gen_java_Engine.ysl2 @@ -12,6 +12,7 @@ tstylesheet { || package org.pEp.jniadapter; + import java.util.ArrayList; import java.util.Vector; final public class «$cname» extends AbstractEngine { @@ -86,7 +87,7 @@ tstylesheet { } template "method", mode=plain { - const "convert", "count(parm/stringlist|parm/string|parm/identity) > 0"; + const "convert", "count(parm/stringlist|parm/stringpairlist|parm/string|parm/identity) > 0"; const "singlereturn", "count(parm/creates|parm/returns) = 1"; const "multireturn", "count(parm/creates|parm/returns) > 1"; @@ -128,6 +129,18 @@ tstylesheet { if "$singlereturn" choose { when "count(parm[returns]/stringlist|parm[returns]/string) > 0" |> return AbstractEngine.toUTF16(_«@name»(`apply "parm[in]", mode=call;`)); + when "count(parm[returns]/stringpairlist) > 0" + || + ArrayList> glist = _«@name»(`apply "parm[in]", mode=call;`); + if(glist != null){ + ArrayList> list = new ArrayList>(); + for (Pair i : glist) + list.add(new Pair(AbstractEngine.toUTF16(i.first), AbstractEngine.toUTF16(i.second))); + return list; + } + return null; + || + when "count(parm[returns]/identity) > 0" |> return new Identity(_«@name»(`apply "parm[in]", mode=call;`)); otherwise diff --git a/src/pEp.yml2 b/src/pEp.yml2 index 5df2572..ef979f3 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -164,6 +164,11 @@ namespace pEp { returns identity ident ); + method OpenPGP_list_keyinfo( + in string pattern, + returns stringpairlist keyinfoList + ); + basic string trustwords(identity ident); basic identity myself(identity ident); basic identity updateIdentity(identity ident); @@ -176,7 +181,9 @@ namespace pEp { basic bool blacklist_is_listed(string fpr); basic void config_passive_mode(bool enable); basic void config_unencrypted_subject(bool enable); - basic void deliver_handshake_result(SyncHandshakeResult result); + basic void accept_sync_handshake_result(identity ident); + basic void reject_sync_handshake_result(identity ident); + basic void cancel_sync_handshake_result(identity ident); }; diff --git a/src/types_c.ysl2 b/src/types_c.ysl2 index 6bb9eee..abab0a7 100644 --- a/src/types_c.ysl2 +++ b/src/types_c.ysl2 @@ -26,6 +26,7 @@ function "jni_type" { choose { when "../enum[@name=$type]" > jint when "$type = 'string'" > jbyteArray + when "$type='bool'" > jboolean otherwise > jobject } }