From f7a1348370be6b130fcdc3be205e1c799839beff Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 23 Jan 2017 19:13:50 +0100 Subject: [PATCH 01/28] made Accepted option in Transfers to send tunnel requests for both encrypted and clear tunnels --- libretroshare/src/ft/ftcontroller.cc | 7 +++++-- retroshare-gui/src/gui/settings/TransferPage.ui | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 3765d6aa2..13bafa5f0 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -876,7 +876,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash // if policy is STRICT // - disable clear, enforce encryption // else - // - if not specified, use clear + // - if not specified, use both // if(mDefaultEncryptionPolicy == RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT) { @@ -884,7 +884,10 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash flags &= ~RS_FILE_REQ_UNENCRYPTED ; } else if(!(flags & ( RS_FILE_REQ_ENCRYPTED | RS_FILE_REQ_UNENCRYPTED ))) - flags |= RS_FILE_REQ_UNENCRYPTED ; + { + flags |= RS_FILE_REQ_ENCRYPTED ; + flags |= RS_FILE_REQ_UNENCRYPTED ; + } if(size == 0) // we treat this special case because { diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index 1ef4fdb8a..9819b267e 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -145,7 +145,7 @@ - <html><head/><body><p>Anonymous tunnels can be end-o-end encrypted. In order to maintain backward compatibility, this can be made optional (choosing &quot;Accepted&quot;), but in the end, all Retroshare nodes will be switched to &quot;Enforced&quot;, meaning that all anonymous transfers will be end-to-end encrypted.</p></body></html> + <html><head/><body><p>Anonymous tunnels can be end-o-end encrypted. In order to maintain backward compatibility, this can be made optional (choosing &quot;Accepted&quot;), but in the end, all Retroshare nodes will be switched to &quot;Enforced&quot;, meaning that all anonymous transfers will be end-to-end encrypted. With &quot;Accepted&quot;, it is likely that you will transfer using twice as many tunnels, since there is no way to know that an encrypted and a clear tunnel actually transfer from the same source.</p></body></html> From f90ebb1dfcb6df4e80a7da91b732d04bae3acb94 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 24 Jan 2017 16:17:53 +0100 Subject: [PATCH 02/28] update Person details window used on Statistics. clean up look and feel of Friend Details to get more user friendly for normal users. --- .../src/gui/Identity/IdDetailsDialog.cpp | 82 ++- .../src/gui/Identity/IdDetailsDialog.h | 5 +- .../src/gui/Identity/IdDetailsDialog.ui | 568 +++++++++++------- .../src/gui/connect/ConfCertDialog.cpp | 36 +- .../src/gui/connect/ConfCertDialog.h | 2 + .../src/gui/connect/ConfCertDialog.ui | 143 +++-- 6 files changed, 532 insertions(+), 304 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index a988a8563..e35f24a00 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -24,6 +24,8 @@ #include "gui/gxs/GxsIdDetails.h" #include "gui/settings/rsharesettings.h" #include "gui/common/UIStateHelper.h" +#include "gui/msgs/MessageComposer.h" +#include "gui/RetroShareLink.h" #include @@ -85,6 +87,9 @@ IdDetailsDialog::IdDetailsDialog(const RsGxsGroupId& id, QWidget *parent) : //connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(changeGroup())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); + connect(ui->autoBanIdentities_CB, SIGNAL(toggled(bool)), this, SLOT(toggleAutoBanIdentities(bool))); + + connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); requestIdDetails(); } @@ -98,6 +103,17 @@ IdDetailsDialog::~IdDetailsDialog() delete(mIdQueue); } +void IdDetailsDialog::toggleAutoBanIdentities(bool b) +{ + RsPgpId id(ui->lineEdit_GpgId->text().left(16).toStdString()); + + if(!id.isNull()) + { + rsReputations->banNode(id,b) ; + //requestIdList(); + } +} + static QString getHumanReadableDuration(uint32_t seconds) { if(seconds < 60) @@ -155,8 +171,13 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) ui->lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str())); ui->lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString())); - //ui->lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString())); - ui->lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString())); + if(data.mPgpKnown) + ui->lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString())); + else + ui->lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString()) + tr(" [unverified]")); + + ui->autoBanIdentities_CB->setVisible(!data.mPgpId.isNull()) ; + ui->banoption_label->setVisible(!data.mPgpId.isNull()) ; time_t now = time(NULL) ; ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; @@ -238,6 +259,8 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) // No Reputation yet! mStateHelper->setWidgetEnabled(ui->ownOpinion_CB, true); } + + ui->autoBanIdentities_CB->setChecked(rsReputations->isNodeBanned(data.mPgpId)); /* now fill in the reputation information */ @@ -265,8 +288,28 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),data.mPgpId,info) ; #warning (csoler) Do we need to do this? This code is apparently not used. - ui->neighborNodesOpinion_TF->setText(QString::number(info.mFriendAverageScore)); - ui->overallOpinion_TF->setText(QString::number(info.mOverallReputationLevel)); + + QString frep_string ; + if(info.mFriendsPositiveVotes > 0) frep_string += QString::number(info.mFriendsPositiveVotes) + tr(" positive ") ; + if(info.mFriendsNegativeVotes > 0) frep_string += QString::number(info.mFriendsNegativeVotes) + tr(" negative ") ; + + if(info.mFriendsPositiveVotes==0 && info.mFriendsNegativeVotes==0) + frep_string = tr("No votes from friends") ; + + ui->neighborNodesOpinion_TF->setText(frep_string) ; + + ui->label_positive->setText(QString::number(info.mFriendsPositiveVotes)); + ui->label_negative->setText(QString::number(info.mFriendsNegativeVotes)); + + switch(info.mOverallReputationLevel) + { + case RsReputations::REPUTATION_LOCALLY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive")) ; break ; + case RsReputations::REPUTATION_LOCALLY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (Banned by you)")) ; break ; + case RsReputations::REPUTATION_REMOTELY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive (according to your friends)")) ; break ; + case RsReputations::REPUTATION_REMOTELY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (according to your friends)")) ; break ; + default: + case RsReputations::REPUTATION_NEUTRAL: ui->overallOpinion_TF->setText(tr("Neutral")) ; break ; + } switch(info.mOwnOpinion) { @@ -408,3 +451,34 @@ void IdDetailsDialog::loadRequest(const TokenQueue *queue, const TokenRequest &r std::cerr << std::endl; } } + +QString IdDetailsDialog::inviteMessage() +{ + return tr("Hi,
I want to be friends with you on RetroShare.
"); +} + +void IdDetailsDialog::sendInvite() +{ + /* create a message */ + MessageComposer *composer = MessageComposer::newMsg(); + + composer->setTitleText(tr("You have a friend invite")); + + RsPeerId ownId = rsPeers->getOwnId(); + RetroShareLink link; + link.createCertificate(ownId); + + RsGxsId keyId(ui->lineEdit_KeyId->text().toStdString()); + + QString sMsgText = inviteMessage(); + sMsgText += "

"; + sMsgText += tr("Respond now:") + "
"; + sMsgText += link.toHtml() + "
"; + sMsgText += "
"; + sMsgText += tr("Thanks,
") + QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()); + composer->setMsgText(sMsgText); + composer->addRecipient(MessageComposer::TO, RsGxsId(keyId)); + + composer->show(); + +} diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.h b/retroshare-gui/src/gui/Identity/IdDetailsDialog.h index 4992297ad..524275454 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.h @@ -48,7 +48,10 @@ public: private slots: void modifyReputation(); - + void toggleAutoBanIdentities(bool b); + + static QString inviteMessage(); + void sendInvite(); private : void requestIdDetails(); void insertIdDetails(uint32_t token); diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui b/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui index e9e57478d..73e1006f0 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui @@ -6,8 +6,8 @@ 0 0 - 698 - 472 + 688 + 475
@@ -18,7 +18,16 @@ :/images/logo/logo_32.png:/images/logo/logo_32.png - + + 0 + + + 0 + + + 0 + + 0 @@ -53,9 +62,113 @@ - + 6 + + 6 + + + 6 + + + 6 + + + + + + 75 + true + + + + Overall: + + + + + + + Friends votes: + + + + + + + Your opinion: + + + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">Your own opinion about an identity rules the visibility of that identity for yourself and your friend nodes. Your own opinion is shared among friends and used to compute a reputation score: If your opinion about an identity is neutral, the reputation score is the average of your friend's opinions. If not, your own opinion gives the score.</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity. When the overall score is lower than -0.6, the identity is banned, which prevents all messages and forums/channels authored by this identity to be forwarded, both ways. Some forums also have special anti-spam flags that require a higher reputation level, making them more sensitive to bad opinions. Banned identities gradually lose their activity and eventually disappear (after 30 days). </span></p></body></html> + + + 0 + + + + Negative + + + + :/icons/png/thumbs-down.png:/icons/png/thumbs-down.png + + + + + Neutral + + + + :/icons/png/thumbs-neutral.png:/icons/png/thumbs-neutral.png + + + + + Positive + + + + :/icons/png/thumbs-up.png:/icons/png/thumbs-up.png + + + + + + + + <html><head/><body><p>Average opinion of neighbor nodes about this identity. Negative is bad,</p><p>positive is good. Zero is neutral.</p></body></html> + + + true + + + + + + + <html><head/><body><p>Overall reputation score, accounting for yours and your friends'.</p><p>Negative is bad, positive is good. Zero is neutral. If the score is too low,</p><p>the identity is flagged as bad, and will be filtered out in forums, chat lobbies,</p><p>channels, etc.</p></body></html> + + + true + + + @@ -70,39 +183,6 @@ - - - - - - - true - - - true - - - - - - - true - - - true - - - - - - - true - - - true - - - @@ -110,16 +190,6 @@ - - - - true - - - true - - - @@ -134,20 +204,28 @@ - - - - Qt::Vertical + + + + Last used: - - - 20 - 40 - - - +
- + + + + Ban-option: + + + + + + + Auto-Ban all identities signed by the same node + + + + true @@ -157,189 +235,227 @@ - - - - Last used: + + + + true + + + true + + + + + + + true + + + true + + + + + + + + + + true + + + true + + + + + + + true + + + true - - - - - 0 - 0 - + + + + QLayout::SetDefaultConstraint - - - 128 - 128 - - - - - 128 - 128 - - - - Your Avatar - - - true - - - Qt::AlignCenter - - - true - - - - - - - + + - + 0 0 - - Reputation + + + 128 + 128 + + + + + 128 + 128 + + + + QFrame::Box + + + QFrame::Sunken + + + Your Avatar + + + true + + + Qt::AlignCenter - - - - - - - <html><head/><body><p>Average opinion of neighbor nodes about this identity. Negative is bad,</p><p>positive is good. Zero is neutral.</p></body></html> - - - true - - - - - - - Your opinion: - - - - - - - Neighbor nodes: - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Your own opinion about an identity rules the visibility of that identity for yourself,</p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">and is shared among friends. A final score is calculated according to a formula that accounts your own opinion and your friends' opinions about someone:</p> -<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> S = own_opinion * a + friends_opinion * (1-a)</p> -<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The factor 'a' depends on the type of ID. </p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- anonymous IDs: </p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- PGP-signed IDs by unknown PGP keys: a=</p> -<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity:</p> -<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">S &lt; -0.5: Posts are not stored, nor forwarded </p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">S &lt; 0.2: Posts are hidden, but still transmitted</p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">S &lt; 0.0: </p> -<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The overall rating is computed in such a way that it is not possible for a single person to deterministically change someone's status at neighbor nodes.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - - - 0 - - - - Negative - - - - ../icons/yellow_biohazard64.png../icons/yellow_biohazard64.png - - - - - Neutral - - - - - Positive - - - - - - - - <html><head/><body><p>Overall reputation score, accounting for yours and your friends'.</p><p>Negative is bad, positive is good. Zero is neutral. If the score is too low,</p><p>the identity is flagged as bad, and will be filtered out in forums, chat lobbies,</p><p>channels, etc.</p></body></html> - - - true - - - - - - - - 75 - true - - - - Overall: - - - - - - + + + + Send Invite + + + + + + + 6 + + + + + + 34 + 34 + + + + + + + :/icons/png/thumbs-up.png + + + true + + + + + + + + 16 + + + + Positive votes + + + 0 + + + + + + + Qt::Vertical + + + + + + + + 34 + 34 + + + + + + + :/icons/png/thumbs-down.png + + + true + + + + + + + + 16 + + + + Negative votes + + + 0 + + + + + + + + + Qt::Vertical + + + + 118 + 17 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + 9 + + + 9 + + + 9 + + 9 @@ -367,6 +483,19 @@ p, li { white-space: pre-wrap; } + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -379,6 +508,7 @@ p, li { white-space: pre-wrap; } + diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 51a190152..9dba69c27 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -84,16 +84,8 @@ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidge /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); -// if(id.isNull()) -// ui._useOldFormat_CB->setChecked(true) ; -// else -// { -// ui._useOldFormat_CB->setChecked(false) ; -// ui._useOldFormat_CB->setEnabled(false) ; -// } - - ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png")); - ui.headerFrame->setHeaderText(tr("Friend node details")); + ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png")); + //ui.headerFrame->setHeaderText(tr("Friend node details")); //ui._chat_CB->hide() ; @@ -142,16 +134,21 @@ void ConfCertDialog::load() return; } - //ui.pgpfingerprint->setText(QString::fromUtf8(detail.name.c_str())); - ui.peerid->setText(QString::fromStdString(detail.id.toStdString())); + //ui.pgpfingerprint->setText(QString::fromUtf8(detail.name.c_str())); + ui.peerid->setText(QString::fromStdString(detail.id.toStdString())); + + nameAndLocation = QString("%1 (%2)").arg(QString::fromUtf8(detail.name.c_str())).arg(QString::fromUtf8(detail.location.c_str())); - RetroShareLink link; - link.createPerson(detail.gpg_id); + ui.headerFrame->setHeaderText(nameAndLocation); - ui.pgpfingerprint->setText(link.toHtml()); - ui.pgpfingerprint->setToolTip(link.title()); - ui.avatar->setId(ChatId(peerId)); + RetroShareLink link; + link.createPerson(detail.gpg_id); + + ui.pgpfingerprint->setText(link.toHtml()); + ui.pgpfingerprint->setToolTip(link.title()); + + ui.avatar->setId(ChatId(peerId)); ui.loc->setText(QString::fromUtf8(detail.location.c_str())); // Dont Show a timestamp in RS calculate the day @@ -161,6 +158,11 @@ void ConfCertDialog::load() std::string version; rsDisc->getPeerVersion(detail.id, version); ui.version->setText(QString::fromStdString(version)); + + /* Custom state string */ + QString statustring = QString::fromUtf8(rsMsgs->getCustomStateString(detail.id).c_str()); + ui.statusmessage->setText(statustring); + RsPeerCryptoParams cdet ; if(RsControl::instance()->getPeerCryptoDetails(detail.id,cdet) && cdet.connexion_state!=0) diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index b9529fe7a..2188d2ebb 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -86,6 +86,8 @@ private: RsPeerId peerId; RsPgpId pgpId; + QString nameAndLocation; + /** Qt Designer generated object */ Ui::ConfCertDialog ui; }; diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index d5acc190b..66724a7a7 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -6,8 +6,8 @@ 0 0 - 742 - 915 + 722 + 546 @@ -69,7 +69,7 @@ - 1 + 0 @@ -85,13 +85,20 @@ - Node info + Friend info + + + + true + + + - + 0 0 @@ -125,13 +132,6 @@ - - - - true - - - @@ -197,7 +197,17 @@ - PGP key : + Name: + + + + + + + + + + Status message: @@ -210,14 +220,14 @@ - 96 - 96 + 128 + 128 - 96 - 96 + 128 + 128 @@ -252,7 +262,18 @@ - + + + + + + :/images/kcmsystem24.png:/images/kcmsystem24.png + + + Advanced + + + 0 @@ -403,55 +424,51 @@ + + + Retroshare Certificate + + + + + + Use this certificate to make friends: + + + + + + + + + + + + Include signatures + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + - - - - :/images/view-certificate-sign-32.png:/images/view-certificate-sign-32.png - - - Retroshare Certificate - - - - - - Use this certificate to make friends: - - - - - - - - - - - - Include signatures - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - From 7327f1a98bc9d204bce1a88dc3c4c407dddaf585 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 28 Jan 2017 15:26:12 +0100 Subject: [PATCH 03/28] fixed deadlock caused by locking the mutex in p3Identity after the one in p3GxsReputation --- libretroshare/src/services/p3gxsreputation.cc | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index aa64bec14..0152909ef 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -451,24 +451,25 @@ void p3GxsReputation::cleanup() ++it ; } - // update opinions based on flags and contact information + // Update opinions based on flags and contact information. + // Note: the call to rsIdentity->isARegularContact() is done off-mutex, in order to avoid a cross-deadlock, as + // normally, p3GxsReputation gets called by p3dentity and not te reverse. That explains the weird implementation + // of these two loops. { - std::list should_set_to_positive ; + std::list should_set_to_positive_candidates ; + if(mAutoSetPositiveOptionToContacts) { RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ for(std::map::iterator it(mReputations.begin());it!=mReputations.end();++it) - { - bool is_a_contact = rsIdentity->isARegularContact(it->first) ; - - if(mAutoSetPositiveOptionToContacts && is_a_contact && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL) - should_set_to_positive.push_back(it->first) ; - } + if(it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL) + should_set_to_positive_candidates.push_back(it->first) ; } - for(std::list::const_iterator it(should_set_to_positive.begin());it!=should_set_to_positive.end();++it) - setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ; + for(std::list::const_iterator it(should_set_to_positive_candidates.begin());it!=should_set_to_positive_candidates.end();++it) + if(rsIdentity->isARegularContact(*it)) + setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ; } } From 7861b092c392185b0d4ebe8d6f952b84a09a7e99 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 29 Jan 2017 19:01:38 +0100 Subject: [PATCH 04/28] Fixed to display Avatars and nickname on news feeds Messages Item for Distant Messages. Added for Invite Message RS_MSG_USER_REQUEST flag & auto send invites to outbox. Optimized Messages Item for Invite Messages, display a Send Invite Button, to send back own rs cert link via Distant Message. --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 29 +-- retroshare-gui/src/gui/Identity/IdDialog.h | 2 +- retroshare-gui/src/gui/Identity/IdDialog.ui | 230 ++++++++++++++++-- retroshare-gui/src/gui/feeds/MsgItem.cpp | 35 ++- retroshare-gui/src/gui/feeds/MsgItem.h | 1 + retroshare-gui/src/gui/feeds/MsgItem.ui | 12 +- .../src/gui/msgs/MessageComposer.cpp | 41 ++++ retroshare-gui/src/gui/msgs/MessageComposer.h | 3 + .../src/gui/qss/stylesheet/Standard.qss | 7 + 9 files changed, 307 insertions(+), 53 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 811742b62..239a6b592 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -230,6 +230,8 @@ IdDialog::IdDialog(QWidget *parent) : ui->mainSplitter->setStretchFactor(0, 0); ui->mainSplitter->setStretchFactor(1, 1); + ui->inviteFrame->hide(); + /*remove QList sizes; sizes << width() << 500; // Qt calculates the right sizes @@ -2458,28 +2460,13 @@ void IdDialog::sendInvite() { return; } - /* create a message */ - MessageComposer *composer = MessageComposer::newMsg(); - composer->setTitleText(tr("You have a friend invite")); + RsGxsId id(ui->lineEdit_KeyId->text().toStdString()); - RsPeerId ownId = rsPeers->getOwnId(); - RetroShareLink link; - link.createCertificate(ownId); + MessageComposer::sendInvite(id); - std::string keyId = item->text(RSID_COL_KEYID).toStdString(); - - QString sMsgText = inviteMessage(); - sMsgText += "

"; - sMsgText += tr("Respond now:") + "
"; - sMsgText += link.toHtml() + "
"; - sMsgText += "
"; - sMsgText += tr("Thanks,
") + QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()); - composer->setMsgText(sMsgText); - composer->addRecipient(MessageComposer::TO, RsGxsId(keyId)); - - composer->show(); - + ui->inviteFrame->show(); + ui->inviteButton->setEnabled(false); } void IdDialog::negativePerson() @@ -2557,3 +2544,7 @@ QList selected_items = ui->idTreeWidget->selectedItems(); requestIdList(); } +void IdDialog::on_closeInfoFrameButton_clicked() +{ + ui->inviteFrame->setVisible(false); +} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index d8f515f4e..a44d83677 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -93,7 +93,7 @@ private slots: void editIdentity(); void chatIdentity(); void sendMsg(); - + void on_closeInfoFrameButton_clicked(); void updateSelection(); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index 036584851..b3bfbddfb 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -20,7 +20,16 @@
- + + 0 + + + 0 + + + 0 + + 0 @@ -38,7 +47,16 @@ QFrame::Sunken - + + 2 + + + 2 + + + 2 + + 2 @@ -129,7 +147,16 @@ QFrame::Sunken - + + 1 + + + 1 + + + 1 + + 1 @@ -222,7 +249,7 @@ Votes - AlignLeft|AlignVCenter + AlignLeading|AlignVCenter @@ -299,14 +326,14 @@ Identity info - + Identity name : - + true @@ -316,7 +343,7 @@ - + @@ -459,14 +486,14 @@ - + Identity ID : - + true @@ -476,24 +503,24 @@ - + Type: - + - + Owner node ID : - + true @@ -503,14 +530,14 @@ - + Owner node name : - + true @@ -520,31 +547,31 @@ - + Last used: - + - + Qt::Horizontal - + Your opinion: - + @@ -600,28 +627,28 @@ p, li { white-space: pre-wrap; } - + Ban-option: - + Auto-Ban all identities signed by the same node - + Friend votes: - + <html><head/><body><p>Average opinion of neighbor nodes about this identity. Negative is bad,</p><p>positive is good. Zero is neutral.</p></body></html> @@ -631,7 +658,7 @@ p, li { white-space: pre-wrap; } - + @@ -644,7 +671,7 @@ p, li { white-space: pre-wrap; } - + <html><head/><body><p>Overall reputation score, accounting for yours and your friends'.</p><p>Negative is bad, positive is good. Zero is neutral. If the score is too low,</p><p>the identity is flagged as bad, and will be filtered out in forums, chat lobbies,</p><p>channels, etc.</p></body></html> @@ -654,6 +681,157 @@ p, li { white-space: pre-wrap; } + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + + + + QFrame::Box + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 16 + 16 + + + + + + + :/images/info16.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Invite messages stay into your Outbox until an acknowledgement of receipt has been received. + + + + + + + + 16 + 16 + + + + Qt::NoFocus + + + Close + + + QToolButton +{ + border-image: url(:/images/closenormal.png) +} + +QToolButton:hover +{ +border-image: url(:/images/closehover.png) +} + +QToolButton:pressed { +border-image: url(:/images/closepressed.png) +} + + + true + + + + + + diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index c56173e59..21ecdb321 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -62,6 +62,8 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId, connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) ); connect( deleteButton, SIGNAL( clicked( void ) ), this, SLOT( deleteMsg ( void ) ) ); connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyMsg ( void ) ) ); + connect( sendinviteButton, SIGNAL( clicked( void ) ), this, SLOT( sendInvite ( void ) ) ); + expandFrame->hide(); @@ -87,7 +89,7 @@ void MsgItem::updateItemStatic() /* get peer Id */ - if (mi.msgflags & RS_MSG_SIGNED) + if (mi.msgflags & RS_MSG_DISTANT) avatar->setGxsId(mi.rsgxsid_srcId) ; else avatar->setId(ChatId(mi.rspeerid_srcId)) ; @@ -99,7 +101,7 @@ void MsgItem::updateItemStatic() srcName = "RetroShare"; else { - if(mi.msgflags & RS_MSG_SIGNED) + if(mi.msgflags & RS_MSG_DISTANT) { RsIdentityDetails details ; rsIdentity->getIdDetails(mi.rsgxsid_srcId, details) ; @@ -110,11 +112,19 @@ void MsgItem::updateItemStatic() srcName = QString::fromUtf8(rsPeers->getPeerName(mi.rspeerid_srcId).c_str()); } - timestampLabel->setText(DateTime::formatLongDateTime(mi.ts)); if (!mIsHome) { - title = tr("Message From") + ": "; + if (mi.msgflags & RS_MSG_USER_REQUEST) + { + title = QString::fromUtf8(mi.title.c_str()) + " " + tr("from") + " " + srcName; + subjectLabel->hide(); + } + else + { + title = tr("Message From") + ": " + srcName; + sendinviteButton->hide(); + } } else { @@ -141,11 +151,11 @@ void MsgItem::updateItemStatic() break; } } - title += srcName; titleLabel->setText(title); subjectLabel->setText(QString::fromUtf8(mi.title.c_str())); mMsg = QString::fromUtf8(mi.msg.c_str()); + timestampLabel->setText(DateTime::formatLongDateTime(mi.ts)); if (wasExpanded() || expandFrame->isVisible()) { fillExpandFrame(); @@ -344,3 +354,18 @@ void MsgItem::checkMessageReadStatus() removeItem(); } + +void MsgItem::sendInvite() +{ + MessageInfo mi; + + if (!rsMail) + return; + + if (!rsMail->getMessage(mMsgId, mi)) + return; + + + MessageComposer::sendInvite(mi.rsgxsid_srcId); + +} diff --git a/retroshare-gui/src/gui/feeds/MsgItem.h b/retroshare-gui/src/gui/feeds/MsgItem.h index 9b036260e..3c5ad6c99 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.h +++ b/retroshare-gui/src/gui/feeds/MsgItem.h @@ -56,6 +56,7 @@ private slots: void playMedia(); void deleteMsg(); void replyMsg(); + void sendInvite(); void checkMessageReadStatus(); void updateItem(); diff --git a/retroshare-gui/src/gui/feeds/MsgItem.ui b/retroshare-gui/src/gui/feeds/MsgItem.ui index b53cc3b26..138f810a6 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.ui +++ b/retroshare-gui/src/gui/feeds/MsgItem.ui @@ -146,6 +146,7 @@ + 12 75 true true @@ -165,7 +166,7 @@ Qt::Horizontal - QSizePolicy::Preferred + QSizePolicy::Expanding @@ -206,6 +207,13 @@ + + + + Send Invite + + + @@ -225,7 +233,7 @@ Qt::ToolButtonTextBesideIcon - true + false diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 41d019a8d..ecd4327e6 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -2758,3 +2758,44 @@ void MessageComposer::on_closeInfoFrameButton_clicked() { ui.distantFrame->setVisible(false); } + +QString MessageComposer::inviteMessage() +{ + return tr("Hi,
I want to be friends with you on RetroShare.
"); +} + +void MessageComposer::sendInvite(const RsGxsId &to, const QString &msg, bool autoSend) +{ + /* create a message */ + MessageComposer *composer = MessageComposer::newMsg(); + + composer->setTitleText(tr("You have a friend invite")); + composer->msgFlags |= RS_MSG_USER_REQUEST; + + + RsPeerId ownId = rsPeers->getOwnId(); + RetroShareLink link; + link.createCertificate(ownId); + + QString sMsgText = inviteMessage(); + sMsgText += "

