Commit 4c9badef authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Rolf Eike Beer

fix GnuPG error messages missing if key generation fails

If GnuPG reports the error to the control fd it was not shown to the user.
parent 799ea98a
...@@ -189,7 +189,8 @@ KGpgGenerateKey::nextLine(const QString &line) ...@@ -189,7 +189,8 @@ KGpgGenerateKey::nextLine(const QString &line)
result = true; result = true;
} else if (line.contains(QLatin1String("KEY_NOT_CREATED"))) { } else if (line.contains(QLatin1String("KEY_NOT_CREATED"))) {
result = true; result = true;
} } else
m_errorOutput << line;
emit statusMessage(msg); emit statusMessage(msg);
...@@ -216,18 +217,13 @@ KGpgGenerateKey::finish() ...@@ -216,18 +217,13 @@ KGpgGenerateKey::finish()
emit statusMessage(i18n("Key %1 generated", getFingerprint())); emit statusMessage(i18n("Key %1 generated", getFingerprint()));
break; break;
default: default:
{ while (getProcess()->hasLineStandardError()) {
QStringList errorLines; QByteArray b;
getProcess()->readLineStandardError(&b);
while (getProcess()->hasLineStandardError()) { m_errorOutput << QString::fromUtf8(b);
QByteArray b;
getProcess()->readLineStandardError(&b);
errorLines << QString::fromUtf8(b);
}
m_errorOutput = errorLines.join(QLatin1String("\n"));
emit statusMessage(i18n("gpg process did not finish. Cannot generate a new key pair."));
} }
emit statusMessage(i18n("gpg process did not finish. Cannot generate a new key pair."));
} }
} }
...@@ -259,5 +255,5 @@ KGpgGenerateKey::getFingerprint() const ...@@ -259,5 +255,5 @@ KGpgGenerateKey::getFingerprint() const
QString QString
KGpgGenerateKey::gpgErrorMessage() const KGpgGenerateKey::gpgErrorMessage() const
{ {
return m_errorOutput; return m_errorOutput.join(QLatin1Char('\n'));
} }
/* /*
* Copyright (C) 2008,2009,2012,2013 Rolf Eike Beer <kde@opensource.sf-tec.de> * Copyright (C) 2008,2009,2012,2013,2016 Rolf Eike Beer <kde@opensource.sf-tec.de>
*/ */
/*************************************************************************** /***************************************************************************
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QStringList>
/** /**
* @brief generate a new key pair * @brief generate a new key pair
...@@ -84,7 +85,7 @@ private: ...@@ -84,7 +85,7 @@ private:
const unsigned int m_expire; const unsigned int m_expire;
const unsigned int m_expireunit; const unsigned int m_expireunit;
QString m_fingerprint; QString m_fingerprint;
QString m_errorOutput; QStringList m_errorOutput;
}; };
#endif // KGPGGENERATEKEY_H #endif // KGPGGENERATEKEY_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment