aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lang/cpp')
-rw-r--r--lang/cpp/src/context.cpp24
-rw-r--r--lang/cpp/src/context.h6
-rw-r--r--lang/cpp/src/key.cpp28
-rw-r--r--lang/cpp/src/key.h18
4 files changed, 76 insertions, 0 deletions
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index ada7bead..040e8f32 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -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,
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index 2c205b02..b075bf1b 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -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);
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 4f7ec54b..3cc26a77 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -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(";
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 3f596a82..b0599c7f 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -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;