From b9a4cdcd50facfa15bc581fd5425fc1c0cb881fc Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 13 Feb 2022 22:38:32 +0100 Subject: [PATCH] fixed up using invite flags to populate certificate comments --- libretroshare | 2 +- retroshare-gui/src/gui/HomePage.cpp | 3 +- .../src/gui/connect/ConfCertDialog.cpp | 30 +++++++++++-------- .../src/gui/connect/ConfCertDialog.h | 2 +- .../src/gui/connect/ConnectFriendWizard.cpp | 4 ++- .../src/gui/settings/CryptoPage.cpp | 2 +- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/libretroshare b/libretroshare index d26821b89..61dbe774d 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit d26821b891d7b3e72da475896814a82716574e56 +Subproject commit 61dbe774d60070a7ce371f925f230a878996cdd5 diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 0908b5c37..b55829fbd 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -238,8 +238,7 @@ void HomePage::getOwnCert(QString& invite,QString& description) const else invite = QString::fromStdString(rsPeers->GetRetroshareInvite(detail.id,invite_flags)); - bool include_extra_locators = mIncludeIPHistoryact->isChecked(); - description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatact->isChecked(),include_extra_locators); + description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatact->isChecked(),invite_flags); } void HomePage::updateOwnCert() diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index dc8c871e0..6a407cb49 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -283,7 +283,7 @@ void ConfCertDialog::loadInvitePage() ui.stabWidget->setTabText(PageCertificate, tr("Retroshare Certificate")); } - QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),ui._shortFormat_CB->isChecked(), ui._includeIPHistory_CB->isChecked() ); + QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),ui._shortFormat_CB->isChecked(), flags ); ui.userCertificateText->setToolTip(infotext) ; @@ -297,7 +297,7 @@ void ConfCertDialog::loadInvitePage() ui.userCertificateText->setText(QString::fromUtf8(invite.c_str())); } -QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bool signatures_included,bool use_short_format,bool include_additional_locators) +QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail, bool signatures_included, bool use_short_format,RetroshareInviteFlags invite_flags) { //infotext += tr("

Use this certificate to make new friends. Send it by email, or give it hand to hand.

") ; QString infotext; @@ -330,19 +330,23 @@ QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bo if(detail.isHiddenNode) infotext += tr("
  • onion address and port") +" (" + detail.hiddenNodeAddress.c_str() + ":" + QString::number(detail.hiddenNodePort)+ ")
  • "; - else if(!include_additional_locators) + else if(!!(invite_flags & RetroshareInviteFlags::FULL_IP_HISTORY)) + for(auto it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) + { + infotext += "
  • " ; + infotext += tr("IP address and port: ") + QString::fromStdString(*it) ; + infotext += "
  • " ; + } + else { - if(!detail.localAddr.empty()) infotext += tr("
  • IP address and port: ") + detail.localAddr.c_str() + ":" + QString::number(detail.localPort)+ "
  • "; - if(!detail.extAddr.empty()) infotext += tr("
  • IP address and port: ") + detail.extAddr.c_str() + ":" + QString::number(detail.extPort)+ "
  • "; - } - else for(auto it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) - { - infotext += "
  • " ; - infotext += tr("IP address and port: ") + QString::fromStdString(*it) ; - infotext += "
  • " ; - } + if(!!(invite_flags & RetroshareInviteFlags::CURRENT_LOCAL_IP) && !detail.localAddr.empty()) + infotext += tr("
  • IP address and port: ") + detail.localAddr.c_str() + ":" + QString::number(detail.localPort)+ "
  • "; - if(!detail.dyndns.empty()) + if(!!(invite_flags & RetroshareInviteFlags::CURRENT_EXTERNAL_IP) && !detail.extAddr.empty()) + infotext += tr("
  • IP address and port: ") + detail.extAddr.c_str() + ":" + QString::number(detail.extPort)+ "
  • "; + } + + if(!!(invite_flags & RetroshareInviteFlags::DNS) && !detail.dyndns.empty()) { infotext += "
  • " ; infotext += tr("DNS: : ") + QString::fromStdString(detail.dyndns); diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index a883dfd17..4760835da 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -59,7 +59,7 @@ public: /* window will destroy itself! */ } static void loadAll(); - static QString getCertificateDescription(const RsPeerDetails& det, bool signatures_included, bool use_short_format, bool extra_locators_included); + static QString getCertificateDescription(const RsPeerDetails& det, bool signatures_included, bool use_short_format,RetroshareInviteFlags invite_flags); signals: void configChanged(); diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index ca56e06aa..81287c6c4 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -891,7 +891,9 @@ void ConnectFriendWizard::cleanFriendCert() whileBlocking(ui->friendCertEdit)->setPlainText(QString::fromUtf8(cleanCert.c_str())); whileBlocking(ui->friendCertEdit)->setTextCursor(textCursor); - certDetail = ConfCertDialog::getCertificateDescription(details,false,mIsShortInvite,!details.ipAddressList.empty()); + // use dummy flags so that the content of the description is driven by what's in the "details" variable. + RetroshareInviteFlags dummy_flags = RetroshareInviteFlags::ALL; + certDetail = ConfCertDialog::getCertificateDescription(details,false,mIsShortInvite,dummy_flags); } if (mIsShortInvite) diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index 9f813209a..6c171bb1a 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -165,7 +165,7 @@ CryptoPage::load() RsPeerDetails detail; rsPeers->getPeerDetails(rsPeers->getOwnId(),detail); - ui.certplainTextEdit->setToolTip(ConfCertDialog::getCertificateDescription(detail, ui._includeSignatures_CB->isChecked(), ui._shortFormat_CB->isChecked(), ui._includeAllIPs_CB->isChecked() )); + ui.certplainTextEdit->setToolTip(ConfCertDialog::getCertificateDescription(detail, ui._includeSignatures_CB->isChecked(), ui._shortFormat_CB->isChecked(), flags)); } void