diff --git a/src/basic_api.cc b/src/basic_api.cc index 620973c..a7e869c 100644 --- a/src/basic_api.cc +++ b/src/basic_api.cc @@ -75,6 +75,22 @@ JNIEXPORT jobject JNICALL Java_org_pEp_jniadapter_Engine_updateIdentity( return from_identity(env, _ident); } +JNIEXPORT jobject JNICALL Java_org_pEp_jniadapter_Engine_setOwnKey( + JNIEnv *env, + jobject obj, + jobject ident, + jbyteArray fpr + ) +{ + PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle"); + pEp_identity *_ident = to_identity(env, ident); + char *_fpr = to_string(env, fpr); + + ::set_own_key(session, _ident, _fpr); + + return from_identity(env, _ident); +} + JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_keyMistrusted( JNIEnv *env, jobject obj, @@ -311,6 +327,7 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_cancel_1sync_1handshake( JNIEXPORT jbyteArray JNICALL Java_org_pEp_jniadapter_Engine_getCrashdumpLog( JNIEnv *env, jobject obj, + jint dummy, jint maxlines ) { diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 index b921ff0..a232130 100644 --- a/src/gen_java_Engine.ysl2 +++ b/src/gen_java_Engine.ysl2 @@ -34,37 +34,88 @@ tstylesheet { const "pname", "name(parm/*[2])"; || - private native «$itype» «@name»(«$pitype» «$pname»); + private native «$itype» «@name»(`apply "parm/*", mode=basic_iparm`); - public «$jtype» «@name»(«$pjtype» «$pname») { + public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`) { || - choose { - when "$ptype = 'string'" - |> «$pitype» _«$pname» = «$pname».getBytes(); - when "$ptype = 'bool'" - |> «$pitype» _«$pname» = «$pname».booleanValue(); - when "$ptype = 'int'" - |> «$pitype» _«$pname» = «$pname»; - when "ancestor::namespace/child::enum[@name=$ptype]" - |> «$pitype» _«$pname» = «$pname».value; - otherwise - |> «$pitype» _«$pname» = new «$pitype»(«$pname»); - } + apply "parm/*", mode=basic_parm_set; choose { when "@type = 'void'" - |> «@name»(_«$pname»); + |> «@name»(`apply "parm/*", mode=basic_parm_name`); when "@type = 'identity'" - |> return new Identity(«@name»(_«$pname»)); + |> return new Identity(«@name»(`apply "parm/*", mode=basic_parm_name`)); when "@type = 'bool'" - |> return new Boolean(«@name»(_«$pname»)); + |> return new Boolean(«@name»(`apply "parm/*", mode=basic_parm_name`)); otherwise - |> return AbstractEngine.toUTF16(«@name»(_«$pname»)); + |> return AbstractEngine.toUTF16(«@name»(`apply "parm/*", mode=basic_parm_name`)); } || } || } + + template "*", mode=basic_parm_name choose { + when "position() mod 2" { + if "position() = 1 and name(.)='int'" + > 23, + if "position() > 1" > , + } + otherwise { + > _«name(.)» + } + } + + template "*", mode=basic_parm choose { + when "position() mod 2" { + if "position() > 1" > , + choose { + when "name(.) = 'string'" + > String + when "name(.) = 'identity'" + > Identity + when "name(.) = 'bool'" + > Boolean + otherwise + > «name(.)» + } + } + otherwise { + > «name(.)» + } + } + + template "*", mode=basic_iparm choose { + when "position() mod 2" { + const "pitype" call "toIntermediate" with "type", "name(.)"; + if "position() = 1 and name(.)='int'" + > int dummy, + if "position() > 1" > , + > «$pitype» + } + otherwise { + > «name(.)» + } + } + + template "*", mode=basic_parm_set { + const "ptype", "name(preceding-sibling::*[1])"; + const "pname", "name(.)"; + const "pitype" call "toIntermediate" with "type", "$ptype"; + + if "not(position() mod 2)" choose { + when "$ptype = 'string'" + | «$pitype» _«$pname» = «$pname».getBytes(); + when "$ptype = 'bool'" + | «$pitype» _«$pname» = «$pname».booleanValue(); + when "$ptype = 'int'" + | «$pitype» _«$pname» = «$pname»; + when "ancestor::namespace/child::enum[@name=$ptype]" + | «$pitype» _«$pname» = «$pname».value; + otherwise + | «$pitype» _«$pname» = new «$pitype»(«$pname»); + } + } function "returnJava" { const "returning", "count(parm/creates|parm/returns)"; diff --git a/src/pEp.yml2 b/src/pEp.yml2 index 98beb59..daae21d 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -237,6 +237,7 @@ namespace pEp { basic string trustwords(identity ident); basic identity myself(identity ident); basic identity updateIdentity(identity ident); + basic identity setOwnKey(identity ident, string fpr); basic void keyMistrusted(identity ident); basic void keyResetTrust(identity ident); basic void trustPersonalKey(identity ident);