mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-02 03:06:31 -04:00
Removed p3ConnectMgr. Replaced it with p3LinkMgr, p3NetMgr and p3PeerMgr.
Updated references in other classes. * Most classes need p3LinkMgr, and only use two functions: OwnId() and getOnlineList() git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4416 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
21487bfdf6
commit
f6f721a492
55 changed files with 1226 additions and 1044 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "pqi/pqibin.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
#include "pqi/pqistore.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
#include "services/p3chatservice.h"
|
||||
|
||||
|
@ -41,8 +42,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
p3ChatService::p3ChatService(p3ConnectMgr *cm)
|
||||
:p3Service(RS_SERVICE_TYPE_CHAT), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mConnMgr(cm)
|
||||
p3ChatService::p3ChatService(p3LinkMgr *lm)
|
||||
:p3Service(RS_SERVICE_TYPE_CHAT), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mLinkMgr(lm)
|
||||
{
|
||||
addSerialType(new RsChatSerialiser());
|
||||
|
||||
|
@ -72,10 +73,10 @@ int p3ChatService::sendPublicChat(std::wstring &msg)
|
|||
|
||||
std::list<std::string> ids;
|
||||
std::list<std::string>::iterator it;
|
||||
mConnMgr->getOnlineList(ids);
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
|
||||
/* add in own id -> so get reflection */
|
||||
ids.push_back(mConnMgr->getOwnId());
|
||||
ids.push_back(mLinkMgr->getOwnId());
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat()";
|
||||
|
@ -156,7 +157,7 @@ class p3ChatService::AvatarInfo
|
|||
void p3ChatService::sendGroupChatStatusString(const std::string& status_string)
|
||||
{
|
||||
std::list<std::string> ids;
|
||||
mConnMgr->getOnlineList(ids);
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat(): sending group chat status string: " << status_string << std::endl ;
|
||||
|
@ -235,7 +236,7 @@ bool p3ChatService::sendPrivateChat(std::string &id, std::wstring &msg)
|
|||
ci->recvTime = ci->sendTime;
|
||||
ci->message = msg;
|
||||
|
||||
if (!mConnMgr->isOnline(id)) {
|
||||
if (!mLinkMgr->isOnline(id)) {
|
||||
/* peer is offline, add to outgoing list */
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -690,7 +691,7 @@ void p3ChatService::setOwnCustomStateString(const std::string& s)
|
|||
for(std::map<std::string,StateStringInfo>::iterator it(_state_strings.begin());it!=_state_strings.end();++it)
|
||||
it->second._own_is_new = true ;
|
||||
|
||||
mConnMgr->getOnlineList(onlineList);
|
||||
mLinkMgr->getOnlineList(onlineList);
|
||||
}
|
||||
|
||||
rsicontrol->getNotify().notifyOwnStatusMessageChanged() ;
|
||||
|
@ -1022,7 +1023,7 @@ bool p3ChatService::saveList(bool& cleanup, std::list<RsItem*>& list)
|
|||
if(_own_avatar != NULL)
|
||||
{
|
||||
RsChatAvatarItem *ci = makeOwnAvatarItem() ;
|
||||
ci->PeerId(mConnMgr->getOwnId());
|
||||
ci->PeerId(mLinkMgr->getOwnId());
|
||||
|
||||
list.push_back(ci) ;
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include "retroshare/rsmsgs.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
|
||||
//!The basic Chat service.
|
||||
/**
|
||||
*
|
||||
|
@ -45,7 +46,7 @@
|
|||
class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
{
|
||||
public:
|
||||
p3ChatService(p3ConnectMgr *cm);
|
||||
p3ChatService(p3LinkMgr *cm);
|
||||
|
||||
/***** overloaded from p3Service *****/
|
||||
/*!
|
||||
|
@ -199,7 +200,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
|||
RsChatAvatarItem *makeOwnAvatarItem() ;
|
||||
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
||||
std::list<RsChatMsgItem *> publicList;
|
||||
std::list<RsChatMsgItem *> privateIncomingList;
|
||||
|
|
|
@ -29,9 +29,11 @@
|
|||
#include "retroshare/rspeers.h"
|
||||
#include "services/p3disc.h"
|
||||
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
#include "pqi/authssl.h"
|
||||
#include "pqi/authgpg.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <errno.h>
|
||||
|
@ -82,10 +84,10 @@ const uint32_t P3DISC_FLAGS_ASK_VERSION = 0x0080;
|
|||
******************************************************************************************
|
||||
*****************************************************************************************/
|
||||
|
||||
p3disc::p3disc(p3ConnectMgr *cm, pqipersongrp *pqih)
|
||||
p3disc::p3disc(p3PeerMgr *pm, p3LinkMgr *lm, pqipersongrp *pqih)
|
||||
:p3Service(RS_SERVICE_TYPE_DISC),
|
||||
p3Config(CONFIG_TYPE_P3DISC),
|
||||
mConnMgr(cm),
|
||||
mPeerMgr(pm), mLinkMgr(lm),
|
||||
mPqiPersonGrp(pqih), mDiscMtx("p3disc")
|
||||
{
|
||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -114,7 +116,7 @@ int p3disc::tick()
|
|||
#endif
|
||||
lastSentHeartbeatTime = time(NULL);
|
||||
std::list <std::string> peers;
|
||||
mConnMgr->getOnlineList(peers);
|
||||
mLinkMgr->getOnlineList(peers);
|
||||
for (std::list<std::string>::const_iterator pit = peers.begin(); pit != peers.end(); ++pit) {
|
||||
sendHeartbeat(*pit);
|
||||
}
|
||||
|
@ -132,8 +134,8 @@ int p3disc::handleIncoming()
|
|||
#endif
|
||||
|
||||
// if off discard item.
|
||||
peerConnectState detail;
|
||||
if (!mConnMgr->getOwnNetStatus(detail) || (detail.visState & RS_VIS_STATE_NODISC))
|
||||
peerState detail;
|
||||
if (!mPeerMgr->getOwnNetStatus(detail) || (detail.visState & RS_VIS_STATE_NODISC))
|
||||
{
|
||||
while(NULL != (item = recvItem()))
|
||||
{
|
||||
|
@ -288,8 +290,8 @@ void p3disc::sendAllInfoToJustConnectedPeer(const std::string &id)
|
|||
/* send them a list of all friend's details */
|
||||
for(friendIdsIt = friendIds.begin(); friendIdsIt != friendIds.end(); friendIdsIt++) {
|
||||
/* get details */
|
||||
peerConnectState detail;
|
||||
if (!mConnMgr->getFriendNetStatus(*friendIdsIt, detail)) {
|
||||
peerState detail;
|
||||
if (!mPeerMgr->getFriendNetStatus(*friendIdsIt, detail)) {
|
||||
/* major error! */
|
||||
continue;
|
||||
}
|
||||
|
@ -368,8 +370,8 @@ RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &a
|
|||
|
||||
|
||||
// if off discard item.
|
||||
peerConnectState detail;
|
||||
if (!mConnMgr->getOwnNetStatus(detail) || (detail.visState & RS_VIS_STATE_NODISC)) {
|
||||
peerState detail;
|
||||
if (!mPeerMgr->getOwnNetStatus(detail) || (detail.visState & RS_VIS_STATE_NODISC)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -405,8 +407,8 @@ RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &a
|
|||
if(sslChilds.size() == 1 || to != *sslChildIt) // We don't send info to a peer about itself, when there are more than one ssl children,
|
||||
{ // but we allow sending info about peers with the same GPG id. When there is only one ssl child,
|
||||
// we must send it to transfer the signers of the gpg key. The receiver is skipping the own id.
|
||||
peerConnectState detail;
|
||||
if (!mConnMgr->getFriendNetStatus(*sslChildIt, detail)
|
||||
peerState detail;
|
||||
if (!mPeerMgr->getFriendNetStatus(*sslChildIt, detail)
|
||||
|| detail.visState & RS_VIS_STATE_NODISC)
|
||||
{
|
||||
#ifdef P3DISC_DEBUG
|
||||
|
@ -430,8 +432,8 @@ RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &a
|
|||
rsPeerNetItem.netMode = detail.netMode;
|
||||
rsPeerNetItem.visState = detail.visState;
|
||||
rsPeerNetItem.lastContact = detail.lastcontact;
|
||||
rsPeerNetItem.currentlocaladdr = detail.currentlocaladdr;
|
||||
rsPeerNetItem.currentremoteaddr = detail.currentserveraddr;
|
||||
rsPeerNetItem.currentlocaladdr = detail.localaddr;
|
||||
rsPeerNetItem.currentremoteaddr = detail.serveraddr;
|
||||
rsPeerNetItem.dyndns = detail.dyndns;
|
||||
detail.ipAddrs.mLocal.loadTlv(rsPeerNetItem.localAddrList);
|
||||
detail.ipAddrs.mExt.loadTlv(rsPeerNetItem.extAddrList);
|
||||
|
@ -452,8 +454,8 @@ RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &a
|
|||
//send own details
|
||||
if (about == rsPeers->getGPGOwnId())
|
||||
{
|
||||
peerConnectState detail;
|
||||
if (mConnMgr->getOwnNetStatus(detail))
|
||||
peerState detail;
|
||||
if (mPeerMgr->getOwnNetStatus(detail))
|
||||
{
|
||||
shouldWeSendGPGKey = true;
|
||||
RsPeerNetItem rsPeerNetItem ;
|
||||
|
@ -464,8 +466,8 @@ RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &a
|
|||
rsPeerNetItem.netMode = detail.netMode;
|
||||
rsPeerNetItem.visState = detail.visState;
|
||||
rsPeerNetItem.lastContact = time(NULL);
|
||||
rsPeerNetItem.currentlocaladdr = detail.currentlocaladdr;
|
||||
rsPeerNetItem.currentremoteaddr = detail.currentserveraddr;
|
||||
rsPeerNetItem.currentlocaladdr = detail.localaddr;
|
||||
rsPeerNetItem.currentremoteaddr = detail.serveraddr;
|
||||
rsPeerNetItem.dyndns = detail.dyndns;
|
||||
detail.ipAddrs.mLocal.loadTlv(rsPeerNetItem.localAddrList);
|
||||
detail.ipAddrs.mExt.loadTlv(rsPeerNetItem.extAddrList);
|
||||
|
@ -534,8 +536,8 @@ void p3disc::askInfoToAllPeers(std::string about)
|
|||
#endif
|
||||
|
||||
|
||||
peerConnectState connectState;
|
||||
if (!mConnMgr->getFriendNetStatus(about, connectState)) // || (connectState.visState & RS_VIS_STATE_NODISC)) {
|
||||
peerState connectState;
|
||||
if (!mPeerMgr->getFriendNetStatus(about, connectState)) // || (connectState.visState & RS_VIS_STATE_NODISC)) {
|
||||
{
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "p3disc::askInfoToAllPeers() friend disc is off, don't send the request." << std::endl;
|
||||
|
@ -551,7 +553,7 @@ void p3disc::askInfoToAllPeers(std::string about)
|
|||
}
|
||||
|
||||
// if off discard item.
|
||||
if (!mConnMgr->getOwnNetStatus(connectState) || (connectState.visState & RS_VIS_STATE_NODISC)) {
|
||||
if (!mPeerMgr->getOwnNetStatus(connectState) || (connectState.visState & RS_VIS_STATE_NODISC)) {
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "p3disc::askInfoToAllPeers() no gpg id found" << std::endl;
|
||||
#endif
|
||||
|
@ -644,7 +646,7 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
|||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "--> Adding to friends list " << pitem->pid << " - " << pitem->gpg_id << std::endl;
|
||||
#endif
|
||||
mConnMgr->addFriend(pitem->pid, pitem->gpg_id, pitem->netMode, 0, 0);
|
||||
mPeerMgr->addFriend(pitem->pid, pitem->gpg_id, pitem->netMode, 0, 0);
|
||||
RsPeerDetails storedDetails;
|
||||
|
||||
// Update if know this peer
|
||||
|
@ -660,9 +662,9 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
|||
std::cerr << " -> network mode: " << pitem->netMode << std::endl;
|
||||
std::cerr << " -> location: " << pitem->location << std::endl;
|
||||
#endif
|
||||
mConnMgr->setNetworkMode(pitem->pid, pitem->netMode);
|
||||
mPeerMgr->setNetworkMode(pitem->pid, pitem->netMode);
|
||||
}
|
||||
mConnMgr->setLocation(pitem->pid, pitem->location);
|
||||
mPeerMgr->setLocation(pitem->pid, pitem->location);
|
||||
|
||||
// The info from the peer itself is ultimately trustable, so we can override some info,
|
||||
// such as:
|
||||
|
@ -683,10 +685,10 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
|||
// When the peer sends his own list of IPs, the info replaces the existing info, because the
|
||||
// peer is the primary source of his own IPs.
|
||||
|
||||
mConnMgr->setLocalAddress(pitem->pid, pitem->currentlocaladdr);
|
||||
mConnMgr->setExtAddress(pitem->pid, pitem->currentremoteaddr);
|
||||
pitem->visState &= ~RS_VIS_STATE_NODISC ;
|
||||
mConnMgr->setVisState(pitem->pid, pitem->visState);
|
||||
mPeerMgr->setLocalAddress(pitem->pid, pitem->currentlocaladdr);
|
||||
mPeerMgr->setExtAddress(pitem->pid, pitem->currentremoteaddr);
|
||||
//pitem->visState &= ~RS_VIS_STATE_NODISC ;
|
||||
mPeerMgr->setVisState(pitem->pid, pitem->visState);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -706,9 +708,9 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
|||
#endif
|
||||
// allways update address list and dns, except if it's ours
|
||||
if (pitem->dyndns != "")
|
||||
mConnMgr->setDynDNS(pitem->pid, pitem->dyndns);
|
||||
mPeerMgr->setDynDNS(pitem->pid, pitem->dyndns);
|
||||
|
||||
mConnMgr->updateAddressList(pitem->pid, addrsFromPeer);
|
||||
mPeerMgr->updateAddressList(pitem->pid, addrsFromPeer);
|
||||
}
|
||||
#ifdef P3DISC_DEBUG
|
||||
else
|
||||
|
@ -817,7 +819,7 @@ AuthGPGOperation *p3disc::getGPGOperation()
|
|||
while (!sendIdList.empty()) {
|
||||
std::map<std::string, std::list<std::string> >::iterator sendIdIt = sendIdList.begin();
|
||||
|
||||
if (!sendIdIt->second.empty() && mConnMgr->isOnline(sendIdIt->first)) {
|
||||
if (!sendIdIt->second.empty() && mLinkMgr->isOnline(sendIdIt->first)) {
|
||||
std::string gpgId = sendIdIt->second.front();
|
||||
sendIdIt->second.pop_front();
|
||||
|
||||
|
|
|
@ -72,7 +72,8 @@ class autoneighbour: public autoserver
|
|||
|
||||
};
|
||||
|
||||
class p3ConnectMgr;
|
||||
class p3PeerMgr;
|
||||
class p3LinkMgr;
|
||||
|
||||
|
||||
class p3disc: public p3Service, public pqiMonitor, public p3Config, public AuthGPGService
|
||||
|
@ -80,7 +81,7 @@ class p3disc: public p3Service, public pqiMonitor, public p3Config, public AuthG
|
|||
public:
|
||||
|
||||
|
||||
p3disc(p3ConnectMgr *cm, pqipersongrp *persGrp);
|
||||
p3disc(p3PeerMgr *pm, p3LinkMgr *lm, pqipersongrp *persGrp);
|
||||
|
||||
/************* from pqiMonitor *******************/
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
|
@ -141,9 +142,11 @@ int idServers();
|
|||
|
||||
private:
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
pqipersongrp *mPqiPersonGrp;
|
||||
time_t lastSentHeartbeatTime;
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
||||
pqipersongrp *mPqiPersonGrp;
|
||||
time_t lastSentHeartbeatTime;
|
||||
|
||||
/* data */
|
||||
RsMutex mDiscMtx;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "services/p3gamelauncher.h"
|
||||
#include "services/p3gameservice.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
@ -109,9 +109,9 @@ const uint32_t RS_GAME_MSG_REJECT = 6; /* ANY -> ANY */
|
|||
|
||||
const int p3gamezone = 1745;
|
||||
|
||||
p3GameLauncher::p3GameLauncher(p3ConnectMgr *connMgr)
|
||||
p3GameLauncher::p3GameLauncher(p3LinkMgr *lm)
|
||||
:p3Service(RS_SERVICE_TYPE_GAME_LAUNCHER),
|
||||
mConnMgr(connMgr)
|
||||
mLinkMgr(lm)
|
||||
{
|
||||
#ifdef GAME_DEBUG
|
||||
std::cerr << "p3GameLauncher::p3GameLauncher()";
|
||||
|
@ -119,7 +119,7 @@ p3GameLauncher::p3GameLauncher(p3ConnectMgr *connMgr)
|
|||
#endif
|
||||
|
||||
addSerialType(new RsGameSerialiser());
|
||||
mOwnId = mConnMgr->getOwnId();
|
||||
mOwnId = mLinkMgr->getOwnId();
|
||||
}
|
||||
|
||||
int p3GameLauncher::tick()
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "serialiser/rsgameitems.h"
|
||||
#include "retroshare/rsgame.h"
|
||||
|
||||
class p3ConnectMgr;
|
||||
class p3LinkMgr;
|
||||
|
||||
|
||||
class gameAvail
|
||||
|
@ -76,7 +76,7 @@ class p3GameService;
|
|||
class p3GameLauncher: public p3Service, public RsGameLauncher
|
||||
{
|
||||
public:
|
||||
p3GameLauncher(p3ConnectMgr *connMgr);
|
||||
p3GameLauncher(p3LinkMgr *lm);
|
||||
|
||||
/***** EXTERNAL RsGameLauncher Interface *******/
|
||||
/* server commands */
|
||||
|
@ -144,7 +144,7 @@ bool checkGameProperties(uint16_t serviceId, uint16_t players);
|
|||
std::map<uint16_t, p3GameService *> gameList;
|
||||
std::map<std::string, gameStatus> gamesCurrent;
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
std::string mOwnId;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "pqi/pqibin.h"
|
||||
#include "pqi/pqiarchive.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
#include "services/p3msgservice.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
@ -54,14 +54,14 @@ const int msgservicezone = 54319;
|
|||
*/
|
||||
|
||||
|
||||
p3MsgService::p3MsgService(p3ConnectMgr *cm)
|
||||
p3MsgService::p3MsgService(p3LinkMgr *lm)
|
||||
:p3Service(RS_SERVICE_TYPE_MSG), p3Config(CONFIG_TYPE_MSGS),
|
||||
mConnMgr(cm), mMsgMtx("p3MsgService"), msgChanged(1), mMsgUniqueId(1)
|
||||
mLinkMgr(lm), mMsgMtx("p3MsgService"), msgChanged(1), mMsgUniqueId(1)
|
||||
{
|
||||
addSerialType(new RsMsgSerialiser());
|
||||
|
||||
/* Initialize standard tag types */
|
||||
if(cm)
|
||||
if(lm)
|
||||
initStandardTagTypes();
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ void p3MsgService::processMsg(RsMsgItem *mi)
|
|||
|
||||
RsStackMutex stack(mMsgMtx); /*** STACK LOCKED MTX ***/
|
||||
|
||||
if (mi -> PeerId() == mConnMgr->getOwnId())
|
||||
if (mi -> PeerId() == mLinkMgr->getOwnId())
|
||||
{
|
||||
/* from the loopback device */
|
||||
mi -> msgFlags |= RS_MSG_FLAGS_OUTGOING;
|
||||
|
@ -207,7 +207,7 @@ int p3MsgService::checkOutgoingMessages()
|
|||
bool changed = false ;
|
||||
|
||||
{
|
||||
const std::string ownId = mConnMgr->getOwnId();
|
||||
const std::string ownId = mLinkMgr->getOwnId();
|
||||
|
||||
std::list<uint32_t>::iterator it;
|
||||
std::list<uint32_t> toErase;
|
||||
|
@ -225,7 +225,7 @@ int p3MsgService::checkOutgoingMessages()
|
|||
peerConnectState pstate;
|
||||
bool toSend = false;
|
||||
|
||||
if (mConnMgr->getFriendNetStatus(pid, pstate))
|
||||
if (mLinkMgr->getFriendNetStatus(pid, pstate))
|
||||
{
|
||||
if (pstate.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ static void getStandardTagTypes(MsgTagType &tags)
|
|||
void p3MsgService::initStandardTagTypes()
|
||||
{
|
||||
bool bChanged = false;
|
||||
std::string ownId = mConnMgr->getOwnId();
|
||||
std::string ownId = mLinkMgr->getOwnId();
|
||||
|
||||
MsgTagType tags;
|
||||
getStandardTagTypes(tags);
|
||||
|
@ -507,7 +507,7 @@ void p3MsgService::loadWelcomeMsg()
|
|||
/* Load Welcome Message */
|
||||
RsMsgItem *msg = new RsMsgItem();
|
||||
|
||||
//msg -> PeerId(mConnMgr->getOwnId());
|
||||
//msg -> PeerId(mLinkMgr->getOwnId());
|
||||
|
||||
msg -> sendTime = time(NULL);
|
||||
msg -> recvTime = time(NULL);
|
||||
|
@ -796,7 +796,7 @@ bool p3MsgService::setMsgParentId(uint32_t msgId, uint32_t msgParentId)
|
|||
{
|
||||
if (msgParentId) {
|
||||
RsMsgParentId* msp = new RsMsgParentId();
|
||||
msp->PeerId (mConnMgr->getOwnId());
|
||||
msp->PeerId (mLinkMgr->getOwnId());
|
||||
msp->msgId = msgId;
|
||||
msp->msgParentId = msgParentId;
|
||||
mParentId.insert(std::pair<uint32_t, RsMsgParentId*>(msgId, msp));
|
||||
|
@ -842,7 +842,7 @@ int p3MsgService::sendMessage(RsMsgItem *item)
|
|||
/* STORE MsgID */
|
||||
msgOutgoing[item->msgId] = item;
|
||||
|
||||
if (item->PeerId() != mConnMgr->getOwnId()) {
|
||||
if (item->PeerId() != mLinkMgr->getOwnId()) {
|
||||
/* not to the loopback device */
|
||||
RsMsgSrcId* msi = new RsMsgSrcId();
|
||||
msi->msgId = item->msgId;
|
||||
|
@ -891,7 +891,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
|||
}
|
||||
|
||||
/* send to ourselves as well */
|
||||
RsMsgItem *msg = initMIRsMsg(info, mConnMgr->getOwnId());
|
||||
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
||||
if (msg)
|
||||
{
|
||||
/* use processMsg to get the new msgId */
|
||||
|
@ -909,7 +909,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
|||
|
||||
bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
|
||||
{
|
||||
RsMsgItem *msg = initMIRsMsg(info, mConnMgr->getOwnId());
|
||||
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
||||
if (msg)
|
||||
{
|
||||
uint32_t msgId = 0;
|
||||
|
@ -992,7 +992,7 @@ bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32
|
|||
|
||||
/* new tag */
|
||||
RsMsgTagType* tagType = new RsMsgTagType();
|
||||
tagType->PeerId (mConnMgr->getOwnId());
|
||||
tagType->PeerId (mLinkMgr->getOwnId());
|
||||
tagType->rgb_color = rgb_color;
|
||||
tagType->tagId = tagId;
|
||||
tagType->text = text;
|
||||
|
@ -1136,7 +1136,7 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
|
|||
if (set) {
|
||||
/* new msg */
|
||||
RsMsgTags* tag = new RsMsgTags();
|
||||
tag->PeerId (mConnMgr->getOwnId());
|
||||
tag->PeerId (mLinkMgr->getOwnId());
|
||||
|
||||
tag->msgId = mid;
|
||||
tag->tagIds.push_back(tagId);
|
||||
|
@ -1280,7 +1280,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
|
|||
|
||||
/* translate flags, if we sent it... outgoing */
|
||||
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
|| (msg->PeerId() == mConnMgr->getOwnId()))
|
||||
|| (msg->PeerId() == mLinkMgr->getOwnId()))
|
||||
{
|
||||
mi.msgflags |= RS_MSG_OUTGOING;
|
||||
}
|
||||
|
@ -1379,7 +1379,7 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
|||
|
||||
/* translate flags, if we sent it... outgoing */
|
||||
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
|| (msg->PeerId() == mConnMgr->getOwnId()))
|
||||
|| (msg->PeerId() == mLinkMgr->getOwnId()))
|
||||
{
|
||||
mis.msgflags |= RS_MSG_OUTGOING;
|
||||
}
|
||||
|
@ -1456,7 +1456,7 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to)
|
|||
}
|
||||
|
||||
/* We don't fill in bcc (unless to ourselves) */
|
||||
if (to == mConnMgr->getOwnId())
|
||||
if (to == mLinkMgr->getOwnId())
|
||||
{
|
||||
for(pit = info.msgbcc.begin(); pit != info.msgbcc.end(); pit++)
|
||||
{
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
#include "serialiser/rsmsgitems.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
class p3ConnectMgr;
|
||||
class p3LinkMgr;
|
||||
|
||||
class p3MsgService: public p3Service, public p3Config, public pqiMonitor
|
||||
{
|
||||
public:
|
||||
p3MsgService(p3ConnectMgr *cm);
|
||||
p3MsgService(p3LinkMgr *lm);
|
||||
|
||||
/* External Interface */
|
||||
bool MsgsChanged(); /* should update display */
|
||||
|
@ -113,7 +113,7 @@ RsMsgItem *initMIRsMsg(MessageInfo &info, std::string to);
|
|||
|
||||
void initStandardTagTypes();
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
||||
/* Mutex Required for stuff below */
|
||||
|
||||
|
|
|
@ -27,8 +27,10 @@
|
|||
#include "services/p3portservice.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
|
||||
p3PortService::p3PortService(p3ConnectMgr *cm)
|
||||
:p3Service(RS_SERVICE_TYPE_PORT), mConnMgr(cm), mEnabled(false)
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
p3PortService::p3PortService(p3LinkMgr *lm)
|
||||
:p3Service(RS_SERVICE_TYPE_PORT), mLinkMgr(lm), mEnabled(false)
|
||||
{
|
||||
/* For Version 1, we'll just use the very simple RsRawItem packets
|
||||
* which are handled in the RsServiceSerialiser
|
||||
|
|
|
@ -59,13 +59,14 @@
|
|||
|
||||
#include "serialiser/rsbaseitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
|
||||
|
||||
class p3PortService: public p3Service
|
||||
{
|
||||
public:
|
||||
p3PortService(p3ConnectMgr *cm);
|
||||
p3PortService(p3LinkMgr *lm);
|
||||
|
||||
/* example setup functions */
|
||||
bool enablePortForwarding(uint32_t port, std::string peerId);
|
||||
|
@ -75,7 +76,7 @@ virtual int tick();
|
|||
|
||||
private:
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
||||
bool mEnabled;
|
||||
bool mPeerOnline;
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
|
||||
{
|
||||
out << "StatusInfo: " << std::endl;
|
||||
|
@ -43,8 +45,8 @@ std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
|
|||
|
||||
RsStatus *rsStatus = NULL;
|
||||
|
||||
p3StatusService::p3StatusService(p3ConnectMgr *cm)
|
||||
:p3Service(RS_SERVICE_TYPE_STATUS), p3Config(CONFIG_TYPE_STATUS), mConnMgr(cm), mStatusMtx("p3StatusService")
|
||||
p3StatusService::p3StatusService(p3LinkMgr *cm)
|
||||
:p3Service(RS_SERVICE_TYPE_STATUS), p3Config(CONFIG_TYPE_STATUS), mLinkMgr(cm), mStatusMtx("p3StatusService")
|
||||
{
|
||||
addSerialType(new RsStatusSerialiser());
|
||||
|
||||
|
@ -61,7 +63,7 @@ bool p3StatusService::getOwnStatus(StatusInfo& statusInfo)
|
|||
#endif
|
||||
|
||||
std::map<std::string, StatusInfo>::iterator it;
|
||||
std::string ownId = mConnMgr->getOwnId();
|
||||
std::string ownId = mLinkMgr->getOwnId();
|
||||
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
it = mStatusInfoMap.find(ownId);
|
||||
|
@ -128,7 +130,7 @@ bool p3StatusService::sendStatus(const std::string &id, uint32_t status)
|
|||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
|
||||
statusInfo.id = mConnMgr->getOwnId();
|
||||
statusInfo.id = mLinkMgr->getOwnId();
|
||||
statusInfo.status = status;
|
||||
|
||||
// don't save inactive status
|
||||
|
@ -148,7 +150,7 @@ bool p3StatusService::sendStatus(const std::string &id, uint32_t status)
|
|||
}
|
||||
|
||||
if (id.empty()) {
|
||||
mConnMgr->getOnlineList(onlineList);
|
||||
mLinkMgr->getOnlineList(onlineList);
|
||||
} else {
|
||||
onlineList.push_back(id);
|
||||
}
|
||||
|
@ -257,11 +259,11 @@ bool p3StatusService::saveList(bool& cleanup, std::list<RsItem*>& ilist){
|
|||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
it = mStatusInfoMap.find(mConnMgr->getOwnId());
|
||||
it = mStatusInfoMap.find(mLinkMgr->getOwnId());
|
||||
|
||||
if(it == mStatusInfoMap.end()){
|
||||
std::cerr << "p3StatusService::saveList() :" << "Did not find your status"
|
||||
<< mConnMgr->getOwnId() << std::endl;
|
||||
<< mLinkMgr->getOwnId() << std::endl;
|
||||
delete own_status;
|
||||
return false;
|
||||
}
|
||||
|
@ -295,14 +297,14 @@ bool p3StatusService::loadList(std::list<RsItem*>& load){
|
|||
|
||||
if(own_status != NULL){
|
||||
|
||||
own_info.id = mConnMgr->getOwnId();
|
||||
own_info.id = mLinkMgr->getOwnId();
|
||||
own_info.status = own_status->status;
|
||||
own_info.time_stamp = own_status->sendTime;
|
||||
delete own_status;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mStatusMtx);
|
||||
std::pair<std::string, StatusInfo> pr(mConnMgr->getOwnId(), own_info);
|
||||
std::pair<std::string, StatusInfo> pr(mLinkMgr->getOwnId(), own_info);
|
||||
mStatusInfoMap.insert(pr);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,10 @@
|
|||
#include "serialiser/rsstatusitems.h"
|
||||
#include "retroshare/rsstatus.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
|
||||
//! handles standard status messages (busy, away, online, offline) set by user
|
||||
/*!
|
||||
|
@ -45,7 +48,7 @@ class p3StatusService: public p3Service, public p3Config, public pqiMonitor
|
|||
{
|
||||
public:
|
||||
|
||||
p3StatusService(p3ConnectMgr* );
|
||||
p3StatusService(p3LinkMgr *lm);
|
||||
virtual ~p3StatusService();
|
||||
|
||||
/***** overloaded from p3Service *****/
|
||||
|
@ -90,7 +93,7 @@ virtual bool loadList(std::list<RsItem*>& load);
|
|||
|
||||
virtual void receiveStatusQueue();
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
||||
std::map<std::string, StatusInfo> mStatusInfoMap;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue