qt,cpp: Implement adding ADSKs to existing keys

* lang/cpp/src/context.cpp: Add functions for adding ADSKs.
* lang/cpp/src/context.h: Ditto.
* lang/qt/src/qgpgmequickjob.cpp: Add implementation of ADSK job.
* lang/qt/src/qgpgmequickjob.h: Ditto.
* lang/qt/src/quickjob.h: Add job for adding ADSKs.
This commit is contained in:
Tobias Fella 2024-01-08 11:33:28 +01:00
parent e42b72bc2b
commit 15718cb295
No known key found for this signature in database
GPG Key ID: F315CBBEE5E1889B
5 changed files with 28 additions and 0 deletions

View File

@ -1799,6 +1799,16 @@ Error Context::startRevokeSignature(const Key &key, const Key &signingKey,
key.impl(), signingKey.impl(), uids.c_str(), flags));
}
Error Context::addAdsk(const Key &k, const char *adsk)
{
return Error(d->lasterr = gpgme_op_createsubkey(d->ctx, k.impl(), adsk, 0, 0, GPGME_CREATE_ADSK));
}
Error Context::startAddAdsk(const Key &k, const char *adsk)
{
return Error(d->lasterr = gpgme_op_createsubkey_start(d->ctx, k.impl(), adsk, 0, 0, GPGME_CREATE_ADSK));
}
Error Context::setFlag(const char *name, const char *value)
{
return Error(d->lasterr = gpgme_set_ctx_flag(d->ctx, name, value));

View File

@ -324,6 +324,9 @@ public:
Error startRevokeSignature(const Key &key, const Key &signingKey,
const std::vector<UserID> &userIds = std::vector<UserID>());
Error addAdsk(const Key &k, const char *adsk);
Error startAddAdsk(const Key &k, const char *adsk);
// using TofuInfo::Policy
Error setTofuPolicy(const Key &k, unsigned int policy);
Error setTofuPolicyStart(const Key &k, unsigned int policy);

View File

@ -109,6 +109,12 @@ static QGpgMEQuickJob::result_type revokeSignatureWorker(Context *ctx,
return std::make_tuple(err, QString(), Error());
}
static QGpgMEQuickJob::result_type addAdskWorker(Context *ctx, const Key &key, const char *adsk)
{
const auto err = ctx->addAdsk(key, adsk);
return std::make_tuple(err, QString(), Error());
}
void QGpgMEQuickJob::startCreate(const QString &uid,
const char *algo,
const QDateTime &expires,
@ -142,4 +148,9 @@ void QGpgMEQuickJob::startRevokeSignature(const Key &key, const Key &signingKey,
run(std::bind(&revokeSignatureWorker, std::placeholders::_1, key, signingKey, userIds));
}
void QGpgMEQuickJob::startAddAdsk(const GpgME::Key &key, const char *adsk)
{
run(std::bind(&addAdskWorker, std::placeholders::_1, key, adsk));
}
#include "qgpgmequickjob.moc"

View File

@ -71,6 +71,7 @@ public:
unsigned int flags = 0) override;
void startRevokeSignature(const GpgME::Key &key, const GpgME::Key &signingKey,
const std::vector<GpgME::UserID> &userIds = std::vector<GpgME::UserID>()) override;
void startAddAdsk(const GpgME::Key &key, const char *adsk) override;
};
}

View File

@ -85,6 +85,9 @@ public:
virtual void startRevokeSignature(const GpgME::Key &key, const GpgME::Key &signingKey,
const std::vector<GpgME::UserID> &userIds = std::vector<GpgME::UserID>()) = 0;
/** Start --quick-add-adsk */
virtual void startAddAdsk(const GpgME::Key &key, const char *adsk) = 0;
Q_SIGNALS:
void result(const GpgME::Error &error,
const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());