cpp: Add origin and last_update to UserID

* NEWS: Mention it.
* lang/cpp/src/key.cpp, lang/cpp/src/key.h (UserID::lastUpdate),
(UserID::origin): New.
(gpgme_origin_to_pp_origin): New helper.
This commit is contained in:
Andre Heinecke 2018-04-19 11:56:15 +02:00
parent 0adaf7bafd
commit d65d632931
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C
3 changed files with 49 additions and 19 deletions

2
NEWS
View File

@ -5,6 +5,8 @@ Noteworthy changes in version 1.11.1 (unreleased)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpp: Key::origin NEW.
cpp: Key::lastUpdate NEW.
cpp: UserID::origin NEW.
cpp: UserID::lastUpdate NEW.
Noteworthy changes in version 1.11.0 (2018-04-18)
-------------------------------------------------

View File

@ -967,6 +967,42 @@ Error UserID::revoke()
return ret;
}
static Key::Origin gpgme_origin_to_pp_origin (const unsigned int origin)
{
switch (origin) {
case GPGME_KEYORG_KS:
return Key::OriginKS;
case GPGME_KEYORG_DANE:
return Key::OriginDane;
case GPGME_KEYORG_WKD:
return Key::OriginWKD;
case GPGME_KEYORG_URL:
return Key::OriginURL;
case GPGME_KEYORG_FILE:
return Key::OriginFile;
case GPGME_KEYORG_SELF:
return Key::OriginSelf;
case GPGME_KEYORG_OTHER:
return Key::OriginOther;
case GPGME_KEYORG_UNKNOWN:
default:
return Key::OriginUnknown;
}
}
Key::Origin UserID::origin() const
{
if (isNull()) {
return Key::OriginUnknown;
}
return gpgme_origin_to_pp_origin(uid->origin);
}
time_t UserID::lastUpdate() const
{
return static_cast<time_t>(uid ? uid->last_update : 0);
}
Error Key::addUid(const char *uid)
{
if (isNull()) {
@ -986,25 +1022,7 @@ Key::Origin Key::origin() const
if (isNull()) {
return OriginUnknown;
}
switch (key->origin) {
case GPGME_KEYORG_KS:
return OriginKS;
case GPGME_KEYORG_DANE:
return OriginDane;
case GPGME_KEYORG_WKD:
return OriginWKD;
case GPGME_KEYORG_URL:
return OriginURL;
case GPGME_KEYORG_FILE:
return OriginFile;
case GPGME_KEYORG_SELF:
return OriginSelf;
case GPGME_KEYORG_OTHER:
return OriginOther;
case GPGME_KEYORG_UNKNOWN:
default:
return OriginUnknown;
}
return gpgme_origin_to_pp_origin(key->origin);
}
time_t Key::lastUpdate() const

View File

@ -392,6 +392,16 @@ public:
*
* @returns an error on error.*/
Error revoke();
/*! Get the origin of the key.
*
* @returns the Origin. */
Key::Origin origin() const;
/*! Get the last update time.
*
* @returns the last update time. */
time_t lastUpdate() const;
private:
shared_gpgme_key_t key;
gpgme_user_id_t uid;