cpp: Add revuid and adduid support
* lang/cpp/src/context.cpp (Context::revUid, Context::startRevUid), (Context::addUid, Context::startAddUid): New. * lang/cpp/src/context.h: Declare new functions. * lang/cpp/src/key.cpp (Key::UserID::revoke) (Key::addUid): Idomatic helpers. lang/cpp/src/key.h: Declare new functions. * NEWS: Update accordingly.
This commit is contained in:
parent
efe58fe011
commit
e416f99618
11
NEWS
11
NEWS
@ -1,6 +1,17 @@
|
||||
Noteworthy changes in version 1.8.1 (unreleased)
|
||||
------------------------------------------------
|
||||
|
||||
* cpp: Support for adduid and revuid operations.
|
||||
|
||||
* Interface changes relative to the 1.8.0 release:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
cpp: Context::revUid(const Key&, const char*) NEW.
|
||||
cpp: Context::startRevUid(const Key&, const char*) NEW.
|
||||
cpp: Context::addUid(const Key&, const char*) NEW.
|
||||
cpp: Context::startAddUid(const Key&, const char*) NEW.
|
||||
cpp: Key::UserID::revoke() NEW.
|
||||
cpp: Key::addUid() NEW.
|
||||
|
||||
|
||||
Noteworthy changes in version 1.8.0 (2016-11-16)
|
||||
------------------------------------------------
|
||||
|
@ -1376,6 +1376,30 @@ Error Context::setTofuPolicyStart(const Key &k, unsigned int policy)
|
||||
k.impl(), to_tofu_policy_t(policy)));
|
||||
}
|
||||
|
||||
Error Context::addUid(const Key &k, const char *userid)
|
||||
{
|
||||
return Error(d->lasterr = gpgme_op_adduid(d->ctx,
|
||||
k.impl(), userid, 0));
|
||||
}
|
||||
|
||||
Error Context::startAddUid(const Key &k, const char *userid)
|
||||
{
|
||||
return Error(d->lasterr = gpgme_op_adduid_start(d->ctx,
|
||||
k.impl(), userid, 0));
|
||||
}
|
||||
|
||||
Error Context::revUid(const Key &k, const char *userid)
|
||||
{
|
||||
return Error(d->lasterr = gpgme_op_revuid(d->ctx,
|
||||
k.impl(), userid, 0));
|
||||
}
|
||||
|
||||
Error Context::startRevUid(const Key &k, const char *userid)
|
||||
{
|
||||
return Error(d->lasterr = gpgme_op_revuid_start(d->ctx,
|
||||
k.impl(), userid, 0));
|
||||
}
|
||||
|
||||
// Engine Spawn stuff
|
||||
Error Context::spawn(const char *file, const char *argv[],
|
||||
Data &input, Data &output, Data &err,
|
||||
|
@ -214,6 +214,12 @@ public:
|
||||
GpgME::Error edit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
||||
GpgME::Error startEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
||||
|
||||
Error addUid(const Key &key, const char *userid);
|
||||
Error startAddUid(const Key &key, const char *userid);
|
||||
|
||||
Error revUid(const Key &key, const char *userid);
|
||||
Error startRevUid(const Key &key, const char *userid);
|
||||
|
||||
// using TofuInfo::Policy
|
||||
Error setTofuPolicy(const Key &k, unsigned int policy);
|
||||
Error setTofuPolicyStart(const Key &k, unsigned int policy);
|
||||
|
@ -906,6 +906,34 @@ std::string UserID::addrSpec() const
|
||||
return uid->address;
|
||||
}
|
||||
|
||||
Error UserID::revoke()
|
||||
{
|
||||
if (isNull()) {
|
||||
return Error::fromCode(GPG_ERR_GENERAL);
|
||||
}
|
||||
auto ctx = Context::createForProtocol(parent().protocol());
|
||||
if (!ctx) {
|
||||
return Error::fromCode(GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
Error ret = ctx->revUid(key, id());
|
||||
delete ctx;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Error Key::addUid(const char *uid)
|
||||
{
|
||||
if (isNull()) {
|
||||
return Error::fromCode(GPG_ERR_GENERAL);
|
||||
}
|
||||
auto ctx = Context::createForProtocol(protocol());
|
||||
if (!ctx) {
|
||||
return Error::fromCode(GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
Error ret = ctx->addUid(key, uid);
|
||||
delete ctx;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const UserID &uid)
|
||||
{
|
||||
os << "GpgME::UserID(";
|
||||
|
@ -152,6 +152,17 @@ public:
|
||||
* how long the keylisting takes.*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* @brief Add a user id to this key.
|
||||
*
|
||||
* Needs gnupg 2.1.13 and the key needs to be updated
|
||||
* afterwards to see the new uid.
|
||||
*
|
||||
* @param uid should be fully formated and UTF-8 encoded.
|
||||
*
|
||||
* @returns a possible error.
|
||||
**/
|
||||
Error addUid(const char *uid);
|
||||
private:
|
||||
gpgme_key_t impl() const
|
||||
{
|
||||
@ -335,6 +346,13 @@ public:
|
||||
* @returns a normalized mail address for this userid
|
||||
* or an empty string. */
|
||||
std::string addrSpec() const;
|
||||
|
||||
/*! Revoke the user id.
|
||||
*
|
||||
* Key needs update afterwards.
|
||||
*
|
||||
* @returns an error on error.*/
|
||||
Error revoke();
|
||||
private:
|
||||
shared_gpgme_key_t key;
|
||||
gpgme_user_id_t uid;
|
||||
|
Loading…
Reference in New Issue
Block a user