diff --git a/TODO.txt b/TODO.txt index 9d1e6e55d..9601e2a8f 100644 --- a/TODO.txt +++ b/TODO.txt @@ -27,7 +27,7 @@ E [ ] do we keep "Getting Started" ? the look needs to be improved E [ ] Recommendation messages do not show complete links. Links show up in some buttons and the text is truncated E [ ] Recommendation messages should not be signed by the retroshare team!! E [ ] when adding a friend through clicking on cert links, the add friend wizard is shown twice! -M [ ] add a flag in friends option to allow auto-download of recommended files +M [X] add a flag in friends option to allow auto-download of recommended files Messages H [ ] distant messages should be made async-ed diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index bef0970ef..8a3fde866 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -292,7 +292,7 @@ void ftController::searchForDirectSources() if(mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info)) for(std::list::const_iterator pit = info.peers.begin(); pit != info.peers.end(); ++pit) - if(rsPeers->servicePermissionFlags(pit->peerId) & RS_SERVICE_PERM_DIRECT_DL) + if(rsPeers->servicePermissionFlags(pit->peerId) & RS_NODE_PERM_DIRECT_DL) if(it->second->mTransfer->addFileSource(pit->peerId)) /* if the sources don't exist already - add in */ setPeerState(it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceId, pit->peerId)); } @@ -1134,7 +1134,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash // if(!(flags & RS_FILE_REQ_CACHE)) for(std::list::iterator it = srcIds.begin(); it != srcIds.end(); ) - if(!(rsPeers->servicePermissionFlags(*it) & RS_SERVICE_PERM_DIRECT_DL)) + if(!(rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL)) { std::list::iterator tmp(it) ; ++tmp ; @@ -1190,7 +1190,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash */ for(it = srcIds.begin(); it != srcIds.end(); ++it) - if(rsPeers->servicePermissionFlags(*it) & RS_SERVICE_PERM_DIRECT_DL) + if(rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL) { uint32_t i, j; if ((dit->second)->mTransfer->getPeerState(*it, i, j)) @@ -1245,7 +1245,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash #endif // Because this is auto-add, we only add sources that we allow to DL from using direct transfers. - if ((srcIds.end() == std::find( srcIds.begin(), srcIds.end(), pit->peerId)) && (RS_SERVICE_PERM_DIRECT_DL & rsPeers->servicePermissionFlags(pit->peerId))) + if ((srcIds.end() == std::find( srcIds.begin(), srcIds.end(), pit->peerId)) && (RS_NODE_PERM_DIRECT_DL & rsPeers->servicePermissionFlags(pit->peerId))) { srcIds.push_back(pit->peerId); diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index ca9539ac6..7e7720a77 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1700,7 +1700,7 @@ bool p3PeerMgrIMPL::loadList(std::list& load) std::cerr << std::endl; #endif /* ************* */ - addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_SERVICE_PERM_ALL); + addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_NODE_PERM_DEFAULT); setLocation(pitem->peerId, pitem->location); } @@ -2135,7 +2135,7 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPeerId& ssl std::map::const_iterator it = mFriendList.find(ssl_id); if(it == mFriendList.end()) - return RS_SERVICE_PERM_ALL ; + return RS_NODE_PERM_DEFAULT ; gpg_id = it->second.gpg_id ; } @@ -2152,7 +2152,7 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPgpId& pgp_ std::map::const_iterator it = mFriendsPermissionFlags.find( pgp_id ) ; if(it == mFriendsPermissionFlags.end()) - return RS_SERVICE_PERM_ALL ; + return RS_NODE_PERM_DEFAULT ; else return it->second ; } diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index 69b1d9348..6df264366 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -116,7 +116,7 @@ virtual ~p3PeerMgr() { return; } virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id, uint32_t netMode = RS_NET_MODE_UDP, uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL, - time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL)) = 0; + time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)) = 0; virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0; virtual bool isFriend(const RsPeerId& ssl_id) = 0; @@ -217,7 +217,7 @@ class p3PeerMgrIMPL: public p3PeerMgr, public p3Config virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP, uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL, - time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL)); + time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)); virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId); virtual bool removeFriend(const RsPgpId &pgp_id); diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 1fd900d3b..f4d62e875 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -75,9 +75,11 @@ const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008; // Service option flags. // -const ServicePermissionFlags RS_SERVICE_PERM_NONE ( 0x00000000 ) ; -const ServicePermissionFlags RS_SERVICE_PERM_DIRECT_DL ( 0x00000008 ) ; -const ServicePermissionFlags RS_SERVICE_PERM_ALL = RS_SERVICE_PERM_DIRECT_DL ; +const ServicePermissionFlags RS_NODE_PERM_NONE ( 0x00000000 ) ;// 0x1, 0x2 and Ox4 are deprecated. +const ServicePermissionFlags RS_NODE_PERM_DIRECT_DL ( 0x00000008 ) ;// Accept to directly DL from this peer (breaks anonymity) +const ServicePermissionFlags RS_NODE_PERM_ALLOW_PUSH ( 0x00000010 ) ;// Auto-DL files recommended by this peer +const ServicePermissionFlags RS_NODE_PERM_DEFAULT = RS_NODE_PERM_DIRECT_DL ; +const ServicePermissionFlags RS_NODE_PERM_ALL = RS_NODE_PERM_DIRECT_DL | RS_NODE_PERM_ALLOW_PUSH; // ... @@ -321,7 +323,7 @@ class RsPeers virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0; /* Add/Remove Friends */ - virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0; + virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT) = 0; virtual bool removeFriend(const RsPgpId& pgp_id) = 0; virtual bool removeFriendLocation(const RsPeerId& sslId) = 0; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 3ffa6c59e..b7eab2286 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -1087,7 +1087,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai pd.location = cert.location_name_string(); pd.isOnlyGPGdetail = pd.id.isNull(); - pd.service_perm_flags = RS_SERVICE_PERM_ALL ; + pd.service_perm_flags = RS_NODE_PERM_DEFAULT ; if (!cert.hidden_node_string().empty()) { diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 9f8443f9e..f15b1d5e2 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -75,7 +75,7 @@ virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list &ids virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ; /* Add/Remove Friends */ -virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL); +virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT); virtual bool removeFriend(const RsPgpId& gpgid); virtual bool removeFriendLocation(const RsPeerId& sslId); diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index 9e83d4c5a..67177948c 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -911,7 +911,7 @@ void p3discovery2::processContactInfo(const SSLID &fromId, const RsDiscContactIt #ifdef P3DISC_DEBUG std::cerr << "--> Adding to friends list " << item->sslId << " - " << item->pgpId << std::endl; #endif - mPeerMgr->addFriend(item->sslId, item->pgpId, item->netMode, RS_VS_DISC_OFF, RS_VS_DHT_FULL,(time_t)0,RS_SERVICE_PERM_ALL); + mPeerMgr->addFriend(item->sslId, item->pgpId, item->netMode, RS_VS_DISC_OFF, RS_VS_DHT_FULL,(time_t)0,RS_NODE_PERM_DEFAULT); updatePeerAddresses(item); } } diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index ef8d6ae9b..9d9715ae9 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -196,6 +196,13 @@ void p3MsgService::processMsg(RsMsgItem *mi, bool incoming) mSrcIds.insert(std::pair(msi->msgId, msi)); IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ } + // If the peer is allowed to push files, then auto-download the recommended files. + + if(rsPeers->servicePermissionFlags(mi->PeerId()) & RS_NODE_PERM_ALLOW_PUSH) + for(std::list::const_iterator it(mi->attachment.items.begin());it!=mi->attachment.items.end();++it) + rsFiles->FileRequest((*it).name,(*it).hash,(*it).filesize,std::string(),RS_FILE_REQ_ANONYMOUS_ROUTING,std::list()) ; + + RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD); diff --git a/retroshare-gui/src/gui/ServicePermissionDialog.cpp b/retroshare-gui/src/gui/ServicePermissionDialog.cpp index 017500714..9d364c271 100644 --- a/retroshare-gui/src/gui/ServicePermissionDialog.cpp +++ b/retroshare-gui/src/gui/ServicePermissionDialog.cpp @@ -38,7 +38,7 @@ ServicePermissionDialog::ServicePermissionDialog() : Settings->loadWidgetInformation(this); ui->headerFrame->setHeaderImage(QPixmap(":/images/user/servicepermissions64.png")); - ui->headerFrame->setHeaderText(tr("Service Permissions")); + ui->headerFrame->setHeaderText(tr("Service Permissions")); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(setPermissions())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); @@ -49,9 +49,12 @@ ServicePermissionDialog::ServicePermissionDialog() : ui->servicePermissionList->setModus(FriendSelectionWidget::MODUS_SINGLE); ui->servicePermissionList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GPG); - /* add columns */ - int column = ui->servicePermissionList->addColumn(tr("Use as direct source, when available")); - mColumns[column] = RS_SERVICE_PERM_DIRECT_DL; + /* add columns */ + int column ; + column = ui->servicePermissionList->addColumn(tr("Use as direct source, when available")); + mColumns[column] = RS_NODE_PERM_DIRECT_DL; + column = ui->servicePermissionList->addColumn(tr("Auto-download recommended files")); + mColumns[column] = RS_NODE_PERM_ALLOW_PUSH; ui->servicePermissionList->start(); } diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index f3fd8abdf..a01f5ed92 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -140,7 +140,8 @@ void ConfCertDialog::setServiceFlags() { ServicePermissionFlags flags(0) ; - if( ui._direct_transfer_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DIRECT_DL ; + if( ui._direct_transfer_CB->isChecked()) flags = flags | RS_NODE_PERM_DIRECT_DL ; + if( ui._allow_push_CB->isChecked()) flags = flags | RS_NODE_PERM_ALLOW_PUSH ; rsPeers->setServicePermissionFlags(pgpId,flags) ; } @@ -175,7 +176,8 @@ void ConfCertDialog::load() ui.make_friend_button->setToolTip("") ; } - ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL ) ; + ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_DIRECT_DL ) ; + ui._allow_push_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ; ui.name->setText(QString::fromUtf8(detail.name.c_str())); ui.peerid->setText(QString::fromStdString(detail.id.toStdString())); diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index d3128fd47..635326f03 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -813,7 +813,7 @@ p, li { white-space: pre-wrap; } Options - + Qt::Vertical @@ -836,6 +836,13 @@ p, li { white-space: pre-wrap; } + + + + Auto-download recommended files from this node + + + diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index a69ade269..29f32e564 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -256,7 +256,8 @@ void ConnectFriendWizard::initializePage(int id) { std::cerr << "Conclusion page id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl; - ui->_direct_transfer_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL) ; + ui->_direct_transfer_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_NODE_PERM_DIRECT_DL) ; + ui->_allow_push_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ; RsPeerDetails tmp_det ; bool already_in_keyring = rsPeers->getGPGDetails(peerDetails.gpg_id, tmp_det) ; @@ -620,9 +621,11 @@ ServicePermissionFlags ConnectFriendWizard::serviceFlags() const if (hasVisitedPage(Page_FriendRequest)) { - if( ui->_direct_transfer_CB->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ; + if( ui->_direct_transfer_CB->isChecked()) flags |= RS_NODE_PERM_DIRECT_DL ; + if( ui->_allow_push_CB->isChecked()) flags |= RS_NODE_PERM_ALLOW_PUSH ; } else if (hasVisitedPage(Page_Conclusion)) { - if( ui->_direct_transfer_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ; + if( ui->_direct_transfer_CB_2->isChecked()) flags |= RS_NODE_PERM_DIRECT_DL ; + if( ui->_allow_push_CB_2->isChecked()) flags |= RS_NODE_PERM_ALLOW_PUSH ; } return flags ; } diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui index d583f1ccd..8b9f8dc7b 100644 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui @@ -7,7 +7,7 @@ 0 0 662 - 623 + 650 @@ -687,6 +687,13 @@ + + + + Auto-download recommended files + + + @@ -996,34 +1003,20 @@ - Service permissions + Options - Direct source + Can be used as direct source - + - Discovery - - - - - - - Forums/channels - - - - - - - Anonymous routing + Auto-download recommended files @@ -1093,17 +1086,17 @@ - - StyledLabel - QLabel -
gui/common/StyledLabel.h
-
AvatarWidget QLabel
gui/common/AvatarWidget.h
1
+ + StyledLabel + QLabel +
gui/common/StyledLabel.h
+
FriendSelectionWidget QWidget diff --git a/retroshare-nogui/src/rpc/proto/rpcprotopeers.cc b/retroshare-nogui/src/rpc/proto/rpcprotopeers.cc index 9e507da55..cfe9c9076 100644 --- a/retroshare-nogui/src/rpc/proto/rpcprotopeers.cc +++ b/retroshare-nogui/src/rpc/proto/rpcprotopeers.cc @@ -153,7 +153,7 @@ int RpcProtoPeers::processAddPeer(uint32_t chan_id, uint32_t /* msg_id */, uint3 case rsctrl::peers::RequestAddPeer::ADD: // TODO. NEED TO HANDLE SERVICE PERMISSION FLAGS. - success = rsPeers->addFriend(ssl_id,pgp_id, RS_SERVICE_PERM_ALL); + success = rsPeers->addFriend(ssl_id,pgp_id, RS_NODE_PERM_DEFAULT); break; case rsctrl::peers::RequestAddPeer::REMOVE: