C++11 library providing functionality common to all adapters.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
786 B

1 year ago
  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #ifndef LIBPEPADAPTER_PASSPHRASE_CACHE_HXX
  4. #define LIBPEPADAPTER_PASSPHRASE_CACHE_HXX
  5. #include "passphrase_cache.hh"
  6. namespace pEp {
  7. template<typename... A>
  8. PEP_STATUS PassphraseCache::api(PEP_STATUS f(PEP_SESSION, A...), PEP_SESSION session, A... a)
  9. {
  10. PEP_STATUS status;
  11. for_each_passphrase([&](std::string passphrase) {
  12. status = ::config_passphrase(session, passphrase.c_str());
  13. if (status)
  14. return true;
  15. status = f(session, a...);
  16. return status != PEP_PASSPHRASE_REQUIRED && status != PEP_WRONG_PASSPHRASE;
  17. });
  18. return status;
  19. }
  20. }; // namespace pEp
  21. #endif // LIBPEPADAPTER_PASSPHRASE_CACHE_HXX