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