From 42b8eccfd24446bb309ec64c910614a943c8d62b Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 14 Feb 2018 21:48:56 +0100 Subject: [PATCH 1/6] prevent RS from making friends with your own location --- .../src/gui/common/RsCollectionDialog.ui | 27 +++++++++-- .../src/gui/connect/ConnectFriendWizard.cpp | 47 +++++++++++++++---- .../src/gui/connect/ConnectFriendWizard.ui | 2 +- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.ui b/retroshare-gui/src/gui/common/RsCollectionDialog.ui index a930d2e7d..7595413ca 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.ui +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.ui @@ -6,7 +6,7 @@ 0 0 - 969 + 978 778 @@ -279,7 +279,11 @@ <html><head/><body><p>Add selected item to collection one by one.</p><p>Select parent dir to add this too.</p><p><span style=" font-style:italic; vertical-align:sub;">&lt;Enter&gt;</span></p></body></html> - > + + + + + :/images/feedback_arrow.png:/images/feedback_arrow.png @@ -301,7 +305,11 @@ <html><head/><body><p>Add selected item to collection.</p><p>If a directory is selected, all of his children will be added.</p><p><span style=" text-decoration: underline; vertical-align:sub;">&lt;Shift + Enter&gt;</span></p></body></html> - >> + + + + + :/images/Update.png:/images/Update.png @@ -323,7 +331,11 @@ <html><head/><body><p>Remove selected item from collection.</p><p><span style=" font-style:italic; vertical-align:sub;">&lt;Del&gt;</span></p></body></html> - < + + + + + :/images/deletemail24.png:/images/deletemail24.png @@ -345,7 +357,11 @@ <html><head/><body><p>Make a new directory in the collection.</p><p><span style=" font-style:italic; vertical-align:sub;">&lt;+&gt;</span></p></body></html> - + + + + + + :/images/directoryadd_24x24_shadow.png:/images/directoryadd_24x24_shadow.png @@ -501,6 +517,7 @@ + diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 8c50c719d..4ba20fc75 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -293,17 +293,27 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend #ifdef FRIEND_WIZARD_DEBUG std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl; #endif - mCertificate = certificate.toUtf8().constData(); - // Cyril: I disabled this because it seems to be not used anymore. - //setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion); - setStartId(Page_Conclusion); - if (friendRequest){ - ui->cp_Label->show(); - ui->requestinfolabel->show(); - setTitleText(ui->ConclusionPage, tr("Friend request")); - ui->ConclusionPage->setSubTitle(tr("Details about the request")); - } + if(peerDetails.id == rsPeers->getOwnId()) + { + setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ; + error = false; + setStartId(Page_ErrorMessage); + } + else + { + mCertificate = certificate.toUtf8().constData(); + + // Cyril: I disabled this because it seems to be not used anymore. + //setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion); + setStartId(Page_Conclusion); + if (friendRequest){ + ui->cp_Label->show(); + ui->requestinfolabel->show(); + setTitleText(ui->ConclusionPage, tr("Friend request")); + ui->ConclusionPage->setSubTitle(tr("Details about the request")); + } + } } else { // error message setField("errorMessage", tr("Certificate Load Failed") + ": \n\n" + getErrorString(cert_load_error_code)) ; @@ -435,6 +445,10 @@ void ConnectFriendWizard::initializePage(int id) break; case Page_Conclusion: { + if(peerDetails.id == rsPeers->getOwnId()) + { + } + bool peerIsHiddenNode = peerDetails.isHiddenNode ; bool amIHiddenNode = rsPeers->isHiddenNode(rsPeers->getOwnId()) ; @@ -702,6 +716,13 @@ bool ConnectFriendWizard::validateCurrentPage() #ifdef FRIEND_WIZARD_DEBUG std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl; #endif + + if(peerDetails.id == rsPeers->getOwnId()) + { + setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ; + error = false; + } + break; } // error message @@ -735,6 +756,12 @@ bool ConnectFriendWizard::validateCurrentPage() #ifdef FRIEND_WIZARD_DEBUG std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl; #endif + + if(peerDetails.id == rsPeers->getOwnId()) + { + setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ; + error = false; + } } else { setField("errorMessage", QString(tr("Certificate Load Failed:something is wrong with %1")).arg(fn) + " : " + getErrorString(cert_error_code)); error = false; diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui index a11bb18e7..181b164c0 100644 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui @@ -1618,8 +1618,8 @@ resources. - + From ddb2c457909a368e6d59bd8b06fd7097005f8e25 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 14 Feb 2018 21:56:12 +0100 Subject: [PATCH 2/6] disable and hide signature checkbox when key is already signed in ConnectWizard --- retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 4ba20fc75..cf9444b97 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -511,8 +511,8 @@ void ConnectFriendWizard::initializePage(int id) else ui->alreadyRegisteredLabel->hide(); if(tmp_det.ownsign) { - ui->signGPGCheckBox->setChecked(true); - ui->signGPGCheckBox->setEnabled(false); + ui->signGPGCheckBox->setChecked(false); // if already signed, we dont allow to sign it again, and dont show the box. + ui->signGPGCheckBox->setVisible(false); ui->signGPGCheckBox->setToolTip(tr("You have already signed this key")); } From cf33221f2f62ed5becd6325b3339041e48f21ec5 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 14 Feb 2018 22:00:46 +0100 Subject: [PATCH 3/6] removed dead code in previous commit --- retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index cf9444b97..15b2f504f 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -445,10 +445,6 @@ void ConnectFriendWizard::initializePage(int id) break; case Page_Conclusion: { - if(peerDetails.id == rsPeers->getOwnId()) - { - } - bool peerIsHiddenNode = peerDetails.isHiddenNode ; bool amIHiddenNode = rsPeers->isHiddenNode(rsPeers->getOwnId()) ; From 72124bbd3f08ae4f66092271ec45c30f321b8087 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 14 Feb 2018 22:08:07 +0100 Subject: [PATCH 4/6] hide advanced mode option since it is not used anywhere in the software --- retroshare-gui/src/gui/settings/GeneralPage.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/retroshare-gui/src/gui/settings/GeneralPage.cpp b/retroshare-gui/src/gui/settings/GeneralPage.cpp index 58f699cbe..1900bbc85 100755 --- a/retroshare-gui/src/gui/settings/GeneralPage.cpp +++ b/retroshare-gui/src/gui/settings/GeneralPage.cpp @@ -92,6 +92,10 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WindowFlags flags) : //connect(ui.runStartWizard_PB, SIGNAL(clicked()), this,SLOT(runStartWizard())) ; connect(ui.checkAdvanced, SIGNAL(toggled(bool)), this,SLOT(updateAdvancedMode())) ; connect(ui.registerRetroShareProtocol, SIGNAL(toggled(bool)), this,SLOT(updateRegisterRSProtocol())) ; + + // hide advanced checkbox, since the option is not used. + + ui.advGBox->hide(); } /** Destructor */ From 47f9a4907bf9ed08341b39083a431a6511c54994 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 15 Feb 2018 00:02:08 +0100 Subject: [PATCH 5/6] improved cost of reseting search in SharedFileDialog by saving hidden indexes list --- .../gui/FileTransfer/SharedFilesDialog.cpp | 55 ++++++++++--------- .../src/gui/FileTransfer/SharedFilesDialog.h | 4 ++ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index a8ebf7363..504ab96ea 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -966,6 +966,9 @@ void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, con bool invisible = vis.find(local_path) != vis.end(); ui.dirTreeView->setRowHidden(index.row(),index.parent(),invisible ) ; + if(invisible) + mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + if(!invisible && exp.find(local_path) != exp.end()) { #ifdef DEBUG_SHARED_FILES_DIALOG @@ -1330,26 +1333,9 @@ void SharedFilesDialog::startFilter() #define EXPAND_WHILE_SEARCHING 1 -static void recursMakeAllVisible(QTreeView *tree,const QModelIndex& indx) -{ - tree->setRowHidden(indx.row(), indx.parent(), false) ; - - int rowCount = tree->model()->rowCount(indx); - - for (int row = 0; row < rowCount; ++row) - { - QModelIndex child_index = indx.child(row,0); - - recursMakeAllVisible(tree,child_index); - } -#ifdef EXPAND_WHILE_SEARCHING - tree->setExpanded(indx,false) ; -#endif -} - //#define DEBUG_SHARED_FILES_DIALOG -static void recursMakeVisible(QTreeView *tree,const QSortFilterProxyModel *proxyModel,const QModelIndex& indx,uint32_t depth,const std::vector >& pointers) +void recursMakeVisible(QTreeView *tree,const QSortFilterProxyModel *proxyModel,const QModelIndex& indx,uint32_t depth,const std::vector >& pointers,QList& hidden_list) { #ifdef DEBUG_SHARED_FILES_DIALOG for(uint32_t i=0;imapToSource(child_index).internalPointer() << " visible" << std::endl; #endif - recursMakeVisible(tree,proxyModel,child_index,depth+1,pointers) ; + recursMakeVisible(tree,proxyModel,child_index,depth+1,pointers,hidden_list) ; found = true ; } else { tree->setRowHidden(child_index.row(), indx, true) ; + hidden_list.push_back(proxyModel->mapToSource(child_index)) ; #ifdef EXPAND_WHILE_SEARCHING tree->setExpanded(child_index,false) ; #endif @@ -1395,7 +1382,23 @@ static void recursMakeVisible(QTreeView *tree,const QSortFilterProxyModel *proxy } if(!found && depth == 0) + { tree->setRowHidden(indx.row(), indx.parent(), true) ; + hidden_list.push_back(proxyModel->mapToSource(indx)) ; + } +} + +void SharedFilesDialog::restoreInvisibleItems() +{ + for(QList::const_iterator it(mHiddenIndexes.begin());it!=mHiddenIndexes.end();++it) + { + QModelIndex indx = proxyModel->mapFromSource(*it); + + if(indx.isValid()) + ui.dirTreeView->setRowHidden(indx.row(), indx.parent(), false) ; + } + + mHiddenIndexes.clear(); } class QCursorContextBlocker @@ -1436,6 +1439,7 @@ void SharedFilesDialog::FilterItems() std::cerr << "New last text. Performing the filter" << std::endl; mLastFilterText = text ; model->update() ; + restoreInvisibleItems(); QCursorContextBlocker q(ui.dirTreeView) ; @@ -1447,14 +1451,7 @@ void SharedFilesDialog::FilterItems() std::list result_list ; if(text == "") - { - int rowCount = ui.dirTreeView->model()->rowCount(); - - for (int row = 0; row < rowCount; ++row) - recursMakeAllVisible(ui.dirTreeView,ui.dirTreeView->model()->index(row, COLUMN_NAME)) ; - return ; - } if(text.length() < 3) return ; @@ -1525,7 +1522,7 @@ void SharedFilesDialog::FilterItems() int rowCount = ui.dirTreeView->model()->rowCount(); for (int row = 0; row < rowCount; ++row) - recursMakeVisible(ui.dirTreeView,proxyModel,ui.dirTreeView->model()->index(row, COLUMN_NAME),0,pointers); + recursMakeVisible(ui.dirTreeView,proxyModel,ui.dirTreeView->model()->index(row, COLUMN_NAME),0,pointers,mHiddenIndexes); } else { @@ -1554,6 +1551,7 @@ bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString else { ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); + mHiddenIndexes.push_back(proxyModel->mapToSource(index)); return true ; } } @@ -1584,7 +1582,10 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString if (visible || visibleChildCount) { ui.dirTreeView->setRowHidden(index.row(), index.parent(), false); } else { + { ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); + mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + } } return (visible || visibleChildCount); diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index e1c5235f5..f7c866d70 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -107,6 +107,8 @@ protected: bool tree_FilterItem(const QModelIndex &index, const QString &text, int level); bool flat_FilterItem(const QModelIndex &index, const QString &text, int level); + void restoreInvisibleItems(); + QModelIndexList getSelected(); /** Defines the actions for the context menu for QTreeWidget */ @@ -133,6 +135,8 @@ protected: QString lastFilterString; QString mLastFilterText ; + + QList mHiddenIndexes; }; class LocalSharedFilesDialog : public SharedFilesDialog From 83b6205af3a8939728ec9afc6906f7edee7de12c Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 16 Feb 2018 10:22:59 +0100 Subject: [PATCH 6/6] Fix New Chat Invite --- libretroshare/src/chat/distributedchat.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index ee176c56b..00fcd3a97 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -1403,13 +1403,14 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id,const return false; } - std::map::const_iterator vid = _visible_lobbies.find(lobby_id) ; + //std::map::const_iterator vid = _visible_lobbies.find(lobby_id) ; - if(_visible_lobbies.end() == vid) - { - std::cerr << " (EE) Cannot subscribe a non visible chat lobby!!" << std::endl; - return false ; - } + //When invited to new Lobby, it is not visible. + //if(_visible_lobbies.end() == vid) + //{ + // std::cerr << " (EE) Cannot subscribe a non visible chat lobby!!" << std::endl; + // return false ; + //} RsIdentityDetails det ; if( (!rsIdentity->getIdDetails(identity,det)) || !(det.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID)) @@ -1418,7 +1419,7 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id,const return false ; } - if( (vid->second.lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ) && !(det.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)) + if( (it->second.lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ) && !(det.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)) { std::cerr << " (EE) Cannot subscribe with identity " << identity << " because it is unsigned and the lobby requires signed ids only." << std::endl; return false ; @@ -1437,8 +1438,8 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id,const ChatLobbyEntry entry ; entry.participating_friends.insert(it->second.peer_id) ; - entry.lobby_flags = it->second.lobby_flags ; - entry.gxs_id = identity ; + entry.lobby_flags = it->second.lobby_flags ; + entry.gxs_id = identity ; entry.lobby_id = lobby_id ; entry.lobby_name = it->second.lobby_name ; entry.lobby_topic = it->second.lobby_topic ;