made the passwd dialog call Qt-independent (thanks to notifyBase)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1793 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-11-05 19:38:10 +00:00
parent 9df3b567e7
commit 7c1288411a
6 changed files with 25 additions and 10 deletions

View file

@ -54,9 +54,9 @@
*/
#include "authgpg.h"
#include <rsiface/rsiface.h>
#include <iostream>
#include <sstream>
#include <QtGui>
/* Turn a set of parameters into a string */
static std::string setKeyPairParams(bool useRsa, unsigned int blen,
@ -100,9 +100,11 @@ gpgcert::~gpgcert()
gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passphrase_info, int prev_was_bad, int fd)
{
QString text = QInputDialog::getText(NULL, "GPG key passphrase",
"GPG key passphrase", QLineEdit::Password,
NULL, NULL);
std::string text = rsicontrol->getNotify().askForPassword("GPG key passphrase","GPG key passphrase") ;
// QString text = QInputDialog::getText(NULL, "GPG key passphrase",
// "GPG key passphrase", QLineEdit::Password,
// NULL, NULL);
if (prev_was_bad)
@ -111,12 +113,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, text.toStdString().c_str(), text.length());
write(fd, text.c_str(), text.size());
write(fd, "\n", 1); /* needs a new line? */
#else
DWORD written = 0;
HANDLE winFd = (HANDLE) fd;
WriteFile(winFd, text.toStdString().c_str(), text.length(), &written, NULL);
WriteFile(winFd, text.c_str(), text.size(), &written, NULL);
WriteFile(winFd, "\n", 1, &written, NULL);
#endif

View file

@ -207,6 +207,8 @@ class NotifyBase
virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; }
virtual void notifyOwnAvatarChanged() {}
virtual void notifyOwnStatusMessageChanged() {}
virtual std::string askForPassword(const std::string& window_title,const std::string& text) {}
};
const int NOTIFY_LIST_NEIGHBOURS = 1;