aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lang/cpp/src/context.cpp13
-rw-r--r--lang/cpp/src/context.h11
2 files changed, 24 insertions, 0 deletions
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 89bc3fd7..568e0458 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -195,6 +195,19 @@ std::ostream &operator<<(std::ostream &os, const Error &err)
return os << "GpgME::Error(" << err.encodedError() << " (" << err.asString() << "))";
}
+Context::KeyListModeSaver::KeyListModeSaver(Context *ctx)
+ : mCtx{ctx}
+ , mKeyListMode{ctx ? ctx->keyListMode() : 0}
+{
+}
+
+Context::KeyListModeSaver::~KeyListModeSaver()
+{
+ if (mCtx) {
+ mCtx->setKeyListMode(mKeyListMode);
+ }
+}
+
Context::Context(gpgme_ctx_t ctx) : d(new Private(ctx))
{
}
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index 9c2b2a5f..04a1e00a 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -64,6 +64,17 @@ class GPGMEPP_EXPORT Context
public:
//using GpgME::Protocol;
+ /// RAII-style class for saving/restoring the key list mode.
+ class KeyListModeSaver
+ {
+ public:
+ explicit KeyListModeSaver(Context *ctx);
+ ~KeyListModeSaver();
+ private:
+ Context *mCtx;
+ unsigned int mKeyListMode;
+ };
+
//
// Creation and destruction:
//