From f2514d13e2d84ab4e29c56820f40d364a8eeb3eb Mon Sep 17 00:00:00 2001
From: csoler
Date: Mon, 17 Sep 2018 23:03:11 +0200
Subject: [PATCH] added tooltip for certificates in Home
---
retroshare-gui/src/gui/HomePage.cpp | 17 ++++-
.../src/gui/connect/ConfCertDialog.cpp | 68 +++++++++++--------
.../src/gui/connect/ConfCertDialog.h | 2 +
3 files changed, 59 insertions(+), 28 deletions(-)
diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp
index 8d4414250..6a6107415 100644
--- a/retroshare-gui/src/gui/HomePage.cpp
+++ b/retroshare-gui/src/gui/HomePage.cpp
@@ -25,6 +25,7 @@
#include "gui/notifyqt.h"
#include "gui/msgs/MessageComposer.h"
#include "gui/connect/ConnectFriendWizard.h"
+#include "gui/connect/ConfCertDialog.h"
#include
#include "gui/connect/FriendRecommendDialog.h"
@@ -106,9 +107,23 @@ HomePage::~HomePage()
void HomePage::updateOwnCert()
{
- std::string invite = rsPeers->GetRetroshareInvite(false);
+ bool include_extra_locators = false;
+
+ RsPeerDetails detail;
+
+ if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail))
+ {
+ std::cerr << "(EE) Cannot retrieve information about own certificate. That is a real problem!!" << std::endl;
+ return ;
+ }
+
+ std::string invite = rsPeers->GetRetroshareInvite(detail.id,false,include_extra_locators);
ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str()));
+
+ QString description = ConfCertDialog::getCertificateDescription(detail,false,include_extra_locators);
+
+ ui->userCertEdit->setToolTip(description);
}
static void sendMail(QString sAddress, QString sSubject, QString sBody)
diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp
index 3c873fdca..764d193ad 100644
--- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp
+++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp
@@ -270,34 +270,9 @@ void ConfCertDialog::loadInvitePage()
// ui.userCertificateText_2->setFont(font);
// ui.userCertificateText_2->setText(QString::fromUtf8(pgp_key.c_str()));
- std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id
+ std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id
- QString infotext ;
-
- //infotext += tr("Use this certificate to make new friends. Send it by email, or give it hand to hand.
") ;
- infotext += tr("This certificate contains:") ;
- infotext += "
" ;
- infotext += "- a Profile key";
- infotext += " (" + QString::fromUtf8(detail.name.c_str()) + "@" + detail.gpg_id.toStdString().c_str()+") " ;
- if(ui._shouldAddSignatures_CB->isChecked())
- infotext += tr("with")+" "+QString::number(detail.gpgSigners.size()-1)+" "+tr("external signatures
") ;
- else
- infotext += "" ;
-
- infotext += tr("- a node ID and name") +" (" + detail.id.toStdString().c_str() + ", " + QString::fromUtf8(detail.location.c_str()) +")" ;
- infotext += "
" ;
-
- infotext += "- " ;
- if(detail.isHiddenNode)
- infotext += tr("an onion address and port") +" (" + detail.hiddenNodeAddress.c_str() + ":" + QString::number(detail.hiddenNodePort)+ ")";
- else
- infotext += tr("an IP address and port") +" (" + detail.connectAddr.c_str() + ":" + QString::number(detail.connectPort)+ ")";
- infotext += "
" ;
-
- infotext += QString("
") ;
-
- if(rsPeers->getOwnId() == detail.id)
- infotext += tr("You can use this certificate to make new friends. Send it by email, or give it hand to hand.
") ;
+ QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),true); // true, because default parameter in GetRetroshareInvite is true
ui.userCertificateText->setToolTip(infotext) ;
@@ -311,6 +286,45 @@ void ConfCertDialog::loadInvitePage()
ui.userCertificateText->setText(QString::fromUtf8(invite.c_str()));
}
+QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bool signatures_included,bool include_additional_locators)
+{
+ //infotext += tr("Use this certificate to make new friends. Send it by email, or give it hand to hand.
") ;
+ QString infotext = QObject::tr("This certificate contains:") ;
+ infotext += "
" ;
+ infotext += "- a Profile key";
+ infotext += " (" + QString::fromUtf8(detail.name.c_str()) + "@" + detail.gpg_id.toStdString().c_str()+") " ;
+
+ if(signatures_included)
+ infotext += tr("with")+" "+QString::number(detail.gpgSigners.size()-1)+" "+tr("external signatures
") ;
+ else
+ infotext += "" ;
+
+ infotext += tr("- a node ID and name") +" (" + detail.id.toStdString().c_str() + ", " + QString::fromUtf8(detail.location.c_str()) +")" ;
+ infotext += "
" ;
+
+ infotext += "- " ;
+ if(detail.isHiddenNode)
+ infotext += tr("an onion address and port") +" (" + detail.hiddenNodeAddress.c_str() + ":" + QString::number(detail.hiddenNodePort)+ ")";
+ else if(!detail.connectAddr.empty())
+ infotext += tr("an IP address and port") +" (" + detail.connectAddr.c_str() + ":" + QString::number(detail.connectPort)+ ")";
+ infotext += "
" ;
+
+ if(include_additional_locators)
+ for(auto it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
+ {
+ infotext += "- " ;
+ infotext += tr("Extra IP: ") + QString::fromStdString(*it) ;
+ infotext += "
" ;
+ }
+
+ infotext += QString("") ;
+
+ if(rsPeers->getOwnId() == detail.id)
+ infotext += tr("You can use this certificate to make new friends. Send it by email, or give it hand to hand.
") ;
+
+ return infotext;
+}
+
void ConfCertDialog::applyDialog()
{
diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h
index 2188d2ebb..642fcbb56 100644
--- a/retroshare-gui/src/gui/connect/ConfCertDialog.h
+++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h
@@ -27,6 +27,7 @@
#include "ui_ConfCertDialog.h"
#include
+#include
class ConfCertDialog : public QDialog
{
@@ -59,6 +60,7 @@ public:
/* window will destroy itself! */
}
static void loadAll();
+ static QString getCertificateDescription(const RsPeerDetails& det,bool signatures_included,bool extra_locators_included);
signals:
void configChanged();