mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-12 00:23:08 -04:00
Switched most of the services to use p3ServiceControl instead of p3LinkMgr.
- Added a couple of utility fns to p3ServiceControl too. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7211 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
efe9503c3a
commit
190988c3cc
33 changed files with 387 additions and 329 deletions
|
@ -30,13 +30,19 @@
|
|||
|
||||
RsServiceControl *rsServiceControl = NULL;
|
||||
|
||||
p3ServiceControl::p3ServiceControl(p3LinkMgr *linkMgr, uint32_t configId)
|
||||
p3ServiceControl::p3ServiceControl(p3LinkMgr *linkMgr)
|
||||
:RsServiceControl(), /* p3Config(configId), pqiMonitor(), */
|
||||
mLinkMgr(linkMgr),
|
||||
mLinkMgr(linkMgr), mOwnPeerId(linkMgr->getOwnId()),
|
||||
mCtrlMtx("p3ServiceControl"), mMonitorMtx("P3ServiceControl::Monitor")
|
||||
{
|
||||
}
|
||||
|
||||
const RsPeerId& p3ServiceControl::getOwnId()
|
||||
{
|
||||
return mOwnPeerId;
|
||||
}
|
||||
|
||||
|
||||
/* Interface for Services */
|
||||
bool p3ServiceControl::registerService(const RsServiceInfo &info, bool defaultOn)
|
||||
{
|
||||
|
@ -820,6 +826,23 @@ void p3ServiceControl::getPeersConnected(const uint32_t serviceId, std::set<RsPe
|
|||
}
|
||||
|
||||
|
||||
bool p3ServiceControl::isPeerConnected(const uint32_t serviceId, const RsPeerId &peerId)
|
||||
{
|
||||
RsStackMutex stack(mCtrlMtx); /***** LOCK STACK MUTEX ****/
|
||||
|
||||
std::map<uint32_t, std::set<RsPeerId> >::iterator mit;
|
||||
mit = mServicePeerMap.find(serviceId);
|
||||
if (mit != mServicePeerMap.end())
|
||||
{
|
||||
std::set<RsPeerId>::iterator sit;
|
||||
sit = mit->second.find(peerId);
|
||||
return (sit != mit->second.end());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
/**
|
||||
*/
|
||||
p3ServiceControl(p3LinkMgr *linkMgr, uint32_t configId);
|
||||
p3ServiceControl(p3LinkMgr *linkMgr);
|
||||
|
||||
/**
|
||||
* checks and update all added configurations
|
||||
|
@ -70,6 +70,14 @@ public:
|
|||
*/
|
||||
void tick();
|
||||
|
||||
/**
|
||||
* provided so that services don't need linkMgr, and can get all info
|
||||
* from ServiceControl.
|
||||
* @see rsserver
|
||||
*/
|
||||
|
||||
virtual const RsPeerId& getOwnId();
|
||||
|
||||
/**
|
||||
* External Interface (RsServiceControl).
|
||||
*/
|
||||
|
@ -88,6 +96,7 @@ virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermiss
|
|||
|
||||
// Get List of Peers using this Service.
|
||||
virtual void getPeersConnected(const uint32_t serviceId, std::set<RsPeerId> &peerSet);
|
||||
virtual bool isPeerConnected(const uint32_t serviceId, const RsPeerId &peerId);
|
||||
|
||||
/**
|
||||
* Registration for all Services.
|
||||
|
@ -155,6 +164,7 @@ bool createDefaultPermissions_locked(uint32_t serviceId, std::string serviceName
|
|||
bool peerHasPermissionForService_locked(const RsPeerId &peerId, uint32_t serviceId);
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
const RsPeerId mOwnPeerId; // const from constructor
|
||||
|
||||
RsMutex mCtrlMtx; /* below is protected */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue