Browse Source

use passphraseWrap() in CodeGen template too.

JNI-119
heck 5 years ago
parent
commit
476011d774
  1. 1
      src/foundation_pEp_jniadapter_AbstractEngine.cc
  2. 30
      src/gen_cpp_Engine.ysl2

1
src/foundation_pEp_jniadapter_AbstractEngine.cc

@ -3,7 +3,6 @@
#include <pEp/keymanagement.h>
#include <pEp/message_api.h>
#include <pEp/sync_api.h>
#include <pEp/Adapter.hh>
#include <pEp/pEpLog.hh>
#include <pEp/passphrase_cache.hh>
#include <pEp/callback_dispatcher.hh>

30
src/gen_cpp_Engine.ysl2

@ -9,6 +9,7 @@ tstylesheet {
template "interface" document("foundation_pEp_jniadapter_{@name}.cc", "text")
||
#include <cassert>
#include <pEp/blacklist.h>
#include <pEp/openpgp_compat.h>
#include <pEp/key_reset.h>
@ -70,34 +71,7 @@ tstylesheet {
choose {
when "@cached = 'true'" {
||
pEpLog("cached passphrase mode");
bool retryAgain = false;
int maxRetries = 3;
int retryCount = 0;
PEP_STATUS status;
do {
// the actual target function
pEpLog("calling passphrase_cache.api(::«@name»())");
status = passphrase_cache.api(::«@name»,session()`apply "parm", mode=call`);
pEpLog("PEP_STATUS:" << status);
if(status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE || status == PEP_PASSPHRASE_FOR_NEW_KEYS_REQUIRED) {
pEpLog("none of the cached passphrases worked");
if(retryCount < maxRetries) {
// call the app
char* _passphrase = passphraseRequiredCallback(status);
pEpLog("callback returned, config_passphrase() with new passphrase");
PEP_STATUS status = ::config_passphrase(session(),passphrase_cache.add(_passphrase));
retryAgain = true;
retryCount++;
} else {
pEpLog("max retries reached:" << maxRetries);
retryAgain = false;
}
} else {
retryAgain = false;
}
} while (retryAgain);
PEP_STATUS status = passphraseWrap(::«@name», session()`apply "parm", mode=call`);
||
} otherwise {
||

Loading…
Cancel
Save