aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgAutomatonHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function/gpg/GpgAutomatonHandler.cpp')
-rw-r--r--src/core/function/gpg/GpgAutomatonHandler.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/core/function/gpg/GpgAutomatonHandler.cpp b/src/core/function/gpg/GpgAutomatonHandler.cpp
index 802279ed..af2f0cba 100644
--- a/src/core/function/gpg/GpgAutomatonHandler.cpp
+++ b/src/core/function/gpg/GpgAutomatonHandler.cpp
@@ -28,6 +28,8 @@
#include "GpgAutomatonHandler.h"
+#include <utility>
+
#include "core/model/GpgData.h"
#include "core/model/GpgKey.h"
#include "core/utils/GpgUtils.h"
@@ -96,21 +98,30 @@ auto GpgAutomatonHandler::interator_cb_func(void* handle, const char* status,
auto GpgAutomatonHandler::DoInteract(
const GpgKey& key, AutomatonNextStateHandler next_state_handler,
- AutomatonActionHandler action_handler) -> bool {
- auto key_fpr = key.Fingerprint();
- AutomatonHandelStruct handel_struct(key_fpr);
+ AutomatonActionHandler action_handler, int flags) -> bool {
+ gpgme_key_t p_key =
+ flags == GPGME_INTERACT_CARD ? nullptr : static_cast<gpgme_key_t>(key);
+
+ AutomatonHandelStruct handel_struct(
+ flags == GPGME_INTERACT_CARD ? "" : key.Fingerprint());
handel_struct.SetHandler(std::move(next_state_handler),
std::move(action_handler));
GpgData data_out;
- auto err =
- gpgme_op_interact(ctx_.DefaultContext(), static_cast<gpgme_key_t>(key), 0,
- GpgAutomatonHandler::interator_cb_func,
- static_cast<void*>(&handel_struct), data_out);
+ auto err = gpgme_op_interact(ctx_.DefaultContext(), p_key, flags,
+ GpgAutomatonHandler::interator_cb_func,
+ static_cast<void*>(&handel_struct), data_out);
return CheckGpgError(err) == GPG_ERR_NO_ERROR && handel_struct.Success();
}
+auto GpgAutomatonHandler::DoCardInteract(
+ AutomatonNextStateHandler next_state_handler,
+ AutomatonActionHandler action_handler) -> bool {
+ return DoInteract({}, std::move(next_state_handler),
+ std::move(action_handler), GPGME_INTERACT_CARD);
+}
+
auto GpgAutomatonHandler::AutomatonHandelStruct::NextState(
QString gpg_status, QString args) -> AutomatonState {
return next_state_handler_(current_state_, std::move(gpg_status),