From 8440a4703c00ee362374730cad41c7d5acf81042 Mon Sep 17 00:00:00 2001 From: ubbo Date: Sat, 28 Aug 2010 11:20:27 +0000 Subject: try to fix decrpyt-cancel on windows git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@373 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- context.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/context.cpp b/context.cpp index 614a7ad..d31f868 100644 --- a/context.cpp +++ b/context.cpp @@ -377,7 +377,7 @@ gpgme_error_t Context::passphrase(const char *uid_hint, const char * /*passphrase_info*/, int last_was_bad, int fd) { - gpgme_error_t returnValue = GPG_ERR_CANCELED; + gpgme_error_t returnValue; // = GPG_ERR_CANCELED; QString s; QString gpg_hint = uid_hint; bool result; @@ -394,17 +394,23 @@ gpgme_error_t Context::passphrase(const char *uid_hint, s += "Enter Password for
\n" + gpg_hint + "\n"; } + // password saved? if yes, do'nt ask and take from buffer if (mPasswordCache.isEmpty()) { QString password = QInputDialog::getText(0, "Enter Password", s, QLineEdit::Password, "", &result, Qt::Window); - if (result) mPasswordCache = password.toAscii(); - } else { - result = true; - } + // user canceld password entry? + if (result) { + mPasswordCache = password.toAscii(); + } else { + return GPG_ERR_CANCELED; + } + } //else { + // result = true; + //} - if (result) { + //if (result) { #ifndef _WIN32 if (write(fd, mPasswordCache.data(), mPasswordCache.length()) == -1) { @@ -415,8 +421,7 @@ gpgme_error_t Context::passphrase(const char *uid_hint, WriteFile((HANDLE) fd, mPasswordCache.data(), mPasswordCache.length(), &written, 0); #endif - returnValue = 0; - } + returnValue = GPG_ERR_NO_ERROR; #ifndef _WIN32 if (write(fd, "\n", 1) == -1) { @@ -427,6 +432,8 @@ gpgme_error_t Context::passphrase(const char *uid_hint, WriteFile((HANDLE) fd, "\n", 1, &written, 0); #endif + //} + return returnValue; } -- cgit v1.2.3