diff --git a/transactions/kgpgdecrypt.h b/transactions/kgpgdecrypt.h --- a/transactions/kgpgdecrypt.h +++ b/transactions/kgpgdecrypt.h @@ -75,11 +75,14 @@ protected: QStringList command() const override; bool nextLine(const QString &line) override; + void finish() override; + private: int m_fileIndex; int m_plainLength; ///< length of decrypted plain text if given by GnuPG const QString m_outFilename; ///< name of file to write output to + bool decryptSuccess = false; //< flag to determine if decryption succeeded }; #endif // KGPGDECRYPT_H diff --git a/transactions/kgpgdecrypt.cpp b/transactions/kgpgdecrypt.cpp --- a/transactions/kgpgdecrypt.cpp +++ b/transactions/kgpgdecrypt.cpp @@ -113,6 +113,9 @@ { const QList &inputFiles = getInputFiles(); + if (line == QLatin1String("[GNUPG:] DECRYPTION_OKAY")) { + decryptSuccess = true; + } if (!inputFiles.isEmpty()) { if (line == QLatin1String("[GNUPG:] BEGIN_DECRYPTION")) { emit statusMessage(i18nc("Status message 'Decrypting ' (operation starts)", "Decrypting %1", inputFiles.at(m_fileIndex).fileName())); @@ -137,3 +140,13 @@ return KGpgTextOrFileTransaction::nextLine(line); } + +void +KGpgDecrypt::finish() +{ + if(decryptSuccess){ + setSuccess(TS_OK); + }else if (getProcess()->exitCode() != 0) { + setSuccess(TS_MSG_SEQUENCE); + } +}