├── gui
├── sounds
│ ├── ring3.wav
│ ├── ringin.wav
│ ├── incomingcall.wav
│ ├── outgoingcall.wav
│ └── outgoingcallbusy.wav
├── images
│ └── Oxygen-plugin.ico
├── NetExample_images.qrc
├── NetExampleNotify.cpp
├── NetExampleMainpage.h
├── paintwidget.h
├── NetExampleNotify.h
├── paintwidget.cpp
├── NetExampleMainpage.cpp
└── NetExampleMainpage.ui
├── .gitmodules
├── cptest
├── docs
├── Mainpage.dox
└── Doxyfile
├── rename_plugin.sh
├── README.md
├── NetExample.pro
├── interface
└── rsNetExample.h
├── NetExamplePlugin.h
├── services
├── p3NetExample.h
├── rsNetExampleItems.h
├── rsNetExampleItems.cc
└── p3NetExample.cc
└── NetExamplePlugin.cpp
/gui/sounds/ring3.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/ExampleRSPlugin/master/gui/sounds/ring3.wav
--------------------------------------------------------------------------------
/gui/sounds/ringin.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/ExampleRSPlugin/master/gui/sounds/ringin.wav
--------------------------------------------------------------------------------
/gui/images/Oxygen-plugin.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/ExampleRSPlugin/master/gui/images/Oxygen-plugin.ico
--------------------------------------------------------------------------------
/gui/sounds/incomingcall.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/ExampleRSPlugin/master/gui/sounds/incomingcall.wav
--------------------------------------------------------------------------------
/gui/sounds/outgoingcall.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/ExampleRSPlugin/master/gui/sounds/outgoingcall.wav
--------------------------------------------------------------------------------
/gui/sounds/outgoingcallbusy.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/ExampleRSPlugin/master/gui/sounds/outgoingcallbusy.wav
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "html"]
2 | path = html
3 | url = git@github.com:RetroShare/ExampleRSPlugin.git
4 | branch = gh-pages
5 |
--------------------------------------------------------------------------------
/gui/NetExample_images.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/Oxygen-plugin.ico
4 |
5 |
6 |
--------------------------------------------------------------------------------
/cptest:
--------------------------------------------------------------------------------
1 | kdesudo -u retrotester cp lib*.so* /home/retrotester/.retroshare/extensions6/
2 | kdesudo -u retrotester /home/chozabu/git/RetroShare/retroshare-gui/src/RetroShare
3 |
4 |
--------------------------------------------------------------------------------
/docs/Mainpage.dox:
--------------------------------------------------------------------------------
1 | /**
2 | @brief Documentation for the RetroShare Chatserver Sources
3 | @author chozabu & cave
4 | @file
5 | */
6 | /** @defgroup RetroShare */
7 | /**
8 | @mainpage RetroShare Example Plugin
9 | This guide should help you to create your own Plugin.
10 | It should point you to the direction how to untangle the code and run some networking.
11 | */
12 |
--------------------------------------------------------------------------------
/rename_plugin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | newname=$1
3 | oldname="NetExample"
4 | echo "$newname"
5 | echo "$oldname"
6 | find . -not -path '*/\.*' -type f -print0 | xargs -0 sed -i "s/$oldname/$newname/g"
7 | #find . -type f -exec rename "s/$oldname/$newname/' '{}" \;
8 | find . | sed -e "p;s/$oldname/$newname/" | xargs -n2 git mv
9 |
10 | echo "now change 0x12345 in services/*items.h to a unique value of your choice to identify your plugin!"
11 |
--------------------------------------------------------------------------------
/gui/NetExampleNotify.cpp:
--------------------------------------------------------------------------------
1 | #include "NetExampleNotify.h"
2 |
3 | NetExampleNotify::NetExampleNotify(QObject *parent) : QObject(parent)
4 | {
5 |
6 | }
7 |
8 | void NetExampleNotify::notifyReceivedPaint(const RsPeerId &peer_id, int x, int y)
9 | {
10 | std::cout << "pNotify Recvd paint from: " << peer_id;
11 | std::cout << " at " << x << " , " << y;
12 | std::cout << std::endl;
13 | emit NePaintArrived(peer_id, x, y);
14 | }
15 |
16 |
17 | void NetExampleNotify::notifyReceivedMsg(const RsPeerId& peer_id, QString str)
18 | {
19 | std::cout << "pNotify Recvd Packet from: " << peer_id;
20 | std::cout << " saying " << str.toStdString();
21 | std::cout << std::endl;
22 | emit NeMsgArrived(peer_id, str) ;
23 | }
24 |
--------------------------------------------------------------------------------
/gui/NetExampleMainpage.h:
--------------------------------------------------------------------------------
1 | /* This is the main page displayed by the plugin */
2 | #ifndef NEMAINPAGE_H
3 | #define NEMAINPAGE_H
4 |
5 | #include
6 | #include
7 | #include
8 | #include "gui/NetExampleNotify.h"
9 |
10 |
11 |
12 | #include
13 |
14 | namespace Ui {
15 | class NetExampleMainpage;
16 | }
17 |
18 | class NetExampleMainpage : public MainPage
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit NetExampleMainpage(QWidget *parent, NetExampleNotify *notify);
24 | ~NetExampleMainpage();
25 |
26 | private slots:
27 | void mmEvent(int x, int y);
28 | void on_pingAllButton_clicked();
29 | void NeMsgArrived(const RsPeerId &peer_id, QString str);
30 |
31 | void on_broadcastButton_clicked();
32 |
33 | void NePaintArrived(const RsPeerId &peer_id, int x, int y);
34 | private:
35 | Ui::NetExampleMainpage *ui;
36 | NetExampleNotify *mNotify;
37 | };
38 |
39 | #endif // NEMAINPAGE_H
40 |
--------------------------------------------------------------------------------
/gui/paintwidget.h:
--------------------------------------------------------------------------------
1 | /* this is just a local widget that can be drawn on */
2 | #ifndef PAINTWIDGET_H
3 | #define PAINTWIDGET_H
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class TopJCDialog;
11 |
12 | class PaintWidget : public QWidget
13 | {
14 | Q_OBJECT
15 | public:
16 | explicit PaintWidget(QWidget *parent = 0);
17 | void setImage(const QImage&);
18 | QImage getImage();
19 |
20 | void fillImage(QColor color);
21 | virtual void paintAt(int x, int y);
22 |
23 | QColor color;
24 | uint8_t penWidth;
25 | TopJCDialog* tjd;
26 |
27 | signals:
28 | void haveUpdate();
29 | void mmEvent(int x, int y);
30 |
31 |
32 | public slots:
33 |
34 | protected:
35 | virtual void mouseReleaseEvent(QMouseEvent * event);
36 | virtual void paintEvent(QPaintEvent *);
37 | virtual void mouseMoveEvent(QMouseEvent *);
38 |
39 | private:
40 | QImage image;
41 |
42 | };
43 |
44 | #endif // PAINTWIDGET_H
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | RS .6 Example Plugin
2 | ==================
3 |
4 | This is somewhat based on the VOIP plugin.
5 |
6 | Simplified to make it easier to see how things work.
7 |
8 | Features broadcast chat and broadcast paint
9 | all networking is doing by encoding to json rather than the more compact+speedy but verbose multiple RsItem method.
10 | A good middle ground could be msgpack
11 |
12 | ##Compile & run
13 |
14 | Depends on qt5.4+
15 |
16 | this plugin should be built in the retroshare plugins directory, along the lines of:
17 |
18 | cd myretrosharedir/plugins
19 | git clone https://github.com/RetroShare/ExampleRSPlugin.git
20 | cd ExampleRSPlugin
21 | qmake
22 | make
23 | cp *so* ~/.retroshare/extensions6/
24 |
25 | Then reboot retroshare, it will ask if you want to accept the plugin.
26 |
27 | ##Build Plugin based on this plugin
28 |
29 | To use as a basis for your own plugins you can run
30 |
31 | ./rename_plugin.sh NewPluginName
32 |
33 | This will replace all instances of "NetExample" with "NewPluginName"
34 | you must also change the plugins ID from 12345 to a number of your choosing.
35 |
--------------------------------------------------------------------------------
/NetExample.pro:
--------------------------------------------------------------------------------
1 | !include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri")
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4) {
4 | # Qt 5
5 | QT += widgets
6 | }
7 |
8 | exists($$[QMAKE_MKSPECS]/features/mobility.prf) {
9 | CONFIG += mobility
10 | } else {
11 | QT += multimedia
12 | }
13 | CONFIG += qt uic qrc resources
14 | MOBILITY = multimedia
15 |
16 | DEPENDPATH += ../../retroshare-gui/src/temp/ui ../../libretroshare/src
17 | INCLUDEPATH += ../../retroshare-gui/src/temp/ui ../../libretroshare/src
18 |
19 | #################################### Windows #####################################
20 |
21 | linux-* {
22 | INCLUDEPATH += /usr/include
23 | LIBS += $$system(pkg-config --libs opencv)
24 | }
25 |
26 | win32 {
27 | LIBS_DIR = $$PWD/../../../libs
28 | LIBS += -L"$$LIBS_DIR/lib/opencv"
29 |
30 | OPENCV_VERSION = 249
31 | LIBS += -lopencv_core$$OPENCV_VERSION -lopencv_highgui$$OPENCV_VERSION -lopencv_imgproc$$OPENCV_VERSION -llibjpeg -llibtiff -llibpng -llibjasper -lIlmImf -lole32 -loleaut32 -luuid -lavicap32 -lavifil32 -lvfw32 -lz
32 | }
33 |
34 | QMAKE_CXXFLAGS *= -Wall
35 |
36 | SOURCES = NetExamplePlugin.cpp \
37 | services/p3NetExample.cc \
38 | services/rsNetExampleItems.cc \
39 | gui/NetExampleMainpage.cpp \
40 | gui/NetExampleNotify.cpp \
41 | gui/paintwidget.cpp
42 |
43 | HEADERS = NetExamplePlugin.h \
44 | services/p3NetExample.h \
45 | services/rsNetExampleItems.h \
46 | interface/rsNetExample.h \
47 | gui/NetExampleMainpage.h \
48 | gui/NetExampleNotify.h \
49 | gui/paintwidget.h
50 |
51 | #FORMS = gui/AudioInputConfig.ui
52 |
53 | TARGET = NetExample
54 |
55 | RESOURCES = gui/NetExample_images.qrc
56 |
57 |
58 | LIBS += -lspeex -lspeexdsp
59 |
60 | FORMS += \
61 | gui/NetExampleMainpage.ui
62 |
--------------------------------------------------------------------------------
/gui/NetExampleNotify.h:
--------------------------------------------------------------------------------
1 | /****************************************************************
2 | * RetroShare is distributed under the following license:
3 | *
4 | * Copyright (C) 2015
5 | *
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., 51 Franklin Street, Fifth Floor,
19 | * Boston, MA 02110-1301, USA.
20 | ****************************************************************/
21 |
22 | // This class is a Qt object to get notification from the plugin's service threads,
23 | // and responsible to pass the info the the GUI part.
24 | //
25 | // Because the GUI part is async-ed with the service, it is crucial to use the
26 | // QObject connect system to communicate between the p3Service and the gui part (handled by Qt)
27 | //
28 | #ifndef NETEXAMPLENOTIFY_H
29 | #define NETEXAMPLENOTIFY_H
30 |
31 | #include
32 |
33 | #include
34 |
35 | class NetExampleNotify : public QObject
36 | {
37 | Q_OBJECT
38 | public:
39 | explicit NetExampleNotify(QObject *parent = 0);
40 | void notifyReceivedPaint(const RsPeerId &peer_id, int x, int y) ;
41 | void notifyReceivedMsg(const RsPeerId &peer_id, QString str) ;
42 |
43 | signals:
44 | void NeMsgArrived(const RsPeerId &peer_id, QString str) ; // emitted when the peer gets a msg
45 | void NePaintArrived(const RsPeerId &peer_id, int x, int y) ;
46 |
47 | public slots:
48 | };
49 |
50 | #endif // NETEXAMPLENOTIFY_H
51 |
--------------------------------------------------------------------------------
/interface/rsNetExample.h:
--------------------------------------------------------------------------------
1 | /* this is a simple class to make it easy for any part of the plugin to call its services */
2 | /****************************************************************
3 | * RetroShare is distributed under the following license:
4 | *
5 | * Copyright (C) 2015
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., 51 Franklin Street, Fifth Floor,
20 | * Boston, MA 02110-1301, USA.
21 | ****************************************************************/
22 |
23 | // interface class for p3NetExample service
24 | //
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | class RsNetExample ;
35 | extern RsNetExample *rsNetExample;
36 |
37 | //TODO explain this const
38 | static const uint32_t CONFIG_TYPE_NetExample_PLUGIN = 0xe001 ;
39 |
40 | class RsNetExample
41 | {
42 | public:
43 |
44 | //not fully implemented
45 | virtual void ping_all() = 0;
46 |
47 | //broadcasts json packets with some x/y coords for painting
48 | virtual void broadcast_paint(int x, int y) = 0;
49 |
50 | //broadcasts json packets with some text coords for chatting
51 | virtual void msg_all(std::string msg) = 0;
52 |
53 | //send data to a peer using your own serialisation
54 | virtual void raw_msg_peer(RsPeerId peerID, std::string msg) = 0;
55 |
56 | //convenience functions
57 | //virtual void str_msg_peer(RsPeerId peerID, QString strdata) = 0;
58 | //virtual void qvm_msg_peer(RsPeerId peerID, QVariantMap data) = 0;
59 | };
60 |
61 |
62 |
--------------------------------------------------------------------------------
/gui/paintwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "paintwidget.h"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 | PaintWidget::PaintWidget(QWidget *parent) :
10 | QWidget(parent),image(600,300,QImage::Format_RGB32),color(Qt::black),penWidth(8)
11 | {
12 | image.fill(qRgb(255, 255, 255));
13 | }
14 |
15 | void PaintWidget::setImage(const QImage &img){
16 | image=img.copy();
17 | update();
18 | }
19 |
20 | QImage PaintWidget::getImage(){
21 | return image;
22 | }
23 |
24 | void PaintWidget::fillImage(QColor color){
25 | image.fill(qRgb(255, 255, 255));
26 | update();
27 | }
28 |
29 | void PaintWidget::mouseMoveEvent(QMouseEvent *event)
30 | {
31 | QPainter p(&image);
32 | p.setPen(color);
33 | p.setBrush(color);
34 | QPoint pos = event->pos();
35 | if(penWidth==1){
36 | p.drawPoint(pos);
37 | }else{
38 | p.drawEllipse(pos,penWidth/2,penWidth/2);
39 | }
40 | //check if u want to clear Jenster--
41 | // if (event->button() == Qt::RightButton) image.fill(qRgb(255, 255, 255));
42 |
43 | // trigger repaint of widget
44 | update();
45 | emit mmEvent(pos.x(), pos.y());
46 | //tjd->paintMouseMove(event);
47 | }
48 |
49 |
50 | void PaintWidget::paintAt(int x, int y)
51 | {
52 | QPainter p(&image);
53 | p.setPen(color);
54 | p.setBrush(color);
55 | if(penWidth==1){
56 | p.drawPoint(x,y);
57 | }else{
58 | p.drawEllipse(x,y,penWidth/2,penWidth/2);
59 | }
60 | // trigger repaint of widget
61 | update();
62 | }
63 |
64 | qint64 getImgSize(QImage image){
65 | QByteArray ba;
66 | QBuffer buffer(&ba);
67 | buffer.open(QIODevice::WriteOnly);
68 | image.save(&buffer, "PNG");
69 | return buffer.buffer().toBase64().size();
70 | }
71 |
72 | void PaintWidget::mouseReleaseEvent(QMouseEvent *event){
73 | std::cout<<"PaintWidgte::mouseReleseEvent()"<button() == Qt::RightButton) { image.fill(qRgb(255, 255, 255));update(); }
76 | //check to see if we want to send to clipboard
77 | if (event->button() == Qt::MiddleButton) {
78 | QImage img = image.scaledToWidth(image.width()*0.5);
79 | while(getImgSize(img)> 5500){
80 | img = img.scaledToWidth(img.width()*0.8);
81 | }
82 | QApplication::clipboard()->setImage(img);
83 | }
84 |
85 |
86 |
87 | emit haveUpdate();
88 | }
89 |
90 | void PaintWidget::paintEvent(QPaintEvent *event)
91 | {
92 | QPainter p(this);
93 | p.drawImage(0,0,image);
94 | }
95 |
--------------------------------------------------------------------------------
/gui/NetExampleMainpage.cpp:
--------------------------------------------------------------------------------
1 | #include "NetExampleMainpage.h"
2 | #include "ui_NetExampleMainpage.h"
3 | //#include "services/p3NetExample.h"
4 | #include "interface/rsNetExample.h"
5 | #include
6 |
7 |
8 | NetExampleMainpage::NetExampleMainpage(QWidget *parent, NetExampleNotify *notify) :
9 | MainPage(parent),
10 | mNotify(notify),
11 | ui(new Ui::NetExampleMainpage)
12 | {
13 | ui->setupUi(this);
14 |
15 | connect(mNotify, SIGNAL(NeMsgArrived(RsPeerId,QString)), this , SLOT(NeMsgArrived(RsPeerId,QString)));
16 | connect(mNotify, SIGNAL(NePaintArrived(RsPeerId,int,int)), this , SLOT(NePaintArrived(RsPeerId,int,int)));
17 | //ui->listWidget->addItem("str");
18 | connect(ui->paintWidget, SIGNAL(mmEvent(int,int)), this, SLOT(mmEvent(int,int)));
19 |
20 | }
21 |
22 | NetExampleMainpage::~NetExampleMainpage()
23 | {
24 | delete ui;
25 | }
26 |
27 | void NetExampleMainpage::mmEvent(int x, int y)
28 | {
29 | rsNetExample->broadcast_paint(x,y);
30 | }
31 |
32 | void NetExampleMainpage::on_pingAllButton_clicked()
33 | {
34 | rsNetExample->ping_all();
35 | NeMsgArrived(rsPeers->getOwnId(),"ping");
36 | }
37 |
38 |
39 | void NetExampleMainpage::NeMsgArrived(const RsPeerId &peer_id, QString str)
40 | {
41 | QJsonDocument jdoc = QJsonDocument::fromJson(str.toUtf8());
42 | QVariantMap vmap = jdoc.toVariant().toMap();
43 | std::cout << "GUI got Packet from: " << peer_id;
44 | std::cout << " saying " << str.toStdString();
45 | std::cout << std::endl;
46 | QString type = vmap.value("type").toString();
47 | if (type == "chat"){
48 | QString output = QString::fromStdString(rsPeers->getPeerName(peer_id));
49 | output+=": ";
50 | output+=vmap.value("message").toString();
51 | ui->listWidget->addItem(output);
52 | }else if (type == "paint"){
53 | int x =vmap.value("x").toInt();
54 | int y =vmap.value("y").toInt();
55 | NePaintArrived(peer_id,x,y);
56 | }else{
57 | QString output = QString::fromStdString(rsPeers->getPeerName(peer_id));
58 | output+=": ";
59 | output+=str;
60 | ui->listWidget->addItem(output);
61 | }
62 |
63 | {
64 | QString output = QString::fromStdString(rsPeers->getPeerName(peer_id));
65 | output+=": ";
66 | output+=str;
67 | ui->netLogWidget->addItem(output);
68 | }
69 | }
70 | void NetExampleMainpage::NePaintArrived(const RsPeerId &peer_id, int x, int y)
71 | {
72 |
73 | std::cout << "GUI got Paint from: " << peer_id;
74 | std::cout << std::endl;
75 |
76 | ui->paintWidget->paintAt(x,y);
77 | }
78 |
79 | void NetExampleMainpage::on_broadcastButton_clicked()
80 | {
81 | rsNetExample->msg_all(ui->msgInput->text().toStdString());
82 | NeMsgArrived(rsPeers->getOwnId(),ui->msgInput->text());
83 | ui->msgInput->clear();
84 | }
85 |
--------------------------------------------------------------------------------
/NetExamplePlugin.h:
--------------------------------------------------------------------------------
1 | /* this is the central part of the plugin */
2 | /****************************************************************
3 | * RetroShare is distributed under the following license:
4 | *
5 | * Copyright (C) 2015
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., 51 Franklin Street, Fifth Floor,
20 | * Boston, MA 02110-1301, USA.
21 | ****************************************************************/
22 | #pragma once
23 |
24 | /*NetExample*/
25 | #include "services/p3NetExample.h"
26 |
27 | /*libretroshare"*/
28 | #include
29 |
30 | #include "gui/NetExampleMainpage.h"
31 |
32 | class NetExampleGUIHandler ;
33 | class NetExampleNotify ;
34 |
35 | class NetExamplePlugin: public RsPlugin
36 | {
37 | public:
38 | NetExamplePlugin() ;
39 | virtual ~NetExamplePlugin() {}
40 |
41 | virtual p3Service *p3_service() const ;
42 | virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_NetExample_PLUGIN ; }
43 | //virtual ConfigPage *qt_config_page() const ;
44 | virtual QDialog *qt_about_page() const ;
45 | //virtual ChatWidgetHolder *qt_get_chat_widget_holder(ChatWidget *chatWidget) const ;
46 |
47 | virtual QIcon *qt_icon() const;
48 | virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode, const QString& externalDir) const;
49 | virtual void qt_sound_events(SoundEvents &events) const;
50 |
51 | virtual void getPluginVersion(int& major, int& minor, int &build, int& svn_rev) const ;
52 | virtual void setPlugInHandler(RsPluginHandler *pgHandler);
53 |
54 | virtual std::string configurationFileName() const { return "NetExample.cfg" ; }
55 |
56 | virtual std::string getShortPluginDescription() const ;
57 | virtual std::string getPluginName() const;
58 | virtual void setInterfaces(RsPlugInInterfaces& interfaces);
59 |
60 | //================================== RsPlugin Notify ==================================//
61 | //virtual ToasterNotify *qt_toasterNotify();
62 |
63 | virtual MainPage *qt_page() const ;
64 |
65 | private:
66 | mutable p3NetExample *mNetExample ;
67 | mutable RsPluginHandler *mPlugInHandler;
68 | mutable RsPeers* mPeers;
69 | mutable ConfigPage *config_page ;
70 | mutable QIcon *mIcon;
71 | mutable MainPage* mainpage ;
72 |
73 | NetExampleNotify *mNetExampleNotify ;
74 | NetExampleGUIHandler *mNetExampleGUIHandler ;
75 | };
76 |
77 |
--------------------------------------------------------------------------------
/services/p3NetExample.h:
--------------------------------------------------------------------------------
1 | /* this handles the networking service of this plugin */
2 | /****************************************************************
3 | * RetroShare is distributed under the following license:
4 | *
5 | * Copyright (C) 2015
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., 51 Franklin Street, Fifth Floor,
20 | * Boston, MA 02110-1301, USA.
21 | ****************************************************************/
22 |
23 | #pragma once
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | #include "services/rsNetExampleItems.h"
30 | #include "services/p3service.h"
31 | #include "serialiser/rstlvbase.h"
32 | #include "serialiser/rsconfigitems.h"
33 | #include "plugins/rspqiservice.h"
34 | #include
35 |
36 | class p3LinkMgr;
37 | class NetExampleNotify ;
38 |
39 |
40 |
41 | //!The RS NetExample service.
42 | /**
43 | *
44 | * This is sends data to friends.
45 | */
46 |
47 | class p3NetExample: public RsPQIService, public RsNetExample
48 | // Maybe we inherit from these later - but not needed for now.
49 | //, public p3Config, public pqiMonitor
50 | {
51 | public:
52 | p3NetExample(RsPluginHandler *cm,NetExampleNotify *);
53 |
54 | /***** overloaded from rsNetExample *****/
55 |
56 |
57 | /***** overloaded from p3Service *****/
58 | /*!
59 | * This retrieves all chat msg items and also (important!)
60 | * processes chat-status items that are in service item queue. chat msg item requests are also processed and not returned
61 | * (important! also) notifications sent to notify base on receipt avatar, immediate status and custom status
62 | * : notifyCustomState, notifyChatStatus, notifyPeerHasNewAvatar
63 | * @see NotifyBase
64 | */
65 | virtual int tick();
66 | virtual int status();
67 | virtual bool recvItem(RsItem *item);
68 |
69 | /*************** pqiMonitor callback ***********************/
70 | //virtual void statusChange(const std::list &plist);
71 |
72 |
73 | /************* from p3Config *******************/
74 | virtual RsSerialiser *setupSerialiser() ;
75 |
76 | /*!
77 | * chat msg items and custom status are saved
78 | */
79 | virtual bool saveList(bool& cleanup, std::list&) ;
80 | virtual bool loadList(std::list& load) ;
81 | virtual std::string configurationFileName() const { return "NetExample.cfg" ; }
82 |
83 | virtual RsServiceInfo getServiceInfo() ;
84 |
85 | void ping_all();
86 |
87 | void broadcast_paint(int x, int y);
88 | void msg_all(std::string msg);
89 | void str_msg_peer(RsPeerId peerID, QString strdata);
90 | void raw_msg_peer(RsPeerId peerID, std::string msg);
91 | void qvm_msg_peer(RsPeerId peerID, QVariantMap data);
92 | private:
93 |
94 |
95 |
96 | void handleData(RsNetExampleDataItem*) ;
97 |
98 | RsMutex mNetExampleMtx;
99 |
100 |
101 | static RsTlvKeyValue push_int_value(const std::string& key,int value) ;
102 | static int pop_int_value(const std::string& s) ;
103 |
104 |
105 | RsServiceControl *mServiceControl;
106 | NetExampleNotify *mNotify ;
107 |
108 | };
109 |
--------------------------------------------------------------------------------
/services/rsNetExampleItems.h:
--------------------------------------------------------------------------------
1 | /* this describes the datatypes sent over the network, and how to (de)serialise them */
2 | /****************************************************************
3 | * RetroShare is distributed under the following license:
4 | *
5 | * Copyright (C) 2015
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., 51 Franklin Street, Fifth Floor,
20 | * Boston, MA 02110-1301, USA.
21 | ****************************************************************/
22 |
23 | #pragma once
24 |
25 | /*
26 | * libretroshare/src/serialiser: rsNetExampleItems.h
27 | *
28 | * RetroShare Serialiser.
29 | *
30 | * Copyright 2011 by Robert Fernie.
31 | *
32 | * This library is free software; you can redistribute it and/or
33 | * modify it under the terms of the GNU Library General Public
34 | * License Version 2 as published by the Free Software Foundation.
35 | *
36 | * This library is distributed in the hope that it will be useful,
37 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
38 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 | * Library General Public License for more details.
40 | *
41 | * You should have received a copy of the GNU Library General Public
42 | * License along with this library; if not, write to the Free Software
43 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
44 | * USA.
45 | *
46 | * Please report all bugs and problems to "retroshare@lunamutt.com".
47 | *
48 | */
49 |
50 | #include