mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-22 06:09:09 -04:00
Switched most of the services to use p3ServiceControl instead of p3LinkMgr.
- Added a couple of utility fns to p3ServiceControl too. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7211 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
efe9503c3a
commit
190988c3cc
33 changed files with 387 additions and 329 deletions
|
@ -23,7 +23,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3servicecontrol.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
|
||||
#include "util/rsnet.h"
|
||||
|
@ -57,8 +57,8 @@
|
|||
*/
|
||||
|
||||
|
||||
p3BanList::p3BanList(p3LinkMgr *lm, p3NetMgr *nm)
|
||||
:p3Service(), mBanMtx("p3BanList"), mLinkMgr(lm), mNetMgr(nm)
|
||||
p3BanList::p3BanList(p3ServiceControl *sc, p3NetMgr *nm)
|
||||
:p3Service(), mBanMtx("p3BanList"), mServiceCtrl(sc), mNetMgr(nm)
|
||||
{
|
||||
addSerialType(new RsBanListSerialiser());
|
||||
|
||||
|
@ -163,7 +163,7 @@ bool p3BanList::recvBanItem(RsBanListItem *item)
|
|||
/* overloaded from pqiNetAssistSharePeer */
|
||||
void p3BanList::updatePeer(const RsPeerId& /*id*/, const struct sockaddr_storage &addr, int /*type*/, int /*reason*/, int age)
|
||||
{
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
int int_reason = 0;
|
||||
addBanEntry(ownId, addr, RSBANLIST_SOURCE_SELF, int_reason, age);
|
||||
|
@ -265,7 +265,7 @@ bool p3BanList::addBanEntry(const RsPeerId &peerId, const struct sockaddr_storag
|
|||
int p3BanList::condenseBanSources_locked()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
#ifdef DEBUG_BANLIST
|
||||
std::cerr << "p3BanList::condenseBanSources_locked()";
|
||||
|
@ -403,9 +403,9 @@ void p3BanList::sendBanLists()
|
|||
|
||||
/* we ping our peers */
|
||||
/* who is online? */
|
||||
std::list<RsPeerId> idList;
|
||||
std::set<RsPeerId> idList;
|
||||
|
||||
mLinkMgr->getOnlineList(idList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, idList);
|
||||
|
||||
#ifdef DEBUG_BANLIST
|
||||
std::cerr << "p3BanList::sendBanList()";
|
||||
|
@ -413,7 +413,7 @@ void p3BanList::sendBanLists()
|
|||
#endif
|
||||
|
||||
/* prepare packets */
|
||||
std::list<RsPeerId>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
for(it = idList.begin(); it != idList.end(); it++)
|
||||
{
|
||||
#ifdef DEBUG_BANLIST
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "services/p3service.h"
|
||||
//#include "retroshare/rsbanlist.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
class p3NetMgr;
|
||||
|
||||
class BanListPeer
|
||||
|
@ -68,7 +68,7 @@ class BanList
|
|||
class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPeerShare /* , public p3Config, public pqiMonitor */
|
||||
{
|
||||
public:
|
||||
p3BanList(p3LinkMgr *lm, p3NetMgr *nm);
|
||||
p3BanList(p3ServiceControl *sc, p3NetMgr *nm);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/***** overloaded from RsBanList *****/
|
||||
|
@ -126,7 +126,7 @@ class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPe
|
|||
std::map<RsPeerId, BanList> mBanSources;
|
||||
std::map<struct sockaddr_storage, BanListPeer> mBanSet;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
p3NetMgr *mNetMgr;
|
||||
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
#include "util/rsnet.h"
|
||||
|
||||
|
@ -311,38 +312,35 @@ int p3BandwidthControl::printRateInfo_locked(std::ostream &out)
|
|||
}
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
void p3BandwidthControl::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3BandwidthControl::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
if (it->state & RS_PEER_S_FRIEND)
|
||||
{
|
||||
RsStackMutex stack(mBwMtx); /****** LOCKED MUTEX *******/
|
||||
RsStackMutex stack(mBwMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
if (it->actions & RS_PEER_DISCONNECTED)
|
||||
if (it->actions & RS_SERVICE_PEER_DISCONNECTED)
|
||||
{
|
||||
/* remove from map */
|
||||
std::map<RsPeerId, BwCtrlData>::iterator bit;
|
||||
bit = mBwMap.find(it->id);
|
||||
if (bit == mBwMap.end())
|
||||
{
|
||||
/* remove from map */
|
||||
std::map<RsPeerId, BwCtrlData>::iterator bit;
|
||||
bit = mBwMap.find(it->id);
|
||||
if (bit == mBwMap.end())
|
||||
{
|
||||
std::cerr << "p3BandwidthControl::statusChange() ERROR";
|
||||
std::cerr << " Entry not in map";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
mBwMap.erase(bit);
|
||||
}
|
||||
std::cerr << "p3BandwidthControl::statusChange() ERROR";
|
||||
std::cerr << " Entry not in map";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else if (it->actions & RS_PEER_CONNECTED)
|
||||
else
|
||||
{
|
||||
/* stuff */
|
||||
BwCtrlData data;
|
||||
mBwMap[it->id] = data;
|
||||
mBwMap.erase(bit);
|
||||
}
|
||||
}
|
||||
else if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
/* stuff */
|
||||
BwCtrlData data;
|
||||
mBwMap[it->id] = data;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,9 +33,11 @@
|
|||
|
||||
#include "serialiser/rsbwctrlitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "retroshare/rsconfig.h" // for datatypes.
|
||||
|
||||
class pqipersongrp;
|
||||
|
||||
// Extern is defined here - as this is bundled with rsconfig.h
|
||||
class p3BandwidthControl;
|
||||
extern p3BandwidthControl *rsBandwidthControl;
|
||||
|
@ -69,7 +71,7 @@ class BwCtrlData
|
|||
* Sadly this has to be strongly integrated into pqi, with ref to pqipersongrp.
|
||||
*/
|
||||
|
||||
class p3BandwidthControl: public p3Service, public pqiMonitor
|
||||
class p3BandwidthControl: public p3Service, public pqiServiceMonitor
|
||||
{
|
||||
public:
|
||||
p3BandwidthControl(pqipersongrp *pg);
|
||||
|
@ -98,7 +100,7 @@ class p3BandwidthControl: public p3Service, public pqiMonitor
|
|||
*/
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
|
||||
/************* from p3Config *******************/
|
||||
|
|
|
@ -75,8 +75,8 @@ static const uint32_t MAX_ALLOWED_LOBBIES_IN_LIST_WARNING = 50 ;
|
|||
static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number of messages from a given peer in a window for duration below
|
||||
static const uint32_t MAX_MESSAGES_PER_SECONDS_PERIOD = 10 ; // duration window for max number of messages before messages get dropped.
|
||||
|
||||
p3ChatService::p3ChatService(p3LinkMgr *lm, p3HistoryMgr *historyMgr)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mLinkMgr(lm) , mHistoryMgr(historyMgr)
|
||||
p3ChatService::p3ChatService(p3ServiceControl *sc, p3LinkMgr *lm, p3HistoryMgr *historyMgr)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mServiceCtrl(sc), mLinkMgr(lm) , mHistoryMgr(historyMgr)
|
||||
{
|
||||
_serializer = new RsChatSerialiser() ;
|
||||
_own_avatar = NULL ;
|
||||
|
@ -170,13 +170,13 @@ int p3ChatService::sendPublicChat(const std::string &msg)
|
|||
{
|
||||
/* go through all the peers */
|
||||
|
||||
std::list<RsPeerId> ids;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
/* add in own id -> so get reflection */
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
ids.push_back(ownId);
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
ids.insert(ownId);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat()";
|
||||
|
@ -259,15 +259,15 @@ class p3ChatService::AvatarInfo
|
|||
|
||||
void p3ChatService::sendGroupChatStatusString(const std::string& status_string)
|
||||
{
|
||||
std::list<RsPeerId> ids;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat(): sending group chat status string: " << status_string << std::endl ;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
for(std::list<RsPeerId>::iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
for(std::set<RsPeerId>::iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
{
|
||||
RsChatStatusItem *cs = new RsChatStatusItem ;
|
||||
|
||||
|
@ -487,7 +487,7 @@ bool p3ChatService::isOnline(const DistantChatPeerId& pid)
|
|||
if(getDistantChatStatus(pid,status,pgp_id))
|
||||
return true ;
|
||||
else
|
||||
return mLinkMgr->isOnline(pid) ;
|
||||
return mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid);
|
||||
}
|
||||
|
||||
bool p3ChatService::sendPrivateChat(const RsPeerId &id, const std::string &msg)
|
||||
|
@ -556,7 +556,7 @@ bool p3ChatService::sendPrivateChat(const RsPeerId &id, const std::string &m
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mHistoryMgr->addMessage(false, id, mLinkMgr->getOwnId(), ci);
|
||||
mHistoryMgr->addMessage(false, id, mServiceCtrl->getOwnId(), ci);
|
||||
|
||||
checkSizeAndSendMessage_deprecated(ci);
|
||||
|
||||
|
@ -1323,7 +1323,7 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
|||
publicChanged = true;
|
||||
publicList.push_back(ci); // don't delete the item !!
|
||||
|
||||
if (ci->PeerId() != mLinkMgr->getOwnId()) {
|
||||
if (ci->PeerId() != mServiceCtrl->getOwnId()) {
|
||||
/* not from loop back */
|
||||
mHistoryMgr->addMessage(true, RsPeerId(), ci->PeerId(), ci);
|
||||
}
|
||||
|
@ -1388,10 +1388,10 @@ void p3ChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecor
|
|||
|
||||
if(now > MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ + last_visible_lobby_info_request_time)
|
||||
{
|
||||
std::list<RsPeerId> ids ;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids ;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
for(std::set<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << " asking list of public lobbies to " << *it << std::endl;
|
||||
|
@ -1591,7 +1591,7 @@ void p3ChatService::initRsChatInfo(RsChatMsgItem *c, ChatInfo &i)
|
|||
|
||||
void p3ChatService::setOwnCustomStateString(const std::string& s)
|
||||
{
|
||||
std::list<RsPeerId> onlineList;
|
||||
std::set<RsPeerId> onlineList;
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -1603,13 +1603,13 @@ void p3ChatService::setOwnCustomStateString(const std::string& s)
|
|||
for(std::map<RsPeerId,StateStringInfo>::iterator it(_state_strings.begin());it!=_state_strings.end();++it)
|
||||
it->second._own_is_new = true ;
|
||||
|
||||
mLinkMgr->getOnlineList(onlineList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, onlineList);
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyOwnStatusMessageChanged() ;
|
||||
|
||||
// alert your online peers to your newly set status
|
||||
std::list<RsPeerId>::iterator it(onlineList.begin());
|
||||
std::set<RsPeerId>::iterator it(onlineList.begin());
|
||||
for(; it != onlineList.end(); it++){
|
||||
|
||||
RsChatStatusItem *cs = new RsChatStatusItem();
|
||||
|
@ -1984,7 +1984,7 @@ bool p3ChatService::saveList(bool& cleanup, std::list<RsItem*>& list)
|
|||
if(_own_avatar != NULL)
|
||||
{
|
||||
RsChatAvatarItem *ci = makeOwnAvatarItem() ;
|
||||
ci->PeerId(mLinkMgr->getOwnId());
|
||||
ci->PeerId(mServiceCtrl->getOwnId());
|
||||
|
||||
list.push_back(ci) ;
|
||||
}
|
||||
|
@ -2075,54 +2075,54 @@ RsSerialiser *p3ChatService::setupSerialiser()
|
|||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
|
||||
void p3ChatService::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3ChatService::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++) {
|
||||
if (it->state & RS_PEER_S_FRIEND) {
|
||||
if (it->actions & RS_PEER_CONNECTED) {
|
||||
|
||||
/* send the saved outgoing messages */
|
||||
bool changed = false;
|
||||
if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
/* send the saved outgoing messages */
|
||||
bool changed = false;
|
||||
|
||||
std::vector<RsChatMsgItem*> to_send ;
|
||||
std::vector<RsChatMsgItem*> to_send ;
|
||||
|
||||
if (privateOutgoingList.size())
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
if (privateOutgoingList.size())
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
std::list<RsChatMsgItem *>::iterator cit = privateOutgoingList.begin();
|
||||
while (cit != privateOutgoingList.end()) {
|
||||
RsChatMsgItem *c = *cit;
|
||||
std::list<RsChatMsgItem *>::iterator cit = privateOutgoingList.begin();
|
||||
while (cit != privateOutgoingList.end()) {
|
||||
RsChatMsgItem *c = *cit;
|
||||
|
||||
if (c->PeerId() == it->id) {
|
||||
mHistoryMgr->addMessage(false, c->PeerId(), ownId, c);
|
||||
if (c->PeerId() == it->id) {
|
||||
mHistoryMgr->addMessage(false, c->PeerId(), ownId, c);
|
||||
|
||||
to_send.push_back(c) ;
|
||||
to_send.push_back(c) ;
|
||||
|
||||
changed = true;
|
||||
changed = true;
|
||||
|
||||
cit = privateOutgoingList.erase(cit);
|
||||
cit = privateOutgoingList.erase(cit);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
cit++;
|
||||
continue;
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
for(uint32_t i=0;i<to_send.size();++i)
|
||||
checkSizeAndSendMessage_deprecated(to_send[i]); // delete item
|
||||
|
||||
if (changed) {
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_DEL);
|
||||
|
||||
IndicateConfigChanged();
|
||||
cit++;
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
for(uint32_t i=0;i<to_send.size();++i)
|
||||
checkSizeAndSendMessage_deprecated(to_send[i]); // delete item
|
||||
|
||||
if (changed) {
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_DEL);
|
||||
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
} else if (it->actions & RS_PEER_MOVED) {
|
||||
}
|
||||
else if (it->actions & RS_SERVICE_PEER_REMOVED)
|
||||
{
|
||||
/* now handle remove */
|
||||
clearPrivateChatQueue(true, it->id);
|
||||
clearPrivateChatQueue(false, it->id);
|
||||
|
@ -2163,7 +2163,7 @@ bool p3ChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const RsPe
|
|||
|
||||
// Adds the peer id to the list of friend participants, even if it's not original msg source
|
||||
|
||||
if(peer_id != mLinkMgr->getOwnId())
|
||||
if(peer_id != mServiceCtrl->getOwnId())
|
||||
lobby.participating_friends.insert(peer_id) ;
|
||||
|
||||
lobby.nick_names[item->nick] = now ;
|
||||
|
@ -2196,7 +2196,7 @@ bool p3ChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const RsPe
|
|||
// Forward to allparticipating friends, except this peer.
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(lobby.participating_friends.begin());it!=lobby.participating_friends.end();++it)
|
||||
if((*it)!=peer_id && mLinkMgr->isOnline(*it))
|
||||
if((*it)!=peer_id && mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, *it))
|
||||
{
|
||||
RsChatLobbyBouncingObject *obj2 = item->duplicate() ; // makes a copy
|
||||
RsChatItem *item2 = dynamic_cast<RsChatItem*>(obj2) ;
|
||||
|
@ -2270,7 +2270,7 @@ void p3ChatService::sendLobbyStatusItem(const ChatLobbyId& lobby_id,int type,con
|
|||
item.string1 = status_string ;
|
||||
item.sendTime = time(NULL) ;
|
||||
}
|
||||
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||
bounceLobbyObject(&item,ownId) ;
|
||||
}
|
||||
|
||||
|
@ -2429,10 +2429,10 @@ void p3ChatService::sendConnectionChallenge(ChatLobbyId lobby_id)
|
|||
|
||||
// Broadcast to all direct friends
|
||||
|
||||
std::list<RsPeerId> ids ;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
std::set<RsPeerId> ids ;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||
|
||||
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
for(std::set<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
{
|
||||
RsChatLobbyConnectChallengeItem *item = new RsChatLobbyConnectChallengeItem ;
|
||||
|
||||
|
|
|
@ -33,10 +33,12 @@
|
|||
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pgp/pgphandler.h"
|
||||
#include "turtle/turtleclientservice.h"
|
||||
#include "retroshare/rsmsgs.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
class p3LinkMgr;
|
||||
class p3HistoryMgr;
|
||||
class p3turtle ;
|
||||
|
@ -50,10 +52,10 @@ typedef RsPeerId ChatLobbyVirtualPeerId ;
|
|||
* This service uses rsnotify (callbacks librs clients (e.g. rs-gui))
|
||||
* @see NotifyBase
|
||||
*/
|
||||
class p3ChatService: public p3Service, public p3Config, public pqiMonitor, public RsTurtleClientService
|
||||
class p3ChatService: public p3Service, public p3Config, public pqiServiceMonitor, public RsTurtleClientService
|
||||
{
|
||||
public:
|
||||
p3ChatService(p3LinkMgr *cm, p3HistoryMgr *historyMgr);
|
||||
p3ChatService(p3ServiceControl *cs, p3LinkMgr *cm, p3HistoryMgr *historyMgr);
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
|
@ -69,7 +71,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||
virtual int status();
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
/*!
|
||||
* public chat sent to all peers
|
||||
|
@ -276,6 +278,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||
RsChatAvatarItem *makeOwnAvatarItem() ;
|
||||
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
||||
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3HistoryMgr *mHistoryMgr;
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@ void DiscPgpInfo::mergeFriendList(const std::list<PGPID> &friends)
|
|||
}
|
||||
|
||||
|
||||
p3discovery2::p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr)
|
||||
:p3Service(), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr),
|
||||
p3discovery2::p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr, p3ServiceControl *sc)
|
||||
:p3Service(), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr), mServiceCtrl(sc),
|
||||
mDiscMtx("p3discovery2")
|
||||
{
|
||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -752,7 +752,7 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
|||
mit != ffit->second.mSslIds.end(); mit++)
|
||||
{
|
||||
SSLID sslid = mit->first;
|
||||
if (mLinkMgr->isOnline(sslid))
|
||||
if (mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, sslid))
|
||||
{
|
||||
// TODO IGNORE if sslid == aboutId, or sslid == ownId.
|
||||
#ifdef P3DISC_DEBUG
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "services/p3service.h"
|
||||
#include "pqi/authgpg.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
|
||||
|
||||
typedef RsPgpId PGPID;
|
||||
|
@ -78,7 +79,7 @@ class p3discovery2: public RsDisc, public p3Service, public pqiServiceMonitor, p
|
|||
{
|
||||
public:
|
||||
|
||||
p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr);
|
||||
p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr, p3ServiceControl *sc);
|
||||
virtual ~p3discovery2();
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
@ -133,6 +134,7 @@ virtual void setGPGOperation(AuthGPGOperation *operation);
|
|||
p3PeerMgr *mPeerMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
/* data */
|
||||
RsMutex mDiscMtx;
|
||||
|
|
|
@ -63,8 +63,8 @@ RsDsdv *rsDsdv = NULL;
|
|||
*
|
||||
****/
|
||||
|
||||
p3Dsdv::p3Dsdv(p3LinkMgr *lm)
|
||||
:p3Service(), /* p3Config(CONFIG_TYPE_DSDV), */ mDsdvMtx("p3Dsdv"), mLinkMgr(lm)
|
||||
p3Dsdv::p3Dsdv(p3ServiceControl *sc)
|
||||
:p3Service(), /* p3Config(CONFIG_TYPE_DSDV), */ mDsdvMtx("p3Dsdv"), mServiceCtrl(sc)
|
||||
{
|
||||
addSerialType(new RsDsdvSerialiser());
|
||||
|
||||
|
@ -195,8 +195,8 @@ int p3Dsdv::generateRoutingTables(bool incremental)
|
|||
{
|
||||
/* we ping our peers */
|
||||
/* who is online? */
|
||||
std::list<std::string> idList;
|
||||
mLinkMgr->getOnlineList(idList);
|
||||
std::set<RsPeerId> idList;
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, idList);
|
||||
|
||||
#ifdef DEBUG_DSDV
|
||||
std::cerr << "p3Dsdv::generateRoutingTables(" << incremental << ")";
|
||||
|
@ -210,7 +210,7 @@ int p3Dsdv::generateRoutingTables(bool incremental)
|
|||
}
|
||||
|
||||
/* prepare packets */
|
||||
std::list<std::string>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
for(it = idList.begin(); it != idList.end(); it++)
|
||||
{
|
||||
#ifdef DEBUG_DSDV
|
||||
|
@ -228,7 +228,7 @@ int p3Dsdv::generateRoutingTables(bool incremental)
|
|||
}
|
||||
|
||||
|
||||
int p3Dsdv::generateRoutingTable(const std::string &peerId, bool incremental)
|
||||
int p3Dsdv::generateRoutingTable(const RsPeerId &peerId, bool incremental)
|
||||
{
|
||||
RsDsdvRouteItem *dsdv = new RsDsdvRouteItem();
|
||||
dsdv->PeerId(peerId);
|
||||
|
@ -385,7 +385,7 @@ int p3Dsdv::handleDSDV(RsDsdvRouteItem *dsdv)
|
|||
}
|
||||
|
||||
/* look for this in mAllRoutes */
|
||||
std::map<std::string, RsDsdvRoute>::iterator rit;
|
||||
std::map<RsPeerId, RsDsdvRoute>::iterator rit;
|
||||
rit = v.mAllRoutes.find(dsdv->PeerId());
|
||||
if (rit == v.mAllRoutes.end())
|
||||
{
|
||||
|
@ -485,11 +485,11 @@ int p3Dsdv::selectStableRoutes()
|
|||
continue; // Ignore if we are source.
|
||||
}
|
||||
|
||||
std::map<std::string, RsDsdvRoute>::iterator rit;
|
||||
std::map<RsPeerId, RsDsdvRoute>::iterator rit;
|
||||
uint32_t newest = 0;
|
||||
std::string newestId;
|
||||
RsPeerId newestId;
|
||||
uint32_t closest = RSDSDV_MAX_DISTANCE + 1;
|
||||
std::string closestId;
|
||||
RsPeerId closestId;
|
||||
time_t closestAge = 0;
|
||||
|
||||
/* find newest sequence number */
|
||||
|
@ -646,9 +646,9 @@ int p3Dsdv::clearOldRoutes()
|
|||
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
void p3Dsdv::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3Dsdv::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for(it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
/* only care about disconnected / not friends cases */
|
||||
|
@ -738,7 +738,7 @@ int p3Dsdv::addDsdvId(RsDsdvId *id, std::string realHash)
|
|||
RsDsdvTableEntry v;
|
||||
v.mDest = *id;
|
||||
|
||||
v.mStableRoute.mNextHop = mLinkMgr->getOwnId();
|
||||
v.mStableRoute.mNextHop = mServiceCtrl->getOwnId();
|
||||
v.mStableRoute.mReceived = now;
|
||||
v.mStableRoute.mValidSince = now;
|
||||
v.mStableRoute.mSequence = 0;
|
||||
|
@ -901,7 +901,7 @@ std::ostream &operator<<(std::ostream &out, const RsDsdvTableEntry &entry)
|
|||
out << "\tAll Routes:" << std::endl;
|
||||
}
|
||||
|
||||
std::map<std::string, RsDsdvRoute>::const_iterator it;
|
||||
std::map<RsPeerId, RsDsdvRoute>::const_iterator it;
|
||||
for(it = entry.mAllRoutes.begin(); it != entry.mAllRoutes.end(); it++)
|
||||
{
|
||||
out << "\t\t" << it->second << std::endl;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "retroshare/rsdsdv.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
|
||||
#define RSDSDV_MAX_DISTANCE 3
|
||||
|
@ -49,10 +49,10 @@ class p3LinkMgr;
|
|||
* Finds RS wide paths to Services and Peers.
|
||||
*/
|
||||
|
||||
class p3Dsdv: public RsDsdv, public p3Service /* , public p3Config */, public pqiMonitor
|
||||
class p3Dsdv: public RsDsdv, public p3Service /* , public p3Config */, public pqiServiceMonitor
|
||||
{
|
||||
public:
|
||||
p3Dsdv(p3LinkMgr *cm);
|
||||
p3Dsdv(p3ServiceControl *cm);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/*** internal librs interface ****/
|
||||
|
@ -71,7 +71,7 @@ void clearSignificantChangesFlags();
|
|||
|
||||
|
||||
int generateRoutingTables(bool incremental);
|
||||
int generateRoutingTable(const std::string &peerId, bool incremental);
|
||||
int generateRoutingTable(const RsPeerId &peerId, bool incremental);
|
||||
|
||||
int processIncoming();
|
||||
|
||||
|
@ -97,7 +97,7 @@ virtual int getDsdvEntry(const std::string &hash, RsDsdvTableEntry &entry);
|
|||
virtual int status();
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
/************* from p3Config *******************/
|
||||
//virtual RsSerialiser *setupSerialiser() ;
|
||||
|
@ -115,7 +115,7 @@ virtual int getDsdvEntry(const std::string &hash, RsDsdvTableEntry &entry);
|
|||
|
||||
bool mSignificantChanges;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -28,11 +28,14 @@
|
|||
#include "services/p3heartbeat.h"
|
||||
#include "serialiser/rsheartbeatitems.h"
|
||||
|
||||
#include "pqi/p3servicecontrol.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
//#define HEART_DEBUG 1
|
||||
|
||||
|
||||
p3heartbeat::p3heartbeat(p3LinkMgr *linkMgr, pqipersongrp *pqipg)
|
||||
:p3Service(), mLinkMgr(linkMgr), mPqiPersonGrp(pqipg),
|
||||
p3heartbeat::p3heartbeat(p3ServiceControl *sc, pqipersongrp *pqipg)
|
||||
:p3Service(), mServiceCtrl(sc), mPqiPersonGrp(pqipg),
|
||||
mHeartMtx("p3heartbeat")
|
||||
{
|
||||
RsStackMutex stack(mHeartMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -82,10 +85,10 @@ int p3heartbeat::tick()
|
|||
{
|
||||
mLastHeartbeat = time(NULL);
|
||||
|
||||
std::list<RsPeerId> peers;
|
||||
std::list<RsPeerId>::const_iterator pit;
|
||||
std::set<RsPeerId> peers;
|
||||
std::set<RsPeerId>::const_iterator pit;
|
||||
|
||||
mLinkMgr->getOnlineList(peers);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, peers);
|
||||
for (pit = peers.begin(); pit != peers.end(); ++pit)
|
||||
{
|
||||
sendHeartbeat(*pit);
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
|
||||
// Moved Heartbeat to a seperate service.
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
#include "services/p3service.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
class pqipersongrp;
|
||||
|
||||
class p3heartbeat: public p3Service
|
||||
{
|
||||
public:
|
||||
|
||||
p3heartbeat(p3LinkMgr *linkMgr, pqipersongrp *pqipg);
|
||||
p3heartbeat(p3ServiceControl *sc, pqipersongrp *pqipg);
|
||||
virtual ~p3heartbeat();
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
@ -51,7 +51,7 @@ virtual RsServiceInfo getServiceInfo();
|
|||
|
||||
private:
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
pqipersongrp *mPqiPersonGrp;
|
||||
|
||||
/* data */
|
||||
|
|
|
@ -75,9 +75,9 @@ static const uint8_t ENCRYPTED_MSG_PROTOCOL_VERSION_01 = 0x37 ;
|
|||
*/
|
||||
|
||||
|
||||
p3MsgService::p3MsgService(p3LinkMgr *lm)
|
||||
p3MsgService::p3MsgService(p3ServiceControl *sc)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_MSGS),
|
||||
mLinkMgr(lm), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
|
||||
mServiceCtrl(sc), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
|
||||
{
|
||||
_serialiser = new RsMsgSerialiser();
|
||||
addSerialType(_serialiser);
|
||||
|
@ -85,7 +85,7 @@ p3MsgService::p3MsgService(p3LinkMgr *lm)
|
|||
mDistantMessagingEnabled = true ;
|
||||
|
||||
/* Initialize standard tag types */
|
||||
if(lm)
|
||||
if(sc)
|
||||
initStandardTagTypes();
|
||||
|
||||
#ifdef GROUTER
|
||||
|
@ -280,10 +280,24 @@ void p3MsgService::handleIncomingItem(RsMsgItem *mi)
|
|||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
}
|
||||
|
||||
void p3MsgService::statusChange(const std::list<pqipeer> &/*plist*/)
|
||||
void p3MsgService::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
/* should do it properly! */
|
||||
checkOutgoingMessages();
|
||||
/* only do this when a new peer is connected */
|
||||
bool newPeers = false;
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for(it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
newPeers = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (newPeers)
|
||||
{
|
||||
checkOutgoingMessages();
|
||||
}
|
||||
}
|
||||
|
||||
void p3MsgService::checkSizeAndSendMessage(RsMsgItem *msg)
|
||||
|
@ -357,7 +371,7 @@ int p3MsgService::checkOutgoingMessages()
|
|||
std::list<RsMsgItem*> output_queue ;
|
||||
|
||||
{
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
std::list<uint32_t>::iterator it;
|
||||
std::list<uint32_t> toErase;
|
||||
|
@ -407,7 +421,7 @@ int p3MsgService::checkOutgoingMessages()
|
|||
#endif
|
||||
}
|
||||
|
||||
if(tunnel_is_ok || mLinkMgr->isOnline(pid) || pid == ownId) /* FEEDBACK Msg to Ourselves */
|
||||
if(tunnel_is_ok || mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid) || pid == ownId) /* FEEDBACK Msg to Ourselves */
|
||||
{
|
||||
/* send msg */
|
||||
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
|
||||
|
@ -542,7 +556,7 @@ static void getStandardTagTypes(MsgTagType &tags)
|
|||
void p3MsgService::initStandardTagTypes()
|
||||
{
|
||||
bool bChanged = false;
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
MsgTagType tags;
|
||||
getStandardTagTypes(tags);
|
||||
|
@ -722,7 +736,7 @@ void p3MsgService::loadWelcomeMsg()
|
|||
/* Load Welcome Message */
|
||||
RsMsgItem *msg = new RsMsgItem();
|
||||
|
||||
//msg -> PeerId(mLinkMgr->getOwnId());
|
||||
//msg -> PeerId(mServiceCtrl->getOwnId());
|
||||
|
||||
msg -> sendTime = time(NULL);
|
||||
msg -> recvTime = time(NULL);
|
||||
|
@ -1008,7 +1022,7 @@ bool p3MsgService::setMsgParentId(uint32_t msgId, uint32_t msgParentId)
|
|||
{
|
||||
if (msgParentId) {
|
||||
RsMsgParentId* msp = new RsMsgParentId();
|
||||
msp->PeerId (mLinkMgr->getOwnId());
|
||||
msp->PeerId (mServiceCtrl->getOwnId());
|
||||
msp->msgId = msgId;
|
||||
msp->msgParentId = msgParentId;
|
||||
mParentId.insert(std::pair<uint32_t, RsMsgParentId*>(msgId, msp));
|
||||
|
@ -1054,7 +1068,7 @@ int p3MsgService::sendMessage(RsMsgItem *item)
|
|||
/* STORE MsgID */
|
||||
msgOutgoing[item->msgId] = item;
|
||||
|
||||
if (item->PeerId() != mLinkMgr->getOwnId()) {
|
||||
if (item->PeerId() != mServiceCtrl->getOwnId()) {
|
||||
/* not to the loopback device */
|
||||
RsMsgSrcId* msi = new RsMsgSrcId();
|
||||
msi->msgId = item->msgId;
|
||||
|
@ -1104,7 +1118,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
|||
}
|
||||
|
||||
/* send to ourselves as well */
|
||||
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
||||
RsMsgItem *msg = initMIRsMsg(info, mServiceCtrl->getOwnId());
|
||||
if (msg)
|
||||
{
|
||||
std::list<RsPgpId>::iterator it ;
|
||||
|
@ -1138,7 +1152,7 @@ bool p3MsgService::SystemMessage(const std::string &title, const std::string &me
|
|||
return false;
|
||||
}
|
||||
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
RsMsgItem *msg = new RsMsgItem();
|
||||
|
||||
|
@ -1169,7 +1183,7 @@ bool p3MsgService::SystemMessage(const std::string &title, const std::string &me
|
|||
|
||||
bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
|
||||
{
|
||||
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
||||
RsMsgItem *msg = initMIRsMsg(info, mServiceCtrl->getOwnId());
|
||||
if (msg)
|
||||
{
|
||||
uint32_t msgId = 0;
|
||||
|
@ -1250,7 +1264,7 @@ bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32
|
|||
|
||||
/* new tag */
|
||||
RsMsgTagType* tagType = new RsMsgTagType();
|
||||
tagType->PeerId (mLinkMgr->getOwnId());
|
||||
tagType->PeerId (mServiceCtrl->getOwnId());
|
||||
tagType->rgb_color = rgb_color;
|
||||
tagType->tagId = tagId;
|
||||
tagType->text = text;
|
||||
|
@ -1391,7 +1405,7 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
|
|||
if (set) {
|
||||
/* new msg */
|
||||
RsMsgTags* tag = new RsMsgTags();
|
||||
tag->PeerId (mLinkMgr->getOwnId());
|
||||
tag->PeerId (mServiceCtrl->getOwnId());
|
||||
|
||||
tag->msgId = mid;
|
||||
tag->tagIds.push_back(tagId);
|
||||
|
@ -1535,7 +1549,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
|
|||
|
||||
/* translate flags, if we sent it... outgoing */
|
||||
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
/*|| (msg->PeerId() == mLinkMgr->getOwnId())*/)
|
||||
/*|| (msg->PeerId() == mServiceCtrl->getOwnId())*/)
|
||||
{
|
||||
mi.msgflags |= RS_MSG_OUTGOING;
|
||||
}
|
||||
|
@ -1668,7 +1682,7 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
|||
|
||||
/* translate flags, if we sent it... outgoing */
|
||||
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
/*|| (msg->PeerId() == mLinkMgr->getOwnId())*/)
|
||||
/*|| (msg->PeerId() == mServiceCtrl->getOwnId())*/)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_OUTGOING;
|
||||
}
|
||||
|
@ -1756,7 +1770,7 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const RsPeerId &to)
|
|||
}
|
||||
|
||||
/* We don't fill in bcc (unless to ourselves) */
|
||||
if (to == mLinkMgr->getOwnId())
|
||||
if (to == mServiceCtrl->getOwnId())
|
||||
{
|
||||
for(pit = info.msgbcc.begin(); pit != info.msgbcc.end(); pit++)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "pqi/pqi.h"
|
||||
#include "pqi/pqiindic.h"
|
||||
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
#include "services/p3service.h"
|
||||
|
@ -53,13 +53,13 @@
|
|||
class p3LinkMgr;
|
||||
|
||||
// Temp tweak to test grouter
|
||||
class p3MsgService: public p3Service, public p3Config, public pqiMonitor, public RsTurtleClientService
|
||||
class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor, public RsTurtleClientService
|
||||
#ifdef GROUTER
|
||||
, public GRouterClientService
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
p3MsgService(p3LinkMgr *lm);
|
||||
p3MsgService(p3ServiceControl *sc);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/* External Interface */
|
||||
|
@ -106,7 +106,7 @@ virtual void saveDone();
|
|||
/*** Overloaded from p3Config ****/
|
||||
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
int checkOutgoingMessages();
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
|
||||
|
@ -188,7 +188,7 @@ RsMsgItem *initMIRsMsg(MessageInfo &info, const RsPeerId &to);
|
|||
|
||||
void initStandardTagTypes();
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
/* Mutex Required for stuff below */
|
||||
|
||||
|
|
|
@ -116,8 +116,8 @@ static double convert64bitsToTs(uint64_t bits)
|
|||
|
||||
|
||||
|
||||
p3rtt::p3rtt(p3LinkMgr *lm)
|
||||
:p3FastService(), mRttMtx("p3rtt"), mLinkMgr(lm)
|
||||
p3rtt::p3rtt(p3ServiceControl *sc)
|
||||
:p3FastService(), mRttMtx("p3rtt"), mServiceCtrl(sc)
|
||||
{
|
||||
addSerialType(new RsRttSerialiser());
|
||||
|
||||
|
@ -186,9 +186,9 @@ void p3rtt::sendPingMeasurements()
|
|||
|
||||
/* we ping our peers */
|
||||
/* who is online? */
|
||||
std::list<RsPeerId> idList;
|
||||
std::set<RsPeerId> idList;
|
||||
|
||||
mLinkMgr->getOnlineList(idList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, idList);
|
||||
|
||||
double ts = getCurrentTS();
|
||||
|
||||
|
@ -198,7 +198,7 @@ void p3rtt::sendPingMeasurements()
|
|||
#endif
|
||||
|
||||
/* prepare packets */
|
||||
std::list<RsPeerId>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
for(it = idList.begin(); it != idList.end(); it++)
|
||||
{
|
||||
#ifdef DEBUG_RTT
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "services/p3service.h"
|
||||
#include "retroshare/rsrtt.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
class RttPeerInfo
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ class RttPeerInfo
|
|||
class p3rtt: public RsRtt, public p3FastService
|
||||
{
|
||||
public:
|
||||
p3rtt(p3LinkMgr *cm);
|
||||
p3rtt(p3ServiceControl *sc);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/***** overloaded from rsRtt *****/
|
||||
|
@ -111,7 +111,7 @@ virtual bool recvItem(RsItem *item); // Overloaded from p3FastService.
|
|||
time_t mSentPingTime;
|
||||
uint32_t mCounter;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
|
|||
|
||||
RsStatus *rsStatus = NULL;
|
||||
|
||||
p3StatusService::p3StatusService(p3LinkMgr *cm)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_STATUS), mLinkMgr(cm), mStatusMtx("p3StatusService")
|
||||
p3StatusService::p3StatusService(p3ServiceControl *sc)
|
||||
:p3Service(), p3Config(CONFIG_TYPE_STATUS), mServiceCtrl(sc), mStatusMtx("p3StatusService")
|
||||
{
|
||||
addSerialType(new RsStatusSerialiser());
|
||||
|
||||
|
@ -83,7 +83,7 @@ bool p3StatusService::getOwnStatus(StatusInfo& statusInfo)
|
|||
#endif
|
||||
|
||||
std::map<RsPeerId, StatusInfo>::iterator it;
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
||||
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
it = mStatusInfoMap.find(ownId);
|
||||
|
@ -154,12 +154,12 @@ bool p3StatusService::getStatus(const RsPeerId &id, StatusInfo &statusInfo)
|
|||
bool p3StatusService::sendStatus(const RsPeerId &id, uint32_t status)
|
||||
{
|
||||
StatusInfo statusInfo;
|
||||
std::list<RsPeerId> onlineList;
|
||||
std::set<RsPeerId> onlineList;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
|
||||
statusInfo.id = mLinkMgr->getOwnId();
|
||||
statusInfo.id = mServiceCtrl->getOwnId();
|
||||
statusInfo.status = status;
|
||||
|
||||
// don't save inactive status
|
||||
|
@ -179,13 +179,13 @@ bool p3StatusService::sendStatus(const RsPeerId &id, uint32_t status)
|
|||
}
|
||||
|
||||
if (id.isNull()) {
|
||||
mLinkMgr->getOnlineList(onlineList);
|
||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, onlineList);
|
||||
} else {
|
||||
onlineList.push_back(id);
|
||||
onlineList.insert(id);
|
||||
}
|
||||
}
|
||||
|
||||
std::list<RsPeerId>::iterator it;
|
||||
std::set<RsPeerId>::iterator it;
|
||||
|
||||
#ifdef STATUS_DEBUG
|
||||
std::cerr << "p3StatusService::sendStatus() " << std::endl;
|
||||
|
@ -288,11 +288,11 @@ bool p3StatusService::saveList(bool& cleanup, std::list<RsItem*>& ilist){
|
|||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
it = mStatusInfoMap.find(mLinkMgr->getOwnId());
|
||||
it = mStatusInfoMap.find(mServiceCtrl->getOwnId());
|
||||
|
||||
if(it == mStatusInfoMap.end()){
|
||||
std::cerr << "p3StatusService::saveList() :" << "Did not find your status"
|
||||
<< mLinkMgr->getOwnId() << std::endl;
|
||||
<< mServiceCtrl->getOwnId() << std::endl;
|
||||
delete own_status;
|
||||
return false;
|
||||
}
|
||||
|
@ -326,14 +326,14 @@ bool p3StatusService::loadList(std::list<RsItem*>& load){
|
|||
|
||||
if(own_status != NULL){
|
||||
|
||||
own_info.id = mLinkMgr->getOwnId();
|
||||
own_info.id = mServiceCtrl->getOwnId();
|
||||
own_info.status = own_status->status;
|
||||
own_info.time_stamp = own_status->sendTime;
|
||||
delete own_status;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
std::pair<RsPeerId, StatusInfo> pr(mLinkMgr->getOwnId(), own_info);
|
||||
std::pair<RsPeerId, StatusInfo> pr(mServiceCtrl->getOwnId(), own_info);
|
||||
mStatusInfoMap.insert(pr);
|
||||
}
|
||||
|
||||
|
@ -363,48 +363,52 @@ int p3StatusService::status(){
|
|||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
|
||||
void p3StatusService::statusChange(const std::list<pqipeer> &plist)
|
||||
void p3StatusService::statusChange(const std::list<pqiServicePeer> &plist)
|
||||
{
|
||||
bool changedState = false;
|
||||
|
||||
StatusInfo statusInfo;
|
||||
std::list<pqipeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++) {
|
||||
if (it->state & RS_PEER_S_FRIEND) {
|
||||
if (it->actions & RS_PEER_DISCONNECTED)
|
||||
std::list<pqiServicePeer>::const_iterator it;
|
||||
for (it = plist.begin(); it != plist.end(); it++)
|
||||
{
|
||||
if (it->actions & RS_SERVICE_PEER_DISCONNECTED)
|
||||
{
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
/* remove peer from status map */
|
||||
mStatusInfoMap.erase(it->id);
|
||||
} /* UNLOCKED */
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
/* remove peer from status map */
|
||||
mStatusInfoMap.erase(it->id);
|
||||
} /* UNLOCKED */
|
||||
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_OFFLINE);
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_OFFLINE);
|
||||
}
|
||||
|
||||
if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
||||
{
|
||||
/* send current status, only call getOwnStatus once in the loop */
|
||||
if (statusInfo.id.isNull() == false || getOwnStatus(statusInfo))
|
||||
{
|
||||
sendStatus(it->id, statusInfo.status);
|
||||
}
|
||||
|
||||
if (it->actions & RS_PEER_CONNECTED) {
|
||||
/* send current status, only call getOwnStatus once in the loop */
|
||||
if (statusInfo.id.isNull() == false || getOwnStatus(statusInfo)) {
|
||||
sendStatus(it->id, statusInfo.status);
|
||||
}
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
/* We assume that the peer is online. If not, he send us a new status */
|
||||
StatusInfo info;
|
||||
info.id = it->id;
|
||||
info.status = RS_STATUS_ONLINE;
|
||||
info.time_stamp = time(NULL);
|
||||
|
||||
/* We assume that the peer is online. If not, he send us a new status */
|
||||
StatusInfo info;
|
||||
info.id = it->id;
|
||||
info.status = RS_STATUS_ONLINE;
|
||||
info.time_stamp = time(NULL);
|
||||
mStatusInfoMap[it->id] = info;
|
||||
} /* UNLOCKED */
|
||||
|
||||
mStatusInfoMap[it->id] = info;
|
||||
} /* UNLOCKED */
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_ONLINE);
|
||||
}
|
||||
|
||||
changedState = true;
|
||||
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_ONLINE);
|
||||
}
|
||||
} else if (it->actions & RS_PEER_MOVED) {
|
||||
if (it->actions & RS_SERVICE_PEER_REMOVED)
|
||||
{
|
||||
/* now handle remove */
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
#include "retroshare/rsstatus.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3ServiceControl;
|
||||
|
||||
//! handles standard status messages (busy, away, online, offline) set by user
|
||||
/*!
|
||||
|
@ -44,11 +44,11 @@ class p3LinkMgr;
|
|||
* custom string.
|
||||
* @see rsiface/rsstatus.h for status constants
|
||||
*/
|
||||
class p3StatusService: public p3Service, public p3Config, public pqiMonitor
|
||||
class p3StatusService: public p3Service, public p3Config, public pqiServiceMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
p3StatusService(p3LinkMgr *lm);
|
||||
p3StatusService(p3ServiceControl *sc);
|
||||
virtual ~p3StatusService();
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
@ -58,7 +58,7 @@ virtual int tick();
|
|||
virtual int status();
|
||||
|
||||
/*************** pqiMonitor callback ***********************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
|
||||
/********* RsStatus ***********/
|
||||
|
||||
|
@ -95,7 +95,7 @@ virtual bool loadList(std::list<RsItem*>& load);
|
|||
|
||||
virtual void receiveStatusQueue();
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
std::map<RsPeerId, StatusInfo> mStatusInfoMap;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue