summaryrefslogtreecommitdiff
path: root/lang/cpp/src/context.cpp
diff options
context:
space:
mode:
authorTizenOpenSource <tizenopensrc@samsung.com>2023-02-01 18:22:00 +0900
committerTizenOpenSource <tizenopensrc@samsung.com>2023-02-01 18:22:00 +0900
commit73f75b48c0470a46b31340f5cc9e5219d6ee0faa (patch)
treede57a4f03945b3365d4a85eac0ea2eb4c68ab801 /lang/cpp/src/context.cpp
parent9dc2bb3fe7e57cb5a597efe3a7bf78bda815f374 (diff)
downloadgpgme-73f75b48c0470a46b31340f5cc9e5219d6ee0faa.tar.gz
gpgme-73f75b48c0470a46b31340f5cc9e5219d6ee0faa.tar.bz2
gpgme-73f75b48c0470a46b31340f5cc9e5219d6ee0faa.zip
Imported Upstream version 1.18.0upstream/1.18.0
Diffstat (limited to 'lang/cpp/src/context.cpp')
-rw-r--r--lang/cpp/src/context.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 5072681..dba958c 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))
{
}
@@ -522,19 +535,25 @@ const char *Context::getSender ()
Error Context::startKeyListing(const char *pattern, bool secretOnly)
{
- d->lastop = Private::KeyList;
+ d->lastop = (((keyListMode() & GpgME::Locate) == GpgME::Locate)
+ ? Private::KeyListWithImport
+ : Private::KeyList);
return Error(d->lasterr = gpgme_op_keylist_start(d->ctx, pattern, int(secretOnly)));
}
Error Context::startKeyListing(const char *patterns[], bool secretOnly)
{
- d->lastop = Private::KeyList;
+ d->lastop = (((keyListMode() & GpgME::Locate) == GpgME::Locate)
+ ? Private::KeyListWithImport
+ : Private::KeyList);
return Error(d->lasterr = gpgme_op_keylist_ext_start(d->ctx, patterns, int(secretOnly), 0));
}
Key Context::nextKey(GpgME::Error &e)
{
- d->lastop = Private::KeyList;
+ d->lastop = (((keyListMode() & GpgME::Locate) == GpgME::Locate)
+ ? Private::KeyListWithImport
+ : Private::KeyList);
gpgme_key_t key = nullptr;
e = Error(d->lasterr = gpgme_op_keylist_next(d->ctx, &key));
return Key(key, false);
@@ -1154,6 +1173,7 @@ Error Context::startCombinedDecryptionAndVerification(const Data &cipherText, Da
return startCombinedDecryptionAndVerification(cipherText, plainText, DecryptNone);
}
+namespace {
unsigned int to_auditlog_flags(unsigned int flags)
{
unsigned int result = 0;
@@ -1168,6 +1188,7 @@ unsigned int to_auditlog_flags(unsigned int flags)
}
return result;
}
+}
Error Context::startGetAuditLog(Data &output, unsigned int flags)
{
@@ -1620,6 +1641,16 @@ Error Context::startRevUid(const Key &k, const char *userid)
k.impl(), userid, 0));
}
+Error Context::setPrimaryUid(const Key &k, const char *userid)
+{
+ return Error(d->lasterr = gpgme_op_set_uid_flag(d->ctx, k.impl(), userid, "primary", nullptr));
+}
+
+Error Context::startSetPrimaryUid(const Key &k, const char *userid)
+{
+ return Error(d->lasterr = gpgme_op_set_uid_flag_start(d->ctx, k.impl(), userid, "primary", nullptr));
+}
+
Error Context::createSubkey(const Key &k, const char *algo,
unsigned long reserved,
unsigned long expires,
@@ -1847,6 +1878,7 @@ std::ostream &operator<<(std::ostream &os, KeyListMode mode)
CHECK(WithTofu);
CHECK(WithKeygrip);
CHECK(WithSecret);
+ CHECK(ForceExtern);
#undef CHECK
return os << ')';
}