forked from chozabu/FriendMap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FriendMapPlugin.cpp
169 lines (148 loc) · 4.6 KB
/
FriendMapPlugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*!
* @file FriendMapPlugin.cpp
* @author Nyfor, RetroShare Team
*
* Copyright (C) 2014 - RetroShare Team
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <marble/MarbleGlobal.h>
#include <GeoIP.h>
#include "FriendMapPlugin.h"
#include "interface.h"
//!
//!
//!
extern "C" {
void* RETROSHARE_PLUGIN_provide() {
static auto p = new FriendMapPlugin();
return (void*)p;
}
// 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
// with same revision numbers, assuming that the revision numbers are up-to-date.
//
uint32_t RETROSHARE_PLUGIN_revision = RS_REVISION_NUMBER;
// 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
// with same revision numbers, assuming that the revision numbers are up-to-date.
//
uint32_t RETROSHARE_PLUGIN_api = RS_PLUGIN_API_VERSION;
}
//!
//! \brief FriendMapPlugin::FriendMapPlugin
//!
FriendMapPlugin::FriendMapPlugin() : mPlugInHandler(nullptr) {
Q_INIT_RESOURCE(images);
mIcon = new QIcon(":/images/globeicon.png");
controller = new FriendMapController();
}
//!
//! \brief FriendMapPlugin::~FriendMapPlugin
//!
FriendMapPlugin::~FriendMapPlugin() {
delete mIcon;
delete controller;
}
//!
//! \brief FriendMapPlugin::qt_page
//! \return
//!
MainPage* FriendMapPlugin::qt_page() const {
return controller->qt_page();
}
//!
//! \brief FriendMapPlugin::qt_config_page
//! \return
//!
ConfigPage* FriendMapPlugin::qt_config_page() const {
return controller->qt_config_page();
}
//!
//! \brief FriendMapPlugin::qt_about_page
//! \return
//!
QDialog* FriendMapPlugin::qt_about_page() const {
static QMessageBox* about_dialog = nullptr;
if (about_dialog == nullptr) {
about_dialog = new QMessageBox();
QString text;
text += QObject::tr("<h3>RetroShare FriendMap plugin</h3><br/>* Developer: Nyfor<br/>This plugin is based on Marble (http://marble.kde.org)");
text += QObject::tr("<br/><br/>FriendMap shows selected map with your friends location.");
text += QObject::tr("<br/><br/>This is an experimental feature. Use it on your own risk.");
about_dialog->setText(text);
about_dialog->setStandardButtons(QMessageBox::Ok);
}
return about_dialog;
}
//!
//! \brief FriendMapPlugin::qt_icon
//! \return
//!
QIcon* FriendMapPlugin::qt_icon() const {
return mIcon;
}
//!
//! \brief FriendMapPlugin::getShortPluginDescription
//! \return
//!
std::string FriendMapPlugin::getShortPluginDescription() const {
return "This plugin shows a map with your friends.";
}
//!
//! \brief FriendMapPlugin::getPluginName
//! \return
//!
std::string FriendMapPlugin::getPluginName() const {
return "FriendMap";
}
//!
//! \brief FriendMapPlugin::getPluginVersion
//! \param major
//! \param minor
//! \param svn_rev
//!
void FriendMapPlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_rev) const {
major = RS_MAJOR_VERSION;
minor = RS_MINOR_VERSION;
build = RS_BUILD_NUMBER;
svn_rev = RS_REVISION_NUMBER;
}
void FriendMapPlugin::getLibraries(std::list<RsLibraryInfo> &libraries)
{
libraries.push_back(RsLibraryInfo("GeoIP", GeoIP_lib_version()));
libraries.push_back(RsLibraryInfo("Marble", MARBLE_VERSION_STRING.toStdString()));
}
//
//========================== Plugin Interface ================================//
//
// Use these methods to access main objects from RetroShare.
//
//!
//! \brief FriendMapPlugin::setInterfaces
//! \param interfaces
//!
void FriendMapPlugin::setInterfaces(RsPlugInInterfaces& interfaces) {
interface::init(interfaces);
}
//!
//! \brief FriendMapPlugin::setPlugInHandler
//! \param pgHandler
//!
void FriendMapPlugin::setPlugInHandler(RsPluginHandler* pgHandler) {
mPlugInHandler = pgHandler;
controller->getSettings()->setStdPaths(pgHandler);
}
// eof