mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added optional display of short invites in places with certificates
This commit is contained in:
parent
8fddb559b9
commit
3a799bae37
@ -1129,6 +1129,7 @@ enum class RsShortInviteFieldType : uint8_t
|
||||
SSL_ID = 0x00,
|
||||
PEER_NAME = 0x01,
|
||||
LOCATOR = 0x02,
|
||||
PGP_FINGERPRINT = 0x03,
|
||||
|
||||
/* The following will be deprecated, and ported to LOCATOR when generic
|
||||
* trasport layer will be implemented */
|
||||
@ -1156,6 +1157,10 @@ bool p3Peers::getShortInvite(
|
||||
RS_SERIAL_PROCESS(tType);
|
||||
RS_SERIAL_PROCESS(sslId);
|
||||
|
||||
tType = RsShortInviteFieldType::PGP_FINGERPRINT;
|
||||
RS_SERIAL_PROCESS(tType);
|
||||
RS_SERIAL_PROCESS(tDetails.fpr);
|
||||
|
||||
tType = RsShortInviteFieldType::PEER_NAME;
|
||||
RS_SERIAL_PROCESS(tType);
|
||||
RS_SERIAL_PROCESS(tDetails.name);
|
||||
@ -1220,8 +1225,7 @@ bool p3Peers::getShortInvite(
|
||||
return ctx.mOk;
|
||||
}
|
||||
|
||||
bool p3Peers::parseShortInvite(
|
||||
const std::string& inviteStrUrl, RsPeerDetails& details )
|
||||
bool p3Peers::parseShortInvite(const std::string& inviteStrUrl, RsPeerDetails& details )
|
||||
{
|
||||
if(inviteStrUrl.empty())
|
||||
{
|
||||
@ -1261,6 +1265,11 @@ bool p3Peers::parseShortInvite(
|
||||
case RsShortInviteFieldType::PEER_NAME:
|
||||
RS_SERIAL_PROCESS(details.name);
|
||||
break;
|
||||
|
||||
case RsShortInviteFieldType::PGP_FINGERPRINT:
|
||||
RS_SERIAL_PROCESS(details.fpr);
|
||||
break;
|
||||
|
||||
case RsShortInviteFieldType::LOCATOR:
|
||||
{
|
||||
std::string locatorStr;
|
||||
|
@ -48,7 +48,8 @@
|
||||
HomePage::HomePage(QWidget *parent) :
|
||||
MainPage(parent),
|
||||
ui(new Ui::HomePage),
|
||||
mIncludeAllIPs(false)
|
||||
mIncludeAllIPs(false),
|
||||
mUseShortFormat(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -109,11 +110,19 @@ void HomePage::certContextMenu(QPoint point)
|
||||
menu.addAction(CopyAction);
|
||||
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())
|
||||
{
|
||||
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()));
|
||||
includeIPsAct->setCheckable(true);
|
||||
includeIPsAct->setChecked(mIncludeAllIPs);
|
||||
|
||||
menu.addAction(includeIPsAct);
|
||||
}
|
||||
@ -121,6 +130,11 @@ void HomePage::certContextMenu(QPoint point)
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void HomePage::toggleUseShortFormat()
|
||||
{
|
||||
mUseShortFormat = !mUseShortFormat;
|
||||
updateOwnCert();
|
||||
}
|
||||
void HomePage::toggleIncludeAllIPs()
|
||||
{
|
||||
mIncludeAllIPs = !mIncludeAllIPs;
|
||||
@ -144,11 +158,16 @@ void HomePage::updateOwnCert()
|
||||
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()));
|
||||
|
||||
QString description = ConfCertDialog::getCertificateDescription(detail,false,include_extra_locators);
|
||||
QString description = ConfCertDialog::getCertificateDescription(detail,false,mUseShortFormat,include_extra_locators);
|
||||
|
||||
ui->userCertEdit->setToolTip(description);
|
||||
}
|
||||
|
@ -59,11 +59,13 @@ private slots:
|
||||
void openWebHelp() ;
|
||||
void recommendFriends();
|
||||
void toggleIncludeAllIPs();
|
||||
void toggleUseShortFormat();
|
||||
|
||||
private:
|
||||
Ui::HomePage *ui;
|
||||
|
||||
bool mIncludeAllIPs;
|
||||
bool mUseShortFormat;
|
||||
|
||||
};
|
||||
|
||||
|
@ -89,11 +89,13 @@ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidge
|
||||
//ui._chat_CB->hide() ;
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
ui._shortFormat_CB->setChecked(true);
|
||||
|
||||
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog()));
|
||||
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(ui._shouldAddSignatures_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);
|
||||
|
||||
@ -270,14 +272,14 @@ 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(),
|
||||
ui._includeIPHistory_CB->isChecked()
|
||||
) ;
|
||||
std::string invite ;
|
||||
|
||||
QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),
|
||||
ui._includeIPHistory_CB->isChecked()
|
||||
);
|
||||
if(ui._shortFormat_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) ;
|
||||
|
||||
@ -291,15 +293,20 @@ void ConfCertDialog::loadInvitePage()
|
||||
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>") ;
|
||||
QString infotext = QObject::tr("<p>This certificate contains:") ;
|
||||
infotext += "<UL>" ;
|
||||
|
||||
if(use_short_format)
|
||||
infotext += "<li> a <b>Profile fingerprint</b>";
|
||||
else
|
||||
infotext += "<li> a <b>Profile key</b>";
|
||||
|
||||
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>") ;
|
||||
else
|
||||
infotext += "</li>" ;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
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:
|
||||
void configChanged();
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>584</height>
|
||||
<width>658</width>
|
||||
<height>1120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -389,6 +389,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_shortFormat_CB">
|
||||
<property name="text">
|
||||
<string>short format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_includeIPHistory_CB">
|
||||
<property name="text">
|
||||
|
@ -44,9 +44,12 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
ui._shortFormat_CB->setChecked(true);
|
||||
|
||||
// connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
|
||||
connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(fileSaveAs()));
|
||||
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._copyLink_PB, SIGNAL(clicked()), this, SLOT(copyRSLink()));
|
||||
connect(ui.showStats_PB, SIGNAL(clicked()), this, SLOT(showStats()));
|
||||
@ -97,16 +100,21 @@ CryptoPage::~CryptoPage()
|
||||
void
|
||||
CryptoPage::load()
|
||||
{
|
||||
ui.certplainTextEdit->setPlainText(
|
||||
QString::fromUtf8(
|
||||
rsPeers->GetRetroshareInvite( rsPeers->getOwnId(), ui._includeSignatures_CB->isChecked(), ui._includeAllIPs_CB->isChecked() ).c_str()
|
||||
) );
|
||||
std::string cert ;
|
||||
|
||||
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;
|
||||
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
|
||||
CryptoPage::copyRSLink()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>989</width>
|
||||
<width>1531</width>
|
||||
<height>678</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -460,6 +460,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_shortFormat_CB">
|
||||
<property name="text">
|
||||
<string>Short format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_includeAllIPs_CB">
|
||||
<property name="toolTip">
|
||||
|
Loading…
Reference in New Issue
Block a user