diff options
author | JinWang An <jinwang.an@samsung.com> | 2021-12-01 16:54:37 +0900 |
---|---|---|
committer | JinWang An <jinwang.an@samsung.com> | 2021-12-01 16:54:37 +0900 |
commit | 398648eddb70bc844e1bc5996521e87dea3188e9 (patch) | |
tree | 1c186970f769d3d37d9ec3248a7145cdc12c0fd3 /lang/cpp/src/key.cpp | |
parent | fd4d11c14daa6a54c81202dffc02cc419fa67568 (diff) | |
download | gpgme-398648eddb70bc844e1bc5996521e87dea3188e9.tar.gz gpgme-398648eddb70bc844e1bc5996521e87dea3188e9.tar.bz2 gpgme-398648eddb70bc844e1bc5996521e87dea3188e9.zip |
Imported Upstream version 1.11.1upstream/1.11.1
Diffstat (limited to 'lang/cpp/src/key.cpp')
-rw-r--r-- | lang/cpp/src/key.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index 0e86a19..034286f 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -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()) { @@ -981,6 +1017,19 @@ Error Key::addUid(const char *uid) return ret; } +Key::Origin Key::origin() const +{ + if (isNull()) { + return OriginUnknown; + } + return gpgme_origin_to_pp_origin(key->origin); +} + +time_t Key::lastUpdate() const +{ + return static_cast<time_t>(key ? key->last_update : 0); +} + std::ostream &operator<<(std::ostream &os, const UserID &uid) { os << "GpgME::UserID("; |