2014-04-13 17:52:53 -04:00
|
|
|
/*
|
|
|
|
* nxsdummyservices.h
|
|
|
|
*
|
|
|
|
* Created on: 13 Apr 2014
|
|
|
|
* Author: crispy
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NXSDUMMYSERVICES_H_
|
|
|
|
#define NXSDUMMYSERVICES_H_
|
|
|
|
|
2014-04-18 17:58:14 -04:00
|
|
|
#include <list>
|
|
|
|
#include <map>
|
|
|
|
#include <retroshare/rstypes.h>
|
|
|
|
#include <gxs/rsgixs.h>
|
|
|
|
#include <gxs/rsgxsnetutils.h>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2014-04-13 17:52:53 -04:00
|
|
|
|
|
|
|
namespace rs_nxs_test
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* This dummy circles implementation
|
|
|
|
* allow instantiation with simple membership
|
|
|
|
* list for a given circle
|
|
|
|
*/
|
|
|
|
class RsNxsSimpleDummyCircles : public RsGcxs
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::map<RsGxsCircleId, std::list<RsPgpId> > Membership;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
* @param membership
|
|
|
|
* @param cached
|
|
|
|
*/
|
2014-04-18 17:58:14 -04:00
|
|
|
RsNxsSimpleDummyCircles(std::list<Membership>& membership, bool cached);
|
2014-04-13 17:52:53 -04:00
|
|
|
|
|
|
|
/* GXS Interface - for working out who can receive */
|
|
|
|
bool isLoaded(const RsGxsCircleId &circleId);
|
|
|
|
bool loadCircle(const RsGxsCircleId &circleId);
|
|
|
|
|
|
|
|
int canSend(const RsGxsCircleId &circleId, const RsPgpId &id);
|
|
|
|
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
|
|
|
|
bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::list<Membership> mMembership;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* This dummy reputation allows you to set the
|
|
|
|
* reputations of peers
|
|
|
|
*/
|
|
|
|
class RsNxsSimpleDummyReputation : public RsGixsReputation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef std::map<RsGxsId, GixsReputation> RepMap;
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Instantiate the dummy rep service with
|
|
|
|
* a reputation map
|
|
|
|
* @param repMap should contain the reputations of a set of ids
|
|
|
|
* @param cached this means initial call for an ids \n
|
|
|
|
* rep will return false, until a request has been made to load it
|
|
|
|
*/
|
|
|
|
RsNxsSimpleDummyReputation(RepMap& repMap, bool cached );
|
|
|
|
|
|
|
|
bool haveReputation(const RsGxsId &id);
|
|
|
|
bool loadReputation(const RsGxsId &id, const std::list<RsPeerId>& peers);
|
|
|
|
bool getReputation(const RsGxsId &id, GixsReputation &rep);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
RepMap mRepMap;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Very simple net manager
|
|
|
|
*/
|
|
|
|
class RsNxsNetDummyMgr : public RsNxsNetMgr
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-04-18 17:58:14 -04:00
|
|
|
RsNxsNetDummyMgr(const RsPeerId& ownId, const std::list<RsPeerId>& peers) : mOwnId(ownId), mPeers(peers) {
|
2014-04-13 17:52:53 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
const RsPeerId& getOwnId() { return mOwnId; }
|
2014-04-18 17:58:14 -04:00
|
|
|
void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers)
|
|
|
|
{
|
|
|
|
RsPeerId::std_list::iterator lit = mPeers.begin();
|
|
|
|
|
|
|
|
for(; lit != mPeers.end(); lit++)
|
|
|
|
ssl_peers.insert(*lit);
|
|
|
|
}
|
2014-04-13 17:52:53 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
RsPeerId mOwnId;
|
2014-04-18 17:58:14 -04:00
|
|
|
std::list<RsPeerId> mPeers;
|
2014-04-13 17:52:53 -04:00
|
|
|
|
|
|
|
};
|
2014-04-18 17:58:14 -04:00
|
|
|
|
|
|
|
|
2014-04-13 17:52:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NXSDUMMYSERVICES_H_ */
|