Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get FriendMap plugin working with latest retroshare code #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion FriendMap.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ TARGET = FriendMap

CONFIG += qt uic qrc resources

greaterThan(QT_MAJOR_VERSION, 4) {
# Qt 5
QT += widgets
}

HEADERS -= upnp/upnputil.h
SOURCES -= upnp/upnputil.c

Expand Down Expand Up @@ -41,7 +46,7 @@ SOURCES += \
win32{
LIBS += -lmarblewidget
} else {
LIBS += -lmarblewidget -lGeoIP
LIBS += -lmarblewidget-qt5 -lGeoIP
}

FORMS += \
Expand Down
13 changes: 7 additions & 6 deletions FriendMapPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void *RETROSHARE_PLUGIN_provide()
// It will be tested by RS to load the plugin automatically, since it is safe to load plugins
// with same revision numbers, assuming that the revision numbers are up-to-date.
//
uint32_t RETROSHARE_PLUGIN_revision = SVN_REVISION_NUMBER ;
uint32_t RETROSHARE_PLUGIN_revision = 0;

// This symbol contains the svn revision number grabbed from the executable.
// It will be tested by RS to load the plugin automatically, since it is safe to load plugins
Expand Down Expand Up @@ -137,16 +137,17 @@ std::string FriendMapPlugin::getPluginName() const
//! \brief FriendMapPlugin::getPluginVersion
//! \param major
//! \param minor
//! \param build
//! \param svn_rev
//!
void FriendMapPlugin::getPluginVersion(int& major,int& minor,int& svn_rev) const
void FriendMapPlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_rev) const
{
major = 5;
minor = 5;
svn_rev = SVN_REVISION_NUMBER ;
major = RS_MAJOR_VERSION ;
minor = RS_MINOR_VERSION ;
build = RS_MINI_VERSION ;
svn_rev = 0;
}


//
//========================== Plugin Interface ================================//
//
Expand Down
2 changes: 1 addition & 1 deletion FriendMapPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FriendMapPlugin : public RsPlugin

std::string getShortPluginDescription() const;
std::string getPluginName() const;
void getPluginVersion(int& major,int& minor,int& svn_rev) const;
void getPluginVersion(int& major, int& minor, int& build, int& svn_rev) const;

