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 |
--------------------------------------------------------------------------------