mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05: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
@ -22,8 +22,9 @@
|
||||
*/
|
||||
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3servicecontrol.h"
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "util/rsdir.h"
|
||||
|
||||
@ -618,8 +619,9 @@ void CacheStore::locked_storeCacheEntry(const RsCacheData &data)
|
||||
*
|
||||
********************************* CacheStrapper ********************************/
|
||||
|
||||
CacheStrapper::CacheStrapper(p3LinkMgr *lm)
|
||||
:p3Config(CONFIG_TYPE_CACHE), mLinkMgr(lm), csMtx("CacheStrapper")
|
||||
CacheStrapper::CacheStrapper(p3ServiceControl *sc, uint32_t ftServiceId)
|
||||
:p3Config(CONFIG_TYPE_CACHE), mServiceCtrl(sc), mFtServiceId(ftServiceId),
|
||||
csMtx("CacheStrapper")
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -633,12 +635,12 @@ void CacheStrapper::addCachePair(CachePair set)
|
||||
|
||||
/**************** from pqimonclient ********************/
|
||||
|
||||
void CacheStrapper::statusChange(const std::list<pqipeer> &plist)
|
||||
void CacheStrapper::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for(it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
if(it->actions & RS_PEER_CONNECTED)
|
||||
if(it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
/* grab all the cache ids and add */
|
||||
|
||||
@ -666,13 +668,15 @@ void CacheStrapper::refreshCache(const RsCacheData &data,const std::set<RsPeerId
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() : " << data << std::endl;
|
||||
#endif
|
||||
const RsPeerId& ownid = mLinkMgr->getOwnId() ;
|
||||
std::list<RsPeerId> ids;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
ids.push_back(ownid) ;
|
||||
const RsPeerId& ownid = mServiceCtrl->getOwnId() ;
|
||||
std::set<RsPeerId> ids;
|
||||
|
||||
// Need to use ftServiceID as packets are passed through there.
|
||||
mServiceCtrl->getPeersConnected(mFtServiceId, ids);
|
||||
ids.insert(ownid) ;
|
||||
|
||||
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
for(std::list<RsPeerId>::const_iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
for(std::set<RsPeerId>::const_iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
if(destination_peers.find(*it) != destination_peers.end())
|
||||
{
|
||||
#ifdef CS_DEBUG
|
||||
@ -693,14 +697,14 @@ void CacheStrapper::refreshCache(const RsCacheData &data,const std::set<RsPeerId
|
||||
// std::cerr << "CacheStrapper::refreshCache() : " << data << std::endl;
|
||||
// #endif
|
||||
//
|
||||
// std::string ownid = mLinkMgr->getOwnId() ;
|
||||
// std::list<std::string> ids;
|
||||
// mLinkMgr->getOnlineList(ids);
|
||||
// std::string ownid = mServiceCtrl->getOwnId() ;
|
||||
// std::set<std::string> ids;
|
||||
// mServiceCtrl->getOnlineList(ids);
|
||||
// ids.push_back(ownid) ;
|
||||
//
|
||||
// {
|
||||
// RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
// for(std::list<std::string>::const_iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
// for(std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
// if(*it == ownid || isPeerPartipating(*it))
|
||||
// mCacheUpdates.push_back(std::make_pair(*it, data));
|
||||
// }
|
||||
@ -761,7 +765,7 @@ void CacheStrapper::listCaches(std::ostream &out)
|
||||
{
|
||||
/* can overwrite for more control! */
|
||||
std::map<uint16_t, CachePair>::iterator it;
|
||||
out << "CacheStrapper::listCaches() [" << mLinkMgr->getOwnId();
|
||||
out << "CacheStrapper::listCaches() [" << mServiceCtrl->getOwnId();
|
||||
out << "] " << " Total Caches: " << caches.size();
|
||||
out << std::endl;
|
||||
for(it = caches.begin(); it != caches.end(); it++)
|
||||
@ -854,7 +858,7 @@ bool CacheStrapper::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
std::list<RsCacheData>::iterator cit;
|
||||
std::list<RsCacheData> ownCaches;
|
||||
std::list<RsCacheData> remoteCaches;
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
std::map<uint16_t, CachePair>::iterator it;
|
||||
for(it = caches.begin(); it != caches.end(); it++)
|
||||
@ -934,7 +938,7 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
|
||||
#endif
|
||||
std::list<RsCacheData> ownCaches;
|
||||
std::list<RsCacheData> remoteCaches;
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
//peerConnectState ownState;
|
||||
//mPeerMgr->getOwnNetStatus(ownState);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define MRK_CACHE_STRAPPER_H
|
||||
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
#include <list>
|
||||
@ -377,9 +377,9 @@ bool operator<(const CachePair &a, const CachePair &b);
|
||||
* queries and updates as new information arrives.
|
||||
*/
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
class CacheStrapper: public pqiMonitor, public p3Config
|
||||
class CacheStrapper: public pqiServiceMonitor, public p3Config
|
||||
{
|
||||
public:
|
||||
|
||||
@ -387,11 +387,11 @@ class CacheStrapper: public pqiMonitor, public p3Config
|
||||
* @param cm handle used by strapper for getting peer connection information (online peers, sslids...)
|
||||
* @return
|
||||
*/
|
||||
CacheStrapper(p3LinkMgr *lm);
|
||||
CacheStrapper(p3ServiceControl *sc, uint32_t ftServiceId);
|
||||
virtual ~CacheStrapper() { return; }
|
||||
|
||||
/************* from pqiMonitor *******************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
/************* from pqiMonitor *******************/
|
||||
|
||||
/* Feedback from CacheSources */
|
||||
@ -461,7 +461,8 @@ virtual bool loadList(std::list<RsItem *>& load);
|
||||
private:
|
||||
|
||||
/* these are static - so shouldn't need mutex */
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
uint32_t mFtServiceId;
|
||||
|
||||
std::map<uint16_t, CachePair> caches;
|
||||
|
||||
|
@ -98,13 +98,15 @@ ftFileControl::ftFileControl(std::string fname,
|
||||
return;
|
||||
}
|
||||
|
||||
ftController::ftController(CacheStrapper *cs, ftDataMultiplex *dm, std::string /*configDir*/)
|
||||
ftController::ftController(CacheStrapper *cs, ftDataMultiplex *dm, p3ServiceControl *sc, uint32_t ftServiceId)
|
||||
:CacheTransfer(cs), p3Config(CONFIG_TYPE_FT_CONTROL),
|
||||
last_save_time(0),
|
||||
last_clean_time(0),
|
||||
mDataplex(dm),
|
||||
mTurtle(NULL),
|
||||
mFtServer(NULL),
|
||||
mServiceCtrl(sc),
|
||||
mFtServiceId(ftServiceId),
|
||||
ctrlMutex("ftController"),
|
||||
doneMutex("ftController"),
|
||||
mFtActive(false),
|
||||
@ -173,7 +175,7 @@ void ftController::addFileSource(const RsFileHash& hash,const RsPeerId& peer_id)
|
||||
if(it != mDownloads.end())
|
||||
{
|
||||
it->second->mTransfer->addFileSource(peer_id);
|
||||
setPeerState(it->second->mTransfer, peer_id, FT_CNTRL_STANDARD_RATE, mLinkMgr->isOnline( peer_id ));
|
||||
setPeerState(it->second->mTransfer, peer_id, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceId, peer_id ));
|
||||
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "... added." << std::endl ;
|
||||
@ -295,7 +297,7 @@ void ftController::searchForDirectSources()
|
||||
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(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, mLinkMgr->isOnline( pit->peerId ));
|
||||
setPeerState(it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceId, pit->peerId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1208,7 +1210,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
(dit->second)->mTransfer->addFileSource(*it);
|
||||
setPeerState(dit->second->mTransfer, *it, rate, mLinkMgr->isOnline(*it));
|
||||
setPeerState(dit->second->mTransfer, *it, rate, mServiceCtrl->isPeerConnected(mFtServiceId, *it));
|
||||
|
||||
IndicateConfigChanged(); /* new peer for transfer -> save */
|
||||
}
|
||||
@ -1305,7 +1307,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
||||
std::cerr << "ftController::FileRequest() adding peer: " << *it;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
setPeerState(tm, *it, rate, mLinkMgr->isOnline(*it));
|
||||
setPeerState(tm, *it, rate, mServiceCtrl->isPeerConnected(mFtServiceId, *it));
|
||||
}
|
||||
|
||||
/* add structures into the accessible data. Needs to be locked */
|
||||
@ -1333,7 +1335,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
||||
|
||||
bool ftController::setPeerState(ftTransferModule *tm, const RsPeerId& id, uint32_t maxrate, bool online)
|
||||
{
|
||||
if (id == mLinkMgr->getOwnId())
|
||||
if (id == mServiceCtrl->getOwnId())
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::setPeerState() is Self";
|
||||
@ -1815,14 +1817,14 @@ bool ftController::FileDetails(const RsFileHash &hash, FileInfo &info)
|
||||
/* pqiMonitor callback:
|
||||
* Used to tell TransferModules new available peers
|
||||
*/
|
||||
void ftController::statusChange(const std::list<pqipeer> &plist)
|
||||
void ftController::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
uint32_t rate = FT_CNTRL_STANDARD_RATE;
|
||||
|
||||
/* add online to all downloads */
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it;
|
||||
std::list<pqipeer>::const_iterator pit;
|
||||
std::list<pqiServicePeer>::const_iterator pit;
|
||||
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::statusChange()";
|
||||
@ -1842,7 +1844,7 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "Peer: " << pit->id;
|
||||
#endif
|
||||
if (pit->actions & RS_PEER_CONNECTED)
|
||||
if (pit->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << " is Newly Connected!";
|
||||
@ -1850,7 +1852,7 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
|
||||
#endif
|
||||
setPeerState(it->second->mTransfer, pit->id, rate, true);
|
||||
}
|
||||
else if (pit->actions & RS_PEER_DISCONNECTED)
|
||||
else if (pit->actions & RS_SERVICE_PEER_DISCONNECTED)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << " is Just disconnected!";
|
||||
@ -1858,7 +1860,7 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
|
||||
#endif
|
||||
setPeerState(it->second->mTransfer, pit->id, rate, false);
|
||||
}
|
||||
else
|
||||
else // Added or Removed.
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << " had something happen to it: ";
|
||||
@ -1872,41 +1874,42 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
|
||||
// Now also look at turtle virtual peers.
|
||||
//
|
||||
std::list<pqipeer> vlist ;
|
||||
std::list<pqipeer>::const_iterator vit;
|
||||
mTurtle->getSourceVirtualPeersList(it->first,vlist) ;
|
||||
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "vlist.size() = " << vlist.size() << std::endl;
|
||||
#endif
|
||||
|
||||
for(pit = vlist.begin(); pit != vlist.end(); pit++)
|
||||
for(vit = vlist.begin(); vit != vlist.end(); vit++)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "Peer: " << pit->id;
|
||||
std::cerr << "Peer: " << vit->id;
|
||||
#endif
|
||||
if (pit->actions & RS_PEER_CONNECTED)
|
||||
if (vit->actions & RS_PEER_CONNECTED)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << " is Newly Connected!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
setPeerState(it->second->mTransfer, pit->id, rate, true);
|
||||
setPeerState(it->second->mTransfer, vit->id, rate, true);
|
||||
}
|
||||
else if (pit->actions & RS_PEER_DISCONNECTED)
|
||||
else if (vit->actions & RS_PEER_DISCONNECTED)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << " is Just disconnected!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
setPeerState(it->second->mTransfer, pit->id, rate, false);
|
||||
setPeerState(it->second->mTransfer, vit->id, rate, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << " had something happen to it: ";
|
||||
std::cerr << pit-> actions;
|
||||
std::cerr << vit-> actions;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
setPeerState(it->second->mTransfer, pit->id, rate, false);
|
||||
setPeerState(it->second->mTransfer, vit->id, rate, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,11 @@ class ftServer;
|
||||
class ftExtraList;
|
||||
class ftDataMultiplex;
|
||||
class p3turtle ;
|
||||
class p3ServiceControl;
|
||||
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
#include "retroshare/rsfiles.h"
|
||||
@ -112,12 +113,12 @@ class ftPendingRequest
|
||||
};
|
||||
|
||||
|
||||
class ftController: public CacheTransfer, public RsThread, public pqiMonitor, public p3Config
|
||||
class ftController: public CacheTransfer, public RsThread, public pqiServiceMonitor, public p3Config
|
||||
{
|
||||
public:
|
||||
|
||||
/* Setup */
|
||||
ftController(CacheStrapper *cs, ftDataMultiplex *dm, std::string configDir);
|
||||
ftController(CacheStrapper *cs, ftDataMultiplex *dm, p3ServiceControl *sc, uint32_t ftServiceId);
|
||||
|
||||
void setFtSearchNExtra(ftSearch *, ftExtraList *);
|
||||
void setTurtleRouter(p3turtle *) ;
|
||||
@ -187,7 +188,8 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
||||
bool assumeAvailability(const RsPeerId& peer_id) const ;
|
||||
|
||||
/* pqiMonitor callback (also provided mConnMgr pointer!) */
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
void addFileSource(const RsFileHash& hash,const RsPeerId& peer_id) ;
|
||||
void removeFileSource(const RsFileHash& hash,const RsPeerId& peer_id) ;
|
||||
|
||||
@ -238,6 +240,8 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
||||
ftExtraList *mExtraList;
|
||||
p3turtle *mTurtle ;
|
||||
ftServer *mFtServer ;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
uint32_t mFtServiceId;
|
||||
|
||||
RsMutex ctrlMutex;
|
||||
|
||||
|
@ -378,8 +378,8 @@ void ftFiMonitor::setSharedDirectories(const std::list<SharedDirInfo>& dirList)
|
||||
|
||||
|
||||
|
||||
ftCacheStrapper::ftCacheStrapper(p3LinkMgr *lm)
|
||||
:CacheStrapper(lm)
|
||||
ftCacheStrapper::ftCacheStrapper(p3ServiceControl *sc, uint32_t ftServiceId)
|
||||
:CacheStrapper(sc, ftServiceId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
class p3LinkMgr ;
|
||||
class p3PeerMgr ;
|
||||
class p3ServiceControl ;
|
||||
|
||||
|
||||
#include "ft/ftsearch.h"
|
||||
@ -91,7 +92,7 @@ virtual bool loadList(std::list<RsItem *>& load);
|
||||
class ftCacheStrapper: public CacheStrapper, public ftSearch
|
||||
{
|
||||
public:
|
||||
ftCacheStrapper(p3LinkMgr *cm);
|
||||
ftCacheStrapper(p3ServiceControl *cm, uint32_t ftServiceId);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
|
@ -63,16 +63,16 @@ const int ftserverzone = 29539;
|
||||
static const time_t FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD = 5 ; // low priority tasks handling every 5 seconds
|
||||
|
||||
/* Setup */
|
||||
ftServer::ftServer(p3PeerMgr *pm, p3LinkMgr *lm)
|
||||
ftServer::ftServer(p3PeerMgr *pm, p3ServiceControl *sc)
|
||||
: p3Service(),
|
||||
mPeerMgr(pm),
|
||||
mLinkMgr(lm),
|
||||
mServiceCtrl(sc),
|
||||
mCacheStrapper(NULL),
|
||||
mFiStore(NULL), mFiMon(NULL),
|
||||
mFtController(NULL), mFtExtra(NULL),
|
||||
mFtDataplex(NULL), mFtSearch(NULL), srvMutex("ftServer")
|
||||
{
|
||||
mCacheStrapper = new ftCacheStrapper(lm);
|
||||
mCacheStrapper = new ftCacheStrapper(sc, getServiceInfo().mServiceType);
|
||||
|
||||
addSerialType(new RsFileTransferSerialiser()) ;
|
||||
}
|
||||
@ -123,8 +123,8 @@ const RsPeerId& ftServer::OwnId()
|
||||
{
|
||||
static RsPeerId null_id ;
|
||||
|
||||
if (mLinkMgr)
|
||||
return mLinkMgr->getOwnId();
|
||||
if (mServiceCtrl)
|
||||
return mServiceCtrl->getOwnId();
|
||||
else
|
||||
return null_id ;
|
||||
}
|
||||
@ -136,7 +136,7 @@ void ftServer::SetupFtServer()
|
||||
/* setup FiStore/Monitor */
|
||||
std::string localcachedir = mConfigPath + "/cache/local";
|
||||
std::string remotecachedir = mConfigPath + "/cache/remote";
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
/* search/extras List */
|
||||
mFtExtra = new ftExtraList();
|
||||
@ -146,7 +146,7 @@ void ftServer::SetupFtServer()
|
||||
mFtDataplex = new ftDataMultiplex(ownId, this, mFtSearch);
|
||||
|
||||
/* make Controller */
|
||||
mFtController = new ftController(mCacheStrapper, mFtDataplex, mConfigPath);
|
||||
mFtController = new ftController(mCacheStrapper, mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
|
||||
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
|
||||
std::string tmppath = ".";
|
||||
mFtController->setPartialsDirectory(tmppath);
|
||||
@ -167,8 +167,8 @@ void ftServer::SetupFtServer()
|
||||
mFtSearch->addSearchMode(mFiMon, RS_FILE_HINTS_LOCAL);
|
||||
mFtSearch->addSearchMode(mFiStore, RS_FILE_HINTS_REMOTE);
|
||||
|
||||
mLinkMgr->addMonitor(mFtController);
|
||||
mLinkMgr->addMonitor(mCacheStrapper);
|
||||
mServiceCtrl->registerServiceMonitor(mFtController, getServiceInfo().mServiceType);
|
||||
mServiceCtrl->registerServiceMonitor(mCacheStrapper, getServiceInfo().mServiceType);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -562,7 +562,7 @@ int ftServer::RequestDirDetails(const RsPeerId& uid, const std::string& path, Di
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
if(uid == mLinkMgr->getOwnId())
|
||||
if(uid == mServiceCtrl->getOwnId())
|
||||
return mFiMon->RequestDirDetails(path, details);
|
||||
else
|
||||
return mFiStore->RequestDirDetails(uid, path, details);
|
||||
|
@ -72,7 +72,7 @@ class p3turtle;
|
||||
class ftDwlQueue;
|
||||
|
||||
class p3PeerMgr;
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTurtleClientService
|
||||
{
|
||||
@ -83,7 +83,7 @@ class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTu
|
||||
/******************** Setup ************************************/
|
||||
/***************************************************************/
|
||||
|
||||
ftServer(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr);
|
||||
ftServer(p3PeerMgr *peerMgr, p3ServiceControl *serviceCtrl);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/* Assign important variables */
|
||||
@ -274,7 +274,7 @@ class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTu
|
||||
* as each component is protected independently.
|
||||
*/
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
ftCacheStrapper *mCacheStrapper;
|
||||
ftFiStore *mFiStore;
|
||||
|
@ -84,7 +84,7 @@ void RsGxsNetService::syncWithPeers()
|
||||
{
|
||||
|
||||
std::set<RsPeerId> peers;
|
||||
mNetMgr->getOnlineList(peers);
|
||||
mNetMgr->getOnlineList(mServiceInfo.mServiceType, peers);
|
||||
|
||||
std::set<RsPeerId>::iterator sit = peers.begin();
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include "rsgxsnetutils.h"
|
||||
#include "pqi/p3servicecontrol.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
|
||||
@ -185,8 +186,8 @@ NxsTransaction::~NxsTransaction(){
|
||||
|
||||
/* Net Manager */
|
||||
|
||||
RsNxsNetMgrImpl::RsNxsNetMgrImpl(p3LinkMgr *lMgr)
|
||||
: mLinkMgr(lMgr), mNxsNetMgrMtx("RsNxsNetMgrImpl")
|
||||
RsNxsNetMgrImpl::RsNxsNetMgrImpl(p3ServiceControl *sc)
|
||||
: mServiceCtrl(sc)
|
||||
{
|
||||
|
||||
}
|
||||
@ -194,24 +195,12 @@ RsNxsNetMgrImpl::RsNxsNetMgrImpl(p3LinkMgr *lMgr)
|
||||
|
||||
const RsPeerId& RsNxsNetMgrImpl::getOwnId()
|
||||
{
|
||||
RsStackMutex stack(mNxsNetMgrMtx);
|
||||
return mLinkMgr->getOwnId();
|
||||
return mServiceCtrl->getOwnId();
|
||||
}
|
||||
|
||||
void RsNxsNetMgrImpl::getOnlineList(std::set<RsPeerId> &ssl_peers)
|
||||
void RsNxsNetMgrImpl::getOnlineList(const uint32_t serviceId, std::set<RsPeerId> &ssl_peers)
|
||||
{
|
||||
ssl_peers.clear();
|
||||
|
||||
std::list<RsPeerId> pList;
|
||||
{
|
||||
RsStackMutex stack(mNxsNetMgrMtx);
|
||||
mLinkMgr->getOnlineList(pList);
|
||||
}
|
||||
|
||||
std::list<RsPeerId>::const_iterator lit = pList.begin();
|
||||
|
||||
for(; lit != pList.end(); lit++)
|
||||
ssl_peers.insert(*lit);
|
||||
mServiceCtrl->getPeersConnected(serviceId, ssl_peers);
|
||||
}
|
||||
|
||||
const time_t GrpCircleVetting::EXPIRY_PERIOD_OFFSET = 5; // 10 seconds
|
||||
|
@ -28,10 +28,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "rsgixs.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
|
||||
/*!
|
||||
* This represents a transaction made
|
||||
@ -82,7 +82,7 @@ public:
|
||||
|
||||
virtual ~RsNxsNetMgr(){};
|
||||
virtual const RsPeerId& getOwnId() = 0;
|
||||
virtual void getOnlineList(std::set<RsPeerId>& ssl_peers) = 0;
|
||||
virtual void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers) = 0;
|
||||
|
||||
};
|
||||
|
||||
@ -91,16 +91,16 @@ class RsNxsNetMgrImpl : public RsNxsNetMgr
|
||||
|
||||
public:
|
||||
|
||||
RsNxsNetMgrImpl(p3LinkMgr* lMgr);
|
||||
RsNxsNetMgrImpl(p3ServiceControl* sc);
|
||||
virtual ~RsNxsNetMgrImpl(){};
|
||||
|
||||
const RsPeerId& getOwnId();
|
||||
void getOnlineList(std::set<RsPeerId>& ssl_peers);
|
||||
virtual const RsPeerId& getOwnId();
|
||||
virtual void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers);
|
||||
|
||||
private:
|
||||
|
||||
p3LinkMgr* mLinkMgr;
|
||||
RsMutex mNxsNetMgrMtx;
|
||||
// No need for mutex as this is constant in the class.
|
||||
p3ServiceControl* mServiceCtrl;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -58,7 +58,7 @@ class RsDsdvRoute
|
||||
{
|
||||
public:
|
||||
|
||||
std::string mNextHop;
|
||||
RsPeerId mNextHop;
|
||||
uint32_t mSequence;
|
||||
uint32_t mDistance;
|
||||
time_t mReceived;
|
||||
@ -75,7 +75,7 @@ class RsDsdvTableEntry
|
||||
RsDsdvRoute mStableRoute;
|
||||
//RsDsdvRoute mFreshestRoute;
|
||||
|
||||
std::map<std::string, RsDsdvRoute> mAllRoutes;
|
||||
std::map<RsPeerId, RsDsdvRoute> mAllRoutes;
|
||||
|
||||
uint32_t mFlags;
|
||||
|
||||
|
@ -1222,7 +1222,7 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
/**************************** BITDHT ***********************************/
|
||||
|
||||
p3ServiceControl *serviceCtrl = new p3ServiceControl(mLinkMgr, 0);
|
||||
p3ServiceControl *serviceCtrl = new p3ServiceControl(mLinkMgr);
|
||||
rsServiceControl = serviceCtrl;
|
||||
|
||||
SecurityPolicy *none = secpolicy_create();
|
||||
@ -1230,12 +1230,12 @@ int RsServer::StartupRetroShare()
|
||||
//pqih = new pqipersongrpDummy(none, flags);
|
||||
|
||||
/****** New Ft Server **** !!! */
|
||||
ftServer *ftserver = new ftServer(mPeerMgr, mLinkMgr);
|
||||
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
|
||||
ftserver->setConfigDirectory(rsAccounts.PathAccountDirectory());
|
||||
|
||||
ftserver->SetupFtServer() ;
|
||||
CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper();
|
||||
CacheTransfer *mCacheTransfer = ftserver->getCacheTransfer();
|
||||
//CacheTransfer *mCacheTransfer = ftserver->getCacheTransfer();
|
||||
|
||||
/* setup any extra bits (Default Paths) */
|
||||
ftserver->setPartialsDirectory(emergencyPartialsDir);
|
||||
@ -1297,11 +1297,11 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
/* create Services */
|
||||
p3ServiceInfo *serviceInfo = new p3ServiceInfo(serviceCtrl);
|
||||
mDisc = new p3discovery2(mPeerMgr, mLinkMgr, mNetMgr);
|
||||
mHeart = new p3heartbeat(mLinkMgr, pqih);
|
||||
msgSrv = new p3MsgService(mLinkMgr);
|
||||
chatSrv = new p3ChatService(mLinkMgr, mHistoryMgr);
|
||||
mStatusSrv = new p3StatusService(mLinkMgr);
|
||||
mDisc = new p3discovery2(mPeerMgr, mLinkMgr, mNetMgr, serviceCtrl);
|
||||
mHeart = new p3heartbeat(serviceCtrl, pqih);
|
||||
msgSrv = new p3MsgService(serviceCtrl);
|
||||
chatSrv = new p3ChatService(serviceCtrl, mLinkMgr, mHistoryMgr);
|
||||
mStatusSrv = new p3StatusService(serviceCtrl);
|
||||
|
||||
#ifdef GROUTER
|
||||
p3GRouter *gr = new p3GRouter(mLinkMgr) ;
|
||||
@ -1383,7 +1383,7 @@ int RsServer::StartupRetroShare()
|
||||
// TODO: temporary to store GXS service data, remove
|
||||
RsDirUtil::checkCreateDirectory(currGxsDir);
|
||||
|
||||
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(mLinkMgr);
|
||||
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl);
|
||||
|
||||
/**** Identity service ****/
|
||||
|
||||
@ -1555,13 +1555,13 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
|
||||
#ifdef RS_RTT
|
||||
p3rtt *mRtt = new p3rtt(mLinkMgr);
|
||||
p3rtt *mRtt = new p3rtt(serviceCtrl);
|
||||
pqih -> addService(mRtt, true);
|
||||
rsRtt = mRtt;
|
||||
#endif
|
||||
|
||||
// new services to test.
|
||||
p3BanList *mBanList = new p3BanList(mLinkMgr, mNetMgr);
|
||||
p3BanList *mBanList = new p3BanList(serviceCtrl, mNetMgr);
|
||||
pqih -> addService(mBanList, true);
|
||||
mBitDht->setupPeerSharer(mBanList);
|
||||
|
||||
@ -1569,7 +1569,7 @@ int RsServer::StartupRetroShare()
|
||||
pqih -> addService(mBwCtrl, true);
|
||||
|
||||
#ifdef SERVICES_DSDV
|
||||
p3Dsdv *mDsdv = new p3Dsdv(mLinkMgr);
|
||||
p3Dsdv *mDsdv = new p3Dsdv(serviceCtrl);
|
||||
pqih -> addService(mDsdv, true);
|
||||
rsDsdv = mDsdv;
|
||||
mDsdv->addTestService();
|
||||
@ -1608,21 +1608,18 @@ int RsServer::StartupRetroShare()
|
||||
mLinkMgr->addMonitor(serviceCtrl);
|
||||
mLinkMgr->addMonitor(serviceInfo);
|
||||
|
||||
// below should be changed to pqiServiceMonitors....
|
||||
mLinkMgr->addMonitor(mCacheStrapper);
|
||||
mLinkMgr->addMonitor(msgSrv);
|
||||
mLinkMgr->addMonitor(mStatusSrv);
|
||||
mLinkMgr->addMonitor(chatSrv);
|
||||
mLinkMgr->addMonitor(mBwCtrl);
|
||||
// NOTE these were added in ftServer (was added twice).
|
||||
//mLinkMgr->addMonitor(mCacheStrapper);
|
||||
//mLinkMgr->addMonitor(((ftController *) mCacheTransfer));
|
||||
|
||||
// Services that have been changed to pqiServiceMonitor
|
||||
serviceCtrl->registerServiceMonitor(msgSrv, msgSrv->getServiceInfo().mServiceType);
|
||||
serviceCtrl->registerServiceMonitor(mDisc, mDisc->getServiceInfo().mServiceType);
|
||||
|
||||
/* must also add the controller as a Monitor...
|
||||
* a little hack to get it to work.
|
||||
*/
|
||||
mLinkMgr->addMonitor(((ftController *) mCacheTransfer));
|
||||
|
||||
serviceCtrl->registerServiceMonitor(mStatusSrv,
|
||||
mStatusSrv->getServiceInfo().mServiceType);
|
||||
serviceCtrl->registerServiceMonitor(chatSrv,
|
||||
chatSrv->getServiceInfo().mServiceType);
|
||||
serviceCtrl->registerServiceMonitor(mBwCtrl, mDisc->getServiceInfo().mServiceType);
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3servicecontrol.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
|
||||
#include "util/rsnet.h"
|
||||
@ -57,8 +57,8 @@
|
||||
*/
|
||||
|
||||
|
||||
p3BanList::p3BanList(p3LinkMgr *lm, p3NetMgr *nm)
|
||||
:p3Service(), mBanMtx("p3BanList"), mLinkMgr(lm), mNetMgr(nm)
|
||||
p3BanList::p3BanList(p3ServiceControl *sc, p3NetMgr *nm)
|
||||
:p3Service(), mBanMtx("p3BanList"), mServiceCtrl(sc), mNetMgr(nm)
|
||||
{
|
||||
addSerialType(new RsBanListSerialiser());
|
||||
|
||||
@ -163,7 +163,7 @@ bool p3BanList::recvBanItem(RsBanListItem *item)
|
||||
/* overloaded from pqiNetAssistSharePeer */
|
||||
void p3BanList::updatePeer(const RsPeerId& /*id*/, const struct sockaddr_storage &addr, int /*type*/, int /*reason*/, int age)
|
||||
{
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
int int_reason = 0;
|
||||
addBanEntry(ownId, addr, RSBANLIST_SOURCE_SELF, int_reason, age);
|
||||
@ -265,7 +265,7 @@ bool p3BanList::addBanEntry(const RsPeerId &peerId, const struct sockaddr_storag
|
||||
int p3BanList::condenseBanSources_locked()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
#ifdef DEBUG_BANLIST
|
||||
std::cerr << "p3BanList::condenseBanSources_locked()";
|
||||
@ -403,9 +403,9 @@ void p3BanList::sendBanLists()
|
||||
|
||||
/* we ping our peers */
|
||||
/* who is online? */
|
||||
std::list<RsPeerId> idList;
|
||||
std::set<RsPeerId> idList;
|
||||
|
||||
mLinkMgr->getOnlineList(idList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, idList);
|
||||
|
||||
#ifdef DEBUG_BANLIST
|
||||
std::cerr << "p3BanList::sendBanList()";
|
||||
@ -413,7 +413,7 @@ void p3BanList::sendBanLists()
|
||||
#endif
|
||||
|
||||
/* prepare packets */
|
||||
std::list<RsPeerId>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
for(it = idList.begin(); it != idList.end(); it++)
|
||||
{
|
||||
#ifdef DEBUG_BANLIST
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "services/p3service.h"
|
||||
//#include "retroshare/rsbanlist.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
class p3NetMgr;
|
||||
|
||||
class BanListPeer
|
||||
@ -68,7 +68,7 @@ class BanList
|
||||
class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPeerShare /* , public p3Config, public pqiMonitor */
|
||||
{
|
||||
public:
|
||||
p3BanList(p3LinkMgr *lm, p3NetMgr *nm);
|
||||
p3BanList(p3ServiceControl *sc, p3NetMgr *nm);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/***** overloaded from RsBanList *****/
|
||||
@ -126,7 +126,7 @@ class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPe
|
||||
std::map<RsPeerId, BanList> mBanSources;
|
||||
std::map<struct sockaddr_storage, BanListPeer> mBanSet;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
p3NetMgr *mNetMgr;
|
||||
|
||||
};
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
#include "util/rsnet.h"
|
||||
|
||||
@ -311,38 +312,35 @@ int p3BandwidthControl::printRateInfo_locked(std::ostream &out)
|
||||
}
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
void p3BandwidthControl::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3BandwidthControl::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
if (it->state & RS_PEER_S_FRIEND)
|
||||
{
|
||||
RsStackMutex stack(mBwMtx); /****** LOCKED MUTEX *******/
|
||||
RsStackMutex stack(mBwMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
if (it->actions & RS_PEER_DISCONNECTED)
|
||||
if (it->actions & RS_SERVICE_PEER_DISCONNECTED)
|
||||
{
|
||||
/* remove from map */
|
||||
std::map<RsPeerId, BwCtrlData>::iterator bit;
|
||||
bit = mBwMap.find(it->id);
|
||||
if (bit == mBwMap.end())
|
||||
{
|
||||
/* remove from map */
|
||||
std::map<RsPeerId, BwCtrlData>::iterator bit;
|
||||
bit = mBwMap.find(it->id);
|
||||
if (bit == mBwMap.end())
|
||||
{
|
||||
std::cerr << "p3BandwidthControl::statusChange() ERROR";
|
||||
std::cerr << " Entry not in map";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
mBwMap.erase(bit);
|
||||
}
|
||||
std::cerr << "p3BandwidthControl::statusChange() ERROR";
|
||||
std::cerr << " Entry not in map";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else if (it->actions & RS_PEER_CONNECTED)
|
||||
else
|
||||
{
|
||||
/* stuff */
|
||||
BwCtrlData data;
|
||||
mBwMap[it->id] = data;
|
||||
mBwMap.erase(bit);
|
||||
}
|
||||
}
|
||||
else if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
/* stuff */
|
||||
BwCtrlData data;
|
||||
mBwMap[it->id] = data;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -33,9 +33,11 @@
|
||||
|
||||
#include "serialiser/rsbwctrlitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "retroshare/rsconfig.h" // for datatypes.
|
||||
|
||||
class pqipersongrp;
|
||||
|
||||
// Extern is defined here - as this is bundled with rsconfig.h
|
||||
class p3BandwidthControl;
|
||||
extern p3BandwidthControl *rsBandwidthControl;
|
||||
@ -69,7 +71,7 @@ class BwCtrlData
|
||||
* Sadly this has to be strongly integrated into pqi, with ref to pqipersongrp.
|
||||
*/
|
||||
|
||||
class p3BandwidthControl: public p3Service, public pqiMonitor
|
||||
class p3BandwidthControl: public p3Service, public pqiServiceMonitor
|
||||
{
|
||||
public:
|
||||
p3BandwidthControl(pqipersongrp *pg);
|
||||
@ -98,7 +100,7 @@ class p3BandwidthControl: public p3Service, public pqiMonitor
|
||||
*/
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
|
||||
/************* from p3Config *******************/
|
||||
|
@ -75,8 +75,8 @@ static const uint32_t MAX_ALLOWED_LOBBIES_IN_LIST_WARNING = 50 ;
|
||||
static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number of messages from a given peer in a window for duration below
|
||||
static const uint32_t MAX_MESSAGES_PER_SECONDS_PERIOD = 10 ; // duration window for max number of messages before messages get dropped.
|
||||
|
||||
p3ChatService::p3ChatService(p3LinkMgr *lm, p3HistoryMgr *historyMgr)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mLinkMgr(lm) , mHistoryMgr(historyMgr)
|
||||
p3ChatService::p3ChatService(p3ServiceControl *sc, p3LinkMgr *lm, p3HistoryMgr *historyMgr)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mServiceCtrl(sc), mLinkMgr(lm) , mHistoryMgr(historyMgr)
|
||||
{
|
||||
_serializer = new RsChatSerialiser() ;
|
||||
_own_avatar = NULL ;
|
||||
@ -170,13 +170,13 @@ int p3ChatService::sendPublicChat(const std::string &msg)
|
||||
{
|
||||
/* go through all the peers */
|
||||
|
||||
std::list<RsPeerId> ids;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
/* add in own id -> so get reflection */
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
ids.push_back(ownId);
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
ids.insert(ownId);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat()";
|
||||
@ -259,15 +259,15 @@ class p3ChatService::AvatarInfo
|
||||
|
||||
void p3ChatService::sendGroupChatStatusString(const std::string& status_string)
|
||||
{
|
||||
std::list<RsPeerId> ids;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat(): sending group chat status string: " << status_string << std::endl ;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
for(std::list<RsPeerId>::iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
for(std::set<RsPeerId>::iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
{
|
||||
RsChatStatusItem *cs = new RsChatStatusItem ;
|
||||
|
||||
@ -487,7 +487,7 @@ bool p3ChatService::isOnline(const DistantChatPeerId& pid)
|
||||
if(getDistantChatStatus(pid,status,pgp_id))
|
||||
return true ;
|
||||
else
|
||||
return mLinkMgr->isOnline(pid) ;
|
||||
return mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid);
|
||||
}
|
||||
|
||||
bool p3ChatService::sendPrivateChat(const RsPeerId &id, const std::string &msg)
|
||||
@ -556,7 +556,7 @@ bool p3ChatService::sendPrivateChat(const RsPeerId &id, const std::string &m
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mHistoryMgr->addMessage(false, id, mLinkMgr->getOwnId(), ci);
|
||||
mHistoryMgr->addMessage(false, id, mServiceCtrl->getOwnId(), ci);
|
||||
|
||||
checkSizeAndSendMessage_deprecated(ci);
|
||||
|
||||
@ -1323,7 +1323,7 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
||||
publicChanged = true;
|
||||
publicList.push_back(ci); // don't delete the item !!
|
||||
|
||||
if (ci->PeerId() != mLinkMgr->getOwnId()) {
|
||||
if (ci->PeerId() != mServiceCtrl->getOwnId()) {
|
||||
/* not from loop back */
|
||||
mHistoryMgr->addMessage(true, RsPeerId(), ci->PeerId(), ci);
|
||||
}
|
||||
@ -1388,10 +1388,10 @@ void p3ChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecor
|
||||
|
||||
if(now > MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ + last_visible_lobby_info_request_time)
|
||||
{
|
||||
std::list<RsPeerId> ids ;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids ;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
for(std::set<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << " asking list of public lobbies to " << *it << std::endl;
|
||||
@ -1591,7 +1591,7 @@ void p3ChatService::initRsChatInfo(RsChatMsgItem *c, ChatInfo &i)
|
||||
|
||||
void p3ChatService::setOwnCustomStateString(const std::string& s)
|
||||
{
|
||||
std::list<RsPeerId> onlineList;
|
||||
std::set<RsPeerId> onlineList;
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
@ -1603,13 +1603,13 @@ void p3ChatService::setOwnCustomStateString(const std::string& s)
|
||||
for(std::map<RsPeerId,StateStringInfo>::iterator it(_state_strings.begin());it!=_state_strings.end();++it)
|
||||
it->second._own_is_new = true ;
|
||||
|
||||
mLinkMgr->getOnlineList(onlineList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, onlineList);
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyOwnStatusMessageChanged() ;
|
||||
|
||||
// alert your online peers to your newly set status
|
||||
std::list<RsPeerId>::iterator it(onlineList.begin());
|
||||
std::set<RsPeerId>::iterator it(onlineList.begin());
|
||||
for(; it != onlineList.end(); it++){
|
||||
|
||||
RsChatStatusItem *cs = new RsChatStatusItem();
|
||||
@ -1984,7 +1984,7 @@ bool p3ChatService::saveList(bool& cleanup, std::list<RsItem*>& list)
|
||||
if(_own_avatar != NULL)
|
||||
{
|
||||
RsChatAvatarItem *ci = makeOwnAvatarItem() ;
|
||||
ci->PeerId(mLinkMgr->getOwnId());
|
||||
ci->PeerId(mServiceCtrl->getOwnId());
|
||||
|
||||
list.push_back(ci) ;
|
||||
}
|
||||
@ -2075,54 +2075,54 @@ RsSerialiser *p3ChatService::setupSerialiser()
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
|
||||
void p3ChatService::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3ChatService::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++) {
|
||||
if (it->state & RS_PEER_S_FRIEND) {
|
||||
if (it->actions & RS_PEER_CONNECTED) {
|
||||
|
||||
/* send the saved outgoing messages */
|
||||
bool changed = false;
|
||||
if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
/* send the saved outgoing messages */
|
||||
bool changed = false;
|
||||
|
||||
std::vector<RsChatMsgItem*> to_send ;
|
||||
std::vector<RsChatMsgItem*> to_send ;
|
||||
|
||||
if (privateOutgoingList.size())
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
if (privateOutgoingList.size())
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
std::list<RsChatMsgItem *>::iterator cit = privateOutgoingList.begin();
|
||||
while (cit != privateOutgoingList.end()) {
|
||||
RsChatMsgItem *c = *cit;
|
||||
std::list<RsChatMsgItem *>::iterator cit = privateOutgoingList.begin();
|
||||
while (cit != privateOutgoingList.end()) {
|
||||
RsChatMsgItem *c = *cit;
|
||||
|
||||
if (c->PeerId() == it->id) {
|
||||
mHistoryMgr->addMessage(false, c->PeerId(), ownId, c);
|
||||
if (c->PeerId() == it->id) {
|
||||
mHistoryMgr->addMessage(false, c->PeerId(), ownId, c);
|
||||
|
||||
to_send.push_back(c) ;
|
||||
to_send.push_back(c) ;
|
||||
|
||||
changed = true;
|
||||
changed = true;
|
||||
|
||||
cit = privateOutgoingList.erase(cit);
|
||||
cit = privateOutgoingList.erase(cit);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
cit++;
|
||||
continue;
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
for(uint32_t i=0;i<to_send.size();++i)
|
||||
checkSizeAndSendMessage_deprecated(to_send[i]); // delete item
|
||||
|
||||
if (changed) {
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_DEL);
|
||||
|
||||
IndicateConfigChanged();
|
||||
cit++;
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
for(uint32_t i=0;i<to_send.size();++i)
|
||||
checkSizeAndSendMessage_deprecated(to_send[i]); // delete item
|
||||
|
||||
if (changed) {
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_DEL);
|
||||
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
} else if (it->actions & RS_PEER_MOVED) {
|
||||
}
|
||||
else if (it->actions & RS_SERVICE_PEER_REMOVED)
|
||||
{
|
||||
/* now handle remove */
|
||||
clearPrivateChatQueue(true, it->id);
|
||||
clearPrivateChatQueue(false, it->id);
|
||||
@ -2163,7 +2163,7 @@ bool p3ChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const RsPe
|
||||
|
||||
// Adds the peer id to the list of friend participants, even if it's not original msg source
|
||||
|
||||
if(peer_id != mLinkMgr->getOwnId())
|
||||
if(peer_id != mServiceCtrl->getOwnId())
|
||||
lobby.participating_friends.insert(peer_id) ;
|
||||
|
||||
lobby.nick_names[item->nick] = now ;
|
||||
@ -2196,7 +2196,7 @@ bool p3ChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const RsPe
|
||||
// Forward to allparticipating friends, except this peer.
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(lobby.participating_friends.begin());it!=lobby.participating_friends.end();++it)
|
||||
if((*it)!=peer_id && mLinkMgr->isOnline(*it))
|
||||
if((*it)!=peer_id && mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, *it))
|
||||
{
|
||||
RsChatLobbyBouncingObject *obj2 = item->duplicate() ; // makes a copy
|
||||
RsChatItem *item2 = dynamic_cast<RsChatItem*>(obj2) ;
|
||||
@ -2270,7 +2270,7 @@ void p3ChatService::sendLobbyStatusItem(const ChatLobbyId& lobby_id,int type,con
|
||||
item.string1 = status_string ;
|
||||
item.sendTime = time(NULL) ;
|
||||
}
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
bounceLobbyObject(&item,ownId) ;
|
||||
}
|
||||
|
||||
@ -2429,10 +2429,10 @@ void p3ChatService::sendConnectionChallenge(ChatLobbyId lobby_id)
|
||||
|
||||
// Broadcast to all direct friends
|
||||
|
||||
std::list<RsPeerId> ids ;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids ;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
for(std::set<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
{
|
||||
RsChatLobbyConnectChallengeItem *item = new RsChatLobbyConnectChallengeItem ;
|
||||
|
||||
|
@ -33,10 +33,12 @@
|
||||
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pgp/pgphandler.h"
|
||||
#include "turtle/turtleclientservice.h"
|
||||
#include "retroshare/rsmsgs.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
class p3LinkMgr;
|
||||
class p3HistoryMgr;
|
||||
class p3turtle ;
|
||||
@ -50,10 +52,10 @@ typedef RsPeerId ChatLobbyVirtualPeerId ;
|
||||
* This service uses rsnotify (callbacks librs clients (e.g. rs-gui))
|
||||
* @see NotifyBase
|
||||
*/
|
||||
class p3ChatService: public p3Service, public p3Config, public pqiMonitor, public RsTurtleClientService
|
||||
class p3ChatService: public p3Service, public p3Config, public pqiServiceMonitor, public RsTurtleClientService
|
||||
{
|
||||
public:
|
||||
p3ChatService(p3LinkMgr *cm, p3HistoryMgr *historyMgr);
|
||||
p3ChatService(p3ServiceControl *cs, p3LinkMgr *cm, p3HistoryMgr *historyMgr);
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
@ -69,7 +71,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||
virtual int status();
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
/*!
|
||||
* public chat sent to all peers
|
||||
@ -276,6 +278,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||
RsChatAvatarItem *makeOwnAvatarItem() ;
|
||||
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
||||
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3HistoryMgr *mHistoryMgr;
|
||||
|
||||
|
@ -84,8 +84,8 @@ void DiscPgpInfo::mergeFriendList(const std::list<PGPID> &friends)
|
||||
}
|
||||
|
||||
|
||||
p3discovery2::p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr)
|
||||
:p3Service(), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr),
|
||||
p3discovery2::p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr, p3ServiceControl *sc)
|
||||
:p3Service(), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr), mServiceCtrl(sc),
|
||||
mDiscMtx("p3discovery2")
|
||||
{
|
||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||
@ -752,7 +752,7 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
||||
mit != ffit->second.mSslIds.end(); mit++)
|
||||
{
|
||||
SSLID sslid = mit->first;
|
||||
if (mLinkMgr->isOnline(sslid))
|
||||
if (mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, sslid))
|
||||
{
|
||||
// TODO IGNORE if sslid == aboutId, or sslid == ownId.
|
||||
#ifdef P3DISC_DEBUG
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/authgpg.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
|
||||
|
||||
typedef RsPgpId PGPID;
|
||||
@ -78,7 +79,7 @@ class p3discovery2: public RsDisc, public p3Service, public pqiServiceMonitor, p
|
||||
{
|
||||
public:
|
||||
|
||||
p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr);
|
||||
p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr, p3ServiceControl *sc);
|
||||
virtual ~p3discovery2();
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
@ -133,6 +134,7 @@ virtual void setGPGOperation(AuthGPGOperation *operation);
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
/* data */
|
||||
RsMutex mDiscMtx;
|
||||
|
@ -63,8 +63,8 @@ RsDsdv *rsDsdv = NULL;
|
||||
*
|
||||
****/
|
||||
|
||||
p3Dsdv::p3Dsdv(p3LinkMgr *lm)
|
||||
:p3Service(), /* p3Config(CONFIG_TYPE_DSDV), */ mDsdvMtx("p3Dsdv"), mLinkMgr(lm)
|
||||
p3Dsdv::p3Dsdv(p3ServiceControl *sc)
|
||||
:p3Service(), /* p3Config(CONFIG_TYPE_DSDV), */ mDsdvMtx("p3Dsdv"), mServiceCtrl(sc)
|
||||
{
|
||||
addSerialType(new RsDsdvSerialiser());
|
||||
|
||||
@ -195,8 +195,8 @@ int p3Dsdv::generateRoutingTables(bool incremental)
|
||||
{
|
||||
/* we ping our peers */
|
||||
/* who is online? */
|
||||
std::list<std::string> idList;
|
||||
mLinkMgr->getOnlineList(idList);
|
||||
std::set<RsPeerId> idList;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, idList);
|
||||
|
||||
#ifdef DEBUG_DSDV
|
||||
std::cerr << "p3Dsdv::generateRoutingTables(" << incremental << ")";
|
||||
@ -210,7 +210,7 @@ int p3Dsdv::generateRoutingTables(bool incremental)
|
||||
}
|
||||
|
||||
/* prepare packets */
|
||||
std::list<std::string>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
for(it = idList.begin(); it != idList.end(); it++)
|
||||
{
|
||||
#ifdef DEBUG_DSDV
|
||||
@ -228,7 +228,7 @@ int p3Dsdv::generateRoutingTables(bool incremental)
|
||||
}
|
||||
|
||||
|
||||
int p3Dsdv::generateRoutingTable(const std::string &peerId, bool incremental)
|
||||
int p3Dsdv::generateRoutingTable(const RsPeerId &peerId, bool incremental)
|
||||
{
|
||||
RsDsdvRouteItem *dsdv = new RsDsdvRouteItem();
|
||||
dsdv->PeerId(peerId);
|
||||
@ -385,7 +385,7 @@ int p3Dsdv::handleDSDV(RsDsdvRouteItem *dsdv)
|
||||
}
|
||||
|
||||
/* look for this in mAllRoutes */
|
||||
std::map<std::string, RsDsdvRoute>::iterator rit;
|
||||
std::map<RsPeerId, RsDsdvRoute>::iterator rit;
|
||||
rit = v.mAllRoutes.find(dsdv->PeerId());
|
||||
if (rit == v.mAllRoutes.end())
|
||||
{
|
||||
@ -485,11 +485,11 @@ int p3Dsdv::selectStableRoutes()
|
||||
continue; // Ignore if we are source.
|
||||
}
|
||||
|
||||
std::map<std::string, RsDsdvRoute>::iterator rit;
|
||||
std::map<RsPeerId, RsDsdvRoute>::iterator rit;
|
||||
uint32_t newest = 0;
|
||||
std::string newestId;
|
||||
RsPeerId newestId;
|
||||
uint32_t closest = RSDSDV_MAX_DISTANCE + 1;
|
||||
std::string closestId;
|
||||
RsPeerId closestId;
|
||||
time_t closestAge = 0;
|
||||
|
||||
/* find newest sequence number */
|
||||
@ -646,9 +646,9 @@ int p3Dsdv::clearOldRoutes()
|
||||
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
void p3Dsdv::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3Dsdv::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for(it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
/* only care about disconnected / not friends cases */
|
||||
@ -738,7 +738,7 @@ int p3Dsdv::addDsdvId(RsDsdvId *id, std::string realHash)
|
||||
RsDsdvTableEntry v;
|
||||
v.mDest = *id;
|
||||
|
||||
v.mStableRoute.mNextHop = mLinkMgr->getOwnId();
|
||||
v.mStableRoute.mNextHop = mServiceCtrl->getOwnId();
|
||||
v.mStableRoute.mReceived = now;
|
||||
v.mStableRoute.mValidSince = now;
|
||||
v.mStableRoute.mSequence = 0;
|
||||
@ -901,7 +901,7 @@ std::ostream &operator<<(std::ostream &out, const RsDsdvTableEntry &entry)
|
||||
out << "\tAll Routes:" << std::endl;
|
||||
}
|
||||
|
||||
std::map<std::string, RsDsdvRoute>::const_iterator it;
|
||||
std::map<RsPeerId, RsDsdvRoute>::const_iterator it;
|
||||
for(it = entry.mAllRoutes.begin(); it != entry.mAllRoutes.end(); it++)
|
||||
{
|
||||
out << "\t\t" << it->second << std::endl;
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
#include "retroshare/rsdsdv.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
|
||||
#define RSDSDV_MAX_DISTANCE 3
|
||||
@ -49,10 +49,10 @@ class p3LinkMgr;
|
||||
* Finds RS wide paths to Services and Peers.
|
||||
*/
|
||||
|
||||
class p3Dsdv: public RsDsdv, public p3Service /* , public p3Config */, public pqiMonitor
|
||||
class p3Dsdv: public RsDsdv, public p3Service /* , public p3Config */, public pqiServiceMonitor
|
||||
{
|
||||
public:
|
||||
p3Dsdv(p3LinkMgr *cm);
|
||||
p3Dsdv(p3ServiceControl *cm);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/*** internal librs interface ****/
|
||||
@ -71,7 +71,7 @@ void clearSignificantChangesFlags();
|
||||
|
||||
|
||||
int generateRoutingTables(bool incremental);
|
||||
int generateRoutingTable(const std::string &peerId, bool incremental);
|
||||
int generateRoutingTable(const RsPeerId &peerId, bool incremental);
|
||||
|
||||
int processIncoming();
|
||||
|
||||
@ -97,7 +97,7 @@ virtual int getDsdvEntry(const std::string &hash, RsDsdvTableEntry &entry);
|
||||
virtual int status();
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
/************* from p3Config *******************/
|
||||
//virtual RsSerialiser *setupSerialiser() ;
|
||||
@ -115,7 +115,7 @@ virtual int getDsdvEntry(const std::string &hash, RsDsdvTableEntry &entry);
|
||||
|
||||
bool mSignificantChanges;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
};
|
||||
|
||||
|
@ -28,11 +28,14 @@
|
||||
#include "services/p3heartbeat.h"
|
||||
#include "serialiser/rsheartbeatitems.h"
|
||||
|
||||
#include "pqi/p3servicecontrol.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
//#define HEART_DEBUG 1
|
||||
|
||||
|
||||
p3heartbeat::p3heartbeat(p3LinkMgr *linkMgr, pqipersongrp *pqipg)
|
||||
:p3Service(), mLinkMgr(linkMgr), mPqiPersonGrp(pqipg),
|
||||
p3heartbeat::p3heartbeat(p3ServiceControl *sc, pqipersongrp *pqipg)
|
||||
:p3Service(), mServiceCtrl(sc), mPqiPersonGrp(pqipg),
|
||||
mHeartMtx("p3heartbeat")
|
||||
{
|
||||
RsStackMutex stack(mHeartMtx); /********** STACK LOCKED MTX ******/
|
||||
@ -82,10 +85,10 @@ int p3heartbeat::tick()
|
||||
{
|
||||
mLastHeartbeat = time(NULL);
|
||||
|
||||
std::list<RsPeerId> peers;
|
||||
std::list<RsPeerId>::const_iterator pit;
|
||||
std::set<RsPeerId> peers;
|
||||
std::set<RsPeerId>::const_iterator pit;
|
||||
|
||||
mLinkMgr->getOnlineList(peers);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, peers);
|
||||
for (pit = peers.begin(); pit != peers.end(); ++pit)
|
||||
{
|
||||
sendHeartbeat(*pit);
|
||||
|
@ -28,16 +28,16 @@
|
||||
|
||||
// Moved Heartbeat to a seperate service.
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
#include "services/p3service.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
class pqipersongrp;
|
||||
|
||||
class p3heartbeat: public p3Service
|
||||
{
|
||||
public:
|
||||
|
||||
p3heartbeat(p3LinkMgr *linkMgr, pqipersongrp *pqipg);
|
||||
p3heartbeat(p3ServiceControl *sc, pqipersongrp *pqipg);
|
||||
virtual ~p3heartbeat();
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
@ -51,7 +51,7 @@ virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
private:
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
pqipersongrp *mPqiPersonGrp;
|
||||
|
||||
/* data */
|
||||
|
@ -75,9 +75,9 @@ static const uint8_t ENCRYPTED_MSG_PROTOCOL_VERSION_01 = 0x37 ;
|
||||
*/
|
||||
|
||||
|
||||
p3MsgService::p3MsgService(p3LinkMgr *lm)
|
||||
p3MsgService::p3MsgService(p3ServiceControl *sc)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_MSGS),
|
||||
mLinkMgr(lm), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
|
||||
mServiceCtrl(sc), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
|
||||
{
|
||||
_serialiser = new RsMsgSerialiser();
|
||||
addSerialType(_serialiser);
|
||||
@ -85,7 +85,7 @@ p3MsgService::p3MsgService(p3LinkMgr *lm)
|
||||
mDistantMessagingEnabled = true ;
|
||||
|
||||
/* Initialize standard tag types */
|
||||
if(lm)
|
||||
if(sc)
|
||||
initStandardTagTypes();
|
||||
|
||||
#ifdef GROUTER
|
||||
@ -280,10 +280,24 @@ void p3MsgService::handleIncomingItem(RsMsgItem *mi)
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
}
|
||||
|
||||
void p3MsgService::statusChange(const std::list<pqipeer> &/*plist*/)
|
||||
void p3MsgService::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
/* should do it properly! */
|
||||
checkOutgoingMessages();
|
||||
/* only do this when a new peer is connected */
|
||||
bool newPeers = false;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for(it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
newPeers = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (newPeers)
|
||||
{
|
||||
checkOutgoingMessages();
|
||||
}
|
||||
}
|
||||
|
||||
void p3MsgService::checkSizeAndSendMessage(RsMsgItem *msg)
|
||||
@ -357,7 +371,7 @@ int p3MsgService::checkOutgoingMessages()
|
||||
std::list<RsMsgItem*> output_queue ;
|
||||
|
||||
{
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
std::list<uint32_t>::iterator it;
|
||||
std::list<uint32_t> toErase;
|
||||
@ -407,7 +421,7 @@ int p3MsgService::checkOutgoingMessages()
|
||||
#endif
|
||||
}
|
||||
|
||||
if(tunnel_is_ok || mLinkMgr->isOnline(pid) || pid == ownId) /* FEEDBACK Msg to Ourselves */
|
||||
if(tunnel_is_ok || mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid) || pid == ownId) /* FEEDBACK Msg to Ourselves */
|
||||
{
|
||||
/* send msg */
|
||||
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
|
||||
@ -542,7 +556,7 @@ static void getStandardTagTypes(MsgTagType &tags)
|
||||
void p3MsgService::initStandardTagTypes()
|
||||
{
|
||||
bool bChanged = false;
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
MsgTagType tags;
|
||||
getStandardTagTypes(tags);
|
||||
@ -722,7 +736,7 @@ void p3MsgService::loadWelcomeMsg()
|
||||
/* Load Welcome Message */
|
||||
RsMsgItem *msg = new RsMsgItem();
|
||||
|
||||
//msg -> PeerId(mLinkMgr->getOwnId());
|
||||
//msg -> PeerId(mServiceCtrl->getOwnId());
|
||||
|
||||
msg -> sendTime = time(NULL);
|
||||
msg -> recvTime = time(NULL);
|
||||
@ -1008,7 +1022,7 @@ bool p3MsgService::setMsgParentId(uint32_t msgId, uint32_t msgParentId)
|
||||
{
|
||||
if (msgParentId) {
|
||||
RsMsgParentId* msp = new RsMsgParentId();
|
||||
msp->PeerId (mLinkMgr->getOwnId());
|
||||
msp->PeerId (mServiceCtrl->getOwnId());
|
||||
msp->msgId = msgId;
|
||||
msp->msgParentId = msgParentId;
|
||||
mParentId.insert(std::pair<uint32_t, RsMsgParentId*>(msgId, msp));
|
||||
@ -1054,7 +1068,7 @@ int p3MsgService::sendMessage(RsMsgItem *item)
|
||||
/* STORE MsgID */
|
||||
msgOutgoing[item->msgId] = item;
|
||||
|
||||
if (item->PeerId() != mLinkMgr->getOwnId()) {
|
||||
if (item->PeerId() != mServiceCtrl->getOwnId()) {
|
||||
/* not to the loopback device */
|
||||
RsMsgSrcId* msi = new RsMsgSrcId();
|
||||
msi->msgId = item->msgId;
|
||||
@ -1104,7 +1118,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
||||
}
|
||||
|
||||
/* send to ourselves as well */
|
||||
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
||||
RsMsgItem *msg = initMIRsMsg(info, mServiceCtrl->getOwnId());
|
||||
if (msg)
|
||||
{
|
||||
std::list<RsPgpId>::iterator it ;
|
||||
@ -1138,7 +1152,7 @@ bool p3MsgService::SystemMessage(const std::string &title, const std::string &me
|
||||
return false;
|
||||
}
|
||||
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
RsMsgItem *msg = new RsMsgItem();
|
||||
|
||||
@ -1169,7 +1183,7 @@ bool p3MsgService::SystemMessage(const std::string &title, const std::string &me
|
||||
|
||||
bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
|
||||
{
|
||||
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
||||
RsMsgItem *msg = initMIRsMsg(info, mServiceCtrl->getOwnId());
|
||||
if (msg)
|
||||
{
|
||||
uint32_t msgId = 0;
|
||||
@ -1250,7 +1264,7 @@ bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32
|
||||
|
||||
/* new tag */
|
||||
RsMsgTagType* tagType = new RsMsgTagType();
|
||||
tagType->PeerId (mLinkMgr->getOwnId());
|
||||
tagType->PeerId (mServiceCtrl->getOwnId());
|
||||
tagType->rgb_color = rgb_color;
|
||||
tagType->tagId = tagId;
|
||||
tagType->text = text;
|
||||
@ -1391,7 +1405,7 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
|
||||
if (set) {
|
||||
/* new msg */
|
||||
RsMsgTags* tag = new RsMsgTags();
|
||||
tag->PeerId (mLinkMgr->getOwnId());
|
||||
tag->PeerId (mServiceCtrl->getOwnId());
|
||||
|
||||
tag->msgId = mid;
|
||||
tag->tagIds.push_back(tagId);
|
||||
@ -1535,7 +1549,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
|
||||
|
||||
/* translate flags, if we sent it... outgoing */
|
||||
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
/*|| (msg->PeerId() == mLinkMgr->getOwnId())*/)
|
||||
/*|| (msg->PeerId() == mServiceCtrl->getOwnId())*/)
|
||||
{
|
||||
mi.msgflags |= RS_MSG_OUTGOING;
|
||||
}
|
||||
@ -1668,7 +1682,7 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
||||
|
||||
/* translate flags, if we sent it... outgoing */
|
||||
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
/*|| (msg->PeerId() == mLinkMgr->getOwnId())*/)
|
||||
/*|| (msg->PeerId() == mServiceCtrl->getOwnId())*/)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_OUTGOING;
|
||||
}
|
||||
@ -1756,7 +1770,7 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const RsPeerId &to)
|
||||
}
|
||||
|
||||
/* We don't fill in bcc (unless to ourselves) */
|
||||
if (to == mLinkMgr->getOwnId())
|
||||
if (to == mServiceCtrl->getOwnId())
|
||||
{
|
||||
for(pit = info.msgbcc.begin(); pit != info.msgbcc.end(); pit++)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "pqi/pqi.h"
|
||||
#include "pqi/pqiindic.h"
|
||||
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
#include "services/p3service.h"
|
||||
@ -53,13 +53,13 @@
|
||||
class p3LinkMgr;
|
||||
|
||||
// Temp tweak to test grouter
|
||||
class p3MsgService: public p3Service, public p3Config, public pqiMonitor, public RsTurtleClientService
|
||||
class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor, public RsTurtleClientService
|
||||
#ifdef GROUTER
|
||||
, public GRouterClientService
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
p3MsgService(p3LinkMgr *lm);
|
||||
p3MsgService(p3ServiceControl *sc);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/* External Interface */
|
||||
@ -106,7 +106,7 @@ virtual void saveDone();
|
||||
/*** Overloaded from p3Config ****/
|
||||
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
int checkOutgoingMessages();
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
|
||||
@ -188,7 +188,7 @@ RsMsgItem *initMIRsMsg(MessageInfo &info, const RsPeerId &to);
|
||||
|
||||
void initStandardTagTypes();
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
/* Mutex Required for stuff below */
|
||||
|
||||
|
@ -116,8 +116,8 @@ static double convert64bitsToTs(uint64_t bits)
|
||||
|
||||
|
||||
|
||||
p3rtt::p3rtt(p3LinkMgr *lm)
|
||||
:p3FastService(), mRttMtx("p3rtt"), mLinkMgr(lm)
|
||||
p3rtt::p3rtt(p3ServiceControl *sc)
|
||||
:p3FastService(), mRttMtx("p3rtt"), mServiceCtrl(sc)
|
||||
{
|
||||
addSerialType(new RsRttSerialiser());
|
||||
|
||||
@ -186,9 +186,9 @@ void p3rtt::sendPingMeasurements()
|
||||
|
||||
/* we ping our peers */
|
||||
/* who is online? */
|
||||
std::list<RsPeerId> idList;
|
||||
std::set<RsPeerId> idList;
|
||||
|
||||
mLinkMgr->getOnlineList(idList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, idList);
|
||||
|
||||
double ts = getCurrentTS();
|
||||
|
||||
@ -198,7 +198,7 @@ void p3rtt::sendPingMeasurements()
|
||||
#endif
|
||||
|
||||
/* prepare packets */
|
||||
std::list<RsPeerId>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
for(it = idList.begin(); it != idList.end(); it++)
|
||||
{
|
||||
#ifdef DEBUG_RTT
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "services/p3service.h"
|
||||
#include "retroshare/rsrtt.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
class RttPeerInfo
|
||||
{
|
||||
@ -63,7 +63,7 @@ class RttPeerInfo
|
||||
class p3rtt: public RsRtt, public p3FastService
|
||||
{
|
||||
public:
|
||||
p3rtt(p3LinkMgr *cm);
|
||||
p3rtt(p3ServiceControl *sc);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/***** overloaded from rsRtt *****/
|
||||
@ -111,7 +111,7 @@ virtual bool recvItem(RsItem *item); // Overloaded from p3FastService.
|
||||
time_t mSentPingTime;
|
||||
uint32_t mCounter;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
};
|
||||
|
||||
|
@ -47,8 +47,8 @@ std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
|
||||
|
||||
RsStatus *rsStatus = NULL;
|
||||
|
||||
p3StatusService::p3StatusService(p3LinkMgr *cm)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_STATUS), mLinkMgr(cm), mStatusMtx("p3StatusService")
|
||||
p3StatusService::p3StatusService(p3ServiceControl *sc)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_STATUS), mServiceCtrl(sc), mStatusMtx("p3StatusService")
|
||||
{
|
||||
addSerialType(new RsStatusSerialiser());
|
||||
|
||||
@ -83,7 +83,7 @@ bool p3StatusService::getOwnStatus(StatusInfo& statusInfo)
|
||||
#endif
|
||||
|
||||
std::map<RsPeerId, StatusInfo>::iterator it;
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
it = mStatusInfoMap.find(ownId);
|
||||
@ -154,12 +154,12 @@ bool p3StatusService::getStatus(const RsPeerId &id, StatusInfo &statusInfo)
|
||||
bool p3StatusService::sendStatus(const RsPeerId &id, uint32_t status)
|
||||
{
|
||||
StatusInfo statusInfo;
|
||||
std::list<RsPeerId> onlineList;
|
||||
std::set<RsPeerId> onlineList;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
|
||||
statusInfo.id = mLinkMgr->getOwnId();
|
||||
statusInfo.id = mServiceCtrl->getOwnId();
|
||||
statusInfo.status = status;
|
||||
|
||||
// don't save inactive status
|
||||
@ -179,13 +179,13 @@ bool p3StatusService::sendStatus(const RsPeerId &id, uint32_t status)
|
||||
}
|
||||
|
||||
if (id.isNull()) {
|
||||
mLinkMgr->getOnlineList(onlineList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, onlineList);
|
||||
} else {
|
||||
onlineList.push_back(id);
|
||||
onlineList.insert(id);
|
||||
}
|
||||
}
|
||||
|
||||
std::list<RsPeerId>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
|
||||
#ifdef STATUS_DEBUG
|
||||
std::cerr << "p3StatusService::sendStatus() " << std::endl;
|
||||
@ -288,11 +288,11 @@ bool p3StatusService::saveList(bool& cleanup, std::list<RsItem*>& ilist){
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
it = mStatusInfoMap.find(mLinkMgr->getOwnId());
|
||||
it = mStatusInfoMap.find(mServiceCtrl->getOwnId());
|
||||
|
||||
if(it == mStatusInfoMap.end()){
|
||||
std::cerr << "p3StatusService::saveList() :" << "Did not find your status"
|
||||
<< mLinkMgr->getOwnId() << std::endl;
|
||||
<< mServiceCtrl->getOwnId() << std::endl;
|
||||
delete own_status;
|
||||
return false;
|
||||
}
|
||||
@ -326,14 +326,14 @@ bool p3StatusService::loadList(std::list<RsItem*>& load){
|
||||
|
||||
if(own_status != NULL){
|
||||
|
||||
own_info.id = mLinkMgr->getOwnId();
|
||||
own_info.id = mServiceCtrl->getOwnId();
|
||||
own_info.status = own_status->status;
|
||||
own_info.time_stamp = own_status->sendTime;
|
||||
delete own_status;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
std::pair<RsPeerId, StatusInfo> pr(mLinkMgr->getOwnId(), own_info);
|
||||
std::pair<RsPeerId, StatusInfo> pr(mServiceCtrl->getOwnId(), own_info);
|
||||
mStatusInfoMap.insert(pr);
|
||||
}
|
||||
|
||||
@ -363,48 +363,52 @@ int p3StatusService::status(){
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
|
||||
void p3StatusService::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3StatusService::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
bool changedState = false;
|
||||
|
||||
StatusInfo statusInfo;
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++) {
|
||||
if (it->state & RS_PEER_S_FRIEND) {
|
||||
if (it->actions & RS_PEER_DISCONNECTED)
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
if (it->actions & RS_SERVICE_PEER_DISCONNECTED)
|
||||
{
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
/* remove peer from status map */
|
||||
mStatusInfoMap.erase(it->id);
|
||||
} /* UNLOCKED */
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
/* remove peer from status map */
|
||||
mStatusInfoMap.erase(it->id);
|
||||
} /* UNLOCKED */
|
||||
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_OFFLINE);
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_OFFLINE);
|
||||
}
|
||||
|
||||
if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
/* send current status, only call getOwnStatus once in the loop */
|
||||
if (statusInfo.id.isNull() == false || getOwnStatus(statusInfo))
|
||||
{
|
||||
sendStatus(it->id, statusInfo.status);
|
||||
}
|
||||
|
||||
if (it->actions & RS_PEER_CONNECTED) {
|
||||
/* send current status, only call getOwnStatus once in the loop */
|
||||
if (statusInfo.id.isNull() == false || getOwnStatus(statusInfo)) {
|
||||
sendStatus(it->id, statusInfo.status);
|
||||
}
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
/* We assume that the peer is online. If not, he send us a new status */
|
||||
StatusInfo info;
|
||||
info.id = it->id;
|
||||
info.status = RS_STATUS_ONLINE;
|
||||
info.time_stamp = time(NULL);
|
||||
|
||||
/* We assume that the peer is online. If not, he send us a new status */
|
||||
StatusInfo info;
|
||||
info.id = it->id;
|
||||
info.status = RS_STATUS_ONLINE;
|
||||
info.time_stamp = time(NULL);
|
||||
mStatusInfoMap[it->id] = info;
|
||||
} /* UNLOCKED */
|
||||
|
||||
mStatusInfoMap[it->id] = info;
|
||||
} /* UNLOCKED */
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_ONLINE);
|
||||
}
|
||||
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_ONLINE);
|
||||
}
|
||||
} else if (it->actions & RS_PEER_MOVED) {
|
||||
if (it->actions & RS_SERVICE_PEER_REMOVED)
|
||||
{
|
||||
/* now handle remove */
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
|
@ -33,9 +33,9 @@
|
||||
#include "retroshare/rsstatus.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
//! handles standard status messages (busy, away, online, offline) set by user
|
||||
/*!
|
||||
@ -44,11 +44,11 @@ class p3LinkMgr;
|
||||
* custom string.
|
||||
* @see rsiface/rsstatus.h for status constants
|
||||
*/
|
||||
class p3StatusService: public p3Service, public p3Config, public pqiMonitor
|
||||
class p3StatusService: public p3Service, public p3Config, public pqiServiceMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
p3StatusService(p3LinkMgr *lm);
|
||||
p3StatusService(p3ServiceControl *sc);
|
||||
virtual ~p3StatusService();
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
@ -58,7 +58,7 @@ virtual int tick();
|
||||
virtual int status();
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
/********* RsStatus ***********/
|
||||
|
||||
@ -95,7 +95,7 @@ virtual bool loadList(std::list<RsItem*>& load);
|
||||
|
||||
virtual void receiveStatusQueue();
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
std::map<RsPeerId, StatusInfo> mStatusInfoMap;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user