aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/function/GpgKeyManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gpg/function/GpgKeyManager.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/gpg/function/GpgKeyManager.cpp b/src/gpg/function/GpgKeyManager.cpp
index 9e0f610e..a6697bc4 100644
--- a/src/gpg/function/GpgKeyManager.cpp
+++ b/src/gpg/function/GpgKeyManager.cpp
@@ -25,29 +25,28 @@
#include "gpg/function/GpgKeyManager.h"
#include "gpg/function/BasicOperator.h"
#include "gpg/function/GpgKeyGetter.h"
+#include <boost/date_time/posix_time/conversion.hpp>
+#include <string>
+
+bool GpgFrontend::GpgKeyManager::signKey(
+ const GpgFrontend::GpgKey &target, GpgFrontend::KeyArgsList &keys,
+ const std::string &uid, std::unique_ptr<boost::gregorian::date> &expires) {
+ using namespace boost::posix_time;
-bool GpgFrontend::GpgKeyManager::signKey(const GpgFrontend::GpgKey &target,
- GpgFrontend::KeyArgsList &keys,
- const QString &uid,
- std::unique_ptr<QDateTime> &expires) {
BasicOperator::GetInstance().SetSigners(keys);
unsigned int flags = 0;
-
unsigned int expires_time_t = 0;
+
if (expires == nullptr)
flags |= GPGME_KEYSIGN_NOEXPIRE;
else
- expires_time_t = QDateTime::currentDateTime().secsTo(*expires);
+ expires_time_t = to_time_t(ptime(*expires));
- auto err = check_gpg_error(gpgme_op_keysign(ctx, gpgme_key_t(target),
- uid.toUtf8().constData(),
- expires_time_t, flags));
+ auto err = check_gpg_error(gpgme_op_keysign(
+ ctx, gpgme_key_t(target), uid.c_str(), expires_time_t, flags));
- if (gpg_err_code(err) == GPG_ERR_NO_ERROR)
- return true;
- else
- return false;
+ return check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR;
}
bool GpgFrontend::GpgKeyManager::revSign(
@@ -60,20 +59,18 @@ bool GpgFrontend::GpgKeyManager::revSign(
auto err = check_gpg_error(gpgme_op_revsig(ctx, gpgme_key_t(key),
gpgme_key_t(signing_key),
signature.uid().data(), 0));
- if (gpg_err_code(err) == GPG_ERR_NO_ERROR)
- return true;
- else
- return false;
+ return check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR;
}
bool GpgFrontend::GpgKeyManager::setExpire(
const GpgFrontend::GpgKey &key, std::unique_ptr<GpgSubKey> &subkey,
- std::unique_ptr<QDateTime> &expires) {
+ std::unique_ptr<boost::gregorian::date> &expires) {
+ using namespace boost::posix_time;
+
unsigned long expires_time = 0;
- if (expires != nullptr) {
- qDebug() << "Expire Datetime" << expires->toString();
- expires_time = QDateTime::currentDateTime().secsTo(*expires);
- }
+
+ if (expires != nullptr)
+ expires_time = to_time_t(ptime(*expires));
const char *sub_fprs = nullptr;
@@ -82,8 +79,6 @@ bool GpgFrontend::GpgKeyManager::setExpire(
auto err = check_gpg_error(
gpgme_op_setexpire(ctx, gpgme_key_t(key), expires_time, sub_fprs, 0));
- if (gpg_err_code(err) == GPG_ERR_NO_ERROR)
- return true;
- else
- return false;
+
+ return check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR;
}