mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-22 22:21:09 -04:00
improved the logic of certificate handling in UI
This commit is contained in:
parent
5270459a5c
commit
c3c171125d
7 changed files with 58 additions and 67 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 5a6f09ee11a34f1c52b5be3f0a440f185b9b2a89
|
Subproject commit d26821b891d7b3e72da475896814a82716574e56
|
|
@ -229,7 +229,7 @@ void GetStartedDialog::inviteFriends()
|
||||||
{
|
{
|
||||||
RsAutoUpdatePage::lockAllEvents();
|
RsAutoUpdatePage::lockAllEvents();
|
||||||
|
|
||||||
cert = rsPeers->GetRetroshareInvite(RsPeerId(),RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::FULL_IP_HISTORY);
|
cert = rsPeers->GetRetroshareInvite(RsPeerId(),RsPeers::defaultCertificateFlags | RetroshareInviteFlags::FULL_IP_HISTORY);
|
||||||
|
|
||||||
RsAutoUpdatePage::unlockAllEvents() ;
|
RsAutoUpdatePage::unlockAllEvents() ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,14 +50,10 @@
|
||||||
|
|
||||||
HomePage::HomePage(QWidget *parent) :
|
HomePage::HomePage(QWidget *parent) :
|
||||||
MainPage(parent),
|
MainPage(parent),
|
||||||
ui(new Ui::HomePage),
|
ui(new Ui::HomePage)
|
||||||
mIncludeAllIPs(false),
|
|
||||||
mUseShortFormat(true)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
updateCertificate();
|
|
||||||
|
|
||||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addFriend()));
|
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addFriend()));
|
||||||
connect(ui->copyIDButton, SIGNAL(clicked()), this, SLOT(copyId()));
|
connect(ui->copyIDButton, SIGNAL(clicked()), this, SLOT(copyId()));
|
||||||
|
|
||||||
|
@ -76,26 +72,33 @@ HomePage::HomePage(QWidget *parent) :
|
||||||
QMenu *menu = new QMenu();
|
QMenu *menu = new QMenu();
|
||||||
menu->addAction(CopyIdAction);
|
menu->addAction(CopyIdAction);
|
||||||
|
|
||||||
if(!RsAccounts::isHiddenNode())
|
|
||||||
{
|
|
||||||
QAction *includeIPsAct = new QAction(QIcon(), tr("Include all your known IPs"),this);
|
|
||||||
connect(includeIPsAct, SIGNAL(triggered()), this, SLOT(toggleIncludeAllIPs()));
|
|
||||||
includeIPsAct->setCheckable(true);
|
|
||||||
includeIPsAct->setChecked(mIncludeAllIPs);
|
|
||||||
|
|
||||||
menu->addAction(includeIPsAct);
|
|
||||||
}
|
|
||||||
QAction *useOldFormatAct = new QAction(QIcon(), tr("Use old certificate format"),this);
|
|
||||||
useOldFormatAct->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format"));
|
|
||||||
connect(useOldFormatAct, SIGNAL(triggered()), this, SLOT(toggleUseOldFormat()));
|
|
||||||
useOldFormatAct->setCheckable(true);
|
|
||||||
useOldFormatAct->setChecked(!mUseShortFormat);
|
|
||||||
menu->addAction(useOldFormatAct);
|
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(SendAction);
|
menu->addAction(SendAction);
|
||||||
menu->addAction(WebMailAction);
|
menu->addAction(WebMailAction);
|
||||||
menu->addAction(RecAction);
|
menu->addAction(RecAction);
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
if(!RsAccounts::isHiddenNode())
|
||||||
|
{
|
||||||
|
mIncludeDNSact = new QAction(QIcon(), tr("Include my DNS"),this);
|
||||||
|
connect(mIncludeDNSact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
|
||||||
|
mIncludeDNSact->setCheckable(true);
|
||||||
|
mIncludeDNSact->setChecked(true);
|
||||||
|
menu->addAction(mIncludeDNSact);
|
||||||
|
|
||||||
|
mIncludeIPsAct = new QAction(QIcon(), tr("Include all your known IPs"),this);
|
||||||
|
connect(mIncludeIPsAct, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
|
||||||
|
mIncludeIPsAct->setCheckable(true);
|
||||||
|
mIncludeIPsAct->setChecked(false);
|
||||||
|
menu->addAction(mIncludeIPsAct);
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction *useOldFormatAct = new QAction(QIcon(), tr("Use old certificate format"),this);
|
||||||
|
useOldFormatAct->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format"));
|
||||||
|
connect(useOldFormatAct, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
|
||||||
|
useOldFormatAct->setCheckable(true);
|
||||||
|
useOldFormatAct->setChecked(false);
|
||||||
|
menu->addAction(useOldFormatAct);
|
||||||
|
|
||||||
ui->shareButton->setMenu(menu);
|
ui->shareButton->setMenu(menu);
|
||||||
|
|
||||||
|
@ -118,6 +121,8 @@ HomePage::HomePage(QWidget *parent) :
|
||||||
|
|
||||||
mEventHandlerId = 0;
|
mEventHandlerId = 0;
|
||||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK );
|
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK );
|
||||||
|
|
||||||
|
updateOwnCert();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomePage::handleEvent(std::shared_ptr<const RsEvent> e)
|
void HomePage::handleEvent(std::shared_ptr<const RsEvent> e)
|
||||||
|
@ -139,13 +144,15 @@ void HomePage::handleEvent(std::shared_ptr<const RsEvent> e)
|
||||||
case RsNetworkEventCode::DNS_UPDATED: // [fallthrough]
|
case RsNetworkEventCode::DNS_UPDATED: // [fallthrough]
|
||||||
RsQThreadUtils::postToObject( [=]()
|
RsQThreadUtils::postToObject( [=]()
|
||||||
{
|
{
|
||||||
updateCertificate();
|
updateOwnCert();
|
||||||
},this);
|
},this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEAD_CODE
|
||||||
void HomePage::certContextMenu(QPoint /*point*/)
|
void HomePage::certContextMenu(QPoint /*point*/)
|
||||||
{
|
{
|
||||||
QMenu menu(this) ;
|
QMenu menu(this) ;
|
||||||
|
@ -178,17 +185,7 @@ void HomePage::certContextMenu(QPoint /*point*/)
|
||||||
|
|
||||||
menu.exec(QCursor::pos());
|
menu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
void HomePage::toggleUseShortFormat()
|
|
||||||
{
|
|
||||||
mUseShortFormat = !mUseShortFormat;
|
|
||||||
updateCertificate();
|
|
||||||
}
|
|
||||||
void HomePage::toggleIncludeAllIPs()
|
|
||||||
{
|
|
||||||
mIncludeAllIPs = !mIncludeAllIPs;
|
|
||||||
updateCertificate();
|
|
||||||
}
|
|
||||||
|
|
||||||
HomePage::~HomePage()
|
HomePage::~HomePage()
|
||||||
{
|
{
|
||||||
|
@ -196,14 +193,9 @@ HomePage::~HomePage()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomePage::updateCertificate()
|
|
||||||
{
|
|
||||||
updateOwnCert();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HomePage::updateOwnCert()
|
void HomePage::updateOwnCert()
|
||||||
{
|
{
|
||||||
bool include_extra_locators = mIncludeAllIPs;
|
bool include_extra_locators = mIncludeIPsAct->isChecked();
|
||||||
|
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
|
|
||||||
|
@ -214,12 +206,12 @@ void HomePage::updateOwnCert()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString invite ;
|
QString invite ;
|
||||||
RetroshareInviteFlags invite_flags = RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS;
|
RetroshareInviteFlags invite_flags = RsPeers::defaultCertificateFlags;
|
||||||
|
|
||||||
if(mIncludeAllIPs)
|
if(mIncludeIPsAct->isChecked())
|
||||||
invite_flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
|
invite_flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
|
||||||
|
|
||||||
if(mUseShortFormat)
|
if(!mUseOldFormatAct->isChecked())
|
||||||
{
|
{
|
||||||
std::string short_invite;
|
std::string short_invite;
|
||||||
rsPeers->getShortInvite(short_invite,rsPeers->getOwnId(),invite_flags | RetroshareInviteFlags::RADIX_FORMAT);
|
rsPeers->getShortInvite(short_invite,rsPeers->getOwnId(),invite_flags | RetroshareInviteFlags::RADIX_FORMAT);
|
||||||
|
@ -245,7 +237,7 @@ void HomePage::updateOwnCert()
|
||||||
|
|
||||||
ui->retroshareid->setText("\n"+invite+"\n");
|
ui->retroshareid->setText("\n"+invite+"\n");
|
||||||
|
|
||||||
QString description = ConfCertDialog::getCertificateDescription(detail,false,mUseShortFormat,include_extra_locators);
|
QString description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatAct->isChecked(),include_extra_locators);
|
||||||
|
|
||||||
ui->retroshareid->setToolTip(description);
|
ui->retroshareid->setToolTip(description);
|
||||||
}
|
}
|
||||||
|
@ -348,9 +340,3 @@ void HomePage::openWebHelp()
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(QUrl(QString("https://retrosharedocs.readthedocs.io/en/latest/")));
|
QDesktopServices::openUrl(QUrl(QString("https://retrosharedocs.readthedocs.io/en/latest/")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomePage::toggleUseOldFormat()
|
|
||||||
{
|
|
||||||
mUseShortFormat = !mUseShortFormat;
|
|
||||||
updateCertificate();
|
|
||||||
}
|
|
||||||
|
|
|
@ -47,27 +47,25 @@ public:
|
||||||
virtual QString helpText() const { return ""; } //MainPage
|
virtual QString helpText() const { return ""; } //MainPage
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
#ifdef DEAD_CODE
|
||||||
void certContextMenu(QPoint);
|
void certContextMenu(QPoint);
|
||||||
|
#endif
|
||||||
void updateOwnCert();
|
void updateOwnCert();
|
||||||
void updateCertificate();
|
|
||||||
void runEmailClient();
|
void runEmailClient();
|
||||||
void copyCert();
|
void copyCert();
|
||||||
void copyId();
|
void copyId();
|
||||||
void saveCert();
|
void saveCert();
|
||||||
void addFriend();
|
void addFriend();
|
||||||
void webMail();
|
void webMail();
|
||||||
//void loadCert();
|
|
||||||
void openWebHelp() ;
|
void openWebHelp() ;
|
||||||
void toggleUseOldFormat() ;
|
|
||||||
void recommendFriends();
|
void recommendFriends();
|
||||||
void toggleIncludeAllIPs();
|
|
||||||
void toggleUseShortFormat();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::HomePage *ui;
|
Ui::HomePage *ui;
|
||||||
|
|
||||||
bool mIncludeAllIPs;
|
QAction *mIncludeDNSact;
|
||||||
bool mUseShortFormat;
|
QAction *mIncludeIPsAct;
|
||||||
|
QAction *mUseOldFormatAct;
|
||||||
|
|
||||||
RsEventsHandlerId_t mEventHandlerId;
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
|
|
||||||
|
|
|
@ -1361,7 +1361,7 @@ bool NewFriendList::exportFriendlist(QString &fileName)
|
||||||
if (!rsPeers->getPeerDetails(*list_iter2, detailSSL))
|
if (!rsPeers->getPeerDetails(*list_iter2, detailSSL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS | RetroshareInviteFlags::RADIX_FORMAT);
|
std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, RsPeers::defaultCertificateFlags | RetroshareInviteFlags::RADIX_FORMAT);
|
||||||
|
|
||||||
// remove \n from certificate
|
// remove \n from certificate
|
||||||
certificate.erase(std::remove(certificate.begin(), certificate.end(), '\n'), certificate.end());
|
certificate.erase(std::remove(certificate.begin(), certificate.end(), '\n'), certificate.end());
|
||||||
|
|
|
@ -264,7 +264,7 @@ void ConfCertDialog::loadInvitePage()
|
||||||
ui._shouldAddSignatures_CB->setEnabled(detail.gpgSigners.size() > 1) ;
|
ui._shouldAddSignatures_CB->setEnabled(detail.gpgSigners.size() > 1) ;
|
||||||
|
|
||||||
std::string invite ;
|
std::string invite ;
|
||||||
RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::RADIX_FORMAT;
|
RetroshareInviteFlags flags = RsPeers::defaultCertificateFlags | RetroshareInviteFlags::RADIX_FORMAT;
|
||||||
|
|
||||||
if(!detail.isHiddenNode && ui._includeIPHistory_CB->isChecked())
|
if(!detail.isHiddenNode && ui._includeIPHistory_CB->isChecked())
|
||||||
flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
|
flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
|
||||||
|
@ -346,6 +346,13 @@ QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bo
|
||||||
infotext += "</li>" ;
|
infotext += "</li>" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!detail.dyndns.empty())
|
||||||
|
{
|
||||||
|
infotext += "<li>" ;
|
||||||
|
infotext += tr("<b>DNS:</b> : ") + QString::fromStdString(detail.dyndns);
|
||||||
|
infotext += "</li>" ;
|
||||||
|
}
|
||||||
|
|
||||||
infotext += QString("</p>") ;
|
infotext += QString("</p>") ;
|
||||||
|
|
||||||
if(rsPeers->getOwnId() == detail.id)
|
if(rsPeers->getOwnId() == detail.id)
|
||||||
|
|
|
@ -103,7 +103,7 @@ void CryptoPage::showEvent ( QShowEvent * /*event*/ )
|
||||||
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString())));
|
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString())));
|
||||||
|
|
||||||
std::string invite ;
|
std::string invite ;
|
||||||
rsPeers->getShortInvite(invite,rsPeers->getOwnId(),RetroshareInviteFlags::RADIX_FORMAT | RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP);
|
rsPeers->getShortInvite(invite,rsPeers->getOwnId(),RetroshareInviteFlags::RADIX_FORMAT | RsPeers::defaultCertificateFlags);
|
||||||
ui.retroshareid->setText(QString::fromUtf8(invite.c_str()));
|
ui.retroshareid->setText(QString::fromUtf8(invite.c_str()));
|
||||||
|
|
||||||
/* set retroshare version */
|
/* set retroshare version */
|
||||||
|
@ -139,7 +139,7 @@ void
|
||||||
CryptoPage::load()
|
CryptoPage::load()
|
||||||
{
|
{
|
||||||
std::string cert ;
|
std::string cert ;
|
||||||
RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP;
|
RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_LOCAL_IP | RetroshareInviteFlags::CURRENT_EXTERNAL_IP;
|
||||||
|
|
||||||
if(ui._shortFormat_CB->isChecked())
|
if(ui._shortFormat_CB->isChecked())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue