added optional display of short invites in places with certificates

This commit is contained in:
csoler 2019-06-06 21:41:38 +02:00
parent 8fddb559b9
commit 3a799bae37
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
8 changed files with 106 additions and 47 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -41,10 +41,10 @@ class HomePage : public MainPage
public:
explicit HomePage(QWidget *parent);
~HomePage();
virtual QIcon iconPixmap() const { return QIcon(":/icons/png/home.png") ; } //MainPage
virtual QString pageName() const { return tr("Home") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage
virtual QIcon iconPixmap() const { return QIcon(":/icons/png/home.png") ; } //MainPage
virtual QString pageName() const { return tr("Home") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage
private slots:
void certContextMenu(QPoint);
@ -52,18 +52,20 @@ private slots:
void runEmailClient();
void copyCert();
void saveCert();
void addFriend();
void webMail();
void loadCert();
void addFriend();
void webMail();
void loadCert();
void runStartWizard() ;
void openWebHelp() ;
void recommendFriends();
void toggleIncludeAllIPs();
void toggleIncludeAllIPs();
void toggleUseShortFormat();
private:
Ui::HomePage *ui;
bool mIncludeAllIPs;
bool mIncludeAllIPs;
bool mUseShortFormat;
};

View File

@ -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>" ;
infotext += "<li> a <b>Profile key</b>";
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>" ;

View File

@ -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();

View File

@ -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">

View File

@ -41,22 +41,25 @@
CryptoPage::CryptoPage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
// 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._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()));
ui._shortFormat_CB->setChecked(true);
// hide profile manager as it causes bugs when generating a new profile.
//ui.profile_Button->hide() ;
// 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()));
connect(ui.createNewNode_PB,SIGNAL(clicked()), this, SLOT(profilemanager()));
// hide profile manager as it causes bugs when generating a new profile.
//ui.profile_Button->hide() ;
ui.onlinesince->setText(DateTime::formatLongDateTime(Rshare::startupTime()));
connect(ui.createNewNode_PB,SIGNAL(clicked()), this, SLOT(profilemanager()));
ui.onlinesince->setText(DateTime::formatLongDateTime(Rshare::startupTime()));
}
void CryptoPage::profilemanager()
@ -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()
{

View File

@ -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">