├── images └── globeicon.png ├── fmimages.qrc ├── .gitignore ├── FriendMapDetached.cpp ├── FriendMapDetached.h ├── FriendMapDetached.ui ├── FriendMapController.h ├── MarbleWidget.h ├── FriendMap.pro ├── FriendMapPage.h ├── FriendMapController.cpp ├── FriendMapPage.ui ├── FriendMapPlugin.h ├── PaintLayer.h ├── FriendMapConfigPage.h ├── FriendMapSettings.h ├── FriendMapPage.cpp ├── FriendMapConfigPage.cpp ├── FriendMapPlugin.cpp ├── FriendMapSettings.cpp ├── readme.md ├── PaintLayer.cpp └── FriendMapConfigPage.ui /images/globeicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/FriendMap-1/master/images/globeicon.png -------------------------------------------------------------------------------- /fmimages.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/globeicon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #files 2 | libFriendMap.so* 3 | *.o 4 | 5 | # C++ objects and libs 6 | 7 | *.slo 8 | *.lo 9 | *.a 10 | *.la 11 | *.lai 12 | *.so 13 | *.dll 14 | *.dylib 15 | 16 | # Qt-es 17 | 18 | *.pro.user 19 | *.pro.user.* 20 | moc_*.cpp 21 | qrc_*.cpp 22 | ui_*.h 23 | Makefile* 24 | *-build-* 25 | 26 | # QtCreator 27 | 28 | *.autosave 29 | -------------------------------------------------------------------------------- /FriendMapDetached.cpp: -------------------------------------------------------------------------------- 1 | #include "FriendMapDetached.h" 2 | #include "ui_FriendMapDetached.h" 3 | 4 | FriendMapDetached::FriendMapDetached(const FriendMapController *controller) : 5 | MainPage(NULL), 6 | ui(new Ui::FriendMapDetached) 7 | { 8 | ui->setupUi(this); 9 | connect(this->ui->btn_ShowMap, SIGNAL(clicked()), controller, SLOT(openWindow())); 10 | } 11 | 12 | FriendMapDetached::~FriendMapDetached() 13 | { 14 | delete ui; 15 | } 16 | -------------------------------------------------------------------------------- /FriendMapDetached.h: -------------------------------------------------------------------------------- 1 | #ifndef FRIENDMAPDETACHED_H 2 | #define FRIENDMAPDETACHED_H 3 | 4 | #include 5 | #include 6 | #include "FriendMapController.h" 7 | 8 | namespace Ui { 9 | class FriendMapDetached; 10 | } 11 | 12 | class FriendMapDetached : public MainPage 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit FriendMapDetached(const FriendMapController *controller = 0); 18 | ~FriendMapDetached(); 19 | 20 | private: 21 | Ui::FriendMapDetached *ui; 22 | }; 23 | 24 | #endif // FRIENDMAPDETACHED_H 25 | -------------------------------------------------------------------------------- /FriendMapDetached.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FriendMapDetached 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 10 20 | 10 21 | 75 22 | 23 23 | 24 | 25 | 26 | Show map 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /FriendMapController.h: -------------------------------------------------------------------------------- 1 | #ifndef FRIENDMAPMANAGER_H 2 | #define FRIENDMAPMANAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "FriendMapSettings.h" 8 | #include "FriendMapPage.h" 9 | #include "FriendMapConfigPage.h" 10 | #include 11 | 12 | class FriendMapController : public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | RsPeers* peers; 17 | RsDisc* mDisc; 18 | explicit FriendMapController(QObject *parent = 0); 19 | ~FriendMapController(); 20 | MainPage* qt_page()const; 21 | ConfigPage* qt_config_page() const; 22 | FriendMapSettings* getSettings(); 23 | 24 | private: 25 | bool detached; //cache settings value to do not allow to change it at runtime 26 | FriendMapSettings* settings; 27 | mutable MainPage* mainPage; 28 | mutable QPointer friendMapPage; 29 | signals: 30 | 31 | public slots: 32 | void configChanged(); 33 | void openWindow(); 34 | }; 35 | 36 | #endif // FRIENDMAPMANAGER_H 37 | -------------------------------------------------------------------------------- /MarbleWidget.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file MarbleWidget.h 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor, RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef MARBLEWIDGET_H 24 | #define MARBLEWIDGET_H 25 | 26 | #include 27 | 28 | #endif // MARBLEWIDGET_H 29 | -------------------------------------------------------------------------------- /FriendMap.pro: -------------------------------------------------------------------------------- 1 | !include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri") 2 | 3 | TARGET = FriendMap 4 | 5 | CONFIG += qt uic qrc resources 6 | 7 | HEADERS -= upnp/upnputil.h 8 | SOURCES -= upnp/upnputil.c 9 | 10 | win32{ 11 | #Fixing libGeoIp compile errors 12 | DEFINES += WINVER=0x0501 _WIN32_WINNT=0x0501 PACKAGE_VERSION=\\\"1.6\\\" 13 | 14 | INCLUDEPATH += ../../../geoip-api-c/libGeoIP ../../../marble/include 15 | SOURCES += ../../../geoip-api-c/libGeoIP/GeoIp.c ../../../geoip-api-c/libGeoIP/GeoIpCity.c ../../../geoip-api-c/libGeoIP/GeoIP_deprecated.c 16 | LIBS += -lQtSVG4 -lQtWebKit4 -lws2_32 17 | } 18 | 19 | RESOURCES += \ 20 | fmimages.qrc 21 | 22 | HEADERS += \ 23 | FriendMapPlugin.h \ 24 | FriendMapPage.h \ 25 | MarbleWidget.h \ 26 | PaintLayer.h \ 27 | FriendMapSettings.h \ 28 | FriendMapConfigPage.h \ 29 | FriendMapDetached.h \ 30 | FriendMapController.h 31 | 32 | SOURCES += \ 33 | FriendMapPlugin.cpp \ 34 | FriendMapPage.cpp \ 35 | PaintLayer.cpp \ 36 | FriendMapSettings.cpp \ 37 | FriendMapConfigPage.cpp \ 38 | FriendMapDetached.cpp \ 39 | FriendMapController.cpp 40 | 41 | win32{ 42 | LIBS += -lmarblewidget 43 | } else { 44 | LIBS += -lmarblewidget -lGeoIP 45 | } 46 | 47 | FORMS += \ 48 | FriendMapPage.ui \ 49 | FriendMapConfigPage.ui \ 50 | FriendMapDetached.ui 51 | -------------------------------------------------------------------------------- /FriendMapPage.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapPage.h 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor, RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef FRIENDMAPPAGE_H 24 | #define FRIENDMAPPAGE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "FriendMapSettings.h" 31 | #include "PaintLayer.h" 32 | 33 | namespace Ui { 34 | class FriendMapPage; 35 | } 36 | 37 | class FriendMapPage : public MainPage 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit FriendMapPage(RsPeers*, RsDisc *disc); 43 | void setConfig(const FriendMapSettings* settings); 44 | ~FriendMapPage(); 45 | 46 | private: 47 | QTimer mTimer; 48 | Ui::FriendMapPage *ui; 49 | RsDisc* mDisc; 50 | RsPeers* peers; 51 | PaintLayer* layer; 52 | }; 53 | 54 | #endif // FRIENDMAPPAGE_H 55 | 56 | -------------------------------------------------------------------------------- /FriendMapController.cpp: -------------------------------------------------------------------------------- 1 | #include "FriendMapController.h" 2 | #include "FriendMapDetached.h" 3 | 4 | FriendMapController::FriendMapController(QObject *parent) : 5 | QObject(parent) 6 | { 7 | settings = new FriendMapSettings(); 8 | this->detached = settings->getDetached(); 9 | mainPage = NULL; 10 | } 11 | 12 | FriendMapController::~FriendMapController() 13 | { 14 | delete settings; 15 | delete mainPage; 16 | if(friendMapPage) 17 | delete friendMapPage; 18 | } 19 | 20 | MainPage *FriendMapController::qt_page() const 21 | { 22 | 23 | if(mainPage == NULL) 24 | { 25 | if(detached) 26 | { 27 | mainPage = new FriendMapDetached(this); 28 | }else{ 29 | friendMapPage = new FriendMapPage(peers, mDisc); 30 | friendMapPage->setConfig(settings); 31 | mainPage = friendMapPage; 32 | } 33 | } 34 | return mainPage; 35 | } 36 | 37 | ConfigPage *FriendMapController::qt_config_page() const 38 | { 39 | FriendMapConfigPage* configPage = new FriendMapConfigPage(settings); 40 | connect(configPage, SIGNAL(configChanged()), this, SLOT(configChanged())); 41 | return configPage; 42 | } 43 | 44 | FriendMapSettings *FriendMapController::getSettings() 45 | { 46 | return settings; 47 | } 48 | 49 | void FriendMapController::configChanged() 50 | { 51 | if(friendMapPage) 52 | friendMapPage->setConfig(settings); 53 | } 54 | 55 | void FriendMapController::openWindow() 56 | { 57 | if(friendMapPage.isNull()) 58 | { 59 | friendMapPage = new FriendMapPage(peers, mDisc); 60 | friendMapPage->setAttribute(Qt::WA_DeleteOnClose, true); 61 | friendMapPage->show(); 62 | friendMapPage->setConfig(settings); 63 | }else{ 64 | friendMapPage->activateWindow(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /FriendMapPage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FriendMapPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 604 10 | 634 11 | 12 | 13 | 14 | FriendMap 15 | 16 | 17 | 18 | 19 | 20 | The Earth 21 | 22 | 23 | The Marble widget displays a virtual globe. 24 | 25 | 26 | 1100 27 | 28 | 29 | false 30 | 31 | 32 | false 33 | 34 | 35 | false 36 | 37 | 38 | true 39 | 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Marble::MarbleWidget 53 | QWidget 54 |
MarbleWidget.h
55 |
56 |
57 | 58 | 59 |
60 | -------------------------------------------------------------------------------- /FriendMapPlugin.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapPlugin.h 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor, RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef EXPORTTOOLSPLUGIN_H 24 | #define EXPORTTOOLSPLUGIN_H 25 | 26 | #include 27 | #include "FriendMapPage.h" 28 | #include "FriendMapConfigPage.h" 29 | #include "FriendMapController.h" 30 | 31 | class FriendMapPlugin : public RsPlugin 32 | { 33 | public: 34 | FriendMapPlugin(); 35 | ~FriendMapPlugin(); 36 | 37 | MainPage* qt_page()const; 38 | ConfigPage* qt_config_page() const; 39 | QDialog* qt_about_page() const; 40 | QIcon* qt_icon() const; 41 | 42 | std::string getShortPluginDescription() const; 43 | std::string getPluginName() const; 44 | void getPluginVersion(int& major,int& minor,int& svn_rev) const; 45 | 46 | // 47 | //========================== Plugin Interface ================================// 48 | // 49 | // Use these methods to access main objects from RetroShare. 50 | // 51 | void setInterfaces(RsPlugInInterfaces& interfaces); 52 | void setPlugInHandler(RsPluginHandler* pgHandler); 53 | 54 | private: 55 | RsPluginHandler* mPlugInHandler; 56 | QIcon* mIcon; 57 | FriendMapController* controller; 58 | }; 59 | 60 | #endif // EXPORTTOOLSPLUGIN_H 61 | -------------------------------------------------------------------------------- /PaintLayer.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file PaintLayer.h 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor, RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef PAINTLAYER_H 24 | #define PAINTLAYER_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include "FriendMapSettings.h" 37 | 38 | using namespace Marble; 39 | 40 | /** 41 | * @brief Define class PaintLayer 42 | */ 43 | class PaintLayer : public LayerInterface, public QObject 44 | { 45 | public: 46 | PaintLayer(RsPeers* peers, RsDisc* disc, const FriendMapSettings* settings); 47 | ~PaintLayer(); 48 | // Implemented from LayerInterface 49 | virtual QStringList renderPosition() const; 50 | 51 | // Implemented from LayerInterface 52 | virtual bool render( GeoPainter *painter, ViewportParams *viewport, 53 | const QString& renderPos = "NONE", GeoSceneLayer * layer = 0 ); 54 | public slots: 55 | void genPeerCache(); 56 | private: 57 | const FriendMapSettings* mSettings; 58 | bool showingLinks; 59 | RsPeers* rsPeers; 60 | RsDisc* rsDisc; 61 | GeoIP* geoip; 62 | }; 63 | 64 | #endif // PAINTLAYER_H 65 | 66 | -------------------------------------------------------------------------------- /FriendMapConfigPage.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapConfigPage.h 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | */ 21 | 22 | #ifndef FRIENDMAPCONFIGPAGE_H 23 | #define FRIENDMAPCONFIGPAGE_H 24 | 25 | #include 26 | #include "retroshare-gui/configpage.h" 27 | #include "FriendMapSettings.h" 28 | #include "FriendMapPage.h" 29 | #include 30 | 31 | namespace Ui { 32 | class FriendMapConfigPage; 33 | } 34 | 35 | class FriendMapConfigPage : public ConfigPage 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit FriendMapConfigPage(FriendMapSettings *settings); 41 | ~FriendMapConfigPage(); 42 | 43 | virtual void load(); 44 | 45 | /** Pages save their config settings here 46 | * and return true if everything was saved successfully. */ 47 | virtual bool save(QString &errmsg); 48 | 49 | // Icon to be used to display the config page. 50 | // 51 | virtual QPixmap iconPixmap() const { return QPixmap(":/images/globeicon.png"); } 52 | 53 | // Name of the page, to put in the leftside list 54 | // 55 | virtual QString pageName() const {return "FriendMap";} 56 | 57 | 58 | virtual QString helpText() const {return "No Help. Sorry.";} 59 | 60 | signals: 61 | void configChanged(); 62 | 63 | private slots: 64 | void detached_toggled(bool state); 65 | 66 | private: 67 | Ui::FriendMapConfigPage *ui; 68 | FriendMapSettings* settings; 69 | }; 70 | 71 | #endif // FRIENDMAPCONFIGPAGE_H 72 | 73 | -------------------------------------------------------------------------------- /FriendMapSettings.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapSettings.h 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor, RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef FRIENDMAPSETTINGS_H 24 | #define FRIENDMAPSETTINGS_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | class FriendMapSettings 32 | { 33 | friend class FriendMapConfigPage; 34 | public: 35 | FriendMapSettings(); 36 | void setStdPaths(RsPluginHandler* pgHandler); 37 | const std::string& getGeoIpDataPath() const {return this->geoip_data_path;} 38 | bool getShowGrid() const {return show_grid;} 39 | bool getShowLinks() const {return show_links;} 40 | bool getShowBorders() const {return show_borders;} 41 | bool getShowCities() const {return show_cities;} 42 | bool getShowIceLayer() const {return show_ice_layer;} 43 | bool getShowClouds() const {return show_clouds;} 44 | bool getShowCityLights() const {return show_city_lights;} 45 | bool getShowSunShading() const {return show_sun_shading;} 46 | bool getShowAvatars() const {return show_avatars;} 47 | bool getDetached() const {return detached;} 48 | Marble::Projection getProjection() const {return projection;} 49 | const std::string& getMapThemeId() const {return map_theme_id;} 50 | bool setMarblePath(const QDir &marble_path); 51 | bool validPaths()const{return !(this->geoip_data_path.empty());} 52 | void processSettings(bool load); 53 | private: 54 | std::string geoip_data_path; 55 | QString marble_path; 56 | bool show_grid; 57 | bool show_links; 58 | bool show_borders; 59 | bool show_cities; 60 | bool show_ice_layer; 61 | bool show_clouds; 62 | bool show_city_lights; 63 | bool show_sun_shading; 64 | bool show_avatars; 65 | bool detached; 66 | 67 | Marble::Projection projection; 68 | std::string map_theme_id; 69 | }; 70 | 71 | #endif // FRIENDMAPSETTINGS_H 72 | 73 | // eof 74 | 75 | -------------------------------------------------------------------------------- /FriendMapPage.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapPage.cpp 3 | * @author RetroShare Team 4 | * 5 | * Copyright (C) 2014 - RetroShare Team 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | */ 21 | 22 | #include "FriendMapPage.h" 23 | #include "ui_FriendMapPage.h" 24 | #include 25 | 26 | //! 27 | //! \brief FriendMapPage::FriendMapPage 28 | //! \param peers 29 | //! 30 | FriendMapPage::FriendMapPage(RsPeers* peers, RsDisc* disc) : 31 | ui(new Ui::FriendMapPage) 32 | { 33 | ui->setupUi(this); 34 | //this->setWindowTitle(QString("FriendMap")); 35 | ui->MarbleWidget->setShowCompass(false); 36 | ui->MarbleWidget->setShowCrosshairs(false); 37 | this->peers = peers; 38 | this->mDisc = disc; 39 | this->layer = NULL; 40 | 41 | mTimer.setInterval(5000); 42 | mTimer.start(1000); 43 | } 44 | 45 | //! 46 | //! \brief FriendMapPage::~FriendMapPage 47 | //! Destructor which destroys the user interace 48 | //! 49 | FriendMapPage::~FriendMapPage() 50 | { 51 | if(layer){ 52 | ui->MarbleWidget->removeLayer(layer); 53 | delete layer; 54 | } 55 | delete ui; 56 | } 57 | 58 | //! 59 | //! \brief FriendMapPage::setConfig 60 | //! \param settings 61 | //! 62 | void FriendMapPage::setConfig(const FriendMapSettings* settings){ 63 | ui->MarbleWidget->setMapThemeId(settings->getMapThemeId().c_str()); 64 | ui->MarbleWidget->setProjection(settings->getProjection()); 65 | ui->MarbleWidget->setShowGrid(settings->getShowGrid()); 66 | 67 | ui->MarbleWidget->setShowBorders(settings->getShowBorders()); 68 | ui->MarbleWidget->setShowCities(settings->getShowCities()); 69 | ui->MarbleWidget->setShowIceLayer(settings->getShowIceLayer()); 70 | ui->MarbleWidget->setShowClouds(settings->getShowClouds()); 71 | ui->MarbleWidget->setShowCityLights(settings->getShowCityLights()); 72 | ui->MarbleWidget->setShowSunShading(settings->getShowSunShading()); 73 | if(settings->validPaths()){ 74 | if(layer != NULL){ 75 | ui->MarbleWidget->removeLayer(layer); 76 | delete layer; 77 | } 78 | layer = new PaintLayer(peers, mDisc, settings); 79 | connect(&mTimer, SIGNAL(timeout()), layer, SLOT(genPeerCache())); 80 | //connect(ui->MarbleWidget, SIGNAL(mouseClickGeoPosition(qreal,qreal,GeoDataCoordinates::Unit)), layer, SLOT(genPeerCache());//enable to update cache on click 81 | ui->MarbleWidget->addLayer(layer); 82 | } else { 83 | QMessageBox::information(this, 84 | tr("FriendMap"), 85 | QString(tr("GeoIP Data not found!"))); 86 | } 87 | } 88 | 89 | // eof 90 | -------------------------------------------------------------------------------- /FriendMapConfigPage.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapConfigPage.cpp 3 | * @author RetroShare Team 4 | * 5 | * Copyright (C) 2014 - RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include "FriendMapConfigPage.h" 24 | #include "ui_FriendMapConfigPage.h" 25 | #include 26 | 27 | //! 28 | //! \brief FriendMapConfigPage::FriendMapConfigPage 29 | //! \param settings 30 | //! 31 | FriendMapConfigPage::FriendMapConfigPage(FriendMapSettings* settings) : 32 | ui(new Ui::FriendMapConfigPage) 33 | { 34 | ui->setupUi(this); 35 | connect(ui->detached_window, SIGNAL(toggled(bool)), this, SLOT(detached_toggled(bool))); 36 | this->settings = settings; 37 | load(); 38 | } 39 | 40 | //! 41 | //! \brief FriendMapConfigPage::~FriendMapConfigPage 42 | //! Destructor - destroys the user interface 43 | // 44 | FriendMapConfigPage::~FriendMapConfigPage() 45 | { 46 | delete ui; 47 | } 48 | 49 | //! 50 | //! \brief FriendMapConfigPage::load 51 | //! 52 | void FriendMapConfigPage::load(){ 53 | int themeindex = ui->theme_dgml->findText(QString::fromStdString(settings->map_theme_id)); 54 | if (themeindex<0)themeindex=0; 55 | ui->theme_dgml->setCurrentIndex(themeindex); 56 | ui->projection_box->setCurrentIndex(settings->getProjection()); 57 | ui->show_grid->setChecked(settings->show_grid); 58 | ui->show_links->setChecked(settings->show_links); 59 | ui->show_borders->setChecked(settings->show_borders); 60 | ui->show_cities->setChecked(settings->show_cities); 61 | ui->show_ice_layer->setChecked(settings->show_ice_layer); 62 | ui->show_clouds->setChecked(settings->show_clouds); 63 | ui->show_city_lights->setChecked(settings->show_city_lights); 64 | ui->show_sun_shading->setChecked(settings->show_sun_shading); 65 | ui->show_avatars->setChecked(settings->show_avatars); 66 | ui->detached_window->setChecked(settings->detached); 67 | 68 | ui->geoip_path_line->setText(QString::fromStdString(settings->geoip_data_path)); 69 | ui->marble_path_line->setText(settings->marble_path); 70 | } 71 | 72 | //! 73 | //! \brief FriendMapConfigPage::save 74 | //! \param errmsg 75 | //! \return 76 | //! 77 | bool FriendMapConfigPage::save(QString &errmsg) 78 | { 79 | settings->show_grid = ui->show_grid->isChecked(); 80 | settings->show_links = ui->show_links->isChecked(); 81 | settings->show_borders = ui->show_borders->isChecked(); 82 | settings->show_cities = ui->show_cities->isChecked(); 83 | settings->show_ice_layer = ui->show_ice_layer->isChecked(); 84 | settings->show_clouds = ui->show_clouds->isChecked(); 85 | settings->show_city_lights = ui->show_city_lights->isChecked(); 86 | settings->show_sun_shading = ui->show_sun_shading->isChecked(); 87 | settings->show_avatars = ui->show_avatars->isChecked(); 88 | settings->detached = ui->detached_window->isChecked(); 89 | 90 | settings->projection = (Marble::Projection)ui->projection_box->currentIndex(); 91 | settings->map_theme_id = ui->theme_dgml->currentText().toStdString(); 92 | settings->geoip_data_path = ui->geoip_path_line->text().toStdString(); 93 | 94 | #ifdef WIN32 95 | // why is this just for windows? On Linux returns warning for unused variable 96 | QString dir = QDir::fromNativeSeparators(ui->marble_path_line->text()); 97 | if(!settings->setMarblePath(QDir(dir))){ 98 | errmsg = "invalid marble path"; 99 | return false; 100 | } 101 | #endif 102 | 103 | emit configChanged(); 104 | settings->processSettings(false); 105 | errmsg = ""; // set errmsg to a null string 106 | return true; 107 | } 108 | 109 | void FriendMapConfigPage::detached_toggled(bool state) 110 | { 111 | if(settings->getDetached() == state) 112 | ui->detached_window->setText(QString("")); 113 | else 114 | ui->detached_window->setText(QString("Restart is required to take effect")); 115 | } 116 | 117 | // eof 118 | -------------------------------------------------------------------------------- /FriendMapPlugin.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapPlugin.cpp 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - RetroShare Team 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | */ 21 | 22 | #include "FriendMapPlugin.h" 23 | #include 24 | #include 25 | 26 | //! 27 | //! 28 | //! 29 | extern "C" { 30 | void *RETROSHARE_PLUGIN_provide() 31 | { 32 | static FriendMapPlugin* p = new FriendMapPlugin() ; 33 | return (void*)p ; 34 | } 35 | // This symbol contains the svn revision number grabbed from the executable. 36 | // It will be tested by RS to load the plugin automatically, since it is safe to load plugins 37 | // with same revision numbers, assuming that the revision numbers are up-to-date. 38 | // 39 | uint32_t RETROSHARE_PLUGIN_revision = SVN_REVISION_NUMBER ; 40 | 41 | // This symbol contains the svn revision number grabbed from the executable. 42 | // It will be tested by RS to load the plugin automatically, since it is safe to load plugins 43 | // with same revision numbers, assuming that the revision numbers are up-to-date. 44 | // 45 | uint32_t RETROSHARE_PLUGIN_api = RS_PLUGIN_API_VERSION ; 46 | } 47 | 48 | //! 49 | //! \brief FriendMapPlugin::FriendMapPlugin 50 | //! 51 | FriendMapPlugin::FriendMapPlugin() 52 | { 53 | Q_INIT_RESOURCE(images); 54 | mIcon = new QIcon(":/images/globeicon.png"); 55 | controller = new FriendMapController(); 56 | } 57 | 58 | //! 59 | //! \brief FriendMapPlugin::~FriendMapPlugin 60 | //! 61 | FriendMapPlugin::~FriendMapPlugin() 62 | { 63 | delete mIcon; 64 | delete controller; 65 | } 66 | 67 | //! 68 | //! \brief FriendMapPlugin::qt_page 69 | //! \return 70 | //! 71 | MainPage* FriendMapPlugin::qt_page() const 72 | { 73 | return controller->qt_page(); 74 | } 75 | 76 | //! 77 | //! \brief FriendMapPlugin::qt_config_page 78 | //! \return 79 | //! 80 | ConfigPage* FriendMapPlugin::qt_config_page() const 81 | { 82 | return controller->qt_config_page(); 83 | } 84 | 85 | //! 86 | //! \brief FriendMapPlugin::qt_about_page 87 | //! \return 88 | //! 89 | QDialog* FriendMapPlugin::qt_about_page() const 90 | { 91 | static QMessageBox *about_dialog = NULL ; 92 | 93 | if(about_dialog == NULL) 94 | { 95 | about_dialog = new QMessageBox() ; 96 | 97 | QString text ; 98 | text += QObject::tr("