//
//========================== Plugin Interface ================================//
Expand Down
56 changes: 26 additions & 30 deletions PaintLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
PaintLayer::PaintLayer(RsPeers *peers, RsDisc *disc, const FriendMapSettings *settings)
{
this->rsPeers = peers;
this->rsDisc = disc;
this->mRsDisc = disc;
this->mSettings = settings;
const std::string& geoip_data_path = settings->getGeoIpDataPath();
showingLinks = settings->getShowLinks();
Expand Down Expand Up @@ -92,8 +92,8 @@ QStringList PaintLayer::renderPosition() const
//!
class GeoPeerLoc{
public:
QString gpg_id;
QString ssl_id;
RsPgpId pgp_id;
RsPeerId ssl_id;
QString name;
GeoDataCoordinates coord;
GeoDataCoordinates coordOff;
Expand All @@ -105,10 +105,10 @@ class GeoPeerLoc{
//!
class GeoPeer{
public:
QString gpg_id;
RsPgpId pgp_id;
QList<GeoPeerLoc> locations;
//QMap<QString, GeoPeer> connections;//could use this
QList<std::string> connectionsList;
QList<RsPgpId> connectionsList;
QPixmap avatar;
};

Expand All @@ -117,32 +117,29 @@ class GeoPeer{
//!

QList<GeoPeer> geoPeers;
QMap<std::string, GeoPeer> peerTable;
QMap<RsPgpId, GeoPeer> peerTable;
void PaintLayer::genPeerCache(){

srand(42);

std::list<std::string> gpg_ids;
rsPeers->getGPGAcceptedList(gpg_ids);
gpg_ids.push_back(rsPeers->getGPGId(rsPeers->getOwnId()));
std::list<RsPgpId> pgp_ids;
rsPeers->getGPGAcceptedList(pgp_ids);
pgp_ids.push_back(rsPeers->getGPGId(rsPeers->getOwnId()));

//QList<GeoPeer> geoPeers;
//QMap<QString, GeoPeer> peerTable;
geoPeers.clear();
peerTable.clear();
//LIST GPG
foreach(const std::string& gpg_id, gpg_ids){
foreach(const RsPgpId& pgp_id, pgp_ids){
GeoPeer gFriend;
gFriend.locations.clear();
RsPeerDetails peer_details;
//rsPeers->getGPGDetails(gpg_id, gpg_detail);
rsPeers->getPeerDetails(gpg_id, peer_details);
rsPeers->getGPGDetails(pgp_id, peer_details);

std::list<std::string> ssl_ids;
rsPeers->getAssociatedSSLIds(gpg_id, ssl_ids);
std::list<RsPeerId> ssl_ids;
rsPeers->getAssociatedSSLIds(pgp_id, ssl_ids);

//LIST SSL
foreach(const std::string& ssl_id, ssl_ids){
foreach(const RsPeerId& ssl_id, ssl_ids){
RsPeerDetails peer_ssl_details;
rsPeers->getPeerDetails(ssl_id, peer_ssl_details);
if(peer_ssl_details.extAddr.compare("0.0.0.0")){
Expand All @@ -154,7 +151,7 @@ void PaintLayer::genPeerCache(){

float rr = ((double) rand() / (RAND_MAX))*PI*2.0f;
sLocation.coordOff = GeoDataCoordinates(r->longitude+cos(rr)*0.3f, r->latitude+sin(rr)*0.3f, 0.0, GeoDataCoordinates::Degree);
sLocation.ssl_id = QString::fromStdString(ssl_id);
sLocation.ssl_id = ssl_id;
sLocation.name = QString::fromUtf8(peer_ssl_details.name.c_str());
gFriend.locations.push_back(sLocation);
GeoIPRecord_delete(r);
Expand All @@ -164,14 +161,14 @@ void PaintLayer::genPeerCache(){

}
if(gFriend.locations.length()>0){
gFriend.gpg_id = QString::fromStdString(gpg_id);
gFriend.pgp_id = pgp_id;

if(mSettings->getShowAvatars()){
AvatarDefs::getAvatarFromGpgId(gpg_id, gFriend.avatar);
AvatarDefs::getAvatarFromGpgId(pgp_id, gFriend.avatar);
gFriend.avatar = gFriend.avatar.scaledToWidth(22);
}
geoPeers.push_back(gFriend);
peerTable.insert(gpg_id,gFriend);
peerTable.insert(pgp_id,gFriend);
}

}
Expand All @@ -180,16 +177,15 @@ void PaintLayer::genPeerCache(){
QList<GeoPeer>::iterator geoPeer;
for (geoPeer = geoPeers.begin(); geoPeer != geoPeers.end(); ++geoPeer){
//foreach(GeoPeer geoPeer, geoPeers){
std::list<std::string> friendList;
rsDisc->getDiscGPGFriends(geoPeer->gpg_id.toStdString(), friendList);
//geoPeer->connections.clear();
std::list<RsPgpId> pgpFriendList;
mRsDisc->getDiscPgpFriends(geoPeer->pgp_id, pgpFriendList);
geoPeer->connectionsList.clear();
foreach(const std::string& gpg_id, friendList){
if (peerTable.contains(gpg_id)){
foreach(const RsPgpId& pgp_id, pgpFriendList){
if (peerTable.contains(pgp_id)){
//QString q_id = QString::fromStdString(gpg_id);
//GeoPeer gp = peerTable[q_id];
//geoPeer->connections.insert(q_id,gp);
geoPeer->connectionsList.push_back(gpg_id);
geoPeer->connectionsList.push_back(pgp_id);
}
}

Expand Down Expand Up @@ -223,7 +219,7 @@ bool PaintLayer::render( GeoPainter *painter, ViewportParams *viewport,
if(mSettings->getShowAvatars())
painter->drawPixmap(coord, geoPeer.avatar);

if(rsPeers->isOnline(geoPeerLoc.ssl_id.toStdString()))
if(rsPeers->isOnline(geoPeerLoc.ssl_id))
painter->setPen(Qt::green);
else
painter->setPen(Qt::red);
Expand All @@ -245,8 +241,8 @@ bool PaintLayer::render( GeoPainter *painter, ViewportParams *viewport,

if(showingLinks){
painter->setPen(Qt::yellow);
foreach(const std::string& gpg_id, geoPeer.connectionsList){
GeoPeer other = peerTable[gpg_id];
foreach(const RsPgpId& pgp_id, geoPeer.connectionsList){
GeoPeer other = peerTable[pgp_id];
if (other.locations.length()>0){
GeoPeerLoc oloc = other.locations.first();
GeoDataLineString conLine;
Expand Down
2 changes: 1 addition & 1 deletion PaintLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public slots:
const FriendMapSettings* mSettings;
bool showingLinks;
RsPeers* rsPeers;
RsDisc* rsDisc;
RsDisc* mRsDisc;
GeoIP* geoip;
};

Expand Down