diff --git a/transactions/kgpgdelkey.cpp b/transactions/kgpgdelkey.cpp index 3a94228a..755577c0 100644 --- a/transactions/kgpgdelkey.cpp +++ b/transactions/kgpgdelkey.cpp @@ -1,96 +1,87 @@ /* * Copyright (C) 2008,2009,2012,2016,2017,2018 Rolf Eike Beer */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "kgpgdelkey.h" #include "gpgproc.h" #include #include static QStringList keyFingerprints(const KGpgKeyNode::List &keys) { QStringList ret; ret.reserve(keys.count()); for (const KGpgKeyNode *key : keys) ret << key->getFingerprint(); return ret; } -KGpgDelKey::KGpgDelKey(QObject *parent, KGpgKeyNode *key) - : KGpgTransaction(parent) - , keys({key}) - , fingerprints(keyFingerprints(keys)) -{ - setCmdLine(); - setExpectedFingerprints(fingerprints); -} - KGpgDelKey::KGpgDelKey(QObject *parent, const KGpgKeyNode::List &keys) : KGpgTransaction(parent) , keys(keys) , fingerprints(keyFingerprints(keys)) { setCmdLine(); setExpectedFingerprints(fingerprints); } KGpgDelKey::~KGpgDelKey() { } bool KGpgDelKey::nextLine(const QString &line) { if (!line.startsWith(QLatin1String("[GNUPG:] GOT_IT"))) setSuccess(KGpgTransaction::TS_MSG_SEQUENCE); return false; } KGpgTransaction::ts_boolanswer KGpgDelKey::boolQuestion(const QString &line) { if (line.startsWith(QLatin1String("delete_key.okay"))) return KGpgTransaction::BA_YES; if (line.startsWith(QLatin1String("delete_key.secret.okay"))) return KGpgTransaction::BA_YES; return KGpgTransaction::boolQuestion(line); } bool KGpgDelKey::preStart() { GPGProc *proc = getProcess(); const QStringList args = proc->program() + fingerprints; proc->setProgram(args); setSuccess(KGpgTransaction::TS_OK); return true; } void KGpgDelKey::setCmdLine() { addArgument(QLatin1String( "--status-fd=1" )); addArgument(QLatin1String( "--command-fd=0" )); addArgument(QLatin1String( "--delete-secret-and-public-key" )); m_argscount = getProcess()->program().count(); } diff --git a/transactions/kgpgdelkey.h b/transactions/kgpgdelkey.h index 07301446..790d41a8 100644 --- a/transactions/kgpgdelkey.h +++ b/transactions/kgpgdelkey.h @@ -1,57 +1,58 @@ /* - * Copyright (C) 2008,2009 Rolf Eike Beer + * Copyright (C) 2008,2009,2018 Rolf Eike Beer */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef KGPGDELKEY_H #define KGPGDELKEY_H #include "kgpgtransaction.h" #include #include /** * @brief delete a public key */ class KGpgDelKey: public KGpgTransaction { Q_OBJECT Q_DISABLE_COPY(KGpgDelKey) KGpgDelKey() = delete; public: - KGpgDelKey(QObject *parent, KGpgKeyNode *key); + inline KGpgDelKey(QObject *parent, KGpgKeyNode *key) + : KGpgDelKey(parent, KGpgKeyNode::List({key})) {} KGpgDelKey(QObject *parent, const KGpgKeyNode::List &keys); virtual ~KGpgDelKey(); /** * @brief the keys that were requested to be removed */ const KGpgKeyNode::List keys; /** * @brief the fingerprints of everything in keys */ const QStringList fingerprints; protected: bool nextLine(const QString &line) override; ts_boolanswer boolQuestion(const QString &line) override; bool preStart() override; private: int m_argscount; void setCmdLine(); }; #endif // KGPGDELKEY_H