Skip to content

Commit

Permalink
Fix result of KGpgMe::passphrase (GPG_ERR_CANCELED was returned)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleb Baryshev committed Nov 30, 2016
1 parent 548f419 commit 60fa333
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ void Archive::open(const QString &path)
// Import the Tags:
importTagEmblems(extractionFolder); // Import and rename tag emblems BEFORE loading them!
QMap<QString, QString> mergedStates = Tag::loadTags(extractionFolder + "tags.xml");
QMap<QString, QString>::Iterator it;
if (mergedStates.count() > 0) {
Tag::saveTags();
}
Expand Down
16 changes: 7 additions & 9 deletions src/kgpgme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ bool KGpgMe::encrypt(const QByteArray& inBuffer, unsigned long length,
.arg(gpgme_strsource(err)).arg(gpgme_strerror(err)));
}
if (err != GPG_ERR_NO_ERROR) {
DEBUG_WIN << "KGpgMe::encrypt error: " << ((err == GPG_ERR_CANCELED) ? "GPG_ERR_CANCELED" : QString::number(err));
DEBUG_WIN << "KGpgMe::encrypt error: " + QString::number(err);
clearCache();
}
if (keys[0])
Expand Down Expand Up @@ -426,10 +426,9 @@ gpgme_error_t KGpgMe::passphrase(const char* uid_hint,
const char* /*passphrase_info*/,
int last_was_bad, int fd)
{
gpgme_error_t res = GPG_ERR_CANCELED;
QString s;
QString gpg_hint = checkForUtf8(uid_hint);
int result;
bool canceled = false;

if (last_was_bad) {
s += "<b>" + i18n("Wrong password.") + "</b><br><br>\n\n";
Expand All @@ -451,14 +450,13 @@ gpgme_error_t KGpgMe::passphrase(const char* uid_hint,

if (dlg.exec())
m_cache = dlg.password();
} else
result = KPasswordDialog::Accepted;
else
canceled = true;
}

if (result == KPasswordDialog::Accepted) {
if (!canceled)
write(fd, m_cache.data(), m_cache.length());
res = 0;
}
write(fd, "\n", 1);
return res;
return canceled ? GPG_ERR_CANCELED : GPG_ERR_NO_ERROR;
}
#endif // HAVE_LIBGPGME

0 comments on commit 60fa333

Please sign in to comment.