diff options
author | Saturneric <[email protected]> | 2021-09-10 23:58:09 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-09-10 16:06:21 +0000 |
commit | 4e076fa1982812ea7d1222c7e981879799ca8853 (patch) | |
tree | 1b96ae4a6296ca0f7b9df8ce3a3c7339643bf1f0 /src/gpg/function/UidOperator.cpp | |
parent | Adjust the code structure. (diff) | |
download | GpgFrontend-4e076fa1982812ea7d1222c7e981879799ca8853.tar.gz GpgFrontend-4e076fa1982812ea7d1222c7e981879799ca8853.zip |
Continue to optimize and improve the code.
Diffstat (limited to 'src/gpg/function/UidOperator.cpp')
-rw-r--r-- | src/gpg/function/UidOperator.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gpg/function/UidOperator.cpp b/src/gpg/function/UidOperator.cpp index 937396d4..d0058540 100644 --- a/src/gpg/function/UidOperator.cpp +++ b/src/gpg/function/UidOperator.cpp @@ -24,14 +24,15 @@ #include "gpg/function/UidOperator.h" +#include "boost/format.hpp" + bool GpgFrontend::UidOperator::addUID(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgUID &uid) { - QString userid = - QString("%1 (%3) <%2>") - .arg(uid.name().c_str(), uid.email().c_str(), uid.comment().c_str()); - auto err = - gpgme_op_adduid(ctx, gpgme_key_t(key), userid.toUtf8().constData(), 0); - if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) + auto userid = (boost::format("%1% (%2%) <%3%>") % uid.name() % uid.comment() % + uid.email()) + .str(); + auto err = gpgme_op_adduid(ctx, gpgme_key_t(key), userid.c_str(), 0); + if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR) return true; else return false; @@ -41,7 +42,7 @@ bool GpgFrontend::UidOperator::revUID(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgUID &uid) { auto err = check_gpg_error( gpgme_op_revuid(ctx, gpgme_key_t(key), uid.uid().c_str(), 0)); - if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) + if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR) return true; else return false; @@ -51,7 +52,7 @@ bool GpgFrontend::UidOperator::setPrimaryUID(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgUID &uid) { auto err = check_gpg_error(gpgme_op_set_uid_flag( ctx, gpgme_key_t(key), uid.uid().c_str(), "primary", nullptr)); - if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) + if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR) return true; else return false; |