From 57a548531cfb46a120694ce080b44e8425375dbe Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 10 Jun 2019 15:15:15 +0200 Subject: [PATCH] fixed adding friend with short invite --- libretroshare/src/rsserver/p3peers.cc | 2 ++ .../src/gui/connect/ConnectFriendWizard.cpp | 31 +++++++++++-------- .../src/gui/connect/ConnectFriendWizard.h | 20 ++++++------ .../src/gui/connect/ConnectFriendWizard.ui | 6 ++-- 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 02615d9e6..70db57b5c 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -1360,6 +1360,8 @@ bool p3Peers::parseShortInvite(const std::string& inviteStrUrl, RsPeerDetails& d details.hasSignedMe = pgp_det.hasSignedMe; details.accept_connection = pgp_det.accept_connection; } + else + details.skip_signature_validation = true; return ctx.mOk; } diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index f77c533c6..48de3b6a2 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -129,6 +129,8 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : body += "\n" + GetStartedDialog::GetCutBelowText(); body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite().c_str()); + mIsShortInvite = false; + std::string advsetting; if(rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES")) { @@ -147,14 +149,10 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : switch (rsFiles->filePermDirectDL()) { case RS_FILE_PERM_DIRECT_DL_YES: -// ui->_direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png")); -// ui->_direct_transfer_CB->setToolTip(ui->_direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes."))); ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png")); ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes."))); break ; case RS_FILE_PERM_DIRECT_DL_NO: -// ui->_direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png")); -// ui->_direct_transfer_CB->setToolTip(ui->_direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No."))); ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png")); ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No."))); break ; @@ -309,6 +307,8 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend } else if(rsPeers->parseShortInvite(certificate.toUtf8().constData(),peerDetails)) { + mIsShortInvite = true; + if(peerDetails.id == rsPeers->getOwnId()) { setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ; @@ -638,7 +638,7 @@ bool ConnectFriendWizard::validateCurrentPage() int ConnectFriendWizard::nextId() const { switch ((Page) currentId()) { - case Page_Text: + case Page_Text: return Page_Conclusion; case Page_WebMail: case Page_ErrorMessage: case Page_Conclusion: @@ -676,7 +676,9 @@ void ConnectFriendWizard::accept() return; } - if(!peerDetails.skip_signature_validation && !mCertificate.empty() && add_key_to_keyring) + // add the profile pgp key to keyring + + if(!mIsShortInvite && !mCertificate.empty() && add_key_to_keyring) { RsPgpId pgp_id ; RsPeerId ssl_id ; @@ -691,6 +693,11 @@ void ConnectFriendWizard::accept() bool runProgressDialog = false; + // add the peer as friend, either with or without pgp signature validation, depending on whether we have the key or not + // Note: that is different than having a short invite or not. + + // first, set data related to profile key. + if(accept_connection && !peerDetails.gpg_id.isNull()) { std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl; @@ -723,6 +730,8 @@ void ConnectFriendWizard::accept() rsPeers->assignPeerToGroup(RsNodeGroupId(groupId.toStdString()), peerDetails.gpg_id, true); } + // Then set data related to node location + if ((accept_connection) && (!peerDetails.id.isNull())) { runProgressDialog = true; @@ -753,9 +762,7 @@ void ConnectFriendWizard::accept() rsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns); } for(auto&& ipr : peerDetails.ipAddressList) - rsPeers->addPeerLocator( - peerDetails.id, - RsUrl(ipr.substr(0, ipr.find(' '))) ); + rsPeers->addPeerLocator( peerDetails.id, RsUrl(ipr.substr(0, ipr.find(' '))) ); } } @@ -768,7 +775,6 @@ void ConnectFriendWizard::accept() } NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ; - QDialog::accept(); } @@ -841,9 +847,8 @@ void ConnectFriendWizard::cleanFriendCert() } else { std::string cleanCert; int error_code; - bool is_short_format; - if (rsPeers->cleanCertificate(cert, cleanCert, is_short_format, error_code)) + if (rsPeers->cleanCertificate(cert, cleanCert, mIsShortInvite, error_code)) { certValid = true; @@ -856,7 +861,7 @@ void ConnectFriendWizard::cleanFriendCert() ui->friendCertCleanLabel->setStyleSheet(""); } - errorMsg = tr("Valid certificate") + (is_short_format?" (Short format)":" (plain format with profile key)"); + errorMsg = tr("Valid certificate") + (mIsShortInvite?" (Short format)":" (plain format with profile key)"); ui->friendCertCleanLabel->setPixmap(QPixmap(":/images/accepted16.png")); } else { diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h index 44ebcacd7..5951fd7c2 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h @@ -99,13 +99,13 @@ private slots: /* ConclusionPage */ void groupCurrentIndexChanged(int index); - + /* WebMailPage */ - void inviteGmail(); - void inviteYahoo(); - void inviteOutlook(); - void inviteAol(); - void inviteYandex(); + void inviteGmail(); + void inviteYahoo(); + void inviteOutlook(); + void inviteAol(); + void inviteYandex(); void toggleAdvanced(); @@ -115,12 +115,14 @@ private: void updateStylesheet(); void setTitleText(QWizardPage *page, const QString &title); bool AdvancedVisible; - + private: bool error; RsPeerDetails peerDetails; std::string mCertificate; + bool mIsShortInvite; + /* Stylesheet */ QString mBannerPixmap; int mTitleFontSize; @@ -137,9 +139,9 @@ private: /* ConclusionPage */ QString groupId; - + /* WebMailPage */ - QString subject; + QString subject; QString body; Ui::ConnectFriendWizard *ui; diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui index efaae261c..8aadc22db 100644 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui @@ -6,8 +6,8 @@ 0 0 - 1100 - 604 + 1139 + 1171 @@ -817,7 +817,7 @@ - <html><head/><body><p align="justify">Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.</p><p align="justify">To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. This setting is applied to all locations of the same node.</p></body></html> + <html><head/><body><p align="justify">Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.</p><p align="justify">To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. This setting is applied to all nodes with the same profile key.</p></body></html> Can be used as direct source