-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNetExamplePlugin.cpp
More file actions
195 lines (162 loc) · 5.62 KB
/
NetExamplePlugin.cpp
File metadata and controls
195 lines (162 loc) · 5.62 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015
*
* 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <retroshare/rsplugin.h>
#include <retroshare/rsversion.h>
#include <retroshare-gui/RsAutoUpdatePage.h>
#include <QTranslator>
#include <QApplication>
#include <QString>
#include <QIcon>
#include <QMessageBox>
#include "NetExamplePlugin.h"
#include "interface/rsNetExample.h"
#include "gui/NetExampleMainpage.h"
#include "gui/NetExampleNotify.h"
#include "rsitems/rsconfigitems.h"
#define IMAGE_NetExample ":/images/Oxygen-plugin.ico"
static void *inited = new NetExamplePlugin() ;
extern "C" {
// This is *the* functions required by RS plugin system to give RS access to the plugin.
// Be careful to:
// - always respect the C linkage convention
// - always return an object of type RsPlugin*
//
void *RETROSHARE_PLUGIN_provide()
{
static NetExamplePlugin *p = new NetExamplePlugin() ;
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 = abs(atoi(RS_EXTRA_VERSION)) ;
// 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 ;
}
void NetExamplePlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_rev) const
{
major = RS_MAJOR_VERSION ;
minor = RS_MINOR_VERSION ;
build = RS_MINI_VERSION ;
svn_rev = abs(atoi(RS_EXTRA_VERSION));
}
NetExamplePlugin::NetExamplePlugin()
{
qRegisterMetaType<RsPeerId>("RsPeerId");
mainpage = NULL ;
mNetExample = NULL ;
mPlugInHandler = NULL;
mPeers = NULL;
config_page = NULL ;
mIcon = NULL ;
mNetExampleNotify = new NetExampleNotify;
}
void NetExamplePlugin::setInterfaces(RsPlugInInterfaces &interfaces)
{
mPeers = interfaces.mPeers;
}
/*ConfigPage *NetExamplePlugin::qt_config_page() const
{
// The config pages are deleted when config is closed, so it's important not to static the
// created object.
//
return new AudioInputConfig() ;
}*/
QDialog *NetExamplePlugin::qt_about_page() const
{
static QMessageBox *about_dialog = NULL ;
if(about_dialog == NULL)
{
about_dialog = new QMessageBox() ;
QString text ;
text += QObject::tr("<h3>RetroShare NetExample plugin</h3><br/> * Contributors: Cyril Soler, Josselin Jacquard, Chozabu<br/>") ;
text += QObject::tr("<br/>The NetExample plugin adds NetExample to the main list of apps in RetroShare.<br>") ;
text += QObject::tr("It Contains an example of Broadcast Painting and Chat<br>") ;
about_dialog->setText(text) ;
about_dialog->setStandardButtons(QMessageBox::Ok) ;
}
return about_dialog ;
}
/*ChatWidgetHolder *NetExamplePlugin::qt_get_chat_widget_holder(ChatWidget *chatWidget) const
{
switch (chatWidget->chatType()) {
case ChatWidget::CHATTYPE_PRIVATE:
return new NetExampleChatWidgetHolder(chatWidget, mNetExampleNotify);
case ChatWidget::CHATTYPE_UNKNOWN:
case ChatWidget::CHATTYPE_LOBBY:
case ChatWidget::CHATTYPE_DISTANT:
break;
}
return NULL;
}*/
p3Service *NetExamplePlugin::p3_service() const
{
if(mNetExample == NULL)
rsNetExample = mNetExample = new p3NetExample(mPlugInHandler,mNetExampleNotify) ; // , 3600 * 24 * 30 * 6); // 6 Months
return mNetExample ;
}
void NetExamplePlugin::setPlugInHandler(RsPluginHandler *pgHandler)
{
mPlugInHandler = pgHandler;
}
QIcon *NetExamplePlugin::qt_icon() const
{
if (mIcon == NULL) {
Q_INIT_RESOURCE(NetExample_images);
mIcon = new QIcon(IMAGE_NetExample);
}
return mIcon;
}
MainPage *NetExamplePlugin::qt_page() const
{
if(mainpage == NULL){
mainpage = new NetExampleMainpage(0, mNetExampleNotify);//mPeers, mFiles) ;
//tpage = new NetExampleMainpage( );
//mainpage = tpage;
}
return mainpage ;
}
std::string NetExamplePlugin::getShortPluginDescription() const
{
return "NetExample";
}
std::string NetExamplePlugin::getPluginName() const
{
return "NetExamplePlugin";
}
QTranslator* NetExamplePlugin::qt_translator(QApplication */*app*/, const QString& languageCode, const QString& externalDir) const
{
return NULL;
}
void NetExamplePlugin::qt_sound_events(SoundEvents &/*events*/) const
{
// events.addEvent(QApplication::translate("NetExample", "NetExample"), QApplication::translate("NetExample", "Incoming call"), NetExample_SOUND_INCOMING_CALL);
}
/*ToasterNotify *NetExamplePlugin::qt_toasterNotify(){
if (!mNetExampleToasterNotify) {
mNetExampleToasterNotify = new NetExampleToasterNotify(mNetExample, mNetExampleNotify);
}
return mNetExampleToasterNotify;
}*/