aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/model/GpgKey.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gpg/model/GpgKey.h33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/gpg/model/GpgKey.h b/src/gpg/model/GpgKey.h
index f34fece1..c0671b35 100644
--- a/src/gpg/model/GpgKey.h
+++ b/src/gpg/model/GpgKey.h
@@ -28,11 +28,14 @@
#include "GpgSubKey.h"
#include "GpgUID.h"
+#include <boost/date_time.hpp>
+#include <boost/date_time/posix_time/conversion.hpp>
+
namespace GpgFrontend {
class GpgKey {
public:
- [[nodiscard]] bool good() const { return _key_ref == nullptr; }
+ [[nodiscard]] bool good() const { return _key_ref != nullptr; }
[[nodiscard]] std::string id() const { return _key_ref->subkeys->keyid; }
@@ -69,16 +72,16 @@ public:
return gpgme_pubkey_algo_name(_key_ref->subkeys->pubkey_algo);
}
- [[nodiscard]] QDateTime last_update() const {
- return QDateTime::fromTime_t(_key_ref->last_update);
+ [[nodiscard]] boost::gregorian::date last_update() const {
+ return boost::posix_time::from_time_t(_key_ref->last_update).date();
}
- [[nodiscard]] QDateTime expires() const {
- return QDateTime::fromTime_t(_key_ref->subkeys->expires);
+ [[nodiscard]] boost::gregorian::date expires() const {
+ return boost::posix_time::from_time_t(_key_ref->subkeys->expires).date();
};
- [[nodiscard]] QDateTime create_time() const {
- return QDateTime::fromTime_t(_key_ref->subkeys->timestamp);
+ [[nodiscard]] boost::gregorian::date create_time() const {
+ return boost::posix_time::from_time_t(_key_ref->subkeys->timestamp).date();
};
[[nodiscard]] unsigned int length() const {
@@ -119,10 +122,12 @@ public:
[[nodiscard]] std::unique_ptr<std::vector<GpgUID>> uids() const;
- explicit GpgKey() = default;
+ GpgKey() = default;
explicit GpgKey(gpgme_key_t &&key);
+ ~GpgKey() = default;
+
GpgKey(const gpgme_key_t &key) = delete;
GpgKey(GpgKey &&k) noexcept;
@@ -134,10 +139,16 @@ public:
explicit operator gpgme_key_t() const { return _key_ref.get(); }
private:
- using KeyRefHandler =
- std::unique_ptr<struct _gpgme_key, std::function<void(gpgme_key_t)>>;
+ struct __key_ref_deletor {
+ void operator()(gpgme_key_t _key) {
+ if (_key != nullptr)
+ gpgme_key_unref(_key);
+ }
+ };
+
+ using KeyRefHandler = std::unique_ptr<struct _gpgme_key, __key_ref_deletor>;
- KeyRefHandler _key_ref;
+ KeyRefHandler _key_ref = nullptr;
};
} // namespace GpgFrontend