From 3fc211ab159c2e1b55dcaca8d7757cef61a646d2 Mon Sep 17 00:00:00 2001 From: joss17 Date: Fri, 30 Oct 2009 21:26:35 +0000 Subject: [PATCH] Add a QTDialog for the gpg key passphrase input git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1790 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/authgpg.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index d7b2aeaf7..6666aad7a 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -56,7 +56,7 @@ #include "authgpg.h" #include #include - +#include /* Turn a set of parameters into a string */ static std::string setKeyPairParams(bool useRsa, unsigned int blen, @@ -100,7 +100,10 @@ gpgcert::~gpgcert() gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passphrase_info, int prev_was_bad, int fd) { - const char *passwd = (const char *) hook; + QString text = QInputDialog::getText(NULL, "GPG key passphrase", + "GPG key passphrase", QLineEdit::Password, + NULL, NULL); + if (prev_was_bad) fprintf(stderr, "pgp_pwd_callback() Prev was bad!\n"); @@ -108,12 +111,12 @@ gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passp fprintf(stderr, "pgp_pwd_callback() Set Password\n"); #ifndef WINDOWS_SYS - write(fd, passwd, strlen(passwd)); + write(fd, text.toStdString().c_str(), text.length()); write(fd, "\n", 1); /* needs a new line? */ #else DWORD written = 0; HANDLE winFd = (HANDLE) fd; - WriteFile(winFd, passwd, strlen(passwd), &written, NULL); + WriteFile(winFd, text.toStdString().c_str(), text.length(), &written, NULL); WriteFile(winFd, "\n", 1, &written, NULL); #endif