mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added new flag to allow peers auto-download recommended files from trusted neighbor nodes, which give the possibility to push data to other nodes
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7955 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d029dd0368
commit
d2c4c3bb09
2
TODO.txt
2
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
|
||||
|
@ -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<TransferInfo>::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<RsPeerId>::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<RsPeerId>::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);
|
||||
|
||||
|
@ -1700,7 +1700,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& 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<RsPeerId, peerState>::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<RsPgpId,ServicePermissionFlags>::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 ;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +196,13 @@ void p3MsgService::processMsg(RsMsgItem *mi, bool incoming)
|
||||
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(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<RsTlvFileItem>::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<RsPeerId>()) ;
|
||||
|
||||
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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()));
|
||||
|
@ -813,7 +813,7 @@ p, li { white-space: pre-wrap; }
|
||||
<string>Options</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -836,6 +836,13 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="_allow_push_CB">
|
||||
<property name="text">
|
||||
<string>Auto-download recommended files from this node</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -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 ;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>662</width>
|
||||
<height>623</height>
|
||||
<height>650</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -687,6 +687,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_allow_push_CB">
|
||||
<property name="text">
|
||||
<string>Auto-download recommended files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
@ -996,34 +1003,20 @@
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Service permissions</string>
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_direct_transfer_CB_2">
|
||||
<property name="text">
|
||||
<string>Direct source</string>
|
||||
<string>Can be used as direct source</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_discovery_CB_2">
|
||||
<widget class="QCheckBox" name="_allow_push_CB_2">
|
||||
<property name="text">
|
||||
<string>Discovery</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_forums_channels_CB_2">
|
||||
<property name="text">
|
||||
<string>Forums/channels</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_anonymous_routing_CB_2">
|
||||
<property name="text">
|
||||
<string>Anonymous routing</string>
|
||||
<string>Auto-download recommended files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1093,17 +1086,17 @@
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>StyledLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>gui/common/StyledLabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AvatarWidget</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>gui/common/AvatarWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>StyledLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>gui/common/StyledLabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>FriendSelectionWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user