From 6f7e656d6c843b7a4fabd53dac5c3216e0eff137 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Jul 2017 21:48:12 +0200 Subject: [PATCH 1/3] Defautl GXS nickname was built from location. Changed it to use profile name --- retroshare-gui/src/gui/GenCertDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 0f2086514..e6dcd6cf3 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -443,7 +443,7 @@ void GenCertDialog::genPerson() } else { - mGXSNickname = ui.node_input->text(); + mGXSNickname = ui.name_input->text(); } if (!mGXSNickname.isEmpty()) From 345f24eb5f795cfeb797b1314fa74a21339749b7 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Jul 2017 22:37:14 +0200 Subject: [PATCH 2/3] fixed clearing of PGP passphrase after creation of default identity --- retroshare-gui/src/gui/GenCertDialog.cpp | 2 -- retroshare-gui/src/gui/StartDialog.cpp | 2 -- retroshare-gui/src/gui/notifyqt.cpp | 7 +++++++ retroshare-gui/src/gui/notifyqt.h | 1 + retroshare-gui/src/main.cpp | 6 +++++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index e6dcd6cf3..550826f43 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -587,8 +587,6 @@ void GenCertDialog::genPerson() std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl; bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err); - rsNotify->clearPgpPassphrase() ; - if (okGen) { /* complete the process */ diff --git a/retroshare-gui/src/gui/StartDialog.cpp b/retroshare-gui/src/gui/StartDialog.cpp index 2a25eff77..27853c3e6 100644 --- a/retroshare-gui/src/gui/StartDialog.cpp +++ b/retroshare-gui/src/gui/StartDialog.cpp @@ -117,8 +117,6 @@ void StartDialog::loadPerson() bool res = Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked()) ; - rsNotify->clearPgpPassphrase(); - if(res) accept(); } diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 91a6153a7..7e6195e5e 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -785,6 +785,13 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) * uses Flags, to detect changes */ +void NotifyQt::resetCachedPassphrases() +{ + std::cerr << "Clearing PGP passphrase." << std::endl; + + rsNotify->clearPgpPassphrase() ; +} + void NotifyQt::enable() { QMutexLocker m(&_mutex) ; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index f04394eb1..446d8d9e2 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -155,6 +155,7 @@ class NotifyQt: public QObject, public NotifyClient public slots: void UpdateGUI(); /* called by timer */ void SetDisableAll(bool bValue); + void resetCachedPassphrases() ; private slots: void runningTick(); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 674e23065..1e2da635b 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -397,7 +397,6 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); uint32_t token = 0; rsIdentity->createIdentity(token, params); } - // I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to // avoid clashes between infos from threads. // @@ -443,6 +442,11 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); WebuiPage::checkStartWebui(); #endif // ENABLE_WEBUI + // This is done using a timer, because the passphrase request from notify is asynchrouneous and therefore clearing the + // passphrase here makes it request for a passphrase when creating the default chat identity. + + QTimer::singleShot(10000, Qt::CoarseTimer, notify, SLOT(resetCachedPassphrases())) ; + /* dive into the endless loop */ int ti = rshare.exec(); delete w ; From e8415c4f03b46d1ab9d60b1b7dc94c14e56255d8 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Jul 2017 23:12:56 +0200 Subject: [PATCH 3/3] made RS not to ask for plugin confirmation on first load --- libretroshare/src/plugins/pluginmanager.cc | 8 +++++--- libretroshare/src/plugins/pluginmanager.h | 2 +- libretroshare/src/pqi/p3notify.cc | 4 ++-- libretroshare/src/pqi/p3notify.h | 2 +- libretroshare/src/retroshare/rsnotify.h | 2 +- retroshare-gui/src/gui/notifyqt.cpp | 7 ++++++- retroshare-gui/src/gui/notifyqt.h | 2 +- retroshare-nogui/src/notifytxt.cc | 2 +- retroshare-nogui/src/notifytxt.h | 2 +- 9 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libretroshare/src/plugins/pluginmanager.cc b/libretroshare/src/plugins/pluginmanager.cc index 70c43a73b..61757f31d 100644 --- a/libretroshare/src/plugins/pluginmanager.cc +++ b/libretroshare/src/plugins/pluginmanager.cc @@ -140,6 +140,8 @@ void RsPluginManager::loadPlugins(const std::vector& plugin_directo // 0 - get the list of files to read + bool first_time = (_accepted_hashes.empty()) && _rejected_hashes.empty() ; + for(uint32_t i=0;i& plugin_directo std::cerr << "Found plugin " << fullname << std::endl; std::cerr << " Loading plugin..." << std::endl; - loadPlugin(fullname) ; + loadPlugin(fullname, first_time) ; } dirIt.closedir(); } @@ -262,7 +264,7 @@ bool RsPluginManager::loadPlugin(RsPlugin *p) return true; } -bool RsPluginManager::loadPlugin(const std::string& plugin_name) +bool RsPluginManager::loadPlugin(const std::string& plugin_name,bool first_time) { std::cerr << " Loading plugin " << plugin_name << std::endl; @@ -289,7 +291,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name) if(!_allow_all_plugins) { if(_accepted_hashes.find(pinfo.file_hash) == _accepted_hashes.end() && _rejected_hashes.find(pinfo.file_hash) == _rejected_hashes.end() ) - if(!RsServer::notify()->askForPluginConfirmation(pinfo.file_name,pinfo.file_hash.toStdString())) + if(!RsServer::notify()->askForPluginConfirmation(pinfo.file_name,pinfo.file_hash.toStdString(),first_time)) _rejected_hashes.insert(pinfo.file_hash) ; // accepted hashes are treated at the end, for security. if(_rejected_hashes.find(pinfo.file_hash) != _rejected_hashes.end() ) diff --git a/libretroshare/src/plugins/pluginmanager.h b/libretroshare/src/plugins/pluginmanager.h index 27a74f870..c8a7d3290 100644 --- a/libretroshare/src/plugins/pluginmanager.h +++ b/libretroshare/src/plugins/pluginmanager.h @@ -106,7 +106,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config private: bool loadPlugin(RsPlugin *) ; - bool loadPlugin(const std::string& shared_library_name) ; + bool loadPlugin(const std::string& shared_library_name, bool first_time) ; RsFileHash hashPlugin(const std::string& shared_library_name) ; std::vector _plugins ; diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index bd92891cf..9eb4b1bfd 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -283,10 +283,10 @@ bool p3Notify::askForPassword (const std::string& title , c return false ; } -bool p3Notify::askForPluginConfirmation (const std::string& plugin_filename, const std::string& plugin_file_hash) +bool p3Notify::askForPluginConfirmation (const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time) { FOR_ALL_NOTIFY_CLIENTS - if( (*it)->askForPluginConfirmation(plugin_filename,plugin_file_hash)) + if( (*it)->askForPluginConfirmation(plugin_filename,plugin_file_hash,first_time)) return true ; return false ; diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index f39201ea7..c31a95eea 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -123,7 +123,7 @@ class p3Notify: public RsNotify void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) ; bool askForPassword (const std::string& title, const std::string& /* key_details */, bool /* prev_is_bad */, std::string&, bool *cancelled /* password */ ) ; - bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */) ; + bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */,bool first_time) ; virtual bool cachePgpPassphrase (const std::string& /* pgp_passphrase */) ; virtual bool clearPgpPassphrase () ; diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index d5a208379..8b636c77f 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -244,7 +244,7 @@ class NotifyClient virtual void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) {} virtual bool askForPassword (const std::string& /* title */, const std::string& /* key_details */, bool /* prev_is_bad */, std::string& /* password */,bool& /* cancelled */ ) { return false ;} - virtual bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */) { return false ;} + virtual bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */,bool /* first_time */) { return false ;} }; #endif diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 7e6195e5e..3810fefc3 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -301,8 +301,13 @@ bool NotifyQt::askForPassword(const std::string& title, const std::string& key_d return false; } -bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash) +bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash, bool first_time) { + // By default, when no information is known about plugins, just dont load them. They will be enabled from the GUI by the user. + + if(first_time) + return false ; + RsAutoUpdatePage::lockAllEvents() ; QMessageBox dialog; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 446d8d9e2..4acbda23c 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -69,7 +69,7 @@ class NotifyQt: public QObject, public NotifyClient virtual void notifyDownloadComplete(const std::string& fileHash); virtual void notifyDownloadCompleteCount(uint32_t count); virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled); - virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash); + virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time); // Queues the signature event so that it canhappen in the main GUI thread (to ask for passwd). // To use this function: call is multiple times as soon as it returns true. diff --git a/retroshare-nogui/src/notifytxt.cc b/retroshare-nogui/src/notifytxt.cc index fbd9decaf..3c5651dc7 100644 --- a/retroshare-nogui/src/notifytxt.cc +++ b/retroshare-nogui/src/notifytxt.cc @@ -84,7 +84,7 @@ void NotifyTxt::notifyChat() return; } -bool NotifyTxt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash) +bool NotifyTxt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash, bool /* first_time */) { std::cerr << "The following plugin is not registered as accepted or denied. You probably upgraded the main executable or the plugin itself." << std::endl; std::cerr << " Hash: " << plugin_file_hash << std::endl; diff --git a/retroshare-nogui/src/notifytxt.h b/retroshare-nogui/src/notifytxt.h index 6fc88bdf8..508bfd7fd 100644 --- a/retroshare-nogui/src/notifytxt.h +++ b/retroshare-nogui/src/notifytxt.h @@ -42,7 +42,7 @@ class NotifyTxt: public NotifyClient virtual void notifyErrorMsg(int list, int sev, std::string msg); virtual void notifyChat(); virtual bool askForPassword(const std::string& title, const std::string& question, bool prev_is_bad, std::string& password,bool& cancel); - virtual bool askForPluginConfirmation(const std::string& plugin_file, const std::string& plugin_hash); + virtual bool askForPluginConfirmation(const std::string& plugin_file, const std::string& plugin_hash,bool first_time); virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_files);