From 753a789a1826bb8063d62ea852d8024e5f02be94 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sat, 4 Jul 2020 18:20:51 +0200 Subject: [PATCH] providing passphrase_cache --- callback_dispatcher.cc | 4 ++++ callback_dispatcher.hh | 1 - passphrase_cache.cc | 2 ++ passphrase_cache.hh | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/callback_dispatcher.cc b/callback_dispatcher.cc index 32ccd1b..f8050b5 100644 --- a/callback_dispatcher.cc +++ b/callback_dispatcher.cc @@ -1,4 +1,5 @@ #include "callback_dispatcher.hh" +#include "passphrase_cache.hh" #include #include @@ -87,6 +88,9 @@ namespace pEp { PEP_STATUS CallbackDispatcher::_messageToSend(::message *msg) { + if (Adapter::on_sync_thread() && !msg) + return PassphraseCache::messageToSend(passphrase_cache, Adapter::session()); + for (auto target : targets) { ::message *_msg = nullptr; if (msg) { diff --git a/callback_dispatcher.hh b/callback_dispatcher.hh index 23bbc91..aeee166 100644 --- a/callback_dispatcher.hh +++ b/callback_dispatcher.hh @@ -36,7 +36,6 @@ namespace pEp { static PEP_STATUS messageToSend(::message *msg); static PEP_STATUS notifyHandshake(::pEp_identity *me, ::pEp_identity *partner, ::sync_handshake_signal signal); - protected: void on_startup(); void on_shutdown(); diff --git a/passphrase_cache.cc b/passphrase_cache.cc index 4019a61..24c3594 100644 --- a/passphrase_cache.cc +++ b/passphrase_cache.cc @@ -1,6 +1,8 @@ #include #include "passphrase_cache.hh" +pEp::PassphraseCache pEp::passphrase_cache; + namespace pEp { PassphraseCache::cache_entry::cache_entry(const std::string& p, time_point t) : passphrase{p, 0, PassphraseCache::cache_entry::max_len}, tp{t} diff --git a/passphrase_cache.hh b/passphrase_cache.hh index 13121e9..e1ee179 100644 --- a/passphrase_cache.hh +++ b/passphrase_cache.hh @@ -87,6 +87,8 @@ namespace pEp { void cleanup(); void refresh(cache::iterator entry); }; + + extern PassphraseCache passphrase_cache; }; #include "passphrase_cache.hxx"