finished updateServicePermissions.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7205 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-03-25 12:13:43 +00:00
parent 5440aec17b
commit 0fac6fecf9
3 changed files with 54 additions and 47 deletions

View File

@ -30,8 +30,9 @@
RsServiceControl *rsServiceControl = NULL; RsServiceControl *rsServiceControl = NULL;
p3ServiceControl::p3ServiceControl(uint32_t configId) p3ServiceControl::p3ServiceControl(p3LinkMgr *linkMgr, uint32_t configId)
:RsServiceControl(), /* p3Config(configId), pqiMonitor(), */ :RsServiceControl(), /* p3Config(configId), pqiMonitor(), */
mLinkMgr(linkMgr),
mCtrlMtx("p3ServiceControl"), mMonitorMtx("P3ServiceControl::Monitor") mCtrlMtx("p3ServiceControl"), mMonitorMtx("P3ServiceControl::Monitor")
{ {
} }
@ -269,17 +270,18 @@ bool p3ServiceControl::updateServicePermissions(uint32_t serviceId, const RsServ
std::map<uint32_t, RsServicePermissions>::iterator it; std::map<uint32_t, RsServicePermissions>::iterator it;
it = mServicePermissionMap.find(serviceId); it = mServicePermissionMap.find(serviceId);
if (it == mServicePermissionMap.end())
{
std::cerr << "p3ServiceControl::updateServicePermissions()";
std::cerr << " ERROR missing previous permissions";
std::cerr << std::endl;
// ERROR.
return false;
}
std::list<RsPeerId> onlinePeers;
/* here we have to check which peers - permissions have changed for, mLinkMgr->getOnlineList(onlinePeers);
* and flag for updates. std::list<RsPeerId>::const_iterator pit;
*
* This is far more complex.
* need to check if versions are compatible and peers are providing service.
*/
#if 0
std::list<std::string> onlinePeers;
std::list<std::string>::const_iterator pit;
if (it != mServicePermissionMap.end()) if (it != mServicePermissionMap.end())
{ {
for(pit = onlinePeers.begin(); pit != onlinePeers.end(); pit++) for(pit = onlinePeers.begin(); pit != onlinePeers.end(); pit++)
@ -291,19 +293,12 @@ bool p3ServiceControl::updateServicePermissions(uint32_t serviceId, const RsServ
} }
} }
} }
else
{
// ERROR!
it = mServicePermissionMap.find[serviceId];
for(pit = onlinePeers.begin(); pit != onlinePeers.end(); pit++)
{
mUpdatedSet.insert(*pit);
}
}
#endif
it->second = permissions; it->second = permissions;
it->second.mServiceId = serviceId; // just to make sure! it->second.mServiceId = serviceId; // just to make sure!
// This is overkill - but will update everything.
updateAllFilters_locked();
return true; return true;
} }
@ -455,6 +450,15 @@ bool p3ServiceControl::updateAllFilters()
RsStackMutex stack(mCtrlMtx); /***** LOCK STACK MUTEX ****/ RsStackMutex stack(mCtrlMtx); /***** LOCK STACK MUTEX ****/
return updateAllFilters_locked();
}
bool p3ServiceControl::updateAllFilters_locked()
{
std::cerr << "p3ServiceControl::updateAllFilters_locked()";
std::cerr << std::endl;
// Create a peerSet from ServicesProvided + PeerFilters. // Create a peerSet from ServicesProvided + PeerFilters.
// This will completely refresh the Filters. // This will completely refresh the Filters.
std::set<RsPeerId> peerSet; std::set<RsPeerId> peerSet;

View File

@ -34,6 +34,7 @@
#include "pqi/p3cfgmgr.h" #include "pqi/p3cfgmgr.h"
#include "pqi/pqimonitor.h" #include "pqi/pqimonitor.h"
#include "pqi/pqiservicemonitor.h" #include "pqi/pqiservicemonitor.h"
#include "pqi/p3linkmgr.h"
class ServiceNotifications class ServiceNotifications
{ {
@ -61,7 +62,7 @@ public:
/** /**
*/ */
p3ServiceControl(uint32_t configId); p3ServiceControl(p3LinkMgr *linkMgr, uint32_t configId);
/** /**
* checks and update all added configurations * checks and update all added configurations
@ -129,6 +130,7 @@ void notifyAboutFriends();
bool createDefaultPermissions_locked(uint32_t serviceId, std::string serviceName, bool defaultOn); bool createDefaultPermissions_locked(uint32_t serviceId, std::string serviceName, bool defaultOn);
bool updateAllFilters(); bool updateAllFilters();
bool updateAllFilters_locked();
bool updateFilterByPeer(const RsPeerId &peerId); bool updateFilterByPeer(const RsPeerId &peerId);
bool updateFilterByPeer_locked(const RsPeerId &peerId); bool updateFilterByPeer_locked(const RsPeerId &peerId);
@ -145,6 +147,7 @@ void updatePeerRemoved(const RsPeerId &peerId);
bool peerHasPermissionForService_locked(const RsPeerId &peerId, uint32_t serviceId); bool peerHasPermissionForService_locked(const RsPeerId &peerId, uint32_t serviceId);
p3LinkMgr *mLinkMgr;
RsMutex mCtrlMtx; /* below is protected */ RsMutex mCtrlMtx; /* below is protected */

View File

@ -1222,7 +1222,7 @@ int RsServer::StartupRetroShare()
/**************************** BITDHT ***********************************/ /**************************** BITDHT ***********************************/
p3ServiceControl *serviceCtrl = new p3ServiceControl(0); p3ServiceControl *serviceCtrl = new p3ServiceControl(mLinkMgr, 0);
rsServiceControl = serviceCtrl; rsServiceControl = serviceCtrl;
SecurityPolicy *none = secpolicy_create(); SecurityPolicy *none = secpolicy_create();