From 7c1288411a23ae957338eb970d54d2d9cba02a62 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 5 Nov 2009 19:38:10 +0000 Subject: [PATCH] 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 --- libretroshare/src/pqi/authgpg.cc | 14 ++++++++------ libretroshare/src/rsiface/rsiface.h | 2 ++ retroshare-gui/src/main.cpp | 9 +++++---- retroshare-gui/src/rsiface/notifyqt.cpp | 7 +++++++ retroshare-gui/src/rsiface/notifyqt.h | 1 + retroshare-gui/src/rsiface/rsiface.h | 2 ++ 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index 6666aad7a..c46858e5d 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -54,9 +54,9 @@ */ #include "authgpg.h" +#include #include #include -#include /* 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 diff --git a/libretroshare/src/rsiface/rsiface.h b/libretroshare/src/rsiface/rsiface.h index 67968cc11..7adda7591 100644 --- a/libretroshare/src/rsiface/rsiface.h +++ b/libretroshare/src/rsiface/rsiface.h @@ -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; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 61accc3c8..80b27b784 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -48,6 +48,10 @@ int main(int argc, char *argv[]) rsiface = NULL; + NotifyQt *notify = new NotifyQt(); + createRsIface(*notify); + createRsControl(*rsiface, *notify); + /* RetroShare Core Objects */ RsInit::InitRsConfig(); bool okStart = RsInit::InitRetroShare(argc, argv); @@ -118,10 +122,6 @@ int main(int argc, char *argv[]) RsInit::LoadCertificates(false); } - NotifyQt *notify = new NotifyQt(); - createRsIface(*notify); - createRsControl(*rsiface, *notify); - rsicontrol->StartupRetroShare(); MainWindow *w = new MainWindow; @@ -145,6 +145,7 @@ int main(int argc, char *argv[]) QObject::connect(notify,SIGNAL(configChanged()) ,w->messagesDialog ,SLOT(displayConfig() )) ; QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); + QObject::connect(notify,SIGNAL(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&))); QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&))); QObject::connect(notify,SIGNAL(ownAvatarChanged()),w->peersDialog,SLOT(updateAvatar())); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus())); diff --git a/retroshare-gui/src/rsiface/notifyqt.cpp b/retroshare-gui/src/rsiface/notifyqt.cpp index f1a267416..a06ca1001 100644 --- a/retroshare-gui/src/rsiface/notifyqt.cpp +++ b/retroshare-gui/src/rsiface/notifyqt.cpp @@ -44,6 +44,13 @@ void NotifyQt::notifyOwnAvatarChanged() emit ownAvatarChanged() ; } +std::string NotifyQt::askForPassword(const std::string& window_title,const std::string& text) +{ + return QInputDialog::getText(NULL, QString::fromStdString(window_title), + QString::fromStdString(text), QLineEdit::Password, + NULL, NULL).toStdString(); +} + void NotifyQt::notifyOwnStatusMessageChanged() { std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ; diff --git a/retroshare-gui/src/rsiface/notifyqt.h b/retroshare-gui/src/rsiface/notifyqt.h index d98cd81d0..e6e0409ab 100644 --- a/retroshare-gui/src/rsiface/notifyqt.h +++ b/retroshare-gui/src/rsiface/notifyqt.h @@ -40,6 +40,7 @@ class NotifyQt: public QObject, public NotifyBase virtual void notifyPeerHasNewAvatar(std::string peer_id) ; virtual void notifyOwnAvatarChanged() ; virtual void notifyOwnStatusMessageChanged() ; + virtual std::string askForPassword(const std::string& window_title,const std::string& text) ; signals: // It's beneficial to send info to the GUI using signals, because signals are thread-safe diff --git a/retroshare-gui/src/rsiface/rsiface.h b/retroshare-gui/src/rsiface/rsiface.h index 67968cc11..7adda7591 100644 --- a/retroshare-gui/src/rsiface/rsiface.h +++ b/retroshare-gui/src/rsiface/rsiface.h @@ -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;