From 7f9d5c6cd204bfd84ea477b284df795b1dadb1af Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Fri, 16 Feb 2018 12:58:54 +0100 Subject: cpp: Add shorthand for key locate * lang/cpp/src/key.cpp (Key::locate): New static helper. * lang/cpp/src/key.h: Update accordingly. --- lang/cpp/src/key.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lang/cpp/src/key.cpp') diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index 66fdea96..0e86a19e 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -371,6 +371,27 @@ void Key::update() return; } +// static +Key Key::locate(const char *mbox) +{ + if (!mbox) { + return Key(); + } + + auto ctx = Context::createForProtocol(OpenPGP); + if (!ctx) { + return Key(); + } + + ctx->setKeyListMode (Extern | Local); + + Error e = ctx->startKeyListing (mbox); + auto ret = ctx->nextKey (e); + delete ctx; + + return ret; +} + // // // class Subkey -- cgit v1.2.3