Added ServiceControl + ServiceInfo. Basics are working, but still a lot to do!

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7196 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-03-22 03:53:44 +00:00
parent a4b54e1021
commit 83a78bcaee
71 changed files with 3168 additions and 209 deletions

View file

@ -58,7 +58,7 @@
p3BanList::p3BanList(p3LinkMgr *lm, p3NetMgr *nm)
:p3Service(RS_SERVICE_TYPE_BANLIST), mBanMtx("p3BanList"), mLinkMgr(lm), mNetMgr(nm)
:p3Service(), mBanMtx("p3BanList"), mLinkMgr(lm), mNetMgr(nm)
{
addSerialType(new RsBanListSerialiser());
@ -66,6 +66,24 @@ p3BanList::p3BanList(p3LinkMgr *lm, p3NetMgr *nm)
}
const std::string BANLIST_APP_NAME = "banlist";
const uint16_t BANLIST_APP_MAJOR_VERSION = 1;
const uint16_t BANLIST_APP_MINOR_VERSION = 0;
const uint16_t BANLIST_MIN_MAJOR_VERSION = 1;
const uint16_t BANLIST_MIN_MINOR_VERSION = 0;
RsServiceInfo p3BanList::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_BANLIST,
BANLIST_APP_NAME,
BANLIST_APP_MAJOR_VERSION,
BANLIST_APP_MINOR_VERSION,
BANLIST_MIN_MAJOR_VERSION,
BANLIST_MIN_MINOR_VERSION);
}
int p3BanList::tick()
{
processIncoming();

View file

@ -69,6 +69,7 @@ class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPe
{
public:
p3BanList(p3LinkMgr *lm, p3NetMgr *nm);
virtual RsServiceInfo getServiceInfo();
/***** overloaded from RsBanList *****/

View file

@ -46,7 +46,7 @@ p3BandwidthControl *rsBandwidthControl;
p3BandwidthControl::p3BandwidthControl(pqipersongrp *pg)
:p3Service(RS_SERVICE_TYPE_BWCTRL), mPg(pg), mBwMtx("p3BwCtrl")
:p3Service(), mPg(pg), mBwMtx("p3BwCtrl")
{
addSerialType(new RsBwCtrlSerialiser());
@ -54,6 +54,24 @@ p3BandwidthControl::p3BandwidthControl(pqipersongrp *pg)
}
const std::string BANDWIDTH_CTRL_APP_NAME = "bandwidth_ctrl";
const uint16_t BANDWIDTH_CTRL_APP_MAJOR_VERSION = 1;
const uint16_t BANDWIDTH_CTRL_APP_MINOR_VERSION = 0;
const uint16_t BANDWIDTH_CTRL_MIN_MAJOR_VERSION = 1;
const uint16_t BANDWIDTH_CTRL_MIN_MINOR_VERSION = 0;
RsServiceInfo p3BandwidthControl::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_BWCTRL,
BANDWIDTH_CTRL_APP_NAME,
BANDWIDTH_CTRL_APP_MAJOR_VERSION,
BANDWIDTH_CTRL_APP_MINOR_VERSION,
BANDWIDTH_CTRL_MIN_MAJOR_VERSION,
BANDWIDTH_CTRL_MIN_MINOR_VERSION);
}
int p3BandwidthControl::tick()
{
processIncoming();

View file

@ -73,6 +73,7 @@ class p3BandwidthControl: public p3Service, public pqiMonitor
{
public:
p3BandwidthControl(pqipersongrp *pg);
virtual RsServiceInfo getServiceInfo();
/***** overloaded from RsBanList *****/

View file

@ -76,7 +76,7 @@ static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number o
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(RS_SERVICE_TYPE_CHAT), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mLinkMgr(lm) , mHistoryMgr(historyMgr)
:p3Service(), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mLinkMgr(lm) , mHistoryMgr(historyMgr)
{
_serializer = new RsChatSerialiser() ;
_own_avatar = NULL ;
@ -91,6 +91,23 @@ p3ChatService::p3ChatService(p3LinkMgr *lm, p3HistoryMgr *historyMgr)
addSerialType(_serializer) ;
}
const std::string CHAT_APP_NAME = "chat";
const uint16_t CHAT_APP_MAJOR_VERSION = 1;
const uint16_t CHAT_APP_MINOR_VERSION = 0;
const uint16_t CHAT_MIN_MAJOR_VERSION = 1;
const uint16_t CHAT_MIN_MINOR_VERSION = 0;
RsServiceInfo p3ChatService::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_CHAT,
CHAT_APP_NAME,
CHAT_APP_MAJOR_VERSION,
CHAT_APP_MINOR_VERSION,
CHAT_MIN_MAJOR_VERSION,
CHAT_MIN_MINOR_VERSION);
}
void p3ChatService::connectToTurtleRouter(p3turtle *tr)
{
mTurtle = tr ;

View file

@ -55,6 +55,8 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
public:
p3ChatService(p3LinkMgr *cm, p3HistoryMgr *historyMgr);
virtual RsServiceInfo getServiceInfo();
/***** overloaded from p3Service *****/
/*!
* This retrieves all chat msg items and also (important!)

View file

@ -85,7 +85,7 @@ void DiscPgpInfo::mergeFriendList(const std::list<PGPID> &friends)
p3discovery2::p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr)
:p3Service(RS_SERVICE_TYPE_DISC), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr),
:p3Service(), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr),
mDiscMtx("p3discovery2")
{
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
@ -105,6 +105,28 @@ p3discovery2::p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *net
return;
}
const std::string DISCOVERY_APP_NAME = "disc";
const uint16_t DISCOVERY_APP_MAJOR_VERSION = 1;
const uint16_t DISCOVERY_APP_MINOR_VERSION = 0;
const uint16_t DISCOVERY_MIN_MAJOR_VERSION = 1;
const uint16_t DISCOVERY_MIN_MINOR_VERSION = 0;
RsServiceInfo p3discovery2::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_DISC,
DISCOVERY_APP_NAME,
DISCOVERY_APP_MAJOR_VERSION,
DISCOVERY_APP_MINOR_VERSION,
DISCOVERY_MIN_MAJOR_VERSION,
DISCOVERY_MIN_MINOR_VERSION);
}
p3discovery2::~p3discovery2()
{
return;

View file

@ -81,6 +81,8 @@ class p3discovery2: public RsDisc, public p3Service, public pqiMonitor, public A
p3discovery2(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr *netMgr);
virtual ~p3discovery2();
virtual RsServiceInfo getServiceInfo();
/************* from pqiMonitor *******************/
virtual void statusChange(const std::list<pqipeer> &plist);
/************* from pqiMonitor *******************/

View file

@ -64,7 +64,7 @@ RsDsdv *rsDsdv = NULL;
****/
p3Dsdv::p3Dsdv(p3LinkMgr *lm)
:p3Service(RS_SERVICE_TYPE_DSDV), /* p3Config(CONFIG_TYPE_DSDV), */ mDsdvMtx("p3Dsdv"), mLinkMgr(lm)
:p3Service(), /* p3Config(CONFIG_TYPE_DSDV), */ mDsdvMtx("p3Dsdv"), mLinkMgr(lm)
{
addSerialType(new RsDsdvSerialiser());
@ -72,6 +72,24 @@ p3Dsdv::p3Dsdv(p3LinkMgr *lm)
mSentIncrementTime = 0;
}
const std::string DSDV_APP_NAME = "dsdv";
const uint16_t DSDV_APP_MAJOR_VERSION = 1;
const uint16_t DSDV_APP_MINOR_VERSION = 0;
const uint16_t DSDV_MIN_MAJOR_VERSION = 1;
const uint16_t DSDV_MIN_MINOR_VERSION = 0;
RsServiceInfo p3Dsdv::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_DSDV,
DSDV_APP_NAME,
DSDV_APP_MAJOR_VERSION,
DSDV_APP_MINOR_VERSION,
DSDV_MIN_MAJOR_VERSION,
DSDV_MIN_MINOR_VERSION);
}
int p3Dsdv::tick()
{
processIncoming();

View file

@ -53,6 +53,7 @@ class p3Dsdv: public RsDsdv, public p3Service /* , public p3Config */, public pq
{
public:
p3Dsdv(p3LinkMgr *cm);
virtual RsServiceInfo getServiceInfo();
/*** internal librs interface ****/

View file

@ -78,6 +78,24 @@ p3GxsChannels::p3GxsChannels(RsGeneralDataService *gds, RsNetworkExchangeService
}
const std::string GXS_CHANNELS_APP_NAME = "gxschannels";
const uint16_t GXS_CHANNELS_APP_MAJOR_VERSION = 1;
const uint16_t GXS_CHANNELS_APP_MINOR_VERSION = 0;
const uint16_t GXS_CHANNELS_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_CHANNELS_MIN_MINOR_VERSION = 0;
RsServiceInfo p3GxsChannels::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_CHANNELS,
GXS_CHANNELS_APP_NAME,
GXS_CHANNELS_APP_MAJOR_VERSION,
GXS_CHANNELS_APP_MINOR_VERSION,
GXS_CHANNELS_MIN_MAJOR_VERSION,
GXS_CHANNELS_MIN_MINOR_VERSION);
}
uint32_t p3GxsChannels::channelsAuthenPolicy()
{
uint32_t policy = 0;

View file

@ -60,6 +60,7 @@ class p3GxsChannels: public RsGenExchange, public RsGxsChannels,
public:
p3GxsChannels(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
virtual RsServiceInfo getServiceInfo();
virtual void service_tick();

View file

@ -130,6 +130,24 @@ p3GxsCircles::p3GxsCircles(RsGeneralDataService *gds, RsNetworkExchangeService *
}
const std::string GXS_CIRCLES_APP_NAME = "gxscircle";
const uint16_t GXS_CIRCLES_APP_MAJOR_VERSION = 1;
const uint16_t GXS_CIRCLES_APP_MINOR_VERSION = 0;
const uint16_t GXS_CIRCLES_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_CIRCLES_MIN_MINOR_VERSION = 0;
RsServiceInfo p3GxsCircles::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_GXSCIRCLE,
GXS_CIRCLES_APP_NAME,
GXS_CIRCLES_APP_MAJOR_VERSION,
GXS_CIRCLES_APP_MINOR_VERSION,
GXS_CIRCLES_MIN_MAJOR_VERSION,
GXS_CIRCLES_MIN_MINOR_VERSION);
}
uint32_t p3GxsCircles::circleAuthenPolicy()
{

View file

@ -135,6 +135,8 @@ class p3GxsCircles: public RsGxsCircleExchange, public RsGxsCircles,
p3GxsCircles(RsGeneralDataService* gds, RsNetworkExchangeService* nes,
p3IdService *identities);
virtual RsServiceInfo getServiceInfo();
/*********** External Interface ***************/
virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details);

View file

@ -61,6 +61,24 @@ p3GxsForums::p3GxsForums(RsGeneralDataService *gds, RsNetworkExchangeService *ne
}
const std::string GXS_FORUMS_APP_NAME = "gxsforums";
const uint16_t GXS_FORUMS_APP_MAJOR_VERSION = 1;
const uint16_t GXS_FORUMS_APP_MINOR_VERSION = 0;
const uint16_t GXS_FORUMS_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_FORUMS_MIN_MINOR_VERSION = 0;
RsServiceInfo p3GxsForums::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_FORUMS,
GXS_FORUMS_APP_NAME,
GXS_FORUMS_APP_MAJOR_VERSION,
GXS_FORUMS_APP_MINOR_VERSION,
GXS_FORUMS_MIN_MAJOR_VERSION,
GXS_FORUMS_MIN_MINOR_VERSION);
}
uint32_t p3GxsForums::forumsAuthenPolicy()
{
uint32_t policy = 0;

View file

@ -46,6 +46,8 @@ class p3GxsForums: public RsGenExchange, public RsGxsForums,
p3GxsForums(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
virtual RsServiceInfo getServiceInfo();
virtual void service_tick();
protected:

View file

@ -123,7 +123,7 @@ uint32_t ConvertToSerialised(int32_t value, bool limit)
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
:p3Service(RS_SERVICE_GXSV2_TYPE_REPUTATION), p3Config(CONFIG_TYPE_GXS_REPUTATION),
:p3Service(), p3Config(CONFIG_TYPE_GXS_REPUTATION),
mReputationMtx("p3GxsReputation"), mLinkMgr(lm)
{
addSerialType(new RsGxsReputationSerialiser());
@ -134,6 +134,24 @@ p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
}
const std::string GXS_REPUTATION_APP_NAME = "gxsreputation";
const uint16_t GXS_REPUTATION_APP_MAJOR_VERSION = 1;
const uint16_t GXS_REPUTATION_APP_MINOR_VERSION = 0;
const uint16_t GXS_REPUTATION_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_REPUTATION_MIN_MINOR_VERSION = 0;
RsServiceInfo p3GxsReputation::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_REPUTATION,
GXS_REPUTATION_APP_NAME,
GXS_REPUTATION_APP_MAJOR_VERSION,
GXS_REPUTATION_APP_MINOR_VERSION,
GXS_REPUTATION_MIN_MAJOR_VERSION,
GXS_REPUTATION_MIN_MINOR_VERSION);
}
int p3GxsReputation::tick()
{
processIncoming();

View file

@ -84,6 +84,7 @@ class p3GxsReputation: public p3Service, public p3Config /* , public pqiMonitor
{
public:
p3GxsReputation(p3LinkMgr *lm);
virtual RsServiceInfo getServiceInfo();
/***** Interface for p3idservice *****/

View file

@ -32,7 +32,7 @@
p3heartbeat::p3heartbeat(p3LinkMgr *linkMgr, pqipersongrp *pqipg)
:p3Service(RS_SERVICE_TYPE_HEARTBEAT), mLinkMgr(linkMgr), mPqiPersonGrp(pqipg),
:p3Service(), mLinkMgr(linkMgr), mPqiPersonGrp(pqipg),
mHeartMtx("p3heartbeat")
{
RsStackMutex stack(mHeartMtx); /********** STACK LOCKED MTX ******/
@ -55,6 +55,24 @@ p3heartbeat::~p3heartbeat()
}
const std::string HEARTBEAT_APP_NAME = "heartbeat";
const uint16_t HEARTBEAT_APP_MAJOR_VERSION = 1;
const uint16_t HEARTBEAT_APP_MINOR_VERSION = 0;
const uint16_t HEARTBEAT_MIN_MAJOR_VERSION = 1;
const uint16_t HEARTBEAT_MIN_MINOR_VERSION = 0;
RsServiceInfo p3heartbeat::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_HEARTBEAT,
HEARTBEAT_APP_NAME,
HEARTBEAT_APP_MAJOR_VERSION,
HEARTBEAT_APP_MINOR_VERSION,
HEARTBEAT_MIN_MAJOR_VERSION,
HEARTBEAT_MIN_MINOR_VERSION);
}
int p3heartbeat::tick()
{
//send a heartbeat to all connected peers

View file

@ -40,6 +40,8 @@ class p3heartbeat: public p3Service
p3heartbeat(p3LinkMgr *linkMgr, pqipersongrp *pqipg);
virtual ~p3heartbeat();
virtual RsServiceInfo getServiceInfo();
int tick();
private:

View file

@ -165,6 +165,24 @@ p3IdService::p3IdService(RsGeneralDataService *gds, RsNetworkExchangeService *ne
loadRecognKeys();
}
const std::string GXSID_APP_NAME = "gxsid";
const uint16_t GXSID_APP_MAJOR_VERSION = 1;
const uint16_t GXSID_APP_MINOR_VERSION = 0;
const uint16_t GXSID_MIN_MAJOR_VERSION = 1;
const uint16_t GXSID_MIN_MINOR_VERSION = 0;
RsServiceInfo p3IdService::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_GXSID,
GXSID_APP_NAME,
GXSID_APP_MAJOR_VERSION,
GXSID_APP_MINOR_VERSION,
GXSID_MIN_MAJOR_VERSION,
GXSID_MIN_MINOR_VERSION);
}
void p3IdService::setNes(RsNetworkExchangeService *nes)
{
RsStackMutex stack(mIdMtx);

View file

@ -216,6 +216,8 @@ class p3IdService: public RsGxsIdExchange, public RsIdentity,
{
public:
p3IdService(RsGeneralDataService* gds, RsNetworkExchangeService* nes);
virtual RsServiceInfo getServiceInfo();
static uint32_t idAuthenPolicy();
virtual void service_tick(); // needed for background processing.

View file

@ -76,7 +76,7 @@ static const uint8_t ENCRYPTED_MSG_PROTOCOL_VERSION_01 = 0x37 ;
p3MsgService::p3MsgService(p3LinkMgr *lm)
:p3Service(RS_SERVICE_TYPE_MSG), p3Config(CONFIG_TYPE_MSGS),
:p3Service(), p3Config(CONFIG_TYPE_MSGS),
mLinkMgr(lm), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
{
_serialiser = new RsMsgSerialiser();
@ -108,6 +108,23 @@ p3MsgService::p3MsgService(p3LinkMgr *lm)
#endif
}
const std::string MSG_APP_NAME = "msg";
const uint16_t MSG_APP_MAJOR_VERSION = 1;
const uint16_t MSG_APP_MINOR_VERSION = 0;
const uint16_t MSG_MIN_MAJOR_VERSION = 1;
const uint16_t MSG_MIN_MINOR_VERSION = 0;
RsServiceInfo p3MsgService::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_MSG,
MSG_APP_NAME,
MSG_APP_MAJOR_VERSION,
MSG_APP_MINOR_VERSION,
MSG_MIN_MAJOR_VERSION,
MSG_MIN_MINOR_VERSION);
}
uint32_t p3MsgService::getNewUniqueMsgId()
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/

View file

@ -60,6 +60,7 @@ class p3MsgService: public p3Service, public p3Config, public pqiMonitor, public
{
public:
p3MsgService(p3LinkMgr *lm);
virtual RsServiceInfo getServiceInfo();
/* External Interface */
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);

View file

@ -92,6 +92,23 @@ p3PhotoService::p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeServi
{
}
const std::string GXS_PHOTO_APP_NAME = "gxsphoto";
const uint16_t GXS_PHOTO_APP_MAJOR_VERSION = 1;
const uint16_t GXS_PHOTO_APP_MINOR_VERSION = 0;
const uint16_t GXS_PHOTO_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_PHOTO_MIN_MINOR_VERSION = 0;
RsServiceInfo p3PhotoService::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_PHOTO,
GXS_PHOTO_APP_NAME,
GXS_PHOTO_APP_MAJOR_VERSION,
GXS_PHOTO_APP_MINOR_VERSION,
GXS_PHOTO_MIN_MAJOR_VERSION,
GXS_PHOTO_MIN_MINOR_VERSION);
}
uint32_t p3PhotoService::photoAuthenPolicy()
{

View file

@ -34,6 +34,7 @@ class p3PhotoService : public RsPhoto, public RsGenExchange
public:
p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
virtual RsServiceInfo getServiceInfo();
static uint32_t photoAuthenPolicy();

View file

@ -46,6 +46,24 @@ p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsG
}
const std::string GXS_POSTED_APP_NAME = "gxsposted";
const uint16_t GXS_POSTED_APP_MAJOR_VERSION = 1;
const uint16_t GXS_POSTED_APP_MINOR_VERSION = 0;
const uint16_t GXS_POSTED_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_POSTED_MIN_MINOR_VERSION = 0;
RsServiceInfo p3Posted::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_POSTED,
GXS_POSTED_APP_NAME,
GXS_POSTED_APP_MAJOR_VERSION,
GXS_POSTED_APP_MINOR_VERSION,
GXS_POSTED_MIN_MAJOR_VERSION,
GXS_POSTED_MIN_MINOR_VERSION);
}
bool p3Posted::getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups)
{
std::vector<RsGxsGrpItem*> grpData;

View file

@ -45,6 +45,7 @@ class p3Posted: public p3PostBase, public RsPosted
public:
p3Posted(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
virtual RsServiceInfo getServiceInfo();
protected:

View file

@ -117,7 +117,7 @@ static double convert64bitsToTs(uint64_t bits)
p3rtt::p3rtt(p3LinkMgr *lm)
:p3FastService(RS_SERVICE_TYPE_RTT), mRttMtx("p3rtt"), mLinkMgr(lm)
:p3FastService(), mRttMtx("p3rtt"), mLinkMgr(lm)
{
addSerialType(new RsRttSerialiser());
@ -127,6 +127,24 @@ p3rtt::p3rtt(p3LinkMgr *lm)
}
const std::string RTT_APP_NAME = "rtt";
const uint16_t RTT_APP_MAJOR_VERSION = 1;
const uint16_t RTT_APP_MINOR_VERSION = 0;
const uint16_t RTT_MIN_MAJOR_VERSION = 1;
const uint16_t RTT_MIN_MINOR_VERSION = 0;
RsServiceInfo p3rtt::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_RTT,
RTT_APP_NAME,
RTT_APP_MAJOR_VERSION,
RTT_APP_MINOR_VERSION,
RTT_MIN_MAJOR_VERSION,
RTT_MIN_MINOR_VERSION);
}
int p3rtt::tick()
{
sendPackets();

View file

@ -64,6 +64,7 @@ class p3rtt: public RsRtt, public p3FastService
{
public:
p3rtt(p3LinkMgr *cm);
virtual RsServiceInfo getServiceInfo();
/***** overloaded from rsRtt *****/

View file

@ -53,12 +53,16 @@ std::string generateRandomServiceId();
//TODO : encryption and upload / download rate implementation
// p3FastService(uint16_t type)
// :pqiService((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) type) << 8)),
class p3FastService: public pqiService
{
protected:
p3FastService(uint16_t type)
:pqiService((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) type) << 8)),
p3FastService()
:pqiService(),
srvMtx("p3FastService"), rsSerialiser(NULL)
{
rsSerialiser = new RsSerialiser();
@ -95,8 +99,8 @@ class p3Service: public p3FastService
{
protected:
p3Service(uint16_t type)
:p3FastService(type)
p3Service()
:p3FastService()
{
return;
}
@ -127,8 +131,8 @@ class nullService: public pqiService
{
protected:
nullService(uint16_t type)
:pqiService((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) type) << 8))
nullService()
:pqiService()
{
return;
}
@ -157,8 +161,8 @@ class p3ThreadedService: public p3Service, public RsThread
{
protected:
p3ThreadedService(uint16_t type)
:p3Service(type) { return; }
p3ThreadedService()
:p3Service() { return; }
public:

View file

@ -0,0 +1,254 @@
/*
* libretroshare/src/services p3serviceinfo.cc
*
* ServiceInfo Service for RetroShare.
*
* Copyright 2014 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "pqi/p3linkmgr.h"
#include "pqi/p3netmgr.h"
#include "util/rsnet.h"
#include "services/p3serviceinfo.h"
#include "serialiser/rsbanlistitems.h"
#include <sys/time.h>
/****
* #define DEBUG_INFO 1
****/
/************ IMPLEMENTATION NOTES *********************************
*
* Send Info to peers about services we are providing.
*/
p3ServiceInfo::p3ServiceInfo(p3ServiceControl *serviceControl)
:p3Service(), mInfoMtx("p3ServiceInfo"),
mServiceControl(serviceControl)
{
addSerialType(new RsServiceInfoSerialiser());
}
const std::string SERVICE_INFO_APP_NAME = "serviceinfo";
const uint16_t SERVICE_INFO_APP_MAJOR_VERSION = 1;
const uint16_t SERVICE_INFO_APP_MINOR_VERSION = 0;
const uint16_t SERVICE_INFO_MIN_MAJOR_VERSION = 1;
const uint16_t SERVICE_INFO_MIN_MINOR_VERSION = 0;
RsServiceInfo p3ServiceInfo::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_SERVICEINFO,
SERVICE_INFO_APP_NAME,
SERVICE_INFO_APP_MAJOR_VERSION,
SERVICE_INFO_APP_MINOR_VERSION,
SERVICE_INFO_MIN_MAJOR_VERSION,
SERVICE_INFO_MIN_MINOR_VERSION);
}
int p3ServiceInfo::tick()
{
processIncoming();
sendPackets();
return 0;
}
int p3ServiceInfo::status()
{
return 1;
}
/***** Implementation ******/
bool p3ServiceInfo::processIncoming()
{
/* for each packet - pass to specific handler */
RsItem *item = NULL;
while(NULL != (item = recvItem()))
{
#ifdef DEBUG_INFO
std::cerr << "p3ServiceInfo::processingIncoming() Received Item:";
std::cerr << std::endl;
item->print(std::cerr);
std::cerr << std::endl;
#endif
switch(item->PacketSubType())
{
default:
break;
case RS_PKT_SUBTYPE_SERVICELIST_ITEM:
{
// Order is important!.
RsServiceInfoListItem *listItem = dynamic_cast<RsServiceInfoListItem *>(item);
if (listItem)
{
recvServiceInfoList(listItem);
}
else
{
// error.
std::cerr << "p3ServiceInfo::processingIncoming() Error with Received Item:";
std::cerr << std::endl;
item->print(std::cerr);
std::cerr << std::endl;
}
}
break;
}
/* clean up */
delete item;
}
return true ;
}
bool convertServiceInfoToItem(
const RsPeerServiceInfo &info,
RsServiceInfoListItem *item)
{
item->mServiceInfo = info.mServiceList;
item->PeerId(info.mPeerId);
return true;
}
bool convertServiceItemToInfo(
const RsServiceInfoListItem *item,
RsPeerServiceInfo &info)
{
info.mServiceList = item->mServiceInfo;
info.mPeerId = item->PeerId();
return true;
}
bool p3ServiceInfo::recvServiceInfoList(RsServiceInfoListItem *item)
{
RsPeerId peerId = item->PeerId();
std::cerr << "p3ServiceInfo::recvServiceInfoList() from: " << peerId.toStdString();
std::cerr << std::endl;
RsPeerServiceInfo info;
if (convertServiceItemToInfo(item, info))
{
#ifdef DEBUG_INFO
std::cerr << "p3ServiceInfo::recvServiceInfoList() Info: ";
std::cerr << std::endl;
std::cerr << info;
std::cerr << std::endl;
#endif
/* update service control */
mServiceControl->updateServicesProvided(peerId, info);
return true;
}
return false;
}
bool p3ServiceInfo::sendPackets()
{
std::set<RsPeerId> updateSet;
{
RsStackMutex stack(mInfoMtx); /****** LOCKED MUTEX *******/
updateSet = mPeersToUpdate;
mPeersToUpdate.clear();
}
mServiceControl->getServiceChanges(updateSet);
RsStackMutex stack(mInfoMtx); /****** LOCKED MUTEX *******/
std::set<RsPeerId>::iterator it;
for(it = updateSet.begin(); it != updateSet.end(); it++)
{
sendServiceInfoList(*it);
}
return (!updateSet.empty());
}
int p3ServiceInfo::sendServiceInfoList(const RsPeerId &peerId)
{
std::cerr << "p3ServiceInfo::sendServiceInfoList() to " << peerId.toStdString();
std::cerr << std::endl;
RsServiceInfoListItem *item = new RsServiceInfoListItem();
RsPeerServiceInfo info;
bool sent = false;
if (mServiceControl->getServicesAllowed(peerId, info))
{
std::cerr << "p3ServiceInfo::sendServiceInfoList() Info: ";
std::cerr << std::endl;
std::cerr << info;
std::cerr << std::endl;
if (convertServiceInfoToItem(info, item))
{
item->PeerId(peerId);
sent = true;
sendItem(item);
}
}
if (!sent)
{
delete item;
}
return sent;
}
void p3ServiceInfo::statusChange(const std::list<pqipeer> &plist)
{
std::cerr << "p3ServiceInfo::statusChange()";
std::cerr << std::endl;
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_CONNECTED)
{
std::cerr << "p3ServiceInfo::statusChange()";
std::cerr << "Peer: " << it->id;
std::cerr << " Connected";
std::cerr << std::endl;
RsStackMutex stack(mInfoMtx); /****** LOCKED MUTEX *******/
mPeersToUpdate.insert(it->id);
}
}
}
}

View file

@ -0,0 +1,75 @@
/*
* libretroshare/src/services/p3serviceinfo.h
*
* Exchange list of Service Information.
*
* Copyright 2014 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef SERVICE_RSSERVICEINFO_HEADER
#define SERVICE_RSSERVICEINFO_HEADER
#include <string>
#include <list>
#include <map>
#include "pqi/p3servicecontrol.h"
#include "pqi/pqimonitor.h"
#include "services/p3service.h"
#include "serialiser/rsserviceinfoitems.h"
//!The ServiceInfo service.
/**
*
* Exchange list of Available Services with peers.
*/
class p3ServiceInfo: public p3Service, public pqiMonitor
{
public:
p3ServiceInfo(p3ServiceControl *serviceControl);
virtual RsServiceInfo getServiceInfo();
virtual int tick();
virtual int status();
/*************** pqiMonitor callback ***********************/
virtual void statusChange(const std::list<pqipeer> &plist);
private:
bool sendPackets();
bool processIncoming();
bool recvServiceInfoList(RsServiceInfoListItem *item);
int sendServiceInfoList(const RsPeerId &peerid);
private:
RsMutex mInfoMtx;
std::set<RsPeerId> mPeersToUpdate;
p3ServiceControl *mServiceControl;
};
#endif // SERVICE_RSSERVICEINFO_HEADER

View file

@ -48,7 +48,7 @@ std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
RsStatus *rsStatus = NULL;
p3StatusService::p3StatusService(p3LinkMgr *cm)
:p3Service(RS_SERVICE_TYPE_STATUS), p3Config(CONFIG_TYPE_STATUS), mLinkMgr(cm), mStatusMtx("p3StatusService")
:p3Service(), p3Config(CONFIG_TYPE_STATUS), mLinkMgr(cm), mStatusMtx("p3StatusService")
{
addSerialType(new RsStatusSerialiser());
@ -58,6 +58,24 @@ p3StatusService::~p3StatusService()
{
}
const std::string STATUS_APP_NAME = "status";
const uint16_t STATUS_APP_MAJOR_VERSION = 1;
const uint16_t STATUS_APP_MINOR_VERSION = 0;
const uint16_t STATUS_MIN_MAJOR_VERSION = 1;
const uint16_t STATUS_MIN_MINOR_VERSION = 0;
RsServiceInfo p3StatusService::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_TYPE_STATUS,
STATUS_APP_NAME,
STATUS_APP_MAJOR_VERSION,
STATUS_APP_MINOR_VERSION,
STATUS_MIN_MAJOR_VERSION,
STATUS_MIN_MINOR_VERSION);
}
bool p3StatusService::getOwnStatus(StatusInfo& statusInfo)
{
#ifdef STATUS_DEBUG

View file

@ -51,6 +51,8 @@ class p3StatusService: public p3Service, public p3Config, public pqiMonitor
p3StatusService(p3LinkMgr *lm);
virtual ~p3StatusService();
virtual RsServiceInfo getServiceInfo();
/***** overloaded from p3Service *****/
virtual int tick();
virtual int status();

View file

@ -56,6 +56,24 @@ p3Wiki::p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs
}
const std::string GXS_WIKI_APP_NAME = "gxswiki";
const uint16_t GXS_WIKI_APP_MAJOR_VERSION = 1;
const uint16_t GXS_WIKI_APP_MINOR_VERSION = 0;
const uint16_t GXS_WIKI_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_WIKI_MIN_MINOR_VERSION = 0;
RsServiceInfo p3Wiki::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_WIKI,
GXS_WIKI_APP_NAME,
GXS_WIKI_APP_MAJOR_VERSION,
GXS_WIKI_APP_MINOR_VERSION,
GXS_WIKI_MIN_MAJOR_VERSION,
GXS_WIKI_MIN_MINOR_VERSION);
}
uint32_t p3Wiki::wikiAuthenPolicy()
{
uint32_t policy = 0;

View file

@ -45,6 +45,7 @@ class p3Wiki: public RsGenExchange, public RsWiki,
{
public:
p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs *gixs);
virtual RsServiceInfo getServiceInfo();
static uint32_t wikiAuthenPolicy();
protected:

View file

@ -43,6 +43,24 @@ p3Wire::p3Wire(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs
}
const std::string WIRE_APP_NAME = "gxswire";
const uint16_t WIRE_APP_MAJOR_VERSION = 1;
const uint16_t WIRE_APP_MINOR_VERSION = 0;
const uint16_t WIRE_MIN_MAJOR_VERSION = 1;
const uint16_t WIRE_MIN_MINOR_VERSION = 0;
RsServiceInfo p3Wire::getServiceInfo()
{
return RsServiceInfo(RS_SERVICE_GXSV2_TYPE_WIRE,
WIRE_APP_NAME,
WIRE_APP_MAJOR_VERSION,
WIRE_APP_MINOR_VERSION,
WIRE_MIN_MAJOR_VERSION,
WIRE_MIN_MINOR_VERSION);
}
uint32_t p3Wire::wireAuthenPolicy()
{
uint32_t policy = 0;

View file

@ -43,6 +43,7 @@ class p3Wire: public RsGenExchange, public RsWire
{
public:
p3Wire(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs *gixs);
virtual RsServiceInfo getServiceInfo();
static uint32_t wireAuthenPolicy();
protected: