mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
c98d6d1595
Obviously lots to do here - but its a start! git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7258 b45a01b8-16f6-495d-af2f-9b41ad6348cc
71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <iostream>
|
|
#include <list>
|
|
|
|
#include <retroshare/rsids.h>
|
|
#include <pqi/p3linkmgr.h>
|
|
|
|
class FakePeerListStatus
|
|
{
|
|
public:
|
|
bool mOnline;
|
|
};
|
|
|
|
|
|
class FakeLinkMgr: public p3LinkMgrIMPL
|
|
{
|
|
public:
|
|
FakeLinkMgr(const RsPeerId& own_id,const std::list<RsPeerId>& friends, bool peersOnline)
|
|
: p3LinkMgrIMPL(NULL,NULL), mOwnId(own_id), mFriends()
|
|
{
|
|
std::list<RsPeerId>::const_iterator it;
|
|
for(it = friends.begin(); it != friends.end(); it++)
|
|
{
|
|
setOnlineStatus(*it, peersOnline);
|
|
}
|
|
}
|
|
|
|
virtual const RsPeerId& getOwnId() { return mOwnId; }
|
|
virtual void getOnlineList(std::list<RsPeerId>& lst)
|
|
{
|
|
std::map<RsPeerId, FakePeerListStatus>::iterator it;
|
|
for(it = mFriends.begin(); it != mFriends.end(); it++)
|
|
{
|
|
if (it->second.mOnline)
|
|
{
|
|
lst.push_back(it->first);
|
|
}
|
|
}
|
|
}
|
|
|
|
virtual void getFriendList(std::list<RsPeerId> &ssl_peers)
|
|
{
|
|
std::map<RsPeerId, FakePeerListStatus>::iterator it;
|
|
for(it = mFriends.begin(); it != mFriends.end(); it++)
|
|
{
|
|
ssl_peers.push_back(it->first);
|
|
}
|
|
}
|
|
|
|
|
|
virtual uint32_t getLinkType(const RsPeerId&) { return RS_NET_CONN_TCP_ALL | RS_NET_CONN_SPEED_NORMAL; }
|
|
|
|
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) { name = ssl_id.toStdString() ; return true ;}
|
|
|
|
|
|
// functions to manipulate status.
|
|
virtual void setOnlineStatus(RsPeerId id, bool online)
|
|
{
|
|
FakePeerListStatus status;
|
|
status.mOnline = online;
|
|
mFriends[id] = status;
|
|
}
|
|
|
|
private:
|
|
RsPeerId mOwnId;
|
|
std::map<RsPeerId, FakePeerListStatus> mFriends;
|
|
};
|
|
|
|
|