Browse Source

call API functions like encrypt_message() or decrypt_message() using cache.api()

JNI-111
heck 5 years ago
parent
commit
e84feed11e
  1. 18
      src/gen_cpp_Engine.ysl2
  2. 17
      src/pEp.yml2

18
src/gen_cpp_Engine.ysl2

@ -17,6 +17,7 @@ tstylesheet {
#include "foundation_pEp_jniadapter_«@name».h" #include "foundation_pEp_jniadapter_«@name».h"
#include "throw_pEp_exception.hh" #include "throw_pEp_exception.hh"
#include "jniutils.hh" #include "jniutils.hh"
#include <pEp/passphrase_cache.hh>
using pEp::Adapter::session; using pEp::Adapter::session;
using namespace pEp::JNIAdapter; using namespace pEp::JNIAdapter;
@ -62,7 +63,20 @@ tstylesheet {
apply "parm[creates|returns]", mode=out; apply "parm[creates|returns]", mode=out;
|| ||
PEP_STATUS status = ::«@name»(session()`apply "parm", mode=call`); ||
choose {
when "@cached = 'true'" {
||
pEpLog("cached passphrase");
PEP_STATUS status = cache.api(::«@name»,session()`apply "parm", mode=call`);
||
} otherwise {
||
PEP_STATUS status = ::«@name»(session()`apply "parm", mode=call`);
||
}
}
||
if ((status > PEP_STATUS_OK && status < PEP_UNENCRYPTED) |`> |` if ((status > PEP_STATUS_OK && status < PEP_UNENCRYPTED) |`> |`
status < PEP_STATUS_OK |`> |` status < PEP_STATUS_OK |`> |`
status >= PEP_TRUSTWORD_NOT_FOUND) { status >= PEP_TRUSTWORD_NOT_FOUND) {
@ -237,6 +251,8 @@ tstylesheet {
| bool _«$name» = (bool) «$name»; | bool _«$name» = (bool) «$name»;
when "$type='int'" when "$type='int'"
| int _«$name» = (int) «$name»; | int _«$name» = (int) «$name»;
when "$type='string'"
| const char *_«$name» = to_string(env, «$name»);
otherwise otherwise
| √$type *_«$name» = to_«$type»(env, «$name»); | √$type *_«$name» = to_«$type»(env, «$name»);
} }

17
src/pEp.yml2

@ -85,32 +85,32 @@ namespace pEp {
}; };
interface Engine { interface Engine {
method encrypt_message( method cached=true encrypt_message(
in message src, in message src,
in stringlist extra, in stringlist extra,
creates message dst, creates message dst,
in EncFormat format, in EncFormat format,
Cconst PEP_encrypt_flags flags "0" Cconst PEP_encrypt_flags flags "(PEP_encrypt_flags_t)0"
); );
method encrypt_message_and_add_priv_key( method cached=true encrypt_message_and_add_priv_key(
in message src, in message src,
creates message dst, creates message dst,
in string fpr, in string fpr,
Cconst PEP_enc_format encformat "PEP_enc_PEP", Cconst PEP_enc_format encformat "PEP_enc_PEP",
Cconst PEP_encrypt_flags flags "0" Cconst PEP_encrypt_flags flags "(PEP_encrypt_flags_t)0"
); );
method encrypt_message_for_self( method cached=true encrypt_message_for_self(
in identity target, in identity target,
in message src, in message src,
in stringlist extra, in stringlist extra,
creates message dst, creates message dst,
Cconst PEP_enc_format encformat "PEP_enc_PEP", Cconst PEP_enc_format encformat "PEP_enc_PEP",
Cconst PEP_encrypt_flags flags "0" Cconst PEP_encrypt_flags flags "(PEP_encrypt_flags_t)0"
); );
method decrypt_message( method cached=true decrypt_message(
inout message src, inout message src,
creates message dst, creates message dst,
inout stringlist keylist, inout stringlist keylist,
@ -150,7 +150,8 @@ namespace pEp {
returns stringlist blacklist returns stringlist blacklist
); );
method own_message_private_key_details( // TODO: WTF is...
method cached=true own_message_private_key_details(
in message msg, in message msg,
returns identity ident returns identity ident
); );

Loading…
Cancel
Save