"; + sMsgText += tr("Respond now:") + "
"; + sMsgText += link.toHtml() + "
"; + sMsgText += "
"; + sMsgText += tr("Thanks,
") + QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()); + composer->setMsgText(sMsgText); + composer->addRecipient(MessageComposer::TO, RsGxsId(to)); + + + if (autoSend) { + if (composer->sendMessage_internal(false)) { + composer->close(); + return; + } + } + + //composer->show(); + + /* window will destroy itself! */ +} + diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index f13ca7b06..6dddf17ff 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -64,6 +64,7 @@ public: static QString recommendMessage(); static void recommendFriend(const std::set &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false); static void sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &sslName); + static void sendInvite(const RsGxsId &to = RsGxsId(), const QString &msg = "", bool autoSend = true); #ifdef UNUSED_CODE static void sendChannelPublishKey(RsGxsChannelGroup &group); static void sendForumPublishKey(RsGxsForumGroup &group); @@ -164,6 +165,8 @@ private slots: void tagRemoveAll(); void on_closeInfoFrameButton_clicked(); + + static QString inviteMessage(); private: static QString buildReplyHeader(const MessageInfo &msgInfo); diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 365a8f9f1..16a40f481 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -623,6 +623,13 @@ IdDialog QLabel#avlabel { border-radius: 10px; } +IdDialog QFrame#inviteFrame { + border: 1px solid #DCDC41; + border-radius: 6px; + background: #FFFFD7; + background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); +} + GxsChannelPostsWidget QFrame#infoFrame { border: 1px solid #DCDC41; From 0a02419a297bdb0e8ab025116ff2f48ad1b479c5 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 31 Jan 2017 20:07:00 +0100 Subject: [PATCH 05/28] fixed a big memory leak in hash cache storage load code, and improved deletion of allocated memory if file reading fails --- .../src/file_sharing/directory_storage.cc | 40 +++++++++++-------- libretroshare/src/file_sharing/filelist_io.cc | 12 +++--- libretroshare/src/file_sharing/hash_cache.cc | 25 +++++++----- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/libretroshare/src/file_sharing/directory_storage.cc b/libretroshare/src/file_sharing/directory_storage.cc index b02d0fc4a..f87da14d4 100644 --- a/libretroshare/src/file_sharing/directory_storage.cc +++ b/libretroshare/src/file_sharing/directory_storage.cc @@ -739,26 +739,29 @@ bool LocalDirectoryStorage::serialiseDirEntry(const EntryIndex& indx,RsTlvBinary // std::string virtual_dir_name = locked_getVirtualDirName(indx) ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_DIR_NAME ,virtual_dir_name )) return false ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RECURS_MODIF_TS,(uint32_t)dir->dir_most_recent_time)) return false ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,(uint32_t)dir->dir_modtime )) return false ; + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_DIR_NAME ,virtual_dir_name )) { free(section_data); return false ;} + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RECURS_MODIF_TS,(uint32_t)dir->dir_most_recent_time)) { free(section_data); return false ;} + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,(uint32_t)dir->dir_modtime )) { free(section_data); return false ;} // serialise number of subdirs and number of subfiles - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subdirs.size() )) return false ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subfiles )) return false ; + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subdirs.size() )) { free(section_data); return false ;} + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subfiles )) { free(section_data); return false ;} // serialise subdirs entry indexes for(uint32_t i=0;ifile_name )) return false ; - if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,file->file_size )) return false ; - if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,file->file_hash )) return false ; - if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_MODIF_TS ,(uint32_t)file->file_modtime)) return false ; + if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_NAME ,file->file_name )) { free(section_data);free(file_section_data);return false ;} + if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,file->file_size )) { free(section_data);free(file_section_data);return false ;} + if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,file->file_hash )) { free(section_data);free(file_section_data);return false ;} + if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_MODIF_TS ,(uint32_t)file->file_modtime)) { free(section_data);free(file_section_data);return false ;} // now write the whole string into a single section in the file - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_REMOTE_FILE_ENTRY,file_section_data,file_section_offset)) return false ; + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_REMOTE_FILE_ENTRY,file_section_data,file_section_offset)) { free(section_data); free(file_section_data);return false ;} #ifdef DEBUG_LOCAL_DIRECTORY_STORAGE std::cerr << " pushing subfile " << file->hash << ", array position=" << i << " indx=" << dir->subfiles[i] << std::endl; @@ -793,7 +796,7 @@ bool LocalDirectoryStorage::serialiseDirEntry(const EntryIndex& indx,RsTlvBinary std::cerr << "Serialised dir entry to send for entry index " << (void*)(intptr_t)indx << ". Data size is " << section_size << " bytes" << std::endl; #endif - bindata.bin_data = section_data ; + bindata.bin_data = realloc(section_data,section_offset) ; // This discards the possibly unused trailing bytes in the end of section_data bindata.bin_len = section_offset ; return true ; @@ -865,6 +868,9 @@ bool RemoteDirectoryStorage::deserialiseUpdateDirEntry(const EntryIndex& indx,co // deserialise directory subfiles, with info for each of them std::vector subfiles_array ; + + // Pre-allocate file_section_data, so that read_field does not need to do it many times. + unsigned char *file_section_data = (unsigned char *)rs_malloc(FL_BASE_TMP_SECTION_SIZE) ; if(!file_section_data) @@ -876,17 +882,17 @@ bool RemoteDirectoryStorage::deserialiseUpdateDirEntry(const EntryIndex& indx,co { // Read the full data section for the file - if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_REMOTE_FILE_ENTRY,file_section_data,file_section_size)) return false ; + if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_REMOTE_FILE_ENTRY,file_section_data,file_section_size)) { free(file_section_data); return false ; } uint32_t file_section_offset = 0 ; InternalFileHierarchyStorage::FileEntry f; uint32_t modtime =0; - if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_NAME ,f.file_name )) return false ; - if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,f.file_size )) return false ; - if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,f.file_hash )) return false ; - if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_MODIF_TS ,modtime )) return false ; + if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_NAME ,f.file_name )) { free(file_section_data); return false ; } + if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,f.file_size )) { free(file_section_data); return false ; } + if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,f.file_hash )) { free(file_section_data); return false ; } + if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_MODIF_TS ,modtime )) { free(file_section_data); return false ; } f.file_modtime = modtime ; diff --git a/libretroshare/src/file_sharing/filelist_io.cc b/libretroshare/src/file_sharing/filelist_io.cc index 7be770c82..618d6c6bb 100644 --- a/libretroshare/src/file_sharing/filelist_io.cc +++ b/libretroshare/src/file_sharing/filelist_io.cc @@ -59,16 +59,16 @@ bool FileListIO::writeField( unsigned char*&buff,uint32_t& buff_size,uint32 bool FileListIO::readField (const unsigned char *buff,uint32_t buff_size,uint32_t& offset,uint8_t check_section_tag, unsigned char *& val,uint32_t& size) { - if(!readSectionHeader(buff,buff_size,offset,check_section_tag,size)) + uint32_t local_size ; + + if(!readSectionHeader(buff,buff_size,offset,check_section_tag,local_size)) return false; - val = (unsigned char *)rs_malloc(size) ; - - if(!val) + if(!checkSectionSize(val,size,0,local_size)) // allocate val if needed to handle local_size bytes. return false; - memcpy(val,&buff[offset],size); - offset += size ; + memcpy(val,&buff[offset],local_size); + offset += local_size ; return true ; } diff --git a/libretroshare/src/file_sharing/hash_cache.cc b/libretroshare/src/file_sharing/hash_cache.cc index 5c5eb8a1a..52cd05bda 100644 --- a/libretroshare/src/file_sharing/hash_cache.cc +++ b/libretroshare/src/file_sharing/hash_cache.cc @@ -365,13 +365,16 @@ bool HashStorage::readHashStorageInfo(const unsigned char *data,uint32_t total_s // of a section because of some unknown field, etc. if(!FileListIO::readField(data,total_size,offset,FILE_LIST_IO_TAG_HASH_STORAGE_ENTRY,section_data,section_size)) - return false; + { + free(section_data); + return false; + } - if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_NAME ,info.filename )) return false ; - if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,info.size )) return false ; - if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_UPDATE_TS ,info.time_stamp)) return false ; - if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,info.modf_stamp)) return false ; - if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,info.hash )) return false ; + if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_NAME ,info.filename )) { free(section_data); return false ; } + if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,info.size )) { free(section_data); return false ; } + if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_UPDATE_TS ,info.time_stamp)) { free(section_data); return false ; } + if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,info.modf_stamp)) { free(section_data); return false ; } + if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,info.hash )) { free(section_data); return false ; } free(section_data); return true; @@ -387,11 +390,11 @@ bool HashStorage::writeHashStorageInfo(unsigned char *& data,uint32_t& total_si uint32_t section_offset = 0 ; uint32_t section_size = FL_BASE_TMP_SECTION_SIZE; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_NAME ,info.filename )) return false ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,info.size )) return false ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_UPDATE_TS ,info.time_stamp)) return false ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,info.modf_stamp)) return false ; - if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,info.hash )) return false ; + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_NAME ,info.filename )) { free(section_data); return false ; } + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,info.size )) { free(section_data); return false ; } + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_UPDATE_TS ,info.time_stamp)) { free(section_data); return false ; } + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,info.modf_stamp)) { free(section_data); return false ; } + if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,info.hash )) { free(section_data); return false ; } // now write the whole string into a single section in the file From deea1b53447e5c32474369830be3f37db03aa5db Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 31 Jan 2017 20:59:50 +0100 Subject: [PATCH 06/28] moved temporary GXS object structures into rsgxsutil.h and used them in p3gxscircles to remove a memory leak --- libretroshare/src/gxs/rsgxsnetservice.cc | 39 ------------- libretroshare/src/gxs/rsgxsutil.h | 64 ++++++++++++++++++++++ libretroshare/src/services/p3gxscircles.cc | 2 +- 3 files changed, 65 insertions(+), 40 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index a41229a2f..49fa13cb6 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -457,45 +457,6 @@ void RsGxsNetService::cleanRejectedMessages() ++it ; } -// temporary holds a map of pointers to class T, and destroys all pointers on delete. - -template -class RsGxsMetaDataTemporaryMap: public std::map -{ -public: - virtual ~RsGxsMetaDataTemporaryMap() - { - clear() ; - } - - virtual void clear() - { - for(typename RsGxsMetaDataTemporaryMap::iterator it = this->begin();it!=this->end();++it) - if(it->second != NULL) - delete it->second ; - - std::map::clear() ; - } -}; - -template -class RsGxsMetaDataTemporaryMapVector: public std::vector -{ -public: - virtual ~RsGxsMetaDataTemporaryMapVector() - { - clear() ; - } - - virtual void clear() - { - for(typename RsGxsMetaDataTemporaryMapVector::iterator it = this->begin();it!=this->end();++it) - if(it->second != NULL) - delete it->second ; - std::vector::clear() ; - } -}; - RsGxsGroupId RsGxsNetService::hashGrpId(const RsGxsGroupId& gid,const RsPeerId& pid) { static const uint32_t SIZE = RsGxsGroupId::SIZE_IN_BYTES + RsPeerId::SIZE_IN_BYTES ; diff --git a/libretroshare/src/gxs/rsgxsutil.h b/libretroshare/src/gxs/rsgxsutil.h index cfd777c90..fdcc96246 100644 --- a/libretroshare/src/gxs/rsgxsutil.h +++ b/libretroshare/src/gxs/rsgxsutil.h @@ -49,6 +49,70 @@ void freeAndClearContainerResource(Container container) container.clear(); } +// temporary holds a map of pointers to class T, and destroys all pointers on delete. + +template +class RsGxsMetaDataTemporaryMap: public std::map +{ +public: + virtual ~RsGxsMetaDataTemporaryMap() + { + clear() ; + } + + virtual void clear() + { + for(typename RsGxsMetaDataTemporaryMap::iterator it = this->begin();it!=this->end();++it) + if(it->second != NULL) + delete it->second ; + + std::map::clear() ; + } +}; + +template +class RsGxsMetaDataTemporaryMapVector: public std::map > +{ +public: + virtual ~RsGxsMetaDataTemporaryMapVector() + { + clear() ; + } + + virtual void clear() + { + for(typename RsGxsMetaDataTemporaryMapVector::iterator it = this->begin();it!=this->end();++it) + { + for(uint32_t i=0;isecond.size();++i) + delete it->second[i] ; + + it->second.clear(); + } + + std::map >::clear() ; + } +}; +#ifdef UNUSED +template +class RsGxsMetaDataTemporaryMapVector: public std::vector +{ +public: + virtual ~RsGxsMetaDataTemporaryMapVector() + { + clear() ; + } + + virtual void clear() + { + for(typename RsGxsMetaDataTemporaryMapVector::iterator it = this->begin();it!=this->end();++it) + if(it->second != NULL) + delete it->second ; + std::vector::clear() ; + } +}; +#endif + + inline RsGxsGrpMsgIdPair getMsgIdPair(RsNxsMsg& msg) { return RsGxsGrpMsgIdPair(std::make_pair(msg.grpId, msg.msgId)); diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 05812d699..9936c202e 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -1978,7 +1978,7 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token) #ifdef DEBUG_CIRCLES std::cerr << "Processing circle membership requests." << std::endl; #endif - GxsMsgDataMap msgItems ; + RsGxsMetaDataTemporaryMapVector msgItems; if(!RsGenExchange::getMsgData(token, msgItems)) { From 0ad581a0ff05fb2dc658f30f676ecfd1fa793bf7 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 1 Feb 2017 13:03:16 +0100 Subject: [PATCH 07/28] Updated Windows build script to openssl-1.0.2k --- build_scripts/Windows/build-libs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/Windows/build-libs/Makefile b/build_scripts/Windows/build-libs/Makefile index 5f0a2351f..5065d7620 100755 --- a/build_scripts/Windows/build-libs/Makefile +++ b/build_scripts/Windows/build-libs/Makefile @@ -1,7 +1,7 @@ ZLIB_VERSION=1.2.3 BZIP2_VERSION=1.0.6 MINIUPNPC_VERSION=2.0 -OPENSSL_VERSION=1.0.2h +OPENSSL_VERSION=1.0.2k SPEEX_VERSION=1.2rc2 SPEEXDSP_VERSION=1.2rc3 OPENCV_VERSION=2.4.13 From 873fbf98ad9886cd5e22de65cad2c2528135a32c Mon Sep 17 00:00:00 2001 From: cyril soler Date: Wed, 1 Feb 2017 14:32:35 +0100 Subject: [PATCH 08/28] added 3 missing delete, responsible for small memory leaks --- libretroshare/src/gxs/rsgxsnetservice.cc | 1 + libretroshare/src/rsserver/p3peers.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 49fa13cb6..4b2161985 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -4179,6 +4179,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_ delete *it ; itemL.clear() ; + delete mItem ; break ; } } diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index d4b5fe332..d700f6a42 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -1073,6 +1073,8 @@ std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures) RsCertificate cert( Detail,mem_block,mem_block_size ) ; + delete[] mem_block ; + return cert.armouredPGPKey() ; } @@ -1125,6 +1127,8 @@ std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_sig RsCertificate cert( Detail,mem_block,mem_block_size ) ; + delete[] mem_block ; + return cert.toStdString() ; } From 2a36d6bad02cbde333cf28830465381a026b2b9c Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 1 Feb 2017 21:55:06 +0100 Subject: [PATCH 09/28] re-working on the node creation wizard (unfinished) --- retroshare-gui/src/gui/GenCertDialog.cpp | 228 ++--- retroshare-gui/src/gui/GenCertDialog.h | 3 +- retroshare-gui/src/gui/GenCertDialog.ui | 1086 +++++++++++----------- 3 files changed, 597 insertions(+), 720 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index d9b2c7c75..e11fcdb04 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -136,48 +136,31 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) ui.headerFrame->setHeaderImage(QPixmap(":/icons/svg/profile.svg")); ui.headerFrame->setHeaderText(tr("Create a new profile")); - connect(ui.new_gpg_key_checkbox, SIGNAL(clicked()), this, SLOT(newGPGKeyGenUiSetup())); - connect(ui.adv_checkbox, SIGNAL(clicked()), this, SLOT(updateUiSetup())); - connect(ui.hidden_checkbox, SIGNAL(clicked()), this, SLOT(updateUiSetup())); + connect(ui.reuse_existing_node_CB, SIGNAL(clicked()), this, SLOT(setupState())); + connect(ui.adv_checkbox, SIGNAL(clicked()), this, SLOT(setupState())); + connect(ui.nodeType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(setupState())); connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson())); connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity())); connect(ui.exportIdentity_PB, SIGNAL(clicked()), this, SLOT(exportIdentity())); - //ui.genName->setFocus(Qt::OtherFocusReason); - -// QObject *obj = QCoreApplication::eventFilter() ; -// std::cerr << "Event filter : " << obj << std::endl; -// QCoreApplication::instance()->setEventFilter(MyEventFilter) ; - entropy_timer = new QTimer ; entropy_timer->start(20) ; QObject::connect(entropy_timer,SIGNAL(timeout()),this,SLOT(grabMouse())) ; -// EntropyCollectorWidget *ecw = new EntropyCollectorWidget(ui.entropy_bar,this) ; -// ecw->resize(size()) ; -// ecw->move(0,0) ; -// -// QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect ; -// effect->setOpacity(0.2) ; -// ecw->setGraphicsEffect(effect) ; - //ecw->setBackgroundColor(QColor::fromRGB(1,1,1)) ; -// ecw->show() ; - ui.entropy_bar->setValue(0) ; // make sure that QVariant always takes an 'int' otherwise the program will crash! - ui.keylength_comboBox->addItem("default (2048 bits, recommended)", QVariant(2048)); - ui.keylength_comboBox->addItem("high (3072 bits)", QVariant(3072)); - ui.keylength_comboBox->addItem("insane (4096 bits)", QVariant(4096)); + ui.keylength_comboBox->addItem("Default (2048 bits, recommended)", QVariant(2048)); + ui.keylength_comboBox->addItem("High (3072 bits)", QVariant(3072)); + ui.keylength_comboBox->addItem("Very high (4096 bits)", QVariant(4096)); #if QT_VERSION >= 0x040700 - ui.email_input->setPlaceholderText(tr("[Optional] Visible to your friends, and friends of friends.")) ; ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ; ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Tor/I2P address - Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ; ui.name_input->setPlaceholderText(tr("[Required] Visible to your friends, and friends of friends.")); ui.nickname_input->setPlaceholderText(tr("[Optional] Used when you write in chat lobbies, forums and channel comments. Can be setup later if you need one.")); - ui.password_input->setPlaceholderText(tr("[Required] This password protects your private PGP key.")); + ui.password_input->setPlaceholderText(tr("[Required] This password protects your node key.")); ui.password_input_2->setPlaceholderText(tr("[Required] Type the same password again here.")); #endif @@ -185,9 +168,6 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) ui.node_input->setToolTip(tr("Enter a meaningful node description. e.g. : home, laptop, etc. \nThis field will be used to differentiate different installations with\nthe same profile (PGP key pair).")) ; - ui.email_input->hide() ; - ui.email_label->hide() ; - /* get all available pgp private certificates.... * mark last one as default. */ @@ -231,7 +211,7 @@ void GenCertDialog::init() if (haveGPGKeys) { ui.no_gpg_key_label->hide(); ui.header_label->show(); - ui.new_gpg_key_checkbox->setChecked(false); + ui.reuse_existing_node_CB->setChecked(false); setWindowTitle(tr("Create new node")); ui.genButton->setText(tr("Generate new node")); ui.headerFrame->setHeaderText(tr("Create a new node")); @@ -239,8 +219,8 @@ void GenCertDialog::init() } else { ui.no_gpg_key_label->setVisible(!mOnlyGenerateIdentity); ui.header_label->setVisible(mOnlyGenerateIdentity); - ui.new_gpg_key_checkbox->setChecked(true); - ui.new_gpg_key_checkbox->setEnabled(true); + ui.reuse_existing_node_CB->setChecked(true); + ui.reuse_existing_node_CB->setEnabled(true); setWindowTitle(tr("Create new profile")); ui.genButton->setText(tr("Generate new profile and node")); ui.headerFrame->setHeaderText(tr("Create a new profile and node")); @@ -263,7 +243,7 @@ void GenCertDialog::init() } ui.header_label->setText(text); #endif - newGPGKeyGenUiSetup(); + setupState(); //updateUiSetup(); } @@ -274,152 +254,62 @@ void GenCertDialog::mouseMoveEvent(QMouseEvent *e) QDialog::mouseMoveEvent(e) ; } -void GenCertDialog::newGPGKeyGenUiSetup() { - bool adv_state = ui.adv_checkbox->isChecked(); - bool hidden_state = ui.hidden_checkbox->isChecked(); +void GenCertDialog::setupState() +{ + bool adv_state = ui.adv_checkbox->isChecked(); + bool hidden_state = ui.nodeType_CB->currentIndex()==1; + bool generate_new = !ui.reuse_existing_node_CB->isChecked(); + + genNewGPGKey = generate_new; + ui.no_node_label->setVisible(false); - if (ui.new_gpg_key_checkbox->isChecked()) { - genNewGPGKey = true; - setWindowTitle(tr("Create new profile")); - ui.headerFrame->setHeaderText(tr("Create a new profile and node")); - if (!mOnlyGenerateIdentity) { - ui.header_label->setVisible(haveGPGKeys); - } - ui.genprofileinfo_label->setVisible(false); - ui.no_gpg_key_label->setText(tr("Welcome to Retroshare. Before you can proceed you need to create a profile and associate a node with it. To do so please fill out this form.\nAlternatively you can import a (previously exported) profile. Just uncheck \"Create a new profile\"")); + setWindowTitle(generate_new?tr("Create new profile and node"):tr("Create new node")); + ui.headerFrame->setHeaderText(generate_new?tr("Create a new profile and node"):tr("Create a new node")); - ui.importIdentity_PB->hide() ; - ui.exportIdentity_PB->hide(); - ui.adv_checkbox->setVisible(true); + ui.label_nodeType->setVisible(adv_state) ; + ui.nodeType_CB->setVisible(adv_state) ; + ui.reuse_existing_node_CB->setVisible(adv_state) ; + ui.importIdentity_PB->setVisible(adv_state) ; + ui.exportIdentity_PB->setVisible(adv_state) ; - ui.genPGPuserlabel->hide(); - ui.genPGPuser->hide(); - ui.name_label->show(); - ui.name_input->show(); - ui.nickname_label->setVisible(!mOnlyGenerateIdentity); - ui.nickname_input->setVisible(!mOnlyGenerateIdentity); - ui.node_label->setVisible(true); - ui.node_input->setVisible(true); -// ui.email_label->show(); -// ui.email_input->show(); - ui.password_label->show(); - ui.password_label_2->show(); - ui.password_input->show(); - ui.password_input_2->show(); - //ui.keylength_label->show(); - //ui.keylength_comboBox->show(); + ui.genPGPuser->setVisible(adv_state && haveGPGKeys) ; - ui.entropy_label->setVisible(true); - ui.entropy_bar->setVisible(true); + ui.genprofileinfo_label->setVisible(false); + ui.no_gpg_key_label->setText(tr("Welcome to Retroshare. Before you can proceed you need to create a profile and associate a node with it. To do so please fill out this form.\nAlternatively you can import a (previously exported) profile. Just uncheck \"Create a new profile\"")); + ui.no_gpg_key_label->setVisible(false); - ui.genButton->setVisible(true); - ui.genButton->setText(tr("Generate new profile and node")); - } else { - genNewGPGKey = false; - setWindowTitle(tr("Create new node")); - ui.headerFrame->setHeaderText(tr("Create a new node")); - ui.header_label->setVisible(false); - //haveGPGKeys = (ui.genPGPuser->count() != 0)?true:false; - if (haveGPGKeys) { - QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex()); - if (!rsAccounts->selectAccountByString(data.toString().toStdString())) { - ui.no_node_label->setText(tr("No node is associated with the profile named") + " " + ui.genPGPuser->currentText() + ". " +tr("Please create a node for it by providing a node name.")); - ui.no_node_label->setVisible(true); - } else { - ui.genprofileinfo_label->show(); - } - } - //ui.genprofileinfo_label->show(); - ui.no_gpg_key_label->setText(tr("Welcome to Retroshare. Before you can proceed you need to import a profile and after that associate a node with it.")); + ui.nickname_label->setVisible(adv_state) ; + ui.nickname_input->setVisible(adv_state) ; - ui.importIdentity_PB->setVisible(!mOnlyGenerateIdentity); - ui.exportIdentity_PB->setVisible(haveGPGKeys); - ui.exportIdentity_PB->setEnabled(haveGPGKeys); - ui.adv_checkbox->setVisible(haveGPGKeys); - ui.adv_checkbox->setChecked(haveGPGKeys && adv_state); + ui.name_label->setVisible(!generate_new); + ui.name_input->setVisible(!generate_new); - //ui.genPGPuserlabel->show(); - //ui.genPGPuser->show(); - ui.genPGPuserlabel->setVisible(haveGPGKeys); - ui.genPGPuser->setVisible(haveGPGKeys); - ui.name_label->hide(); - ui.name_input->hide(); - ui.nickname_label->setVisible(!mOnlyGenerateIdentity && haveGPGKeys); - ui.nickname_input->setVisible(!mOnlyGenerateIdentity && haveGPGKeys); - ui.node_label->setVisible(haveGPGKeys); - ui.node_input->setVisible(haveGPGKeys); -// ui.email_label->hide(); -// ui.email_input->hide(); - ui.password_label->hide(); - ui.password_input->hide(); - ui.password_label_2->hide(); - ui.password_input_2->hide(); - ui.keylength_label->hide(); - ui.keylength_comboBox->hide(); + ui.nickname_label->setVisible(adv_state && !mOnlyGenerateIdentity); + ui.nickname_input->setVisible(adv_state && !mOnlyGenerateIdentity); - ui.entropy_label->setVisible(haveGPGKeys); - ui.entropy_bar->setVisible(haveGPGKeys); + ui.node_label->setVisible(true); + ui.node_input->setVisible(true); - ui.genButton->setText(tr("Generate new node")); - ui.genButton->setVisible(haveGPGKeys); - } - updateUiSetup(); - ui.adv_checkbox->setChecked(adv_state); - ui.hidden_checkbox->setChecked(hidden_state); -} + ui.password_label->setVisible(true); + ui.password_label_2->setVisible(true); + ui.password_input->setVisible(true); + ui.password_input_2->setVisible(true); -void GenCertDialog::updateUiSetup() -{ - if (ui.adv_checkbox->isChecked()) - { - ui.hidden_checkbox->show(); + ui.keylength_label->setVisible(adv_state); + ui.keylength_comboBox->setVisible(adv_state); - if (ui.new_gpg_key_checkbox->isChecked()) - { - // key length is only for pgp key creation - ui.keylength_label->show(); - ui.keylength_comboBox->show(); - } - else - { - ui.keylength_label->hide(); - ui.keylength_comboBox->hide(); - } + ui.entropy_label->setVisible(true); + ui.entropy_bar->setVisible(true); - if(ui.hidden_checkbox->isChecked()) - { - ui.hiddenaddr_input->show(); - ui.hiddenaddr_label->show(); - ui.label_hiddenaddr->show(); - ui.hiddenport_label->show(); - ui.hiddenport_spinBox->show(); - } - else - { - ui.hiddenaddr_input->hide(); - ui.hiddenaddr_label->hide(); - ui.label_hiddenaddr->hide(); - ui.hiddenport_label->hide(); - ui.hiddenport_spinBox->hide(); - } - } - else - { - ui.hiddenaddr_input->hide(); - ui.hiddenaddr_label->hide(); - ui.label_hiddenaddr->hide(); - ui.hiddenport_label->hide(); - ui.hiddenport_spinBox->hide(); - - ui.hidden_checkbox->hide(); - ui.keylength_label->hide(); - ui.keylength_comboBox->hide(); - - if(ui.hidden_checkbox->isChecked()) - ui.hidden_checkbox->setChecked(false) ; - } + ui.genButton->setVisible(true); + ui.genButton->setText(generate_new?tr("Generate new profile and node"):tr("Generate new node")); + ui.hiddenaddr_input->setVisible(hidden_state); + ui.hiddenaddr_label->setVisible(hidden_state); + ui.label_hiddenaddr->setVisible(hidden_state); + ui.hiddenport_label->setVisible(hidden_state); + ui.hiddenport_spinBox->setVisible(hidden_state); } void GenCertDialog::exportIdentity() @@ -498,7 +388,7 @@ void GenCertDialog::genPerson() } } - if (ui.hidden_checkbox->isChecked()) + if (ui.nodeType_CB->currentIndex()==1) { std::string hl = ui.hiddenaddr_input->text().toStdString(); uint16_t port = ui.hiddenport_spinBox->value(); @@ -555,27 +445,25 @@ void GenCertDialog::genPerson() } //generate a new gpg key std::string err_string; - ui.no_gpg_key_label->setText(tr("Generating new PGP key pair, please be patient: this process needs generating large prime numbers, and can take some minutes on slow computers. \n\nFill in your PGP password when asked, to sign your new key.")); + ui.no_gpg_key_label->setText(tr("Generating new node key, please be patient: this process needs generating large prime numbers, and can take some minutes on slow computers. \n\nFill in your password when asked, to sign your new key.")); ui.no_gpg_key_label->show(); - ui.new_gpg_key_checkbox->hide(); + ui.reuse_existing_node_CB->hide(); ui.name_label->hide(); ui.name_input->hide(); ui.nickname_label->hide(); ui.nickname_input->hide(); -// ui.email_label->hide(); -// ui.email_input->hide(); ui.password_label_2->hide(); ui.password_input_2->hide(); ui.password_label->hide(); ui.password_input->hide(); - ui.genPGPuserlabel->hide(); + //ui.genPGPuserlabel->hide(); ui.genPGPuser->hide(); ui.node_label->hide(); ui.node_input->hide(); ui.genButton->hide(); ui.importIdentity_PB->hide(); ui.genprofileinfo_label->hide(); - ui.hidden_checkbox->hide(); + ui.nodeType_CB->hide(); ui.adv_checkbox->hide(); ui.keylength_label->hide(); ui.keylength_comboBox->hide(); diff --git a/retroshare-gui/src/gui/GenCertDialog.h b/retroshare-gui/src/gui/GenCertDialog.h index c66445ebb..f84d29f17 100644 --- a/retroshare-gui/src/gui/GenCertDialog.h +++ b/retroshare-gui/src/gui/GenCertDialog.h @@ -41,9 +41,8 @@ private slots: void genPerson(); void importIdentity(); void exportIdentity(); - void newGPGKeyGenUiSetup(); + void setupState(); void grabMouse(); - void updateUiSetup(); private: void init(); diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index 0229cf023..06c17f778 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -6,8 +6,8 @@ 0 0 - 855 - 572 + 1745 + 1193
@@ -60,196 +60,24 @@ QFrame::Raised - - - - - No node exists for this profile. - - - true - - - - - - - It looks like no profile (PGP keys) exists. Please fill in the form below to create one, or import an existing profile. - - - true - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 178 - - - - - - - 255 - 255 - 178 - - - - - - - - true - - - QFrame::Box - - - You can create and run Retroshare nodes on different computers using the same profile. To do so just export the selected profile, import it on the other computer and create a new node with it. - - - true - - - - - - - - - Use profile + + + + + + + Qt::Horizontal - - - - - + - 0 - 0 + 40 + 20 - - 64 - - + - - - - Node name - - - - - - - This password is for PGP - - - Confirm - - - - - - - - 0 - 0 - - - - Put a strong password here. This password protects your private PGP key. - - - - - - 1024 - - - QLineEdit::Password - - - - - - - Your profile is associated with a PGP key pair. RetroShare currently ignores DSA keys. - - - - - - - Name - - - - - - - - 0 - 0 - - - - - 0 - 0 - - + + 16777215 @@ -257,371 +85,42 @@ - Enter your nickname here - - - 64 - - - - - - - + <html><head/><body><p>Use this if you need to import an existing profile, if you want to generate a new node with an already existing key, or if you want to create a TOR/I2P hidden node.</p></body></html> - Nickname + Advanced options - - - - - - You can have one or more identities. They are used when you write in chat lobbies, forums and channel comments. They act as the destination for distant chat and the Retroshare distant mail system. + + + :/icons/settings/general.svg:/icons/settings/general.svg - - - - - - Email - - - - - - - Be careful: this email will be visible to your friends and friends -of your friends. This information is required by PGP, but to stay -anonymous, you can use a fake email. - - - 64 - - - - - - - This password is for PGP - - - Password - - - - - - - Put a strong password here. This password protects your private PGP key. - - - - - - 1024 - - - QLineEdit::Password - - - - - - - hidden address - - - - - - - 6 - - - - - - 0 - 0 - - - - - 16777215 - 32 - - - - 64 - - - - - - - Port - - - - - - - <html><head/><body><p>This is your connection port.</p><p>Any value between 1024 and 65535 </p><p>should be ok. You can change it later.</p></body></html> - - - 1 - - - 65535 - - - 7812 - - - - - - - - - <html><head/><body><p>This can be a Tor Onion address of the form: xa76giaf6ifda7ri63i263.onion <br/>or an I2P address in the form: [52 characters].b32.i2p </p><p>In order to get one, you must configure either Tor or I2P to create a new hidden service / server tunnel. If you do not yet have one, you can still go on, and make it right later in RetroShare's Options-&gt;Network-&gt;Hidden Service configuration panel.</p></body></html> - - - true - - - - - - - PGP key length - - - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 178 - - - - - - - 255 - 255 - 178 - - - - - - - - true - - - QFrame::Box - - - <html><head/><body><p align="justify">Before proceeding, move your mouse around to help Retroshare collect as much randomness as possible. Filling the progressbar to 20% is needed, 100% is advised.</p></body></html> - - - true - - - - - - - 24 - - - - - - - - - - 16777215 - 32 - - - - Your profile is associated with a PGP key pair - - - Create a new profile - - - - :/icons/svg/profile.svg:/icons/svg/profile.svg - - - - 32 - 32 - - - - false - - - - - - - - 0 - 0 - - - - Import new profile - - - - - - - - 0 - 0 - - - - Export selected profile - - - - - - - - 16777215 - 32 - - - - Your profile is associated with a PGP key pair - - - Advanced options - - - - :/icons/settings/general.svg:/icons/settings/general.svg - - - - 24 - 24 - - - - false - - - - - - - Create a hidden node - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - + - 16777215 - 26 + 24 + 24 - - - 50 - false - - - - - - - Create new profile + + false - + + + + + + + :/images/logo/logo_splash.png + + + Qt::AlignCenter + + + + @@ -702,6 +201,505 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + QFrame::Box + + + You can create and run Retroshare nodes on different computers using the same profile. To do so just export the selected profile, import it on the other computer and create a new node with it. + + + true + + + + + + + It looks like no profile (PGP keys) exists. Please fill in the form below to create one, or import an existing profile. + + + true + + + + + + + No node exists for this profile. + + + true + + + + + + + + + Node type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + This password is for PGP + + + Password (check) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Put a strong password here. This password protects your private PGP key. + + + + + + 1024 + + + QLineEdit::Password + + + + + + + Profile name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 24 + + + + + + + You can have one or more identities. They are used when you write in chat lobbies, forums and channel comments. They act as the destination for distant chat and the Retroshare distant mail system. + + + + + + + + + + Chat identity + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + This password is for PGP + + + Password + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Put a strong password here. This password protects your private PGP key. + + + + + + 1024 + + + QLineEdit::Password + + + + + + + hidden address + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 6 + + + + + + 0 + 0 + + + + + 16777215 + 32 + + + + 64 + + + + + + + Port + + + + + + + <html><head/><body><p>This is your connection port.</p><p>Any value between 1024 and 65535 </p><p>should be ok. You can change it later.</p></body></html> + + + 1 + + + 65535 + + + 7812 + + + + + + + + + <html><head/><body><p>This can be a Tor Onion address of the form: xa76giaf6ifda7ri63i263.onion <br/>or an I2P address in the form: [52 characters].b32.i2p </p><p>In order to get one, you must configure either Tor or I2P to create a new hidden service / server tunnel. If you do not yet have one, you can still go on, and make it right later in RetroShare's Options-&gt;Network-&gt;Hidden Service configuration panel.</p></body></html> + + + true + + + + + + + PGP key length + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + QFrame::Box + + + <html><head/><body><p align="justify">Before proceeding, move your mouse around to help Retroshare collect as much randomness as possible. Filling the progressbar to 20% is needed, 100% is advised.</p></body></html> + + + true + + + + + + + + 0 + 0 + + + + 64 + + + + + + + + + + Go! + + + + + + + + Standard node + + + + + TOR/I2P Hidden node + + + + + + + + Node name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 32 + + + + Enter your nickname here + + + + + + 64 + + + + + + + Your profile is associated with a PGP key pair. RetroShare currently ignores DSA keys. + + + + + + + + 0 + 0 + + + + Export this profle + + + + + + + + 0 + 0 + + + + Import new profile + + + + + + + Re-use existing profile + + + + + + + @@ -734,17 +732,9 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - new_gpg_key_checkbox - importIdentity_PB - exportIdentity_PB - adv_checkbox - genPGPuser - name_input nickname_input - email_input password_input password_input_2 - node_input hiddenaddr_input hiddenport_spinBox From 89a27aef8a0d2b5f8d3257ee8b2aae7733f5ac2d Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 1 Feb 2017 23:08:57 +0100 Subject: [PATCH 10/28] finished new profile creation window --- retroshare-gui/src/gui/GenCertDialog.cpp | 117 +++++++--------- retroshare-gui/src/gui/GenCertDialog.h | 5 +- retroshare-gui/src/gui/GenCertDialog.ui | 162 +++++++++++------------ 3 files changed, 133 insertions(+), 151 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index e11fcdb04..12aeb937d 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -136,7 +136,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) ui.headerFrame->setHeaderImage(QPixmap(":/icons/svg/profile.svg")); ui.headerFrame->setHeaderText(tr("Create a new profile")); - connect(ui.reuse_existing_node_CB, SIGNAL(clicked()), this, SLOT(setupState())); + connect(ui.reuse_existing_node_CB, SIGNAL(clicked()), this, SLOT(switchReuseExistingNode())); connect(ui.adv_checkbox, SIGNAL(clicked()), this, SLOT(setupState())); connect(ui.nodeType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(setupState())); @@ -172,7 +172,8 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) * mark last one as default. */ - init(); + initKeyList(); + setupState(); } GenCertDialog::~GenCertDialog() @@ -180,7 +181,21 @@ GenCertDialog::~GenCertDialog() entropy_timer->stop() ; } -void GenCertDialog::init() +void GenCertDialog::switchReuseExistingNode() +{ + if(ui.reuse_existing_node_CB->isChecked()) + { + // import an existing identity if needed. If none is available, keep the box unchecked. + + if(!haveGPGKeys && !importIdentity()) + ui.reuse_existing_node_CB->setChecked(false); + } + + initKeyList(); + setupState(); +} + +void GenCertDialog::initKeyList() { std::cerr << "Finding PGPUsers" << std::endl; @@ -189,62 +204,19 @@ void GenCertDialog::init() std::list pgpIds; std::list::iterator it; haveGPGKeys = false; -#ifdef TO_REMOVE - /* replace with true/false below */ - if (!mOnlyGenerateIdentity) { -#endif - if (RsAccounts::GetPGPLogins(pgpIds)) { - for(it = pgpIds.begin(); it != pgpIds.end(); ++it) - { - QVariant userData(QString::fromStdString( (*it).toStdString() )); - std::string name, email; - RsAccounts::GetPGPLoginDetails(*it, name, email); - std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl; - QString gid = QString::fromStdString( (*it).toStdString()).right(8) ; - ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData); - haveGPGKeys = true; - } + + if (RsAccounts::GetPGPLogins(pgpIds)) { + for(it = pgpIds.begin(); it != pgpIds.end(); ++it) + { + QVariant userData(QString::fromStdString( (*it).toStdString() )); + std::string name, email; + RsAccounts::GetPGPLoginDetails(*it, name, email); + std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl; + QString gid = QString::fromStdString( (*it).toStdString()).right(8) ; + ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData); + haveGPGKeys = true; } -#ifdef TO_REMOVE } -#endif - if (haveGPGKeys) { - ui.no_gpg_key_label->hide(); - ui.header_label->show(); - ui.reuse_existing_node_CB->setChecked(false); - setWindowTitle(tr("Create new node")); - ui.genButton->setText(tr("Generate new node")); - ui.headerFrame->setHeaderText(tr("Create a new node")); - genNewGPGKey = false; - } else { - ui.no_gpg_key_label->setVisible(!mOnlyGenerateIdentity); - ui.header_label->setVisible(mOnlyGenerateIdentity); - ui.reuse_existing_node_CB->setChecked(true); - ui.reuse_existing_node_CB->setEnabled(true); - setWindowTitle(tr("Create new profile")); - ui.genButton->setText(tr("Generate new profile and node")); - ui.headerFrame->setHeaderText(tr("Create a new profile and node")); - genNewGPGKey = true; - } - -#ifdef TO_REMOVE - QString text; /* = ui.header_label->text() + "\n";*/ - text += tr("You can create a new profile with this form."); - - if (mOnlyGenerateIdentity) { - ui.new_gpg_key_checkbox->setChecked(true); - ui.new_gpg_key_checkbox->hide(); -#endif - ui.genprofileinfo_label->hide(); -#ifdef TO_REMOVE - } else { - text += "\n"; - text += tr("Alternatively you can use an existing profile. Just uncheck \"Create a new profile\""); - } - ui.header_label->setText(text); -#endif - setupState(); - //updateUiSetup(); } void GenCertDialog::mouseMoveEvent(QMouseEvent *e) @@ -257,6 +229,13 @@ void GenCertDialog::mouseMoveEvent(QMouseEvent *e) void GenCertDialog::setupState() { bool adv_state = ui.adv_checkbox->isChecked(); + + if(!adv_state) + { + ui.reuse_existing_node_CB->setChecked(false) ; + ui.nodeType_CB->setCurrentIndex(0) ; + ui.keylength_comboBox->setCurrentIndex(0) ; + } bool hidden_state = ui.nodeType_CB->currentIndex()==1; bool generate_new = !ui.reuse_existing_node_CB->isChecked(); @@ -270,10 +249,10 @@ void GenCertDialog::setupState() ui.label_nodeType->setVisible(adv_state) ; ui.nodeType_CB->setVisible(adv_state) ; ui.reuse_existing_node_CB->setVisible(adv_state) ; - ui.importIdentity_PB->setVisible(adv_state) ; - ui.exportIdentity_PB->setVisible(adv_state) ; + ui.importIdentity_PB->setVisible(adv_state && !generate_new) ; + ui.exportIdentity_PB->setVisible(adv_state && !generate_new) ; - ui.genPGPuser->setVisible(adv_state && haveGPGKeys) ; + ui.genPGPuser->setVisible(adv_state && haveGPGKeys && !generate_new) ; ui.genprofileinfo_label->setVisible(false); ui.no_gpg_key_label->setText(tr("Welcome to Retroshare. Before you can proceed you need to create a profile and associate a node with it. To do so please fill out this form.\nAlternatively you can import a (previously exported) profile. Just uncheck \"Create a new profile\"")); @@ -282,8 +261,10 @@ void GenCertDialog::setupState() ui.nickname_label->setVisible(adv_state) ; ui.nickname_input->setVisible(adv_state) ; - ui.name_label->setVisible(!generate_new); - ui.name_input->setVisible(!generate_new); + ui.name_label->setVisible(true); + ui.name_input->setVisible(generate_new); + + ui.header_label->setVisible(false) ; ui.nickname_label->setVisible(adv_state && !mOnlyGenerateIdentity); ui.nickname_input->setVisible(adv_state && !mOnlyGenerateIdentity); @@ -328,14 +309,14 @@ void GenCertDialog::exportIdentity() QMessageBox::information(this,tr("Profile not saved"),tr("Your profile was not saved. An error occurred.")) ; } -void GenCertDialog::importIdentity() +bool GenCertDialog::importIdentity() { QString fname ; if(!misc::getOpenFileName(this,RshareSettings::LASTDIR_CERT,tr("Import profile"), tr("RetroShare profile files (*.asc);;All files (*)"),fname)) - return ; + return false; if(fname.isNull()) - return ; + return false; RsPgpId gpg_id ; std::string err_string ; @@ -343,7 +324,7 @@ void GenCertDialog::importIdentity() if(!RsAccounts::ImportIdentity(fname.toStdString(),gpg_id,err_string)) { QMessageBox::information(this,tr("Profile not loaded"),tr("Your profile was not loaded properly:")+" \n "+QString::fromStdString(err_string)) ; - return ; + return false; } else { @@ -353,9 +334,9 @@ void GenCertDialog::importIdentity() std::cerr << "Adding PGPUser: " << name << " id: " << gpg_id << std::endl; QMessageBox::information(this,tr("New profile imported"),tr("Your profile was imported successfully:")+" \n"+"\nName :"+QString::fromStdString(name)+"\nemail: " + QString::fromStdString(email)+"\nKey ID: "+QString::fromStdString(gpg_id.toStdString())+"\n\n"+tr("You can use it now to create a new node.")) ; - } - init() ; + return true ; + } } void GenCertDialog::genPerson() diff --git a/retroshare-gui/src/gui/GenCertDialog.h b/retroshare-gui/src/gui/GenCertDialog.h index f84d29f17..51cfaa19c 100644 --- a/retroshare-gui/src/gui/GenCertDialog.h +++ b/retroshare-gui/src/gui/GenCertDialog.h @@ -39,13 +39,14 @@ public: QString getGXSNickname() {return mGXSNickname;} private slots: void genPerson(); - void importIdentity(); + bool importIdentity(); void exportIdentity(); void setupState(); + void switchReuseExistingNode(); void grabMouse(); private: - void init(); + void initKeyList(); /** Qt Designer generated object */ Ui::GenCertDialog ui; diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index 06c17f778..45c93e39d 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -496,86 +496,6 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 178 - - - - - - - 255 - 255 - 178 - - - - - - - - true - - - QFrame::Box - - - <html><head/><body><p align="justify">Before proceeding, move your mouse around to help Retroshare collect as much randomness as possible. Filling the progressbar to 20% is needed, 100% is advised.</p></body></html> - - - true - - - @@ -685,7 +605,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - Import new profile + Import profile @@ -700,6 +620,86 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p
+ + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + QFrame::Box + + + <html><head/><body><p align="justify">Before proceeding, move your mouse around to help Retroshare collect as much randomness as possible. Filling the progressbar to 20% is required, 100% is advised.</p></body></html> + + + true + + +
From bc8aac1ca64c9effb31a321b643a85d5041898ea Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 2 Feb 2017 17:15:32 +0100 Subject: [PATCH 11/28] Added warn messagebox before send invite --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 10 +++++++--- retroshare-gui/src/gui/feeds/MsgItem.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 239a6b592..eda2290f2 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -2463,10 +2463,14 @@ void IdDialog::sendInvite() RsGxsId id(ui->lineEdit_KeyId->text().toStdString()); - MessageComposer::sendInvite(id); + if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) + { + MessageComposer::sendInvite(id); + ui->inviteFrame->show(); + ui->inviteButton->setEnabled(false); + } - ui->inviteFrame->show(); - ui->inviteButton->setEnabled(false); + } void IdDialog::negativePerson() diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 21ecdb321..9c219eb77 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -19,6 +19,7 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ +#include #include #include @@ -365,7 +366,9 @@ void MsgItem::sendInvite() if (!rsMail->getMessage(mMsgId, mi)) return; - - MessageComposer::sendInvite(mi.rsgxsid_srcId); + if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) + { + MessageComposer::sendInvite(mi.rsgxsid_srcId); + } } From 3baaae7a88f3659cf0468ada717e925682fee053 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 2 Feb 2017 17:58:48 +0100 Subject: [PATCH 12/28] Fixed People Header Text color Moved info frame for Invite to Top Header --- retroshare-gui/src/gui/Identity/IdDialog.ui | 324 +++++++++--------- .../src/gui/qss/stylesheet/Standard.qss | 4 + 2 files changed, 174 insertions(+), 154 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index b3bfbddfb..96746244c 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -6,8 +6,8 @@ 0 0 - 1269 - 793 + 1048 + 656 @@ -317,6 +317,174 @@ + + + + + + Qt::Vertical + + + + 518 + 17 + + + + + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + + + + QFrame::Box + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 16 + 16 + + + + + + + :/images/info16.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Invite messages stay into your Outbox until an acknowledgement of receipt has been received. + + + + + + + + 16 + 16 + + + + Qt::NoFocus + + + Close + + + QToolButton +{ + border-image: url(:/images/closenormal.png) +} + +QToolButton:hover +{ +border-image: url(:/images/closehover.png) +} + +QToolButton:pressed { +border-image: url(:/images/closepressed.png) +} + + + true + + + + + + + +
@@ -681,157 +849,6 @@ p, li { white-space: pre-wrap; } - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 178 - - - - - - - 255 - 255 - 178 - - - - - - - - true - - - - - - QFrame::Box - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - - 16 - 16 - - - - - - - :/images/info16.png - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Invite messages stay into your Outbox until an acknowledgement of receipt has been received. - - - - - - - - 16 - 16 - - - - Qt::NoFocus - - - Close - - - QToolButton -{ - border-image: url(:/images/closenormal.png) -} - -QToolButton:hover -{ -border-image: url(:/images/closehover.png) -} - -QToolButton:pressed { -border-image: url(:/images/closepressed.png) -} - - - true - - - - - - @@ -1023,7 +1040,6 @@ border-image: url(:/images/closepressed.png) - diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 16a40f481..9b4e263be 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -614,6 +614,10 @@ IdDialog QLabel#headerTextLabel { color: rgb(255, 255, 255); } +IdDialog QLabel#headerTextLabel_Person { + color: rgb(255, 255, 255); +} + IdDialog QLabel#headerTextLabel_Circles { color: rgb(255, 255, 255); } From a9b7ed31a1463d917dad9b956cbb366343ec49eb Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 2 Feb 2017 21:48:18 +0100 Subject: [PATCH 13/28] attempt to make the login creation window look better --- retroshare-gui/src/gui/GenCertDialog.ui | 70 ++++++++++--------- .../src/gui/qss/stylesheet/Standard.qss | 7 +- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index 45c93e39d..066e26c67 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -7,7 +7,7 @@ 0 0 1745 - 1193 + 1296 @@ -36,7 +36,7 @@ - + 0 0 @@ -358,13 +358,6 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - - - 24 - - - @@ -478,6 +471,12 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + 0 + 0 + + <html><head/><body><p>This can be a Tor Onion address of the form: xa76giaf6ifda7ri63i263.onion <br/>or an I2P address in the form: [52 characters].b32.i2p </p><p>In order to get one, you must configure either Tor or I2P to create a new hidden service / server tunnel. If you do not yet have one, you can still go on, and make it right later in RetroShare's Options-&gt;Network-&gt;Hidden Service configuration panel.</p></body></html> @@ -509,16 +508,6 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - - - - - - Go! - - - @@ -620,6 +609,19 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -700,22 +702,26 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + + 24 + + + + + + + + + + Go! + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 365a8f9f1..28c4906bf 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -295,13 +295,14 @@ GetStartedDialog QTextEdit { /* GenCertDialog */ -GenCertDialog > QFrame#headerFrame { +/* GenCertDialog > QFrame#headerFrame { background-image: url(:/images/genbackground.png); } GenCertDialog > QFrame#headerFrame > QLabel#headerLabel { color: rgb(255, 255, 255); } +*/ /* ConnectFriendWizard */ @@ -642,8 +643,8 @@ IdEditDialog QLabel#info_label GenCertDialog QPushButton#genButton { border-image: url(:/images/btn_blue.png) 4; border-width: 4; - padding: 0px 6px; - font-size: 16px; +/* padding: 0px 6px;*/ +/* font-size: 16px; */ font: bold; color: white; } From 389eff04002bbf381c893b20e3658e9d56e63701 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 2 Feb 2017 22:05:28 +0100 Subject: [PATCH 14/28] improved the qss and look of login window --- retroshare-gui/src/gui/GenCertDialog.cpp | 14 +++--- retroshare-gui/src/gui/GenCertDialog.ui | 27 +--------- .../src/gui/qss/stylesheet/Standard.qss | 49 ++++++++++++++++++- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 12aeb937d..21c5e893e 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -133,8 +133,8 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - ui.headerFrame->setHeaderImage(QPixmap(":/icons/svg/profile.svg")); - ui.headerFrame->setHeaderText(tr("Create a new profile")); + //ui.headerFrame->setHeaderImage(QPixmap(":/icons/svg/profile.svg")); + //ui.headerFrame->setHeaderText(tr("Create a new profile")); connect(ui.reuse_existing_node_CB, SIGNAL(clicked()), this, SLOT(switchReuseExistingNode())); connect(ui.adv_checkbox, SIGNAL(clicked()), this, SLOT(setupState())); @@ -158,15 +158,15 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) #if QT_VERSION >= 0x040700 ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ; ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Tor/I2P address - Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ; - ui.name_input->setPlaceholderText(tr("[Required] Visible to your friends, and friends of friends.")); + ui.name_input->setPlaceholderText(tr("[Required] Identifies your Retrohare node(s). Visible to your friends, and friends of friends.")); ui.nickname_input->setPlaceholderText(tr("[Optional] Used when you write in chat lobbies, forums and channel comments. Can be setup later if you need one.")); - ui.password_input->setPlaceholderText(tr("[Required] This password protects your node key.")); + ui.password_input->setPlaceholderText(tr("[Required] This password protects your data and is required when re-start.")); ui.password_input_2->setPlaceholderText(tr("[Required] Type the same password again here.")); #endif ui.nickname_input->setMaxLength(RSID_MAXIMUM_NICKNAME_SIZE); - ui.node_input->setToolTip(tr("Enter a meaningful node description. e.g. : home, laptop, etc. \nThis field will be used to differentiate different installations with\nthe same profile (PGP key pair).")) ; + ui.node_input->setToolTip(tr("Enter a meaningful node description. e.g. : home, laptop, etc. \nThis field will be used to differentiate different Retroshare nodes for\nthe same profile.")) ; /* get all available pgp private certificates.... * mark last one as default. @@ -243,8 +243,8 @@ void GenCertDialog::setupState() ui.no_node_label->setVisible(false); - setWindowTitle(generate_new?tr("Create new profile and node"):tr("Create new node")); - ui.headerFrame->setHeaderText(generate_new?tr("Create a new profile and node"):tr("Create a new node")); + setWindowTitle(generate_new?tr("Create new profile and new Retroshare node"):tr("Create new Retroshare node")); + //ui.headerFrame->setHeaderText(generate_new?tr("Create a new profile and node"):tr("Create a new node")); ui.label_nodeType->setVisible(adv_state) ; ui.nodeType_CB->setVisible(adv_state) ; diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index 066e26c67..ffef7a78c 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -33,25 +33,6 @@ 0 - - - - - 0 - 0 - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - @@ -601,7 +582,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - Re-use existing profile + Re-use an existing profile @@ -725,12 +706,6 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - HeaderFrame - QFrame -
gui/common/HeaderFrame.h
- 1 -
StyledLabel QLabel diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 28c4906bf..288024a42 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -639,7 +639,54 @@ IdEditDialog QLabel#info_label background: #FFFFD7; background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); } - +GenCertDialog QComboBox#genPGPuser { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} +GenCertDialog QSpinBox#hiddenport_spinBox { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} +GenCertDialog QLineEdit#hiddenaddr_input { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} +GenCertDialog QLineEdit#password_input_2 { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} +GenCertDialog QLineEdit#password_input { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} +GenCertDialog QLineEdit#nickname_input { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} +GenCertDialog QLineEdit#node_input { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} +GenCertDialog QLineEdit#name_input { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + font: bold; +} GenCertDialog QPushButton#genButton { border-image: url(:/images/btn_blue.png) 4; border-width: 4; From 80e6742ab52eece3e149824c7ee6e8c62bdcfa22 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 3 Feb 2017 11:45:00 +0100 Subject: [PATCH 15/28] teaking of the css file --- .../src/gui/qss/stylesheet/Standard.qss | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 288024a42..e5727104a 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -640,49 +640,49 @@ IdEditDialog QLabel#info_label background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); } GenCertDialog QComboBox#genPGPuser { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; } GenCertDialog QSpinBox#hiddenport_spinBox { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; } GenCertDialog QLineEdit#hiddenaddr_input { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; } GenCertDialog QLineEdit#password_input_2 { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; } GenCertDialog QLineEdit#password_input { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; } GenCertDialog QLineEdit#nickname_input { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; } GenCertDialog QLineEdit#node_input { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; } GenCertDialog QLineEdit#name_input { - border: 2px solid #0099cc; + border: 4px solid #0099cc; border-radius: 6px; background: white; font: bold; From 865a5741b201c8d83dc0d59678d1a0e26d440280 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 5 Feb 2017 14:34:33 +0100 Subject: [PATCH 16/28] Fix DisableSysTrayToolTip Option --- retroshare-gui/src/gui/MainWindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 807b43667..2a23f9d5a 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -679,8 +679,6 @@ void MainWindow::updateStatus() // This call is essential to remove locks due to QEventLoop re-entrance while asking gpg passwds. Dont' remove it! if(RsAutoUpdatePage::eventsLocked()) return; - if(Settings->valueFromGroup("StatusBar", "DisableSysTrayToolTip", QVariant(false)).toBool()) - return; float downKb = 0; float upKb = 0; rsConfig->GetCurrentDataRates(downKb, upKb); @@ -698,6 +696,8 @@ void MainWindow::updateStatus() discstatus->update(); } + if(!Settings->valueFromGroup("StatusBar", "DisableSysTrayToolTip", QVariant(false)).toBool()) { + QString tray = "RetroShare\n" + tr("Down: %1 (kB/s)").arg(downKb, 0, 'f', 2) + " | " + tr("Up: %1 (kB/s)").arg(upKb, 0, 'f', 2) + "\n"; if (onlineCount == 1) { @@ -713,6 +713,7 @@ void MainWindow::updateStatus() tray += notifyToolTip; } trayIcon->setToolTip(tray); + } } void MainWindow::updateFriends() From d0ab10cc3894052da74a6e2a82e03f83c5c3556a Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sun, 5 Feb 2017 19:13:40 +0100 Subject: [PATCH 17/28] Fix slow emoticons by using generic regex rules where possible. --- retroshare-gui/src/util/HandleRichText.cpp | 79 +++++++++++++++------- retroshare-gui/src/util/HandleRichText.h | 3 + 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/retroshare-gui/src/util/HandleRichText.cpp b/retroshare-gui/src/util/HandleRichText.cpp index 865bce7e0..f8299687a 100644 --- a/retroshare-gui/src/util/HandleRichText.cpp +++ b/retroshare-gui/src/util/HandleRichText.cpp @@ -168,6 +168,13 @@ RsHtml::RsHtml() void RsHtml::initEmoticons(const QHash, QHash > >& hash) { + //add rules for standard emoticons + QString genericpattern; + genericpattern += "(?:^|\\s)(:\\w{1,40}:)(?:$|\\s)|"; //generic rule for :emoji_name: + genericpattern += "(?:^|\\s)(\\(\\w{1,40}\\))(?:$|\\s)"; //generic rule for (emoji_name) + QRegExp genericrx(genericpattern); + genericrx.setMinimal(true); + QString newRE; for(QHash, QHash > >::const_iterator groupit = hash.begin(); groupit != hash.end(); ++groupit) { QHash group = groupit.value().second; @@ -177,38 +184,42 @@ void RsHtml::initEmoticons(const QHash, QHash(embedInfos); + + while((index = rx.indexIn(text, pos)) != -1) { + if(embedImg.smileys.contains(rx.cap(0).trimmed())) + return index; + else + ++pos; + } + return -1; +} + /** * Parses a DOM tree and replaces text by HTML tags. * The tree is traversed depth-first, but only through children of Element type @@ -376,13 +403,13 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme if(myRE.pattern().length() == 0) // we'll get stuck with an empty regexp return; - if(myRE.indexIn(tempText) == -1) + int nextPos = 0; + if((nextPos = indexInWithValidation(myRE, tempText, embedInfos)) == -1) continue; // there is at least one link inside, we start replacing int currentPos = 0; - int nextPos = 0; - while((nextPos = myRE.indexIn(tempText, currentPos)) != -1) { + do { // if nextPos == 0 it means the text begins by a link if(nextPos > 0) { QDomText textPart = doc.createTextNode(tempText.mid(currentPos, nextPos - currentPos)); @@ -439,7 +466,7 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme index++; currentPos = nextPos + myRE.matchedLength(); - } + } while((nextPos = indexInWithValidation(myRE, tempText, embedInfos, currentPos)) != -1); // text after the last link, only if there's one, don't touch the index // otherwise decrement the index because we're going to remove node diff --git a/retroshare-gui/src/util/HandleRichText.h b/retroshare-gui/src/util/HandleRichText.h index 2c1ab791a..54036b53c 100644 --- a/retroshare-gui/src/util/HandleRichText.h +++ b/retroshare-gui/src/util/HandleRichText.h @@ -86,6 +86,9 @@ protected: virtual bool canReplaceAnchor(QDomDocument &doc, QDomElement &element, const RetroShareLink &link); virtual void anchorTextForImg(QDomDocument &doc, QDomElement &element, const RetroShareLink &link, QString &text); virtual void anchorStylesheetForImg(QDomDocument &doc, QDomElement &element, const RetroShareLink &link, QString &styleSheet); + +private: + int indexInWithValidation(QRegExp &rx, const QString &text, EmbedInHtml &embedInfos, int pos = 0); }; #endif // HANDLE_RICH_TEXT_H_ From d1328f4467bc2fa236196b6ed4d9a8785f188b5b Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sat, 21 Jan 2017 22:53:56 +0100 Subject: [PATCH 18/28] Fix spaces between emoticons in message composer and forum --- retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp | 8 +++++++- retroshare-gui/src/gui/msgs/MessageComposer.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index f73aeef91..23a0bca04 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -400,7 +400,13 @@ void CreateGxsForumMsg::smileyWidgetForums() void CreateGxsForumMsg::addSmileys() { - ui.forumMessage->textCursor().insertText(qobject_cast(sender())->toolTip().split("|").first()); + QString smiley = qobject_cast(sender())->toolTip().split("|").first(); + // add trailing space + smiley += QString(" "); + // add preceding space when needed (not at start of text or preceding space already exists) + if(!ui.forumMessage->textCursor().atStart() && ui.forumMessage->toPlainText()[ui.forumMessage->textCursor().position() - 1] != QChar(' ')) + smiley = QString(" ") + smiley; + ui.forumMessage->textCursor().insertText(smiley); } void CreateGxsForumMsg::addFile() diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index ecd4327e6..a0b2c2e86 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -2200,7 +2200,13 @@ void MessageComposer::smileyWidget() void MessageComposer::addSmileys() { - ui.msgText->textCursor().insertText(qobject_cast(sender())->toolTip().split("|").first()); + QString smiley = qobject_cast(sender())->toolTip().split("|").first(); + // add trailing space + smiley += QString(" "); + // add preceding space when needed (not at start of text or preceding space already exists) + if(!ui.msgText->textCursor().atStart() && ui.msgText->toPlainText()[ui.msgText->textCursor().position() - 1] != QChar(' ')) + smiley = QString(" ") + smiley; + ui.msgText->textCursor().insertText(smiley); } void MessageComposer::currentCharFormatChanged(const QTextCharFormat &format) From 013eb93f70f8180663022ce1bc24b7a81fbf90c5 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 6 Feb 2017 00:11:26 +0100 Subject: [PATCH 19/28] rewrote forum loading method with the proper logarithmic containers --- libretroshare/src/retroshare/rsreputations.h | 2 +- .../src/gui/gxsforums/GxsForumThreadWidget.h | 2 +- .../src/gui/gxsforums/GxsForumsFillThread.cpp | 263 ++++++++++-------- 3 files changed, 151 insertions(+), 116 deletions(-) diff --git a/libretroshare/src/retroshare/rsreputations.h b/libretroshare/src/retroshare/rsreputations.h index b5e9bd8d5..a44f29dc8 100644 --- a/libretroshare/src/retroshare/rsreputations.h +++ b/libretroshare/src/retroshare/rsreputations.h @@ -48,7 +48,7 @@ public: struct ReputationInfo { - ReputationInfo() : mOwnOpinion(OPINION_NEUTRAL), mFriendAverageScore(REPUTATION_THRESHOLD_DEFAULT),mOverallReputationLevel(REPUTATION_NEUTRAL){} + ReputationInfo() : mOwnOpinion(OPINION_NEUTRAL),mFriendsPositiveVotes(0),mFriendsNegativeVotes(0), mFriendAverageScore(REPUTATION_THRESHOLD_DEFAULT),mOverallReputationLevel(REPUTATION_NEUTRAL){} RsReputations::Opinion mOwnOpinion ; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index a2a6eecee..e4ab0b5b4 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -51,7 +51,7 @@ public: unsigned int newCount() { return mNewCount; } unsigned int unreadCount() { return mUnreadCount; } - QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *parent = NULL); + QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *parent); QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId); // Callback for all Loads. diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp index 1a3cf5f57..7a578b6db 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp @@ -31,7 +31,7 @@ #include #include -//#define DEBUG_FORUMS +#define DEBUG_FORUMS #define PROGRESSBAR_MAX 100 @@ -144,9 +144,23 @@ void GxsForumsFillThread::run() emit status(tr("Retrieving")); /* get messages */ - std::vector msgs; - if (!rsGxsForums->getMsgData(token, msgs)) { - return; + std::map msgs; + + { // This forces to delete msgs_array after the conversion to std::map. + + std::vector msgs_array; + + if (!rsGxsForums->getMsgData(token, msgs_array)) { + return; + } + + // now put everything into a map in order to make search log(n) + + for(uint32_t i=0;i > threadList; - QPair threadPair; + + // ThreadList contains the list of parent threads. The algorithm below iterates through all messages + // and tries to establish parenthood relationships between them, given that we only know the + // immediate parent of a message and now its children. Some messages have a missing parent and for them + // a fake top level parent is generated. + + // In order to be efficient, we first create a structure that lists the children of every mesage ID in the list. + // Then the hierarchy of message is build by attaching the kids to every message until all of them have been processed. + // The messages with missing parents will be the last ones remaining in the list. + + std::list > threadStack; + std::map > kids_array ; + std::set missing_parents; - /* add all threads */ - std::vector::iterator msgIt; - for (msgIt = msgs.begin(); msgIt != msgs.end(); ) { - if (wasStopped()) { - break; - } + // The first step is to find the top level thread messages. These are defined as the messages without + // any parent message ID. + + // this trick is needed because while we remove messages, the parents a given msg may already have been removed + // and wrongly understand as a missing parent. - const RsGxsForumMsg &msg = *msgIt; + std::map kept_msgs; - if (!mFlatView && !msg.mMeta.mParentId.isNull()) { - ++msgIt; - continue; - } + for ( std::map::iterator msgIt = msgs.begin(); msgIt != msgs.end();++msgIt) + if(mFlatView || msgIt->second.mMeta.mParentId.isNull()) + { + + /* add all threads */ + if (wasStopped()) + return; + + const RsGxsForumMsg& msg = msgIt->second; #ifdef DEBUG_FORUMS - std::cerr << "GxsForumsFillThread::run() Adding TopLevel Thread: mId: " << msg.mMeta.mMsgId << std::endl; + std::cerr << "GxsForumsFillThread::run() Adding TopLevel Thread: mId: " << msg.mMeta.mMsgId << std::endl; #endif - QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn); - if (!mFlatView) { - threadList.push_back(QPair(msg.mMeta.mMsgId.toStdString(), item)); - } - calculateExpand(msg, item); + QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn,NULL); - mItems.append(item); + if (!mFlatView) + threadStack.push_back(std::make_pair(msg.mMeta.mMsgId,item)) ; - if (++step >= steps) { - step = 0; - emit progress(++pos, PROGRESSBAR_MAX); - } - - msgIt = msgs.erase(msgIt); - } - - /* process messages */ - while (msgs.size()) - { - while (!threadList.empty()) - { - if (wasStopped()) { - break; - } - - threadPair = threadList.front(); - threadList.pop_front(); - -#ifdef DEBUG_FORUMS - std::cerr << "GxsForumsFillThread::run() Getting Children of : " << threadPair.first << std::endl; -#endif - /* iterate through child */ - for (msgIt = msgs.begin(); msgIt != msgs.end(); ) { - const RsGxsForumMsg &msg = *msgIt; - - if (msg.mMeta.mParentId.toStdString() != threadPair.first) { - ++msgIt; - continue; - } - -#ifdef DEBUG_FORUMS - std::cerr << "GxsForumsFillThread::run() adding " << msg.mMeta.mMsgId << std::endl; -#endif - - QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn, threadPair.second); - - calculateExpand(msg, item); - - /* add item to process list */ - threadList.push_back(QPair(msg.mMeta.mMsgId.toStdString(), item)); - - if (++step >= steps) { - step = 0; - emit progress(++pos, PROGRESSBAR_MAX); - } - - msgIt = msgs.erase(msgIt); - } - } - - if (wasStopped()) { - break; - } - - /* process missing messages */ - - /* search for a message with missing parent */ - for (msgIt = msgs.begin(); msgIt != msgs.end(); ++msgIt) { - const RsGxsForumMsg &msg = *msgIt; - - /* search for parent */ - std::vector::iterator msgIt1; - for (msgIt1 = msgs.begin(); msgIt1 != msgs.end(); ++msgIt1) { - if (wasStopped()) { - break; - } - - const RsGxsForumMsg &msg1 = *msgIt1; - - if (msg.mMeta.mParentId == msg1.mMeta.mMsgId) { - /* found parent */ - break; - } - } - - if (wasStopped()) { - break; - } - - if (msgIt1 != msgs.end()) { - /* parant found */ - continue; - } - - /* add dummy item */ - QTreeWidgetItem *item = mParent->generateMissingItem(msg.mMeta.mParentId); - threadList.push_back(QPair(msg.mMeta.mParentId.toStdString(), item)); + calculateExpand(msg, item); mItems.append(item); - break; + + if (++step >= steps) { + step = 0; + emit progress(++pos, PROGRESSBAR_MAX); + } } + else + { +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumsFillThread::run() Storing kid " << msgIt->first << " of message " << msgIt->second.mMeta.mParentId << std::endl; +#endif + // The same missing parent may appear multiple times, so we first store them into a unique container. + + if(msgs.find(msgIt->second.mMeta.mParentId) == msgs.end()) + missing_parents.insert(msgIt->second.mMeta.mParentId); + + kids_array[msgIt->second.mMeta.mParentId].push_back(msgIt->first) ; + kept_msgs.insert(*msgIt) ; + } + + msgs = kept_msgs; + + // Add a fake toplevel item for the parent IDs that we dont actually have. + + for(std::set::const_iterator it(missing_parents.begin());it!=missing_parents.end();++it) + { + // add dummy parent item + QTreeWidgetItem *parent = mParent->generateMissingItem(*it); + mItems.append( parent ); + + threadStack.push_back(std::make_pair(*it,parent)) ; + } +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumsFillThread::run() Processing stack:" << std::endl; +#endif + // Now use a stack to go down the hierarchy + + while (!threadStack.empty()) + { + std::pair threadPair = threadStack.front(); + threadStack.pop_front(); + + std::map >::iterator it = kids_array.find(threadPair.first) ; + +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumsFillThread::run() Node: " << threadPair.first << std::endl; +#endif + if(it == kids_array.end()) + continue ; + + if (wasStopped()) + return; + + for(std::list::const_iterator it2(it->second.begin());it2!=it->second.end();++it2) + { + // We iterate through the top level thread items, and look for which message has the current item as parent. + // When found, the item is put in the thread list itself, as a potential new parent. + + std::map::iterator mit = msgs.find(*it2) ; + + if(mit == msgs.end()) + { + std::cerr << "GxsForumsFillThread::run() Cannot find submessage " << *it2 << " !!!" << std::endl; + continue ; + } + + const RsGxsForumMsg& msg(mit->second) ; +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumsFillThread::run() adding sub_item " << msg.mMeta.mMsgId << std::endl; +#endif + + QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn, threadPair.second); + calculateExpand(msg, item); + + /* add item to process list */ + threadStack.push_back(std::make_pair(msg.mMeta.mMsgId, item)); + + if (++step >= steps) { + step = 0; + emit progress(++pos, PROGRESSBAR_MAX); + } + + msgs.erase(mit); + } + +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumsFillThread::run() Erasing entry " << it->first << " from kids tab." << std::endl; +#endif + kids_array.erase(it) ; // This is not strictly needed, but it improves performance by reducing the search space. } #ifdef DEBUG_FORUMS + std::cerr << "Kids array now has " << kids_array.size() << " elements" << std::endl; + for(std::map >::const_iterator it(kids_array.begin());it!=kids_array.end();++it) + { + std::cerr << "Node " << it->first << std::endl; + for(std::list::const_iterator it2(it->second.begin());it2!=it->second.end();++it2) + std::cerr << " " << *it2 << std::endl; + } + std::cerr << "GxsForumsFillThread::run() stopped: " << (wasStopped() ? "yes" : "no") << std::endl; #endif } + + From 6a9b697e421f8487d89ac4f4c95c4cd3ca0a2d30 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 6 Feb 2017 23:46:01 +0100 Subject: [PATCH 20/28] made RsReputation::overallReputationLevel() to also return the identity ownership flags so that we dont need to rely on async calls to p3IdService to get them --- libretroshare/src/gxs/rsgixs.h | 2 +- libretroshare/src/retroshare/rsreputations.h | 5 ++- libretroshare/src/services/p3gxsreputation.cc | 33 ++++++++++++++++++- libretroshare/src/services/p3gxsreputation.h | 3 +- .../gui/gxsforums/GxsForumThreadWidget.cpp | 14 +++----- .../src/gui/gxsforums/GxsForumsFillThread.cpp | 4 ++- 6 files changed, 46 insertions(+), 15 deletions(-) diff --git a/libretroshare/src/gxs/rsgixs.h b/libretroshare/src/gxs/rsgixs.h index 22993b65f..2f2c0f0ec 100644 --- a/libretroshare/src/gxs/rsgixs.h +++ b/libretroshare/src/gxs/rsgixs.h @@ -177,7 +177,7 @@ class RsGixsReputation { public: // get Reputation. - virtual RsReputations::ReputationLevel overallReputationLevel(const RsGxsId& id) = 0; + virtual RsReputations::ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL) = 0; }; /*** This Class pulls all the GXS Interfaces together ****/ diff --git a/libretroshare/src/retroshare/rsreputations.h b/libretroshare/src/retroshare/rsreputations.h index a44f29dc8..105de420a 100644 --- a/libretroshare/src/retroshare/rsreputations.h +++ b/libretroshare/src/retroshare/rsreputations.h @@ -63,7 +63,10 @@ public: virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) =0; virtual bool getOwnOpinion(const RsGxsId& key_id, Opinion& op) =0; virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info,bool stamp=true) =0; - virtual ReputationLevel overallReputationLevel(const RsGxsId& id)=0; + + // This returns the reputation level and also the flags of the identity service for that id. This is useful in order to get these flags without relying on the async method of p3Identity + + virtual ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL)=0; // parameters diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index 0152909ef..0f5650df7 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -768,14 +768,45 @@ bool p3GxsReputation::updateLatestUpdate(RsPeerId peerid,time_t latest_update) * Opinion ****/ -RsReputations::ReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id) +RsReputations::ReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags) { ReputationInfo info ; getReputationInfo(id,RsPgpId(),info) ; + RsPgpId owner_id ; + + if(identity_flags) + getIdentityFlagsAndOwnerId(id,*identity_flags,owner_id); + return info.mOverallReputationLevel ; } +bool p3GxsReputation::getIdentityFlagsAndOwnerId(const RsGxsId& gxsid, uint32_t& identity_flags,RsPgpId& owner_id) +{ + if(gxsid.isNull()) + return false ; + + RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ + + std::map::iterator it = mReputations.find(gxsid) ; + + if(it == mReputations.end()) + return false ; + + if(!(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_UP_TO_DATE)) + return false ; + + if(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_LINKED) + identity_flags |= RS_IDENTITY_FLAGS_PGP_LINKED ; + + if(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_KNOWN) + identity_flags |= RS_IDENTITY_FLAGS_PGP_KNOWN ; + + owner_id = it->second.mOwnerNode ; + + return true ; +} + bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& ownerNode, RsReputations::ReputationInfo& info, bool stamp) { if(gxsid.isNull()) diff --git a/libretroshare/src/services/p3gxsreputation.h b/libretroshare/src/services/p3gxsreputation.h index d8ca3a39c..baabdaa43 100644 --- a/libretroshare/src/services/p3gxsreputation.h +++ b/libretroshare/src/services/p3gxsreputation.h @@ -115,7 +115,7 @@ public: virtual bool isNodeBanned(const RsPgpId& id); virtual void banNode(const RsPgpId& id,bool b) ; - virtual ReputationLevel overallReputationLevel(const RsGxsId& id); + virtual ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL); virtual void setNodeAutoPositiveOpinionForContacts(bool b) ; virtual bool nodeAutoPositiveOpinionForContacts() ; @@ -143,6 +143,7 @@ public: virtual bool loadList(std::list& load) ; private: + bool getIdentityFlagsAndOwnerId(const RsGxsId& gxsid, uint32_t& identity_flags, RsPgpId &owner_id); bool processIncoming(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index dff2f5546..841e77f77 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -1110,18 +1110,12 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum // Early check for a message that should be hidden because its author // is flagged with a bad reputation - RsIdentityDetails iddetails; - RsReputations::ReputationLevel reputation_level = RsReputations::REPUTATION_NEUTRAL; + uint32_t idflags =0; + RsReputations::ReputationLevel reputation_level = rsReputations->overallReputationLevel(msg.mMeta.mAuthorId,&idflags) ; bool redacted = false; - if( rsIdentity->getIdDetails(msg.mMeta.mAuthorId,iddetails) ) - { - reputation_level = iddetails.mReputation.mOverallReputationLevel; - redacted = (reputation_level == RsReputations::REPUTATION_LOCALLY_NEGATIVE); - } - else - reputation_level = RsReputations::REPUTATION_UNKNOWN; + redacted = (reputation_level == RsReputations::REPUTATION_LOCALLY_NEGATIVE); GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_AVATAR ); item->moveToThread(ui->threadTreeWidget->thread()); @@ -1144,7 +1138,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum rep_warning_level = 2 ; rep_tooltip_str = tr("You have banned this ID. The message will not be\ndisplayed nor forwarded to your friends.") ; } - else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(mForumGroup.mMeta.mSignFlags,iddetails.mFlags)) + else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(mForumGroup.mMeta.mSignFlags,idflags)) { rep_warning_level = 1 ; rep_tooltip_str = tr("You have not set an opinion for this person,\n and your friends do not vote positively: Spam regulation \nprevents the message to be forwarded to your friends.") ; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp index 7a578b6db..4c381ce42 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp @@ -31,7 +31,7 @@ #include #include -#define DEBUG_FORUMS +//#define DEBUG_FORUMS #define PROGRESSBAR_MAX 100 @@ -158,7 +158,9 @@ void GxsForumsFillThread::run() for(uint32_t i=0;i Date: Tue, 7 Feb 2017 17:01:36 +0100 Subject: [PATCH 21/28] Added invite info frame for Friend Request Messages. --- retroshare-gui/src/gui/feeds/MsgItem.cpp | 4 + retroshare-gui/src/gui/feeds/MsgItem.ui | 128 ++++++++++++++- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 26 +++ retroshare-gui/src/gui/msgs/MessageWidget.h | 2 + retroshare-gui/src/gui/msgs/MessageWidget.ui | 148 +++++++++++++++++- .../src/gui/qss/stylesheet/Standard.qss | 22 ++- 6 files changed, 320 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 9c219eb77..8bed391bd 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -67,6 +67,7 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId, expandFrame->hide(); + inviteFrame->hide(); updateItemStatic(); updateItem(); @@ -119,12 +120,15 @@ void MsgItem::updateItemStatic() if (mi.msgflags & RS_MSG_USER_REQUEST) { title = QString::fromUtf8(mi.title.c_str()) + " " + tr("from") + " " + srcName; + replyButton->setText(tr("Reply to invite")); subjectLabel->hide(); + inviteFrame->show(); } else { title = tr("Message From") + ": " + srcName; sendinviteButton->hide(); + inviteFrame->hide(); } } else diff --git a/retroshare-gui/src/gui/feeds/MsgItem.ui b/retroshare-gui/src/gui/feeds/MsgItem.ui index 138f810a6..a14bfedd7 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.ui +++ b/retroshare-gui/src/gui/feeds/MsgItem.ui @@ -6,8 +6,8 @@ 0 0 - 643 - 146 + 707 + 180 @@ -120,7 +120,7 @@ 0 - + @@ -189,7 +189,7 @@ - + @@ -205,7 +205,7 @@ - + @@ -332,6 +332,123 @@ + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + + + + QFrame::Box + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 16 + 16 + + + + + + + :/images/info16.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + You get Invite, accept request and send your own Certificate back + + + + + +
@@ -376,6 +493,7 @@
+ diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index bf1cafee3..249a05118 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -135,6 +135,7 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview())); connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended())); connect(ui.msgText, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); + connect(ui.sendinviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged())); connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged())); @@ -173,6 +174,8 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f } ui.dateText-> setText(""); + + ui.inviteFrame->hide(); } MessageWidget::~MessageWidget() @@ -478,6 +481,12 @@ void MessageWidget::fill(const std::string &msgId) std::cerr << "MessageWidget::fill() Couldn't find Msg" << std::endl; return; } + + if (msgInfo.msgflags & RS_MSG_USER_REQUEST){ + ui.inviteFrame->show(); + } else { + ui.inviteFrame->hide(); + } const std::list &recList = msgInfo.files; std::list::const_iterator it; @@ -738,3 +747,20 @@ void MessageWidget::loadImagesAlways() rsMail->MessageLoadEmbeddedImages(currMsgId, true); } + +void MessageWidget::sendInvite() +{ + MessageInfo mi; + + if (!rsMail) + return; + + if (!rsMail->getMessage(currMsgId, mi)) + return; + + if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) + { + MessageComposer::sendInvite(mi.rsgxsid_srcId); + } + +} diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.h b/retroshare-gui/src/gui/msgs/MessageWidget.h index ef4b4ce56..e4d26068b 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.h +++ b/retroshare-gui/src/gui/msgs/MessageWidget.h @@ -69,6 +69,8 @@ private slots: void printPreview(); void saveAs(); void refill(); + void sendInvite(); + void msgfilelistWidgetCostumPopupMenu(QPoint); void messagesTagsChanged(); diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.ui b/retroshare-gui/src/gui/msgs/MessageWidget.ui index 7d85aa95c..76dd0020c 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.ui +++ b/retroshare-gui/src/gui/msgs/MessageWidget.ui @@ -288,11 +288,157 @@ + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + + + + QFrame::Box + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 16 + 16 + + + + + + + :/images/info16.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + You get Invite, accept request and send your own Certificate back + + + + + + + Send Invite + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - + + 0 + + + 0 + + + 0 + + 0 diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 9b4e263be..007088ae7 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -439,10 +439,17 @@ PeerItem QLabel#peerNameLabel { color: #990033 } -MsgItem > QFrame#frame { - border: 2px solid #3EA2FF; - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2291E0, stop: 1 #3EB3FF); - border-radius: 10px; +MsgItem QFrame#frame { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; +} + +MsgItem QFrame#inviteFrame { + border: 1px solid #DCDC41; + border-radius: 6px; + background: #FFFFD7; + background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); } MsgItem QWidget#avatar { @@ -553,6 +560,13 @@ MessageWidget QFrame#decryptFrame { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #CCFFCC, stop:1 #AAFFAA); } +MessageWidget QFrame#inviteFrame { + border: 1px solid #DCDC41; + border-radius: 6px; + background: #FFFFD7; + background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); +} + /* Posted Links */ PostedCreatePostDialog QLabel#info_label { From 37f3e1a62aff71bf23b15db61ad5176c1304abc1 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 7 Feb 2017 20:15:55 +0100 Subject: [PATCH 22/28] fixed problem in ID creation code. --- libresapi/src/api/ForumHandler.cpp | 2 +- libresapi/src/api/IdentityHandler.cpp | 3 +- libretroshare/src/gxs/rsgenexchange.cc | 4 ++- libretroshare/src/retroshare/rsidentity.h | 8 +++-- libretroshare/src/services/p3gxscircles.cc | 2 +- libretroshare/src/services/p3idservice.cc | 36 +++++++++++++------ .../src/gui/Circles/CreateCircleDialog.cpp | 6 ++-- .../src/gui/Identity/IdDetailsDialog.cpp | 6 ++-- retroshare-gui/src/gui/Identity/IdDialog.cpp | 8 ++--- .../src/gui/Identity/IdEditDialog.cpp | 2 +- .../libretroshare/services/gxs/GxsPeerNode.cc | 2 +- 11 files changed, 48 insertions(+), 31 deletions(-) diff --git a/libresapi/src/api/ForumHandler.cpp b/libresapi/src/api/ForumHandler.cpp index 3a628a5a5..fa7562691 100644 --- a/libresapi/src/api/ForumHandler.cpp +++ b/libresapi/src/api/ForumHandler.cpp @@ -109,7 +109,7 @@ void ForumHandler::handleWildcard(Request &req, Response &resp) //KeyValueReference pgp_id("pgp_id",grp.mPgpId ); // not very happy about this, i think the flags should stay hidden in rsidentities bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); - bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID); + bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility); bool subscribed = IS_GROUP_SUBSCRIBED(grp.mMeta.mSubscribeFlags); resp.mDataStream.getStreamToMember() << id diff --git a/libresapi/src/api/IdentityHandler.cpp b/libresapi/src/api/IdentityHandler.cpp index ab4af9f47..bfaecfc72 100644 --- a/libresapi/src/api/IdentityHandler.cpp +++ b/libresapi/src/api/IdentityHandler.cpp @@ -156,8 +156,7 @@ void IdentityHandler::handleWildcard(Request & /*req*/, Response &resp) RsGxsIdGroup& grp = *vit; //electron: not very happy about this, i think the flags should stay hidden in rsidentities bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); - bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID); - resp.mDataStream.getStreamToMember() + bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecateRSGXSID_GROUPFLAG_REALID_kept_for_compatibilityMember() << makeKeyValueReference("id", grp.mMeta.mGroupId) /// @deprecated using "id" as key can cause problems in some JS based languages like Qml @see gxs_id instead << makeKeyValueReference("gxs_id", grp.mMeta.mGroupId) << makeKeyValueReference("pgp_id",grp.mPgpId ) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 7551d68c3..aa098a1dc 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1569,7 +1569,9 @@ bool RsGenExchange::checkGroupMetaConsistency(const RsGroupMetaData& meta) return false; } - if(meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_PUBLIC && meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_RESTRICTED && meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_PRIVATE) + uint32_t gf = meta.mGroupFlags & GXS_SERV::FLAG_PRIVACY_MASK ; + + if(gf != GXS_SERV::FLAG_PRIVACY_PUBLIC && gf != GXS_SERV::FLAG_PRIVACY_RESTRICTED && gf != GXS_SERV::FLAG_PRIVACY_PRIVATE) { std::cerr << "(EE) mGroupFlags has incorrect value " << std::hex << meta.mGroupFlags << std::dec << ". A value among GXS_SERV::FLAG_PRIVACY_{PUBLIC,RESTRICTED,PRIVATE} is expected." << std::endl; return false ; diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 36b229a8a..143f39d2a 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -43,8 +43,12 @@ extern RsIdentity *rsIdentity; // GroupFlags: Only one so far: -#warning THIS FLAG OVERLAPS THE FLAGS FOR mGroupFlags. This is an error that should be fixed. -#define RSGXSID_GROUPFLAG_REALID 0x0001 + +// The deprecated flag overlaps the privacy flags for mGroupFlags. This is an error that should be fixed. For the sake of keeping some +// backward compatibility, we need to make the change step by step. + +#define RSGXSID_GROUPFLAG_REALID_deprecated 0x0001 +#define RSGXSID_GROUPFLAG_REALID 0x0100 // THESE ARE FLAGS FOR INTERFACE. #define RSID_TYPE_MASK 0xff00 diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 9936c202e..cf731fcd8 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -1602,7 +1602,7 @@ void p3GxsCircles::checkDummyIdData() std::vector::iterator it; for(it = ids.begin(); it != ids.end(); ++it) { - if (it->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + if (it->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { #ifdef DEBUG_CIRCLES std::cerr << "p3GxsCircles::checkDummyIdData() PgpLinkedId: " << it->mMeta.mGroupId; diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index be52a1c64..35971f62a 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -695,12 +695,26 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms) if (params.isPgpLinked) { - id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID; +#warning Backward compatibility issue to fix here in v0.7.0 + + // This is a hack, because a bad decision led to having RSGXSID_GROUPFLAG_REALID be equal to GXS_SERV::FLAG_PRIVACY_PRIVATE. + // In order to keep backward compatibility, we'll also add the new value + // When the ID is not PGP linked, the group flag cannot be let empty, so we use PUBLIC. + // + // The correct combination of flags should be: + // PGP-linked: GXS_SERV::FLAGS_PRIVACY_PUBLIC | RSGXSID_GROUPFLAG_REALID + // Anonymous : GXS_SERV::FLAGS_PRIVACY_PUBLIC + + id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PRIVATE; // this is also equal to RSGXSID_GROUPFLAG_REALID_deprecated + id.mMeta.mGroupFlags |= RSGXSID_GROUPFLAG_REALID; + + // The current version should be able to produce new identities that old peers will accept as well. + // In the future, we need to: + // - set the current group flags here (see above) + // - replace all occurences of RSGXSID_GROUPFLAG_REALID_deprecated by RSGXSID_GROUPFLAG_REALID in the code. } else - { - id.mMeta.mGroupFlags = 0; - } + id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC; createGroup(token, id); @@ -1260,7 +1274,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token) } // update IdScore too. - bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID); + bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated); ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature); ssdata.score.rep.update(); @@ -1876,7 +1890,7 @@ void RsGxsIdCache::init(const RsGxsIdGroupItem *item, const RsTlvPublicRSAKey& i details.mFlags = 0 ; if(item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) details.mFlags |= RS_IDENTITY_FLAGS_IS_OWN_ID; - if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED; + if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED; // do some tests if(details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID) @@ -2830,7 +2844,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte ServiceCreate_Return createStatus; - if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated) { /* create the hash */ Sha1CheckSum hash; @@ -3033,7 +3047,7 @@ bool p3IdService::pgphash_handlerequest(uint32_t token) #endif // DEBUG_IDS /* Filter based on IdType */ - if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)) + if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated)) { #ifdef DEBUG_IDS std::cerr << "p3IdService::pgphash_request() discarding AnonID"; @@ -3609,7 +3623,7 @@ bool p3IdService::recogn_process() ssdata.recogntags.publishTs = item->meta.mPublishTs; // update IdScore too. - bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID); + bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated); ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature); ssdata.score.rep.update(); @@ -3830,7 +3844,7 @@ void p3IdService::generateDummy_FriendPGP() RsGxsIdGroup id; - id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID; + id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_deprecated; int idx = RSRandom::random_f32() * (gpgids.size() - 1); it = gpgids.begin(); @@ -3867,7 +3881,7 @@ void p3IdService::generateDummy_UnknownPGP() RsGxsIdGroup id; // FAKE DATA. - id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID; + id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_deprecated; id.mPgpIdHash = Sha1CheckSum::random() ; id.mPgpIdSign = RSRandom::random_alphaNumericString(20) ; id.mMeta.mGroupName = RSRandom::random_alphaNumericString(10) ; diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp index 8ed0bfc47..e096b99d4 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp @@ -795,9 +795,9 @@ void CreateCircleDialog::loadIdentities(uint32_t token) if (acceptAnonymous) ok = true; else if (acceptAllPGP) - ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ; + ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ; else if (idGroup.mPgpKnown) - ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ; + ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ; if (!ok) { #ifdef DEBUG_CREATE_CIRCLE_DIALOG @@ -816,7 +816,7 @@ void CreateCircleDialog::loadIdentities(uint32_t token) if(idGroup.mImage.mSize == 0 || !pixmap.loadFromData(idGroup.mImage.mData, idGroup.mImage.mSize, "PNG")) pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId))) ; - if (idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + if (idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { if (idGroup.mPgpKnown) { RsPeerDetails details; diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index e35f24a00..e70243126 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -204,7 +204,7 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) } else { - if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) +RSGXSID_GROUPFLAG_REALID_kept_for_compatibilitySID_GROUPFLAG_REALID_deprecated) { ui->lineEdit_GpgName->setText(tr("Unknown real name")); } @@ -236,9 +236,7 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ; - else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) - { - if (data.mPgpKnown) + else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLRSGXSID_GROUPFLAG_REALID_kept_for_compatibility.mPgpKnown) if (rsPeers->isGPGAccepted(data.mPgpId)) ui->lineEdit_Type->setText(tr("Owned by a friend Retroshare node")) ; else diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index eda2290f2..8df4dd856 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1416,7 +1416,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, /* do filtering */ bool ok = false; - if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { if (isLinkedToOwnNode && (accept & RSID_FILTER_YOURSELF)) { @@ -1518,7 +1518,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, QString tooltip; - if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { if (data.mPgpKnown) { @@ -1760,7 +1760,7 @@ void IdDialog::insertIdDetails(uint32_t token) } else { - if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) ui->lineEdit_GpgName->setText(tr("[Unknown node]")); else ui->lineEdit_GpgName->setText(tr("Anonymous Id")); @@ -1796,7 +1796,7 @@ void IdDialog::insertIdDetails(uint32_t token) ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ; - else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { if (data.mPgpKnown) if (rsPeers->isGPGAccepted(data.mPgpId)) diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index f99ebaf03..3bab0f2d4 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -262,7 +262,7 @@ void IdEditDialog::loadExistingId(uint32_t token) setAvatar(avatar); - bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID); + bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility); if (realid) { diff --git a/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc b/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc index 83089fa0c..5e8439af8 100644 --- a/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc +++ b/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc @@ -204,7 +204,7 @@ bool GxsPeerNode::createIdentity(const std::string &name, id.mMeta.mGroupName = name; if (pgpLinked) { - id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID; + id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_kept_for_compatibility; } else { From c61ccda4313c3b48990be367a21681ad060bde68 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 7 Feb 2017 22:04:07 +0100 Subject: [PATCH 23/28] fixed compilation problem caused by a bug in qtcreator global replace. Warning: always check the result of qtcreator global replace --- libresapi/src/api/IdentityHandler.cpp | 3 ++- libretroshare/src/retroshare/rsidentity.h | 4 ++-- libretroshare/src/services/p3idservice.cc | 14 +++++++------- .../src/gui/Identity/IdDetailsDialog.cpp | 8 ++++++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libresapi/src/api/IdentityHandler.cpp b/libresapi/src/api/IdentityHandler.cpp index bfaecfc72..4d3f0ff80 100644 --- a/libresapi/src/api/IdentityHandler.cpp +++ b/libresapi/src/api/IdentityHandler.cpp @@ -156,7 +156,8 @@ void IdentityHandler::handleWildcard(Request & /*req*/, Response &resp) RsGxsIdGroup& grp = *vit; //electron: not very happy about this, i think the flags should stay hidden in rsidentities bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); - bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecateRSGXSID_GROUPFLAG_REALID_kept_for_compatibilityMember() + bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ) ; + resp.mDataStream.getStreamToMember() << makeKeyValueReference("id", grp.mMeta.mGroupId) /// @deprecated using "id" as key can cause problems in some JS based languages like Qml @see gxs_id instead << makeKeyValueReference("gxs_id", grp.mMeta.mGroupId) << makeKeyValueReference("pgp_id",grp.mPgpId ) diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 143f39d2a..82f4932a3 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -47,8 +47,8 @@ extern RsIdentity *rsIdentity; // The deprecated flag overlaps the privacy flags for mGroupFlags. This is an error that should be fixed. For the sake of keeping some // backward compatibility, we need to make the change step by step. -#define RSGXSID_GROUPFLAG_REALID_deprecated 0x0001 -#define RSGXSID_GROUPFLAG_REALID 0x0100 +#define RSGXSID_GROUPFLAG_REALID_kept_for_compatibility 0x0001 +#define RSGXSID_GROUPFLAG_REALID 0x0100 // THESE ARE FLAGS FOR INTERFACE. #define RSID_TYPE_MASK 0xff00 diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 35971f62a..a81d9ccf9 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -1274,7 +1274,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token) } // update IdScore too. - bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated); + bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility); ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature); ssdata.score.rep.update(); @@ -1890,7 +1890,7 @@ void RsGxsIdCache::init(const RsGxsIdGroupItem *item, const RsTlvPublicRSAKey& i details.mFlags = 0 ; if(item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) details.mFlags |= RS_IDENTITY_FLAGS_IS_OWN_ID; - if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED; + if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED; // do some tests if(details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID) @@ -2844,7 +2844,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte ServiceCreate_Return createStatus; - if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated) + if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { /* create the hash */ Sha1CheckSum hash; @@ -3047,7 +3047,7 @@ bool p3IdService::pgphash_handlerequest(uint32_t token) #endif // DEBUG_IDS /* Filter based on IdType */ - if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated)) + if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)) { #ifdef DEBUG_IDS std::cerr << "p3IdService::pgphash_request() discarding AnonID"; @@ -3623,7 +3623,7 @@ bool p3IdService::recogn_process() ssdata.recogntags.publishTs = item->meta.mPublishTs; // update IdScore too. - bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated); + bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility); ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature); ssdata.score.rep.update(); @@ -3844,7 +3844,7 @@ void p3IdService::generateDummy_FriendPGP() RsGxsIdGroup id; - id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_deprecated; + id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_kept_for_compatibility; int idx = RSRandom::random_f32() * (gpgids.size() - 1); it = gpgids.begin(); @@ -3881,7 +3881,7 @@ void p3IdService::generateDummy_UnknownPGP() RsGxsIdGroup id; // FAKE DATA. - id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_deprecated; + id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_kept_for_compatibility; id.mPgpIdHash = Sha1CheckSum::random() ; id.mPgpIdSign = RSRandom::random_alphaNumericString(20) ; id.mMeta.mGroupName = RSRandom::random_alphaNumericString(10) ; diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index e70243126..92b607d8f 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -204,7 +204,7 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) } else { -RSGXSID_GROUPFLAG_REALID_kept_for_compatibilitySID_GROUPFLAG_REALID_deprecated) + if(data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { ui->lineEdit_GpgName->setText(tr("Unknown real name")); } @@ -232,11 +232,15 @@ RSGXSID_GROUPFLAG_REALID_kept_for_compatibilitySID_GROUPFLAG_REALID_deprecated) bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); if (isOwnId) + { if (data.mPgpKnown) ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ; - else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLRSGXSID_GROUPFLAG_REALID_kept_for_compatibility.mPgpKnown) + } + else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) + { + if(data.mPgpKnown) if (rsPeers->isGPGAccepted(data.mPgpId)) ui->lineEdit_Type->setText(tr("Owned by a friend Retroshare node")) ; else From ccacba797f45f77705974e7bddd15b0288fe44c4 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 12 Feb 2017 15:27:13 +0100 Subject: [PATCH 24/28] added pgp passphrase temporary caching in order to avoid re-asking for password at location creation time --- libretroshare/src/pqi/p3notify.cc | 29 ++++++++++++++++++++++++ libretroshare/src/pqi/p3notify.h | 5 ++++ libretroshare/src/retroshare/rsnotify.h | 3 +++ retroshare-gui/src/gui/GenCertDialog.cpp | 7 ++++++ retroshare-gui/src/gui/notifyqt.cpp | 2 +- 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index 53109a6d1..c110665f8 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -245,8 +245,37 @@ void p3Notify::notifyDownloadComplete (const std::string& fileHash ) void p3Notify::notifyDownloadCompleteCount (uint32_t count ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDownloadCompleteCount (count) ; } void p3Notify::notifyHistoryChanged (uint32_t msgId , int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyHistoryChanged (msgId,type) ; } +bool p3Notify::cachePgpPassphrase(const std::string& s) +{ + clearPgpPassphrase() ; + cached_pgp_passphrase = s ; + + std::cerr << "(WW) Caching PGP passphrase." << std::endl; + return true ; +} +bool p3Notify::clearPgpPassphrase() +{ + std::cerr << "(WW) Clearing PGP passphrase." << std::endl; + + // Just whipe out the memory instead of just releasing it. + + for(uint32_t i=0;iaskForPassword(title,key_details,prev_is_bad,password,*cancelled)) return true ; diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index f91450f22..60b3759a6 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -124,6 +124,9 @@ class p3Notify: public RsNotify bool askForPassword (const std::string& title, const std::string& /* key_details */, bool /* prev_is_bad */, std::string&, bool *cancelled /* password */ ) ; bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */) ; + virtual bool cachePgpPassphrase (const std::string& /* pgp_passphrase */) ; + virtual bool clearPgpPassphrase () ; + private: RsMutex noteMtx; @@ -134,6 +137,8 @@ class p3Notify: public RsNotify std::list pendingNewsFeed; std::list notifyClients ; + + std::string cached_pgp_passphrase ; }; diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index 991ba338e..fd09218bd 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -199,6 +199,9 @@ class RsNotify virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg) = 0; virtual bool GetFeedItem(RsFeedItem &item) = 0; + + virtual bool cachePgpPassphrase (const std::string& /* pgp_passphrase */) { return false ; } + virtual bool clearPgpPassphrase () { return false ; } }; class NotifyClient diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 21c5e893e..7412519ba 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -469,6 +470,10 @@ void GenCertDialog::genPerson() err_string); setCursor(Qt::ArrowCursor) ; + + // now cache the PGP password so that it's not asked again for immediately signing the key + + rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; } //generate a random ssl password @@ -484,6 +489,8 @@ void GenCertDialog::genPerson() std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl; bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err); + rsNotify->clearPgpPassphrase() ; + if (okGen) { /* complete the process */ diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e3e02e02c..9f05f7c44 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -278,7 +278,7 @@ bool NotifyQt::askForPassword(const std::string& title, const std::string& key_d dialog.setWindowTitle(QString::fromStdString(title)); } - dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1:\n %2").arg(tr("Please enter your PGP password for key"), QString::fromUtf8(key_details.c_str()))); + dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1:\n\n (%2)\n\n").arg(tr("Please enter your Retroshare password"), QString::fromUtf8(key_details.c_str()))); dialog.setTextEchoMode(QLineEdit::Password); dialog.setModal(true); From 5069ba86dd33d411e3ce0f253ca59f33c83f3e22 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 12 Feb 2017 21:45:22 +0100 Subject: [PATCH 25/28] improved style/layout of gen cert dialog --- retroshare-gui/src/gui/GenCertDialog.cpp | 45 +- retroshare-gui/src/gui/GenCertDialog.h | 1 + retroshare-gui/src/gui/GenCertDialog.ui | 628 ++++++++++-------- .../src/gui/qss/stylesheet/Standard.qss | 4 +- 4 files changed, 397 insertions(+), 281 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 7412519ba..40a2bb74c 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -44,6 +44,9 @@ #include #include +#define IMAGE_GOOD ":/images/accepted16.png" +#define IMAGE_BAD ":/images/deletemail24.png" + class EntropyCollectorWidget: public QTextBrowser { public: @@ -110,12 +113,15 @@ void GenCertDialog::grabMouse() ui.genButton->setEnabled(false) ; //ui.genButton->setIcon(QIcon(":/images/delete.png")) ; ui.genButton->setToolTip(tr("Currently disabled. Please move your mouse around until you reach at least 20%")) ; + + ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_BAD)) ; } else { ui.genButton->setEnabled(true) ; //ui.genButton->setIcon(QIcon(":/images/resume.png")) ; ui.genButton->setToolTip(tr("Click to create your node and/or profile")) ; + ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_GOOD)) ; } RsInit::collectEntropy(E+(F << 16)) ; @@ -145,6 +151,11 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity())); connect(ui.exportIdentity_PB, SIGNAL(clicked()), this, SLOT(exportIdentity())); + connect(ui.password_input, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels())); + connect(ui.password_input_2, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels())); + connect(ui.name_input, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels())); + connect(ui.node_input, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels())); + entropy_timer = new QTimer ; entropy_timer->start(20) ; QObject::connect(entropy_timer,SIGNAL(timeout()),this,SLOT(grabMouse())) ; @@ -158,7 +169,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) #if QT_VERSION >= 0x040700 ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ; - ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Tor/I2P address - Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ; + ui.hiddenaddr_input->setPlaceholderText(tr("[Optional] Tor/I2P address - Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ; ui.name_input->setPlaceholderText(tr("[Required] Identifies your Retrohare node(s). Visible to your friends, and friends of friends.")); ui.nickname_input->setPlaceholderText(tr("[Optional] Used when you write in chat lobbies, forums and channel comments. Can be setup later if you need one.")); ui.password_input->setPlaceholderText(tr("[Required] This password protects your data and is required when re-start.")); @@ -273,15 +284,15 @@ void GenCertDialog::setupState() ui.node_label->setVisible(true); ui.node_input->setVisible(true); - ui.password_label->setVisible(true); - ui.password_label_2->setVisible(true); ui.password_input->setVisible(true); - ui.password_input_2->setVisible(true); + ui.password_label->setVisible(true); + + ui.password_input_2->setVisible(generate_new); + ui.password_label_2->setVisible(generate_new); ui.keylength_label->setVisible(adv_state); ui.keylength_comboBox->setVisible(adv_state); - ui.entropy_label->setVisible(true); ui.entropy_bar->setVisible(true); ui.genButton->setVisible(true); @@ -289,9 +300,10 @@ void GenCertDialog::setupState() ui.hiddenaddr_input->setVisible(hidden_state); ui.hiddenaddr_label->setVisible(hidden_state); - ui.label_hiddenaddr->setVisible(hidden_state); ui.hiddenport_label->setVisible(hidden_state); ui.hiddenport_spinBox->setVisible(hidden_state); + + updateCheckLabels(); } void GenCertDialog::exportIdentity() @@ -310,6 +322,17 @@ void GenCertDialog::exportIdentity() QMessageBox::information(this,tr("Profile not saved"),tr("Your profile was not saved. An error occurred.")) ; } +void GenCertDialog::updateCheckLabels() +{ + QPixmap good( IMAGE_GOOD ) ; + QPixmap bad ( IMAGE_BAD ) ; + + ui.node_name_check_LB ->setPixmap( (ui.node_input->text().length() > 3)?good:bad ) ; + ui.profile_name_check_LB->setPixmap( (ui.name_input->text().length() > 3)?good:bad ) ; + ui.password_check_LB ->setPixmap( (ui.password_input->text().length() > 3)?good:bad ) ; + ui.password2_check_LB ->setPixmap( (ui.password_input->text().length() > 3 && ui.password_input->text() == ui.password_input_2->text())?good:bad) ; +} + bool GenCertDialog::importIdentity() { QString fname ; @@ -386,7 +409,9 @@ void GenCertDialog::genPerson() isHiddenLoc = true; } - if (!genNewGPGKey) { + + if (!genNewGPGKey) + { if (genLoc.length() < 3) { /* Message Dialog */ QMessageBox::warning(this, @@ -470,11 +495,9 @@ void GenCertDialog::genPerson() err_string); setCursor(Qt::ArrowCursor) ; - - // now cache the PGP password so that it's not asked again for immediately signing the key - - rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; } + // now cache the PGP password so that it's not asked again for immediately signing the key + rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; //generate a random ssl password std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ; diff --git a/retroshare-gui/src/gui/GenCertDialog.h b/retroshare-gui/src/gui/GenCertDialog.h index 51cfaa19c..c9c1c2699 100644 --- a/retroshare-gui/src/gui/GenCertDialog.h +++ b/retroshare-gui/src/gui/GenCertDialog.h @@ -44,6 +44,7 @@ private slots: void setupState(); void switchReuseExistingNode(); void grabMouse(); + void updateCheckLabels(); private: void initKeyList(); diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index ffef7a78c..fd87030b1 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -6,7 +6,7 @@ 0 0 - 1745 + 1278 1296 @@ -35,6 +35,12 @@ + + + 0 + 0 + + QFrame::StyledPanel @@ -42,6 +48,19 @@ QFrame::Raised + + + + + + + :/images/logo/logo_splash.png + + + Qt::AlignCenter + + + @@ -88,19 +107,6 @@ - - - - - - - :/images/logo/logo_splash.png - - - Qt::AlignCenter - - - @@ -284,75 +290,10 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - + + - Node type - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - This password is for PGP - - - Password (check) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Put a strong password here. This password protects your private PGP key. - - - - - - 1024 - - - QLineEdit::Password - - - - - - - Profile name - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - You can have one or more identities. They are used when you write in chat lobbies, forums and channel comments. They act as the destination for distant chat and the Retroshare distant mail system. - - - - - - - - - - Chat identity + hidden address Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -372,101 +313,93 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - - - - - - Put a strong password here. This password protects your private PGP key. - - - - - - 1024 - - - QLineEdit::Password + + + + + 0 + 0 + - - + + + + This password is for PGP + - hidden address + Password (check) Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - 6 + + + + - - - - - 0 - 0 - - - - - 16777215 - 32 - - - - 64 - - - - - - - Port - - - - - - - <html><head/><body><p>This is your connection port.</p><p>Any value between 1024 and 65535 </p><p>should be ok. You can change it later.</p></body></html> - - - 1 - - - 65535 - - - 7812 - - - - + - - + + - + 0 0 - - <html><head/><body><p>This can be a Tor Onion address of the form: xa76giaf6ifda7ri63i263.onion <br/>or an I2P address in the form: [52 characters].b32.i2p </p><p>In order to get one, you must configure either Tor or I2P to create a new hidden service / server tunnel. If you do not yet have one, you can still go on, and make it right later in RetroShare's Options-&gt;Network-&gt;Hidden Service configuration panel.</p></body></html> - - - true + + You can have one or more identities. They are used when you write in chat lobbies, forums and channel comments. They act as the destination for distant chat and the Retroshare distant mail system. - + + + + + 0 + 0 + + + + <html><head/><body><p>Please move your mouse around in order to collect as much randomness as possible. A minimum of 20% is needed to create your node keys.</p></body></html> + + + 24 + + + + + + + + + + + + + + + + + + + + + + + + Chat identity + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + PGP key length @@ -478,6 +411,12 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + 0 + 0 + + 0 @@ -489,20 +428,6 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - - - - Standard node - - - - - TOR/I2P Hidden node - - - - @@ -513,12 +438,39 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + + + + + + + + + + 0 + 0 + + + + + Standard node + + + + + TOR/I2P Hidden node + + + + - + 0 0 @@ -548,6 +500,12 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + 0 + 0 + + Your profile is associated with a PGP key pair. RetroShare currently ignores DSA keys. @@ -556,7 +514,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - + 0 0 @@ -569,7 +527,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - + 0 0 @@ -581,6 +539,12 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + 0 + 0 + + Re-use an existing profile @@ -588,6 +552,157 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p + + + + 6 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 32 + + + + <html><head/><body><p>This should be a Tor Onion address of the form: xa76giaf6ifda7ri63i263.onion <br/>or an I2P address in the form: [52 characters].b32.i2p </p><p>In order to get one, you must configure either Tor or I2P to create a new hidden service / server tunnel. </p><p>You can also leave this blank now, but your node will only work if you correctly set the Tor/I2P service address in Options-&gt;Network-&gt;Hidden Service configuration panel.</p></body></html> + + + 64 + + + + + + + Port + + + + + + + + 0 + 0 + + + + <html><head/><body><p>This is your connection port.</p><p>Any value between 1024 and 65535 </p><p>should be ok. You can change it later.</p></body></html> + + + 1 + + + 65535 + + + 7812 + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Put a strong password here. This password protects your private PGP key. + + + + + + 1024 + + + QLineEdit::Password + + + + + + + + + + + + + + + 0 + 0 + + + + Put a strong password here. This password protects your private PGP key. + + + + + + 1024 + + + QLineEdit::Password + + + + + + + Profile name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Node type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Randomness + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -604,101 +719,70 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 178 - - - - - - - 255 - 255 - 178 - - - - - - - - true - - - QFrame::Box - - - <html><head/><body><p align="justify">Before proceeding, move your mouse around to help Retroshare collect as much randomness as possible. Filling the progressbar to 20% is required, 100% is advised.</p></body></html> - - - true - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + + + Go! + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - 24 + + + Qt::Vertical - - - - - - + + + 20 + 40 + - - Go! - - + @@ -713,15 +797,25 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - nickname_input + name_input + node_input password_input password_input_2 + adv_checkbox + keylength_comboBox + nodeType_CB + exportIdentity_PB + reuse_existing_node_CB + nickname_input + genPGPuser hiddenaddr_input hiddenport_spinBox + genButton + importIdentity_PB - + diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index f4fbd36e5..b183eb77c 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -715,8 +715,6 @@ GenCertDialog QLineEdit#name_input { GenCertDialog QPushButton#genButton { border-image: url(:/images/btn_blue.png) 4; border-width: 4; -/* padding: 0px 6px;*/ -/* font-size: 16px; */ font: bold; color: white; } @@ -727,7 +725,7 @@ GenCertDialog QPushButton#genButton:hover { GenCertDialog QPushButton#genButton:disabled { border-image: url(:/images/btn_27.png) 4; - font-size: 16px; +/* font-size: 16px; */ font: bold; color: black; } From 59f428f096b7225ec6702b8e2625b44936de0c01 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 12 Feb 2017 23:35:43 +0100 Subject: [PATCH 26/28] fixed the update of check icons in genCertDialog --- retroshare-gui/src/gui/GenCertDialog.cpp | 87 +++++++++++++++++------- retroshare-gui/src/gui/GenCertDialog.h | 2 + retroshare-gui/src/gui/GenCertDialog.ui | 13 ++-- 3 files changed, 72 insertions(+), 30 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 40a2bb74c..a5c38bf2d 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -108,20 +108,10 @@ void GenCertDialog::grabMouse() ui.entropy_bar->setValue(count*100/2048) ; - if(ui.entropy_bar->value() < 20) + if(!mEntropyOk && ui.entropy_bar->value() >= 20) { - ui.genButton->setEnabled(false) ; - //ui.genButton->setIcon(QIcon(":/images/delete.png")) ; - ui.genButton->setToolTip(tr("Currently disabled. Please move your mouse around until you reach at least 20%")) ; - - ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_BAD)) ; - } - else - { - ui.genButton->setEnabled(true) ; - //ui.genButton->setIcon(QIcon(":/images/resume.png")) ; - ui.genButton->setToolTip(tr("Click to create your node and/or profile")) ; - ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_GOOD)) ; + mEntropyOk = true ; + updateCheckLabels(); } RsInit::collectEntropy(E+(F << 16)) ; @@ -168,22 +158,23 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) ui.keylength_comboBox->addItem("Very high (4096 bits)", QVariant(4096)); #if QT_VERSION >= 0x040700 - ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ; - ui.hiddenaddr_input->setPlaceholderText(tr("[Optional] Tor/I2P address - Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ; - ui.name_input->setPlaceholderText(tr("[Required] Identifies your Retrohare node(s). Visible to your friends, and friends of friends.")); - ui.nickname_input->setPlaceholderText(tr("[Optional] Used when you write in chat lobbies, forums and channel comments. Can be setup later if you need one.")); - ui.password_input->setPlaceholderText(tr("[Required] This password protects your data and is required when re-start.")); + ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...(Visible to friends).")) ; + ui.hiddenaddr_input->setPlaceholderText(tr("[Optional] Tor/I2P address (Example: xa76giaf6ifda7ri63i263.onion)")) ; + ui.name_input->setPlaceholderText(tr("[Required] Visible to friends, and friends of friends.")); + ui.nickname_input->setPlaceholderText(tr("[Optional] Used to write in chat rooms and forums. Can be set later.")); + ui.password_input->setPlaceholderText(tr("[Required] This password protects your data. Dont forget it!")); ui.password_input_2->setPlaceholderText(tr("[Required] Type the same password again here.")); #endif ui.nickname_input->setMaxLength(RSID_MAXIMUM_NICKNAME_SIZE); - ui.node_input->setToolTip(tr("Enter a meaningful node description. e.g. : home, laptop, etc. \nThis field will be used to differentiate different Retroshare nodes for\nthe same profile.")) ; - /* get all available pgp private certificates.... * mark last one as default. */ + mAllFieldsOk = false ; + mEntropyOk = false ; + initKeyList(); setupState(); } @@ -303,7 +294,18 @@ void GenCertDialog::setupState() ui.hiddenport_label->setVisible(hidden_state); ui.hiddenport_spinBox->setVisible(hidden_state); - updateCheckLabels(); + if(mEntropyOk && mAllFieldsOk) + { + ui.genButton->setEnabled(true) ; + ui.genButton->setIcon(QIcon(":/images/resume.png")) ; + ui.genButton->setToolTip(tr("Click to create your node and/or profile")) ; + } + else + { + ui.genButton->setEnabled(false) ; + ui.genButton->setIcon(QIcon(":/images/delete.png")) ; + ui.genButton->setToolTip(tr("Disabled until all fields correctly set and enough randomness collected.")) ; + } } void GenCertDialog::exportIdentity() @@ -327,10 +329,45 @@ void GenCertDialog::updateCheckLabels() QPixmap good( IMAGE_GOOD ) ; QPixmap bad ( IMAGE_BAD ) ; - ui.node_name_check_LB ->setPixmap( (ui.node_input->text().length() > 3)?good:bad ) ; - ui.profile_name_check_LB->setPixmap( (ui.name_input->text().length() > 3)?good:bad ) ; - ui.password_check_LB ->setPixmap( (ui.password_input->text().length() > 3)?good:bad ) ; - ui.password2_check_LB ->setPixmap( (ui.password_input->text().length() > 3 && ui.password_input->text() == ui.password_input_2->text())?good:bad) ; + mAllFieldsOk = true ; + + if(ui.node_input->text().length() > 3) + ui.node_name_check_LB ->setPixmap(good) ; + else + { + mAllFieldsOk = false ; + ui.node_name_check_LB ->setPixmap(bad) ; + } + + if(ui.name_input->text().length() > 3) + ui.profile_name_check_LB ->setPixmap(good) ; + else + { + mAllFieldsOk = false ; + ui.profile_name_check_LB ->setPixmap(bad) ; + } + + if(ui.password_input->text().length() > 3) + ui.password_check_LB ->setPixmap(good) ; + else + { + mAllFieldsOk = false ; + ui.password_check_LB ->setPixmap(bad) ; + } + if(ui.password_input->text().length() > 3 && ui.password_input->text() == ui.password_input_2->text()) + ui.password2_check_LB ->setPixmap(good) ; + else + { + mAllFieldsOk = false ; + ui.password2_check_LB ->setPixmap(bad) ; + } + + if(mEntropyOk) + ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_GOOD)) ; + else + ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_BAD)) ; + + setupState(); } bool GenCertDialog::importIdentity() diff --git a/retroshare-gui/src/gui/GenCertDialog.h b/retroshare-gui/src/gui/GenCertDialog.h index c9c1c2699..f32aa4166 100644 --- a/retroshare-gui/src/gui/GenCertDialog.h +++ b/retroshare-gui/src/gui/GenCertDialog.h @@ -55,6 +55,8 @@ private: bool genNewGPGKey; bool haveGPGKeys; bool mOnlyGenerateIdentity; + bool mAllFieldsOk ; + bool mEntropyOk ; QString mGXSNickname; QTimer *entropy_timer ; diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index fd87030b1..d77dc8481 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -352,7 +352,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - You can have one or more identities. They are used when you write in chat lobbies, forums and channel comments. They act as the destination for distant chat and the Retroshare distant mail system. + <html><head/><body><p>Identities are used when you write in chat rooms, forums and channel comments. </p><p>They also receive/send email over the Retroshare network. You can create</p><p>a signed identity now, or do it later on when you get to need it.</p></body></html> @@ -423,6 +423,9 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p 0 + + <html><head/><body><p>Your node name designates the Retroshare instance that</p><p>will run on this computer.</p></body></html> + 64 @@ -488,7 +491,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - Enter your nickname here + <html><head/><body><p>The profile name identifies you over the network.</p><p>It is used by your friends to accept connections from you.</p><p>You can create multiple Retroshare nodes with the</p><p>same profile on different computers.</p><p><br/></p></body></html> @@ -501,7 +504,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - + 0 0 @@ -631,7 +634,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - Put a strong password here. This password protects your private PGP key. + <html><head/><body><p>Put a strong password here. This password protects your private node key!</p></body></html> @@ -660,7 +663,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new p - Put a strong password here. This password protects your private PGP key. + <html><head/><body><p>Put a strong password here. This password protects your private node key!</p></body></html> From b81764893aadb072b5fd86975b74283ddf929296 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 15 Feb 2017 19:17:41 +0100 Subject: [PATCH 27/28] fixed a few bugs in cert creation window --- retroshare-gui/src/gui/GenCertDialog.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index a5c38bf2d..a41dea21d 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -145,6 +145,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) connect(ui.password_input_2, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels())); connect(ui.name_input, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels())); connect(ui.node_input, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels())); + connect(ui.reuse_existing_node_CB, SIGNAL(toggled(bool)), this, SLOT(updateCheckLabels())); entropy_timer = new QTimer ; entropy_timer->start(20) ; @@ -177,6 +178,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) initKeyList(); setupState(); + updateCheckLabels(); } GenCertDialog::~GenCertDialog() @@ -278,6 +280,7 @@ void GenCertDialog::setupState() ui.password_input->setVisible(true); ui.password_label->setVisible(true); + ui.password2_check_LB->setVisible(generate_new); ui.password_input_2->setVisible(generate_new); ui.password_label_2->setVisible(generate_new); @@ -297,13 +300,13 @@ void GenCertDialog::setupState() if(mEntropyOk && mAllFieldsOk) { ui.genButton->setEnabled(true) ; - ui.genButton->setIcon(QIcon(":/images/resume.png")) ; + ui.genButton->setIcon(QIcon(IMAGE_GOOD)) ; ui.genButton->setToolTip(tr("Click to create your node and/or profile")) ; } else { ui.genButton->setEnabled(false) ; - ui.genButton->setIcon(QIcon(":/images/delete.png")) ; + ui.genButton->setIcon(QIcon(IMAGE_BAD)) ; ui.genButton->setToolTip(tr("Disabled until all fields correctly set and enough randomness collected.")) ; } } @@ -329,6 +332,7 @@ void GenCertDialog::updateCheckLabels() QPixmap good( IMAGE_GOOD ) ; QPixmap bad ( IMAGE_BAD ) ; + bool generate_new = !ui.reuse_existing_node_CB->isChecked(); mAllFieldsOk = true ; if(ui.node_input->text().length() > 3) @@ -339,7 +343,7 @@ void GenCertDialog::updateCheckLabels() ui.node_name_check_LB ->setPixmap(bad) ; } - if(ui.name_input->text().length() > 3) + if(!generate_new || ui.name_input->text().length() > 3) ui.profile_name_check_LB ->setPixmap(good) ; else { @@ -358,7 +362,9 @@ void GenCertDialog::updateCheckLabels() ui.password2_check_LB ->setPixmap(good) ; else { - mAllFieldsOk = false ; + if(generate_new) + mAllFieldsOk = false ; + ui.password2_check_LB ->setPixmap(bad) ; } @@ -498,6 +504,8 @@ void GenCertDialog::genPerson() ui.nickname_input->hide(); ui.password_label_2->hide(); ui.password_input_2->hide(); + ui.password2_check_LB->hide(); + ui.password_check_LB->hide(); ui.password_label->hide(); ui.password_input->hide(); //ui.genPGPuserlabel->hide(); From 391ef3e4c6c32b9acc42955565d4b828b001df4f Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 15 Feb 2017 19:25:46 +0100 Subject: [PATCH 28/28] improved passphrase window --- retroshare-gui/src/gui/StartDialog.ui | 6 +++--- retroshare-gui/src/gui/notifyqt.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/StartDialog.ui b/retroshare-gui/src/gui/StartDialog.ui index df48acbe8..ae198d4a7 100644 --- a/retroshare-gui/src/gui/StartDialog.ui +++ b/retroshare-gui/src/gui/StartDialog.ui @@ -6,8 +6,8 @@ 0 0 - 291 - 433 + 430 + 552 @@ -220,7 +220,7 @@ - Name (PGP Id) - location: + Profile - Location diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 9f05f7c44..ec2c7454b 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -269,7 +269,7 @@ bool NotifyQt::askForPassword(const std::string& title, const std::string& key_d QInputDialog dialog; if (title == "") { - dialog.setWindowTitle(tr("PGP key passphrase")); + dialog.setWindowTitle(tr("Passphrase required")); } else if (title == "AuthSSLimpl::SignX509ReqWithGPG()") { dialog.setWindowTitle(tr("You need to sign your node's certificate.")); } else if (title == "p3IdService::service_CreateGroup()") { @@ -278,7 +278,7 @@ bool NotifyQt::askForPassword(const std::string& title, const std::string& key_d dialog.setWindowTitle(QString::fromStdString(title)); } - dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1:\n\n (%2)\n\n").arg(tr("Please enter your Retroshare password"), QString::fromUtf8(key_details.c_str()))); + dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1
Profile: %2\n").arg(tr("Please enter your Retroshare passphrase"), QString::fromUtf8(key_details.c_str()))); dialog.setTextEchoMode(QLineEdit::Password); dialog.setModal(true);