fixed adding friend with short invite

This commit is contained in:
csoler 2019-06-10 15:15:15 +02:00
parent 38434f2d55
commit 57a548531c
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
4 changed files with 34 additions and 25 deletions

View File

@ -1360,6 +1360,8 @@ bool p3Peers::parseShortInvite(const std::string& inviteStrUrl, RsPeerDetails& d
details.hasSignedMe = pgp_det.hasSignedMe;
details.accept_connection = pgp_det.accept_connection;
}
else
details.skip_signature_validation = true;
return ctx.mOk;
}

View File

@ -129,6 +129,8 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
body += "\n" + GetStartedDialog::GetCutBelowText();
body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite().c_str());
mIsShortInvite = false;
std::string advsetting;
if(rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES"))
{
@ -147,14 +149,10 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
switch (rsFiles->filePermDirectDL())
{
case RS_FILE_PERM_DIRECT_DL_YES:
// ui->_direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png"));
// ui->_direct_transfer_CB->setToolTip(ui->_direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes.")));
ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png"));
ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes.")));
break ;
case RS_FILE_PERM_DIRECT_DL_NO:
// ui->_direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png"));
// ui->_direct_transfer_CB->setToolTip(ui->_direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No.")));
ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png"));
ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No.")));
break ;
@ -309,6 +307,8 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend
}
else if(rsPeers->parseShortInvite(certificate.toUtf8().constData(),peerDetails))
{
mIsShortInvite = true;
if(peerDetails.id == rsPeers->getOwnId())
{
setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ;
@ -638,7 +638,7 @@ bool ConnectFriendWizard::validateCurrentPage()
int ConnectFriendWizard::nextId() const
{
switch ((Page) currentId()) {
case Page_Text:
case Page_Text: return Page_Conclusion;
case Page_WebMail:
case Page_ErrorMessage:
case Page_Conclusion:
@ -676,7 +676,9 @@ void ConnectFriendWizard::accept()
return;
}
if(!peerDetails.skip_signature_validation && !mCertificate.empty() && add_key_to_keyring)
// add the profile pgp key to keyring
if(!mIsShortInvite && !mCertificate.empty() && add_key_to_keyring)
{
RsPgpId pgp_id ;
RsPeerId ssl_id ;
@ -691,6 +693,11 @@ void ConnectFriendWizard::accept()
bool runProgressDialog = false;
// add the peer as friend, either with or without pgp signature validation, depending on whether we have the key or not
// Note: that is different than having a short invite or not.
// first, set data related to profile key.
if(accept_connection && !peerDetails.gpg_id.isNull())
{
std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
@ -723,6 +730,8 @@ void ConnectFriendWizard::accept()
rsPeers->assignPeerToGroup(RsNodeGroupId(groupId.toStdString()), peerDetails.gpg_id, true);
}
// Then set data related to node location
if ((accept_connection) && (!peerDetails.id.isNull()))
{
runProgressDialog = true;
@ -753,9 +762,7 @@ void ConnectFriendWizard::accept()
rsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns);
}
for(auto&& ipr : peerDetails.ipAddressList)
rsPeers->addPeerLocator(
peerDetails.id,
RsUrl(ipr.substr(0, ipr.find(' '))) );
rsPeers->addPeerLocator( peerDetails.id, RsUrl(ipr.substr(0, ipr.find(' '))) );
}
}
@ -768,7 +775,6 @@ void ConnectFriendWizard::accept()
}
NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ;
QDialog::accept();
}
@ -841,9 +847,8 @@ void ConnectFriendWizard::cleanFriendCert()
} else {
std::string cleanCert;
int error_code;
bool is_short_format;
if (rsPeers->cleanCertificate(cert, cleanCert, is_short_format, error_code))
if (rsPeers->cleanCertificate(cert, cleanCert, mIsShortInvite, error_code))
{
certValid = true;
@ -856,7 +861,7 @@ void ConnectFriendWizard::cleanFriendCert()
ui->friendCertCleanLabel->setStyleSheet("");
}
errorMsg = tr("Valid certificate") + (is_short_format?" (Short format)":" (plain format with profile key)");
errorMsg = tr("Valid certificate") + (mIsShortInvite?" (Short format)":" (plain format with profile key)");
ui->friendCertCleanLabel->setPixmap(QPixmap(":/images/accepted16.png"));
} else {

View File

@ -121,6 +121,8 @@ private:
RsPeerDetails peerDetails;
std::string mCertificate;
bool mIsShortInvite;
/* Stylesheet */
QString mBannerPixmap;
int mTitleFontSize;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1100</width>
<height>604</height>
<width>1139</width>
<height>1171</height>
</rect>
</property>
<property name="windowTitle">
@ -817,7 +817,7 @@
<item>
<widget class="QCheckBox" name="_direct_transfer_CB_2">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. This setting is applied to all locations of the same node.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. This setting is applied to all nodes with the same profile key.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Can be used as direct source</string>