aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgKeyOpera.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-10-18 18:15:36 +0000
committersaturneric <[email protected]>2024-10-18 18:15:36 +0000
commitc3a23900281c2024f7d4507ac84b0fe700fbf6dd (patch)
treeb8f611ef7b4121ffe9f0df60eb3b3c3896c444b5 /src/core/function/gpg/GpgKeyOpera.cpp
parentfeat: add filter option of 'comment' at key list of main window (diff)
downloadGpgFrontend-c3a23900281c2024f7d4507ac84b0fe700fbf6dd.tar.gz
GpgFrontend-c3a23900281c2024f7d4507ac84b0fe700fbf6dd.zip
feat: set reason code and text at revoke-certification
Diffstat (limited to '')
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index 332ed1b3..0d84017f 100644
--- a/src/core/function/gpg/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -103,7 +103,17 @@ auto GpgKeyOpera::SetExpire(const GpgKey& key, const SubkeyId& subkey_fpr,
* @return the process doing this job
*/
void GpgKeyOpera::GenerateRevokeCert(const GpgKey& key,
- const QString& output_path) {
+ const QString& output_path,
+ int revocation_reason_code,
+ const QString& revocation_reason_text) {
+ LOG_D() << "revoke code:" << revocation_reason_code
+ << "text:" << revocation_reason_text;
+
+ // dealing with reason text
+ auto reason_text_lines =
+ GpgFrontend::SecureCreateSharedObject<QList<QString>>(
+ revocation_reason_text.split('\n', Qt::SkipEmptyParts).toVector());
+
const auto app_path = Module::RetrieveRTValueTypedOrDefault<>(
"core", "gpgme.ctx.app_path", QString{});
// get all components
@@ -121,17 +131,23 @@ void GpgKeyOpera::GenerateRevokeCert(const GpgKey& key,
}
},
nullptr,
- [](QProcess* proc) -> void {
+ [revocation_reason_code, reason_text_lines](QProcess* proc) -> void {
// Code From Gpg4Win
while (proc->canReadLine()) {
const QString line = QString::fromUtf8(proc->readLine()).trimmed();
+ LOG_D() << "gpg revoke proc line:" << line;
+
if (line == QLatin1String("[GNUPG:] GET_BOOL gen_revoke.okay")) {
proc->write("y\n");
} else if (line == QLatin1String("[GNUPG:] GET_LINE "
"ask_revocation_reason.code")) {
- proc->write("0\n");
+ proc->write(
+ QString("%1%\n").arg(revocation_reason_code).toLatin1());
} else if (line == QLatin1String("[GNUPG:] GET_LINE "
"ask_revocation_reason.text")) {
+ if (!reason_text_lines->isEmpty()) {
+ proc->write(reason_text_lines->takeFirst().toUtf8());
+ }
proc->write("\n");
} else if (line ==
QLatin1String(