File indexing completed on 2024-04-28 09:46:05

0001 /*
0002     SPDX-FileCopyrightText: 2009-2022 Rolf Eike Beer <kde@opensource.sf-tec.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "kgpgsignkey.h"
0007 
0008 #include "model/kgpgitemnode.h"
0009 
0010 KGpgSignKey::KGpgSignKey(QObject *parent, const QString &signer, KGpgKeyNode *key, const bool local, const carefulCheck checking)
0011     : KGpgEditKeyTransaction(parent, key->getId(), QString(), false, false),
0012     KGpgSignTransactionHelper(signer, !local, checking)
0013 {
0014     insertArgument(1, QLatin1String( "-u" ));
0015     insertArgument(2, signer);
0016     m_signerPos = 2;
0017     addArgumentRef(&m_signerPos);
0018 
0019     addArgument(QLatin1String("save"));
0020 
0021     setKey(key);
0022 
0023     setLocal(local);
0024 }
0025 
0026 bool
0027 KGpgSignKey::nextLine(const QString &line)
0028 {
0029     switch (KGpgSignTransactionHelper::nextLine(line)) {
0030     case KGpgSignTransactionHelper::handledFalse:
0031         return false;
0032     case KGpgSignTransactionHelper::handledTrue:
0033         return true;
0034     default:
0035         // just to keep the compiler happy
0036         Q_ASSERT(0);
0037     case KGpgSignTransactionHelper::notHandled:
0038         return KGpgEditKeyTransaction::nextLine(line);
0039     }
0040 }
0041 
0042 KGpgTransaction::ts_boolanswer
0043 KGpgSignKey::boolQuestion(const QString& line)
0044 {
0045     if (line.contains(QLatin1String("sign_all.okay")))
0046         return BA_YES;
0047 
0048     ts_boolanswer ret = KGpgSignTransactionHelper::boolQuestion(line);
0049 
0050     if (ret == BA_UNKNOWN)
0051         ret = KGpgTransaction::boolQuestion(line);
0052 
0053     return ret;
0054 }
0055 
0056 bool
0057 KGpgSignKey::passphraseReceived()
0058 {
0059     setSuccess(KGpgTransaction::TS_OK);
0060     return true;
0061 }
0062 
0063 KGpgTransaction *
0064 KGpgSignKey::asTransaction()
0065 {
0066     return this;
0067 }
0068 
0069 void
0070 KGpgSignKey::replaceCmd(const QString &cmd)
0071 {
0072     replaceCommand(cmd);
0073 }