aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/function/GpgKeyManager.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-09-05 15:02:19 +0000
committerSaturneric <[email protected]>2021-09-05 15:02:19 +0000
commit39440522111abf3adeef6b56cb23722119fbf3c2 (patch)
tree5979b3808d58c8c576e288004877d826556b4cda /src/gpg/function/GpgKeyManager.cpp
parentModified ResultAnalyse. (diff)
downloadGpgFrontend-39440522111abf3adeef6b56cb23722119fbf3c2.tar.gz
GpgFrontend-39440522111abf3adeef6b56cb23722119fbf3c2.zip
Rewrite the core.
Adjust the structure.
Diffstat (limited to '')
-rw-r--r--src/gpg/function/GpgKeyManager.cpp83
1 files changed, 48 insertions, 35 deletions
diff --git a/src/gpg/function/GpgKeyManager.cpp b/src/gpg/function/GpgKeyManager.cpp
index b27163c8..9e0f610e 100644
--- a/src/gpg/function/GpgKeyManager.cpp
+++ b/src/gpg/function/GpgKeyManager.cpp
@@ -22,55 +22,68 @@
*
*/
-
#include "gpg/function/GpgKeyManager.h"
-#include "gpg/function/GpgKeyGetter.h"
#include "gpg/function/BasicOperator.h"
+#include "gpg/function/GpgKeyGetter.h"
-bool GpgFrontend::GpgKeyManager::signKey(const GpgFrontend::GpgKey &target, GpgFrontend::KeyArgsList &keys,
- const QString &uid, std::unique_ptr<QDateTime> &expires) {
- BasicOperator::getInstance().setSigners(keys);
+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 flags = 0;
- unsigned int expires_time_t = 0;
- if (expires == nullptr) flags |= GPGME_KEYSIGN_NOEXPIRE;
- else expires_time_t = QDateTime::currentDateTime().secsTo(*expires);
+ unsigned int expires_time_t = 0;
+ if (expires == nullptr)
+ flags |= GPGME_KEYSIGN_NOEXPIRE;
+ else
+ expires_time_t = QDateTime::currentDateTime().secsTo(*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.toUtf8().constData(),
+ expires_time_t, flags));
- if (gpg_err_code(err) == GPG_ERR_NO_ERROR) return true;
- else return false;
+ if (gpg_err_code(err) == GPG_ERR_NO_ERROR)
+ return true;
+ else
+ return false;
}
-bool
-GpgFrontend::GpgKeyManager::revSign(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgKeySignature &signature) {
-
- auto &key_getter = GpgKeyGetter::getInstance();
- auto signing_key = key_getter.getKey(signature.keyid());
+bool GpgFrontend::GpgKeyManager::revSign(
+ const GpgFrontend::GpgKey &key,
+ const GpgFrontend::GpgKeySignature &signature) {
- 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;
+ auto &key_getter = GpgKeyGetter::GetInstance();
+ auto signing_key = key_getter.GetKey(signature.keyid());
+ 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;
}
-bool GpgFrontend::GpgKeyManager::setExpire(const GpgFrontend::GpgKey &key, std::unique_ptr<GpgSubKey> &subkey,
- std::unique_ptr<QDateTime> &expires) {
- unsigned long expires_time = 0;
- if (expires != nullptr) {
- qDebug() << "Expire Datetime" << expires->toString();
- expires_time = QDateTime::currentDateTime().secsTo(*expires);
- }
+bool GpgFrontend::GpgKeyManager::setExpire(
+ const GpgFrontend::GpgKey &key, std::unique_ptr<GpgSubKey> &subkey,
+ std::unique_ptr<QDateTime> &expires) {
+ unsigned long expires_time = 0;
+ if (expires != nullptr) {
+ qDebug() << "Expire Datetime" << expires->toString();
+ expires_time = QDateTime::currentDateTime().secsTo(*expires);
+ }
- const char *sub_fprs = nullptr;
+ const char *sub_fprs = nullptr;
- if (subkey != nullptr) sub_fprs = subkey->fpr().toUtf8().constData();
+ if (subkey != nullptr)
+ sub_fprs = subkey->fpr().c_str();
- 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;
+ 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;
}