RetroShare FriendMap plugin


* Developer: Nyfor
This plugin is based on Marble (http://marble.kde.org)") ; 99 | text += QObject::tr("

FriendMap shows selected map with your friends location."); 100 | text += QObject::tr("

This is an experimental feature. Use it on your own risk.") ; 101 | 102 | about_dialog->setText(text) ; 103 | about_dialog->setStandardButtons(QMessageBox::Ok) ; 104 | } 105 | 106 | return about_dialog ; 107 | } 108 | 109 | //! 110 | //! \brief FriendMapPlugin::qt_icon 111 | //! \return 112 | //! 113 | QIcon* FriendMapPlugin::qt_icon() const 114 | { 115 | return mIcon; 116 | } 117 | 118 | //! 119 | //! \brief FriendMapPlugin::getShortPluginDescription 120 | //! \return 121 | //! 122 | std::string FriendMapPlugin::getShortPluginDescription() const 123 | { 124 | return "This plugin shows a map with your friends."; 125 | } 126 | 127 | //! 128 | //! \brief FriendMapPlugin::getPluginName 129 | //! \return 130 | //! 131 | std::string FriendMapPlugin::getPluginName() const 132 | { 133 | return "FriendMap"; 134 | } 135 | 136 | //! 137 | //! \brief FriendMapPlugin::getPluginVersion 138 | //! \param major 139 | //! \param minor 140 | //! \param svn_rev 141 | //! 142 | void FriendMapPlugin::getPluginVersion(int& major,int& minor,int& svn_rev) const 143 | { 144 | major = 5; 145 | minor = 5; 146 | svn_rev = SVN_REVISION_NUMBER ; 147 | } 148 | 149 | 150 | // 151 | //========================== Plugin Interface ================================// 152 | // 153 | // Use these methods to access main objects from RetroShare. 154 | // 155 | //! 156 | //! \brief FriendMapPlugin::setInterfaces 157 | //! \param interfaces 158 | //! 159 | void FriendMapPlugin::setInterfaces(RsPlugInInterfaces& interfaces) 160 | { 161 | controller->peers = interfaces.mPeers; 162 | controller->mDisc = interfaces.mDisc; 163 | } 164 | 165 | //! 166 | //! \brief FriendMapPlugin::setPlugInHandler 167 | //! \param pgHandler 168 | //! 169 | void FriendMapPlugin::setPlugInHandler(RsPluginHandler* pgHandler) 170 | { 171 | mPlugInHandler = pgHandler; 172 | controller->getSettings()->setStdPaths(pgHandler); 173 | } 174 | 175 | // eof 176 | 177 | -------------------------------------------------------------------------------- /FriendMapSettings.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file FriendMapSettings.cpp 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor, RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include "FriendMapSettings.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "gui/settings/rsharesettings.h" 30 | 31 | //! 32 | //! \brief FriendMapSettings::FriendMapSettings 33 | //! 34 | FriendMapSettings::FriendMapSettings() 35 | { 36 | this->show_grid = false; 37 | this->show_links = true; 38 | this->projection = Marble::Spherical; 39 | this->geoip_data_path = ""; 40 | this->detached = false; 41 | 42 | //earth/openstreetmap/openstreetmap.dgml 43 | //earth/plain/plain.dgml 44 | //earth/schagen1689/schagen1689.dgml 45 | //"earth/citylights/citylights.dgml" 46 | //this->map_theme_id = "earth/openstreetmap/openstreetmap.dgml"; 47 | this->map_theme_id = "earth/bluemarble/bluemarble.dgml"; 48 | processSettings(true); 49 | } 50 | 51 | //! 52 | //! \brief FriendMapSettings::processSettings 53 | //! \param load 54 | //! 55 | void FriendMapSettings::processSettings(bool load) 56 | { 57 | Settings->beginGroup(QString("FriendMapSettings")); 58 | 59 | if (load) { 60 | // load settings 61 | 62 | show_grid = Settings->value("show_grid").toBool(); 63 | show_links = Settings->value("show_links").toBool(); 64 | show_borders = Settings->value("show_borders").toBool(); 65 | show_cities = Settings->value("show_cities").toBool(); 66 | show_ice_layer = Settings->value("show_ice_layer").toBool(); 67 | show_clouds = Settings->value("show_clouds").toBool(); 68 | show_city_lights = Settings->value("show_city_lights").toBool(); 69 | show_sun_shading = Settings->value("show_sun_shading").toBool(); 70 | show_avatars = Settings->value("show_avatars").toBool(); 71 | detached = Settings->value("detached").toBool(); 72 | projection = (Marble::Projection)Settings->value("projection_type").toInt(); 73 | map_theme_id = Settings->value("map_theme_id").toString().toStdString(); 74 | 75 | if (map_theme_id.length() < 2)map_theme_id = "earth/bluemarble/bluemarble.dgml"; 76 | } else { 77 | // save settings 78 | Settings->setValue("show_grid", show_grid); 79 | Settings->setValue("show_links", show_links); 80 | Settings->setValue("show_borders", show_borders); 81 | Settings->setValue("show_cities", show_cities); 82 | Settings->setValue("show_ice_layer", show_ice_layer); 83 | Settings->setValue("show_clouds", show_clouds); 84 | Settings->setValue("show_city_lights", show_city_lights); 85 | Settings->setValue("show_sun_shading", show_sun_shading); 86 | Settings->setValue("show_avatars", show_avatars); 87 | Settings->setValue("detached", detached); 88 | Settings->setValue("projection_type", projection); 89 | Settings->setValue("map_theme_id", QString::fromStdString(map_theme_id)); 90 | } 91 | 92 | Settings->endGroup(); 93 | } 94 | 95 | //! 96 | //! \brief FriendMapSettings::setMarblePath 97 | //! \param marble_path 98 | //! \return 99 | //! 100 | bool FriendMapSettings::setMarblePath(const QDir &marble_path) 101 | { 102 | this->marble_path = QDir::toNativeSeparators(marble_path.canonicalPath()); 103 | 104 | QDir plugins = QDir(marble_path); 105 | QDir data = QDir(marble_path); 106 | 107 | bool valid = plugins.cd("plugins") && data.cd("data"); 108 | if(valid){ 109 | Marble::MarbleDirs::setMarblePluginPath(plugins.canonicalPath()); 110 | Marble::MarbleDirs::setMarbleDataPath(data.canonicalPath()); 111 | } 112 | return valid; 113 | } 114 | 115 | //! 116 | //! \brief FriendMapSettings::setStdPaths 117 | //! \param pgHandler 118 | //! 119 | void FriendMapSettings::setStdPaths(RsPluginHandler *pgHandler) 120 | { 121 | #ifdef WIN32 122 | //Finding marble installation 123 | //Included with the plugin, RS_folder/marble 124 | QDir marblepathlocal = QDir(QCoreApplication::applicationDirPath()); 125 | if(marblepathlocal.cd("marble") && setMarblePath(marblepathlocal)){ 126 | //found in RS folder, nothing to do 127 | }else{ 128 | //look for it in Program Files 129 | QByteArray pfdir = qgetenv("PROGRAMFILES(X86)"); 130 | if(pfdir.isNull() || pfdir.isEmpty()){ 131 | pfdir = qgetenv("PROGRAMFILES"); 132 | } 133 | 134 | //check it again 135 | if(!pfdir.isNull() && !pfdir.isEmpty()){ 136 | QString path = QString(pfdir); 137 | QDir marblepathprogramfiles = QDir(QDir::fromNativeSeparators(path)); 138 | if(marblepathprogramfiles.cd("marble") && setMarblePath(marblepathprogramfiles)){ 139 | //found in Program Files, nothing to do 140 | //TODO: check installed marble version, only if somebody reports problem about it 141 | }else{ 142 | QString message = QString("Marble not found in the following places, please install Marble and/or set the path manually in the options
"); 143 | message += QString(QCoreApplication::applicationDirPath() + "/marble
"); 144 | message += QString(path + "/marble
"); 145 | QMessageBox::warning(NULL, "Marble not found", message); 146 | } 147 | }else{ 148 | //this shouldn't happen on Windows 149 | QMessageBox::warning(NULL, "Program Files directory not found", "Are your enviroment variables correct?"); 150 | } 151 | } 152 | #endif 153 | 154 | const std::vector& plugin_directories = pgHandler->getPluginDirectories(); 155 | foreach(const std::string& dir, plugin_directories){ 156 | QFileInfo finfo(QString::fromStdString(dir+"GeoLiteCity.dat")); 157 | std::cout<http://www.maxmind.com. 16 | 17 | ####Before attempting to build this plugin, you must build the main retroshare project and it's plugins 18 | 19 | ###Debian GNU/Linux 20 | ####Dependencies 21 | Install libmarble-dev and libgeoip-dev: 22 |
 23 | sudo apt-get  install libmarble-dev libgeoip-dev
 24 | 
25 | 26 | ####Clone From Github 27 | Obtain the source code into the appropriate folder: 28 |
 29 | cd myretrosharetrunk/plugins/  
 30 | git clone git@github.com:chozabu/FriendMap.git
 31 | 
32 | 33 | ####Build 34 | Note: on some Gnu/Linux versions, you may have to type qmake instead of qmake-qt4. 35 |
 36 | cd FriendMap  
 37 | qmake-qt4  
 38 | make clean
 39 | make  
 40 | 
41 | 42 | 43 | ####Install 44 | The following copies the library to the default location: 45 |
 46 | cp libFriendMap.so.1.0.0 ~/.retroshare/extensions  
 47 | cd ~/.retroshare/extensions  
 48 | mv libFriendMap.so.1.0.0 libFriendMap.so  
 49 | 
50 | 51 | Now get the required mapping data: 52 |
 53 | wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz  
 54 | gunzip GeoLiteCity.dat.gz  
 55 | 
56 | 57 | 58 | ###Windows 59 | 60 | ####Before You Start 61 | 62 | It is assumed that you have similar folder structure described in the Retroshare Windows compile instructions, and also that you have Retroshare build enviroment setted up. 63 | 64 | Refer to this page for further instructions: https://wiki.cavebeat.org/index.php/Compile_windows. 65 | 66 | It is assumed your RetroShare development folder is under c:\Development and RetroShare's sourcecode is under c:\Development\src 67 | 68 | It is assumed RetroShare is installed under c:\Program Files (x86)\RetroShare 69 | 70 | You will need a bash terminal with cmake, gcc and Qt in your path: 71 | 72 | * Refer section "Setup build enviroment" 73 | * Start devenv.bat (described in section "Make a script to launch your development environment") or MinGW-Shell.bat (if you have the buildscripts). It is possible that some commands need administrator privileges, so start the script by right click on the bat file and select Run as administrator. 74 | * Run the test described in section "Test if everything is working", if one of this test fails, you may have compile problems. 75 | 76 | You will need a Git client: 77 | 78 | * MSysGit for command line interface: http://msysgit.github.io/ 79 | * TortoiseGit for graphical interface: https://code.google.com/p/tortoisegit/ 80 | * Or any other Git client 81 | 82 | ####LibGeoIP 83 | GeoIP is a C library that enables the user to find geographical and network information of an IP address. To use this library, you may download our free GeoLite Country or City databases. These are updated at the beginning of every month. 84 | 85 | #####Get the source 86 | Checkout the source code under c:\Development\geoip-api-c from https://github.com/maxmind/geoip-api-c.git 87 | Using command line: 88 |
 89 | cd c:\Development
 90 | git clone https://github.com/maxmind/geoip-api-c.git
 91 | 
92 | 93 | Building libGeoIp is problematic, but we don't need the lib, the source files are enough. 94 | 95 | ####Marble 96 | To read more about some of the features of marble, visit http://marble.kde.org/features.php . 97 | 98 | #####Get the source 99 | Checkout the source code under c:\Development\marble from git://anongit.kde.org/marble , branch KDE/4.11 . 100 | Using command line: 101 |
102 | cd c:\Development
103 | git clone -b KDE/4.11 git://anongit.kde.org/marble marble
104 | cd marble
105 | 
106 | 107 | #####Build and install 108 | Marble will be installed under c:\Program Files (x86)\marble\ or c:\Program Files\marble\ by default, you can change the install path by changing the parameters of the cmake. 109 | 110 | For more information visit http://techbase.kde.org/Projects/Marble/WindowsCompiling 111 | 112 | Start devenv.bat or MinGW-Shell.bat with administrator privileges, and run these commands: 113 |
114 | cd c:/Development/marble
115 | mkdir build
116 | cd build
117 | cmake -G "MSYS Makefiles" -DQTONLY=ON -DCMAKE_BUILD_TYPE=Release -DWITH_DESIGNER_PLUGIN=ON ..
118 | make
119 | make install
120 | 
121 | 122 | #####Locating Files 123 | Put some files from Marble to the right place in order to make FriendMap compile 124 | * Copy libmarblewidget.dll.a from c:\Development\marble\build\src\lib\ to c:\Development\lib\ 125 | * Copy include folder from c:\Program Files (x86)\marble\include\ to c:\Development\marble\include\ 126 | 127 | ####FriendMap plugin 128 | #####Get the source 129 | Checkout the source code under c:\Development\src\plugins from git@github.com:chozabu/FriendMap.git 130 | Using command line: 131 |
132 | cd c:\Development\src\plugins  
133 | git clone git@github.com:chozabu/FriendMap.git  
134 | 
135 | 136 | #####Build 137 | Open the file c:\Development\git\plugins\plugins.pro in text editor and add this line: 138 |
139 | FriendMap \
140 | 
141 | 142 | To build the plugin use the build script, or you can use the Qt Creator. 143 | If you are using Qt Creator, open the retroshare.pro, not the FriendMap.pro. With Qt Creator you can rebuild only this plugin, if you have built the other RetroShare components before. 144 | 145 | #####Install the plugin 146 | 147 | To install correctly, complete the following steps: 148 | 149 | * Copy FriendMap.dll from c:\Development\build...\plugins\FriendMap\release to Retroshare\Data\extensions (portable) or to %appdata%\RetroShare\extensions 150 | * Download http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz 151 | * Extract GeoLiteCity.dat under Retroshare\Data\extensions (portable) or to %appdata%\RetroShare\extensions 152 | * Copy libmarblewidget.dll from c:\Development\marble\build\src\lib\ to c:\Program Files (x86)\RetroShare\ 153 | * Copy the following dlls from c:\Qt\4.8.5\bin\ to c:\Program Files (x86)\RetroShare\: 154 | -QtCore4.dll 155 | -QtDeclarative4.dll 156 | -QtGui4.dll 157 | -QtNetwork4.dll 158 | -QtSvg4.dll 159 | -QtWebKit4.dll 160 | -QtXml4.dll 161 | -QtScript4.dll 162 | -QtSql4.dll 163 | -QtXmlPatterns4.dll 164 | 165 | Finally start RetroShare, at the first time it will be slow. 166 | 167 | You may have to set the correct paths under options->FriendMap. 168 | 169 | ####For distributors 170 | FriendMap plugin needs data and plugins from Marble. Please include instructions for installing standalone Marble. 171 | Or you can distribute the required Marble files along with this plugin: 172 | 173 | * Make a folder called "marble" under RetroShare folder 174 | * Copy folder from c:\Program Files (x86)\marble\data to RetroShare\marble\data 175 | * Copy folder from c:\Program Files (x86)\marble\plugins to RetroShare\marble\plugins 176 | * marble.exe and other files are not needed 177 | -------------------------------------------------------------------------------- /PaintLayer.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file PaintLayer.cpp 3 | * @author Nyfor, RetroShare Team 4 | * 5 | * Copyright (C) 2014 - Nyfor, RetroShare Team 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include "PaintLayer.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include "gui/common/AvatarDefs.h" 32 | 33 | #define PI 3.14159265 34 | 35 | //! 36 | //! \brief PaintLayer::PaintLayer 37 | // Obtains settings and the map data file. 38 | //! \param peers 39 | //! \param settings 40 | //! 41 | PaintLayer::PaintLayer(RsPeers *peers, RsDisc *disc, const FriendMapSettings *settings) 42 | { 43 | this->rsPeers = peers; 44 | this->rsDisc = disc; 45 | this->mSettings = settings; 46 | const std::string& geoip_data_path = settings->getGeoIpDataPath(); 47 | showingLinks = settings->getShowLinks(); 48 | this->geoip = GeoIP_open(geoip_data_path.c_str(), GEOIP_STANDARD); 49 | if(geoip == NULL){ 50 | std::cerr<<"Error: GeoLiteCity.dat not found!"<geoip); 63 | } 64 | 65 | //! 66 | //! \brief PaintLayer::renderPosition 67 | //! \return 68 | //! 69 | QStringList PaintLayer::renderPosition() const 70 | { 71 | // We will paint in exactly one of the following layers. 72 | // The current one can be changed by pressing the '+' key 73 | /* 74 | * "NONE" 75 | * "STARS" 76 | * "BEHIND_TARGET" 77 | * "SURFACE" 78 | * "HOVERS_ABOVE_SURFACE" 79 | * "ATMOSPHERE" 80 | * "ORBIT" 81 | * "ALWAYS_ON_TOP" 82 | * "FLOAT_ITEM" 83 | * "USER_TOOLS" 84 | */ 85 | QStringList layers = QStringList() << "ALWAYS_ON_TOP"<<"SURFACE" << "HOVERS_ABOVE_SURFACE"; 86 | layers << "ORBIT" << "USER_TOOLS" << "STARS"; 87 | return QStringList()< locations; 110 | //QMap connections;//could use this 111 | QList connectionsList; 112 | QPixmap avatar; 113 | }; 114 | 115 | //! 116 | //!//! \brief geoPeers 117 | //! 118 | 119 | QList geoPeers; 120 | QMap peerTable; 121 | void PaintLayer::genPeerCache(){ 122 | 123 | srand(42); 124 | 125 | std::list gpg_ids; 126 | rsPeers->getGPGAcceptedList(gpg_ids); 127 | gpg_ids.push_back(rsPeers->getGPGId(rsPeers->getOwnId())); 128 | 129 | //QList geoPeers; 130 | //QMap peerTable; 131 | geoPeers.clear(); 132 | peerTable.clear(); 133 | //LIST GPG 134 | foreach(const std::string& gpg_id, gpg_ids){ 135 | GeoPeer gFriend; 136 | gFriend.locations.clear(); 137 | RsPeerDetails peer_details; 138 | //rsPeers->getGPGDetails(gpg_id, gpg_detail); 139 | rsPeers->getPeerDetails(gpg_id, peer_details); 140 | 141 | std::list ssl_ids; 142 | rsPeers->getAssociatedSSLIds(gpg_id, ssl_ids); 143 | 144 | //LIST SSL 145 | foreach(const std::string& ssl_id, ssl_ids){ 146 | RsPeerDetails peer_ssl_details; 147 | rsPeers->getPeerDetails(ssl_id, peer_ssl_details); 148 | if(peer_ssl_details.extAddr.compare("0.0.0.0")){ 149 | //std::cout<longitude, r->latitude, 0.0, GeoDataCoordinates::Degree); 154 | 155 | float rr = ((double) rand() / (RAND_MAX))*PI*2.0f; 156 | sLocation.coordOff = GeoDataCoordinates(r->longitude+cos(rr)*0.3f, r->latitude+sin(rr)*0.3f, 0.0, GeoDataCoordinates::Degree); 157 | sLocation.ssl_id = QString::fromStdString(ssl_id); 158 | sLocation.name = QString::fromUtf8(peer_ssl_details.name.c_str()); 159 | gFriend.locations.push_back(sLocation); 160 | GeoIPRecord_delete(r); 161 | } 162 | 163 | } 164 | 165 | } 166 | if(gFriend.locations.length()>0){ 167 | gFriend.gpg_id = QString::fromStdString(gpg_id); 168 | 169 | if(mSettings->getShowAvatars()){ 170 | AvatarDefs::getAvatarFromGpgId(gpg_id, gFriend.avatar); 171 | gFriend.avatar = gFriend.avatar.scaledToWidth(22); 172 | } 173 | geoPeers.push_back(gFriend); 174 | peerTable.insert(gpg_id,gFriend); 175 | } 176 | 177 | } 178 | 179 | //Cache connections 180 | QList::iterator geoPeer; 181 | for (geoPeer = geoPeers.begin(); geoPeer != geoPeers.end(); ++geoPeer){ 182 | //foreach(GeoPeer geoPeer, geoPeers){ 183 | std::list friendList; 184 | rsDisc->getDiscGPGFriends(geoPeer->gpg_id.toStdString(), friendList); 185 | //geoPeer->connections.clear(); 186 | geoPeer->connectionsList.clear(); 187 | foreach(const std::string& gpg_id, friendList){ 188 | if (peerTable.contains(gpg_id)){ 189 | //QString q_id = QString::fromStdString(gpg_id); 190 | //GeoPeer gp = peerTable[q_id]; 191 | //geoPeer->connections.insert(q_id,gp); 192 | geoPeer->connectionsList.push_back(gpg_id); 193 | } 194 | } 195 | 196 | } 197 | 198 | } 199 | 200 | //! 201 | //! \brief PaintLayer::render 202 | //! \param painter 203 | //! \param viewport 204 | //! \param renderPos 205 | //! \param layer 206 | //! \return 207 | //! 208 | bool PaintLayer::render( GeoPainter *painter, ViewportParams *viewport, 209 | const QString& renderPos, GeoSceneLayer * layer ) 210 | { 211 | 212 | srand(42); 213 | 214 | foreach(const GeoPeer& geoPeerc, geoPeers){ 215 | GeoPeer geoPeer = geoPeerc; 216 | 217 | foreach(const GeoPeerLoc& geoPeerLoc, geoPeer.locations){ 218 | 219 | float rr = ((double) rand() / (RAND_MAX)); 220 | //GeoDataCoordinates coord = geoPeerLoc.coord; 221 | GeoDataCoordinates coord = geoPeerLoc.coordOff; 222 | //std::cerr << "FRIENDMAP: show avatars: " << mSettings->getShowAvatars() << "\n"; 223 | if(mSettings->getShowAvatars()) 224 | painter->drawPixmap(coord, geoPeer.avatar); 225 | 226 | if(rsPeers->isOnline(geoPeerLoc.ssl_id.toStdString())) 227 | painter->setPen(Qt::green); 228 | else 229 | painter->setPen(Qt::red); 230 | painter->drawEllipse(geoPeerLoc.coord, 2.5f+5.f*rr, 2.5f+5.f*rr); 231 | painter->drawEllipse(coord, 10, 10); 232 | 233 | GeoDataLineString cLine; 234 | cLine.append(coord); 235 | cLine.append(geoPeerLoc.coord); 236 | painter->drawPolyline(cLine); 237 | 238 | painter->setPen(Qt::white); 239 | QFont fonz; 240 | fonz.setBold(true); 241 | fonz.setStyleStrategy(QFont::ForceOutline); 242 | painter->setFont(fonz); 243 | painter->drawText(coord, geoPeerLoc.name); 244 | 245 | 246 | if(showingLinks){ 247 | painter->setPen(Qt::yellow); 248 | foreach(const std::string& gpg_id, geoPeer.connectionsList){ 249 | GeoPeer other = peerTable[gpg_id]; 250 | if (other.locations.length()>0){ 251 | GeoPeerLoc oloc = other.locations.first(); 252 | GeoDataLineString conLine; 253 | conLine.append(oloc.coord); 254 | conLine.append(geoPeerLoc.coord); 255 | painter->drawPolyline(conLine); 256 | } else std::cerr << "error, missing all locations for a peer\n"; 257 | } 258 | } 259 | } 260 | } 261 | 262 | return true; 263 | } 264 | 265 | // eof 266 | 267 | -------------------------------------------------------------------------------- /FriendMapConfigPage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FriendMapConfigPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 517 10 | 373 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 10 20 | 9 21 | 501 22 | 351 23 | 24 | 25 | 26 | 27 | QFormLayout::ExpandingFieldsGrow 28 | 29 | 30 | 31 | 32 | Geo IP Data Path 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Marble Path 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Projection 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Spherical 61 | 62 | 63 | 64 | 65 | Equirectangular 66 | 67 | 68 | 69 | 70 | Mercator 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | Theme 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 0 87 | 0 88 | 89 | 90 | 91 | true 92 | 93 | 94 | 95 | earth/bluemarble/bluemarble.dgml 96 | 97 | 98 | 99 | 100 | earth/openstreetmap/openstreetmap.dgml 101 | 102 | 103 | 104 | 105 | earth/citylights/citylights.dgml 106 | 107 | 108 | 109 | 110 | earth/schagen1689/schagen1689.dgml 111 | 112 | 113 | 114 | 115 | earth/plain/plain.dgml 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | Show Grid 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | Show Links 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | Show Borders 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | Show Cities 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | Ice Layer 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | Show Clouds 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | Show City Lights 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | Sun Shading 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | Show Avatars 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | <html><head/><body><p>The plugin does not use resources when the window is closed</p></body></html> 250 | 251 | 252 | Standalone Window 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 255 265 | 0 266 | 0 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 255 276 | 0 277 | 0 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 120 287 | 120 288 | 120 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | <html><head/><body><p>The plugin does not use resources when the window is closed</p></body></html> 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | --------------------------------------------------------------------------------