mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-30 00:57:28 -04:00
added optional display of short invites in places with certificates
This commit is contained in:
parent
8fddb559b9
commit
3a799bae37
8 changed files with 106 additions and 47 deletions
|
@ -1129,6 +1129,7 @@ enum class RsShortInviteFieldType : uint8_t
|
||||||
SSL_ID = 0x00,
|
SSL_ID = 0x00,
|
||||||
PEER_NAME = 0x01,
|
PEER_NAME = 0x01,
|
||||||
LOCATOR = 0x02,
|
LOCATOR = 0x02,
|
||||||
|
PGP_FINGERPRINT = 0x03,
|
||||||
|
|
||||||
/* The following will be deprecated, and ported to LOCATOR when generic
|
/* The following will be deprecated, and ported to LOCATOR when generic
|
||||||
* trasport layer will be implemented */
|
* trasport layer will be implemented */
|
||||||
|
@ -1156,6 +1157,10 @@ bool p3Peers::getShortInvite(
|
||||||
RS_SERIAL_PROCESS(tType);
|
RS_SERIAL_PROCESS(tType);
|
||||||
RS_SERIAL_PROCESS(sslId);
|
RS_SERIAL_PROCESS(sslId);
|
||||||
|
|
||||||
|
tType = RsShortInviteFieldType::PGP_FINGERPRINT;
|
||||||
|
RS_SERIAL_PROCESS(tType);
|
||||||
|
RS_SERIAL_PROCESS(tDetails.fpr);
|
||||||
|
|
||||||
tType = RsShortInviteFieldType::PEER_NAME;
|
tType = RsShortInviteFieldType::PEER_NAME;
|
||||||
RS_SERIAL_PROCESS(tType);
|
RS_SERIAL_PROCESS(tType);
|
||||||
RS_SERIAL_PROCESS(tDetails.name);
|
RS_SERIAL_PROCESS(tDetails.name);
|
||||||
|
@ -1220,8 +1225,7 @@ bool p3Peers::getShortInvite(
|
||||||
return ctx.mOk;
|
return ctx.mOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::parseShortInvite(
|
bool p3Peers::parseShortInvite(const std::string& inviteStrUrl, RsPeerDetails& details )
|
||||||
const std::string& inviteStrUrl, RsPeerDetails& details )
|
|
||||||
{
|
{
|
||||||
if(inviteStrUrl.empty())
|
if(inviteStrUrl.empty())
|
||||||
{
|
{
|
||||||
|
@ -1261,6 +1265,11 @@ bool p3Peers::parseShortInvite(
|
||||||
case RsShortInviteFieldType::PEER_NAME:
|
case RsShortInviteFieldType::PEER_NAME:
|
||||||
RS_SERIAL_PROCESS(details.name);
|
RS_SERIAL_PROCESS(details.name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RsShortInviteFieldType::PGP_FINGERPRINT:
|
||||||
|
RS_SERIAL_PROCESS(details.fpr);
|
||||||
|
break;
|
||||||
|
|
||||||
case RsShortInviteFieldType::LOCATOR:
|
case RsShortInviteFieldType::LOCATOR:
|
||||||
{
|
{
|
||||||
std::string locatorStr;
|
std::string locatorStr;
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
HomePage::HomePage(QWidget *parent) :
|
HomePage::HomePage(QWidget *parent) :
|
||||||
MainPage(parent),
|
MainPage(parent),
|
||||||
ui(new Ui::HomePage),
|
ui(new Ui::HomePage),
|
||||||
mIncludeAllIPs(false)
|
mIncludeAllIPs(false),
|
||||||
|
mUseShortFormat(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -109,11 +110,19 @@ void HomePage::certContextMenu(QPoint point)
|
||||||
menu.addAction(CopyAction);
|
menu.addAction(CopyAction);
|
||||||
menu.addAction(SaveAction);
|
menu.addAction(SaveAction);
|
||||||
|
|
||||||
|
QAction *shortFormatAct = new QAction(QIcon(), tr("Use new (short) certificate format"),this);
|
||||||
|
connect(shortFormatAct, SIGNAL(triggered()), this, SLOT(toggleUseShortFormat()));
|
||||||
|
shortFormatAct->setCheckable(true);
|
||||||
|
shortFormatAct->setChecked(mUseShortFormat);
|
||||||
|
|
||||||
|
menu.addAction(shortFormatAct);
|
||||||
|
|
||||||
if(!RsAccounts::isHiddenNode())
|
if(!RsAccounts::isHiddenNode())
|
||||||
{
|
{
|
||||||
QAction *includeIPsAct = new QAction(QIcon(), mIncludeAllIPs? tr("Include only current IP"):tr("Include all your known IPs"),this);
|
QAction *includeIPsAct = new QAction(QIcon(), tr("Include all your known IPs"),this);
|
||||||
connect(includeIPsAct, SIGNAL(triggered()), this, SLOT(toggleIncludeAllIPs()));
|
connect(includeIPsAct, SIGNAL(triggered()), this, SLOT(toggleIncludeAllIPs()));
|
||||||
includeIPsAct->setCheckable(true);
|
includeIPsAct->setCheckable(true);
|
||||||
|
includeIPsAct->setChecked(mIncludeAllIPs);
|
||||||
|
|
||||||
menu.addAction(includeIPsAct);
|
menu.addAction(includeIPsAct);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +130,11 @@ void HomePage::certContextMenu(QPoint point)
|
||||||
menu.exec(QCursor::pos());
|
menu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HomePage::toggleUseShortFormat()
|
||||||
|
{
|
||||||
|
mUseShortFormat = !mUseShortFormat;
|
||||||
|
updateOwnCert();
|
||||||
|
}
|
||||||
void HomePage::toggleIncludeAllIPs()
|
void HomePage::toggleIncludeAllIPs()
|
||||||
{
|
{
|
||||||
mIncludeAllIPs = !mIncludeAllIPs;
|
mIncludeAllIPs = !mIncludeAllIPs;
|
||||||
|
@ -144,11 +158,16 @@ void HomePage::updateOwnCert()
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string invite = rsPeers->GetRetroshareInvite(detail.id,false,include_extra_locators);
|
std::string invite ;
|
||||||
|
|
||||||
|
if(mUseShortFormat)
|
||||||
|
rsPeers->getShortInvite(invite,rsPeers->getOwnId(),true,!mIncludeAllIPs);
|
||||||
|
else
|
||||||
|
invite = rsPeers->GetRetroshareInvite(detail.id,false,include_extra_locators);
|
||||||
|
|
||||||
ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str()));
|
ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str()));
|
||||||
|
|
||||||
QString description = ConfCertDialog::getCertificateDescription(detail,false,include_extra_locators);
|
QString description = ConfCertDialog::getCertificateDescription(detail,false,mUseShortFormat,include_extra_locators);
|
||||||
|
|
||||||
ui->userCertEdit->setToolTip(description);
|
ui->userCertEdit->setToolTip(description);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,11 +59,13 @@ private slots:
|
||||||
void openWebHelp() ;
|
void openWebHelp() ;
|
||||||
void recommendFriends();
|
void recommendFriends();
|
||||||
void toggleIncludeAllIPs();
|
void toggleIncludeAllIPs();
|
||||||
|
void toggleUseShortFormat();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::HomePage *ui;
|
Ui::HomePage *ui;
|
||||||
|
|
||||||
bool mIncludeAllIPs;
|
bool mIncludeAllIPs;
|
||||||
|
bool mUseShortFormat;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,13 @@ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidge
|
||||||
//ui._chat_CB->hide() ;
|
//ui._chat_CB->hide() ;
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
ui._shortFormat_CB->setChecked(true);
|
||||||
|
|
||||||
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog()));
|
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog()));
|
||||||
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||||
connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
||||||
connect(ui._includeIPHistory_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
connect(ui._includeIPHistory_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
||||||
|
connect(ui._shortFormat_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
||||||
|
|
||||||
ui.avatar->setFrameType(AvatarWidget::NORMAL_FRAME);
|
ui.avatar->setFrameType(AvatarWidget::NORMAL_FRAME);
|
||||||
|
|
||||||
|
@ -270,14 +272,14 @@ void ConfCertDialog::loadInvitePage()
|
||||||
// ui.userCertificateText_2->setFont(font);
|
// ui.userCertificateText_2->setFont(font);
|
||||||
// ui.userCertificateText_2->setText(QString::fromUtf8(pgp_key.c_str()));
|
// ui.userCertificateText_2->setText(QString::fromUtf8(pgp_key.c_str()));
|
||||||
|
|
||||||
std::string invite = rsPeers->GetRetroshareInvite(detail.id,
|
std::string invite ;
|
||||||
ui._shouldAddSignatures_CB->isChecked(),
|
|
||||||
ui._includeIPHistory_CB->isChecked()
|
|
||||||
) ;
|
|
||||||
|
|
||||||
QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),
|
if(ui._shortFormat_CB->isChecked())
|
||||||
ui._includeIPHistory_CB->isChecked()
|
rsPeers->getShortInvite(invite,detail.id,true,!ui._includeIPHistory_CB->isChecked() );
|
||||||
);
|
else
|
||||||
|
invite = rsPeers->GetRetroshareInvite(detail.id, ui._shouldAddSignatures_CB->isChecked(), ui._includeIPHistory_CB->isChecked() ) ;
|
||||||
|
|
||||||
|
QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),ui._shortFormat_CB->isChecked(), ui._includeIPHistory_CB->isChecked() );
|
||||||
|
|
||||||
ui.userCertificateText->setToolTip(infotext) ;
|
ui.userCertificateText->setToolTip(infotext) ;
|
||||||
|
|
||||||
|
@ -291,15 +293,20 @@ void ConfCertDialog::loadInvitePage()
|
||||||
ui.userCertificateText->setText(QString::fromUtf8(invite.c_str()));
|
ui.userCertificateText->setText(QString::fromUtf8(invite.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bool signatures_included,bool include_additional_locators)
|
QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bool signatures_included,bool use_short_format,bool include_additional_locators)
|
||||||
{
|
{
|
||||||
//infotext += tr("<p>Use this certificate to make new friends. Send it by email, or give it hand to hand.</p>") ;
|
//infotext += tr("<p>Use this certificate to make new friends. Send it by email, or give it hand to hand.</p>") ;
|
||||||
QString infotext = QObject::tr("<p>This certificate contains:") ;
|
QString infotext = QObject::tr("<p>This certificate contains:") ;
|
||||||
infotext += "<UL>" ;
|
infotext += "<UL>" ;
|
||||||
|
|
||||||
|
if(use_short_format)
|
||||||
|
infotext += "<li> a <b>Profile fingerprint</b>";
|
||||||
|
else
|
||||||
infotext += "<li> a <b>Profile key</b>";
|
infotext += "<li> a <b>Profile key</b>";
|
||||||
|
|
||||||
infotext += " (" + QString::fromUtf8(detail.name.c_str()) + "@" + detail.gpg_id.toStdString().c_str()+") " ;
|
infotext += " (" + QString::fromUtf8(detail.name.c_str()) + "@" + detail.gpg_id.toStdString().c_str()+") " ;
|
||||||
|
|
||||||
if(signatures_included)
|
if(signatures_included && !use_short_format)
|
||||||
infotext += tr("with")+" "+QString::number(detail.gpgSigners.size()-1)+" "+tr("external signatures</li>") ;
|
infotext += tr("with")+" "+QString::number(detail.gpgSigners.size()-1)+" "+tr("external signatures</li>") ;
|
||||||
else
|
else
|
||||||
infotext += "</li>" ;
|
infotext += "</li>" ;
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
/* window will destroy itself! */
|
/* window will destroy itself! */
|
||||||
}
|
}
|
||||||
static void loadAll();
|
static void loadAll();
|
||||||
static QString getCertificateDescription(const RsPeerDetails& det,bool signatures_included,bool extra_locators_included);
|
static QString getCertificateDescription(const RsPeerDetails& det, bool signatures_included, bool use_short_format, bool extra_locators_included);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void configChanged();
|
void configChanged();
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>658</width>
|
||||||
<height>584</height>
|
<height>1120</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -389,6 +389,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="_shortFormat_CB">
|
||||||
|
<property name="text">
|
||||||
|
<string>short format</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="_includeIPHistory_CB">
|
<widget class="QCheckBox" name="_includeIPHistory_CB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -44,9 +44,12 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WindowFlags flags)
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
// connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
|
ui._shortFormat_CB->setChecked(true);
|
||||||
|
|
||||||
|
// connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
|
||||||
connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(fileSaveAs()));
|
connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(fileSaveAs()));
|
||||||
connect(ui._includeSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(load()));
|
connect(ui._includeSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(load()));
|
||||||
|
connect(ui._shortFormat_CB, SIGNAL(toggled(bool)), this, SLOT(load()));
|
||||||
connect(ui._includeAllIPs_CB, SIGNAL(toggled(bool)), this, SLOT(load()));
|
connect(ui._includeAllIPs_CB, SIGNAL(toggled(bool)), this, SLOT(load()));
|
||||||
connect(ui._copyLink_PB, SIGNAL(clicked()), this, SLOT(copyRSLink()));
|
connect(ui._copyLink_PB, SIGNAL(clicked()), this, SLOT(copyRSLink()));
|
||||||
connect(ui.showStats_PB, SIGNAL(clicked()), this, SLOT(showStats()));
|
connect(ui.showStats_PB, SIGNAL(clicked()), this, SLOT(showStats()));
|
||||||
|
@ -97,16 +100,21 @@ CryptoPage::~CryptoPage()
|
||||||
void
|
void
|
||||||
CryptoPage::load()
|
CryptoPage::load()
|
||||||
{
|
{
|
||||||
ui.certplainTextEdit->setPlainText(
|
std::string cert ;
|
||||||
QString::fromUtf8(
|
|
||||||
rsPeers->GetRetroshareInvite( rsPeers->getOwnId(), ui._includeSignatures_CB->isChecked(), ui._includeAllIPs_CB->isChecked() ).c_str()
|
if(ui._shortFormat_CB->isChecked())
|
||||||
) );
|
rsPeers->getShortInvite(cert,rsPeers->getOwnId(), true, !ui._includeAllIPs_CB->isChecked());
|
||||||
|
else
|
||||||
|
cert = rsPeers->GetRetroshareInvite( rsPeers->getOwnId(), ui._includeSignatures_CB->isChecked(), ui._includeAllIPs_CB->isChecked() );
|
||||||
|
|
||||||
|
ui.certplainTextEdit->setPlainText( QString::fromUtf8( cert.c_str() ) );
|
||||||
|
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
rsPeers->getPeerDetails(rsPeers->getOwnId(),detail);
|
rsPeers->getPeerDetails(rsPeers->getOwnId(),detail);
|
||||||
|
|
||||||
ui.certplainTextEdit->setToolTip(ConfCertDialog::getCertificateDescription(detail, ui._includeSignatures_CB->isChecked(), ui._includeAllIPs_CB->isChecked() ));
|
ui.certplainTextEdit->setToolTip(ConfCertDialog::getCertificateDescription(detail, ui._includeSignatures_CB->isChecked(), ui._shortFormat_CB->isChecked(), ui._includeAllIPs_CB->isChecked() ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CryptoPage::copyRSLink()
|
CryptoPage::copyRSLink()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>989</width>
|
<width>1531</width>
|
||||||
<height>678</height>
|
<height>678</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -460,6 +460,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="_shortFormat_CB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Short format</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="_includeAllIPs_CB">
|
<widget class="QCheckBox" name="_includeAllIPs_CB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue