mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 03:49:29 -04:00
added communitation between service and GUI part of VOIP plugin.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4990 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
12b3ed02f1
commit
db07053214
9 changed files with 107 additions and 7 deletions
|
@ -17,6 +17,8 @@ SOURCES = services/p3vors.cc \
|
||||||
gui/audiodevicehelper.cpp \
|
gui/audiodevicehelper.cpp \
|
||||||
gui/VoipStatistics.cpp \
|
gui/VoipStatistics.cpp \
|
||||||
gui/AudioPopupChatDialog.cpp \
|
gui/AudioPopupChatDialog.cpp \
|
||||||
|
gui/PluginGUIHandler.cpp \
|
||||||
|
gui/PluginNotifier.cpp \
|
||||||
VOIPPlugin.cpp
|
VOIPPlugin.cpp
|
||||||
|
|
||||||
HEADERS = services/p3vors.h \
|
HEADERS = services/p3vors.h \
|
||||||
|
@ -28,6 +30,8 @@ HEADERS = services/p3vors.h \
|
||||||
gui/audiodevicehelper.h \
|
gui/audiodevicehelper.h \
|
||||||
gui/VoipStatistics.h \
|
gui/VoipStatistics.h \
|
||||||
gui/AudioPopupChatDialog.h \
|
gui/AudioPopupChatDialog.h \
|
||||||
|
gui/PluginGUIHandler.h \
|
||||||
|
gui/PluginNotifier.h \
|
||||||
interface/rsvoip.h
|
interface/rsvoip.h
|
||||||
|
|
||||||
FORMS = gui/AudioInputConfig.ui \
|
FORMS = gui/AudioInputConfig.ui \
|
||||||
|
|
|
@ -10,10 +10,18 @@
|
||||||
#include "gui/VoipStatistics.h"
|
#include "gui/VoipStatistics.h"
|
||||||
#include "gui/AudioInputConfig.h"
|
#include "gui/AudioInputConfig.h"
|
||||||
#include "gui/AudioPopupChatDialog.h"
|
#include "gui/AudioPopupChatDialog.h"
|
||||||
|
#include "gui/PluginGUIHandler.h"
|
||||||
|
#include "gui/PluginNotifier.h"
|
||||||
|
|
||||||
static void *inited = new VOIPPlugin() ;
|
static void *inited = new VOIPPlugin() ;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
// This is *the* function 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()
|
void *RETROSHARE_PLUGIN_provide()
|
||||||
{
|
{
|
||||||
static VOIPPlugin *p = new VOIPPlugin() ;
|
static VOIPPlugin *p = new VOIPPlugin() ;
|
||||||
|
@ -35,6 +43,12 @@ VOIPPlugin::VOIPPlugin()
|
||||||
mPlugInHandler = NULL;
|
mPlugInHandler = NULL;
|
||||||
mPeers = NULL;
|
mPeers = NULL;
|
||||||
config_page = NULL ;
|
config_page = NULL ;
|
||||||
|
|
||||||
|
mPluginGUIHandler = new PluginGUIHandler ;
|
||||||
|
mPluginNotifier = new PluginNotifier ;
|
||||||
|
|
||||||
|
QObject::connect(mPluginNotifier,SIGNAL(voipInvitationReceived(const QString&)),mPluginGUIHandler,SLOT(ReceivedInvitation(const QString&)),Qt::QueuedConnection) ;
|
||||||
|
QObject::connect(mPluginNotifier,SIGNAL(voipDataReceived(const QString&)),mPluginGUIHandler,SLOT(ReceivedVoipData(const QString&)),Qt::QueuedConnection) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VOIPPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
void VOIPPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||||
|
@ -65,7 +79,7 @@ RsPQIService *VOIPPlugin::rs_pqi_service() const
|
||||||
{
|
{
|
||||||
if(mVoip == NULL)
|
if(mVoip == NULL)
|
||||||
{
|
{
|
||||||
mVoip = new p3VoRS(mPlugInHandler) ; // , 3600 * 24 * 30 * 6); // 6 Months
|
mVoip = new p3VoRS(mPlugInHandler,mPluginNotifier) ; // , 3600 * 24 * 30 * 6); // 6 Months
|
||||||
rsVoip = mVoip ;
|
rsVoip = mVoip ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
#include <retroshare/rsplugin.h>
|
#include <retroshare/rsplugin.h>
|
||||||
#include "services/p3vors.h"
|
#include "services/p3vors.h"
|
||||||
|
|
||||||
|
class PluginGUIHandler ;
|
||||||
|
class PluginNotifier ;
|
||||||
|
|
||||||
class VOIPPlugin: public RsPlugin
|
class VOIPPlugin: public RsPlugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -32,5 +35,8 @@ class VOIPPlugin: public RsPlugin
|
||||||
mutable RsPluginHandler *mPlugInHandler;
|
mutable RsPluginHandler *mPlugInHandler;
|
||||||
mutable RsPeers* mPeers;
|
mutable RsPeers* mPeers;
|
||||||
mutable ConfigPage *config_page ;
|
mutable ConfigPage *config_page ;
|
||||||
|
|
||||||
|
PluginNotifier *mPluginNotifier ;
|
||||||
|
PluginGUIHandler *mPluginGUIHandler ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
13
plugins/VOIP/gui/PluginGUIHandler.cpp
Normal file
13
plugins/VOIP/gui/PluginGUIHandler.cpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include "PluginGUIHandler.h"
|
||||||
|
|
||||||
|
void PluginGUIHandler::ReceivedInvitation(const QString& peer_id)
|
||||||
|
{
|
||||||
|
std::cerr << "****** Plugin GUI handler: received data!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginGUIHandler::ReceivedVoipData(const QString& peer_id)
|
||||||
|
{
|
||||||
|
std::cerr << "****** Plugin GUI handler: received invitation!" << std::endl;
|
||||||
|
}
|
||||||
|
|
17
plugins/VOIP/gui/PluginGUIHandler.h
Normal file
17
plugins/VOIP/gui/PluginGUIHandler.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// This class receives async-ed signals from the plugin notifier,
|
||||||
|
// and executes GUI requests.
|
||||||
|
//
|
||||||
|
// It is never called directly: it is called by Qt signal-received callback,
|
||||||
|
// in the main GUI thread.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class PluginGUIHandler: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ReceivedInvitation(const QString& peer_id) ;
|
||||||
|
void ReceivedVoipData(const QString& peer_id) ;
|
||||||
|
};
|
10
plugins/VOIP/gui/PluginNotifier.cpp
Normal file
10
plugins/VOIP/gui/PluginNotifier.cpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#include "PluginNotifier.h"
|
||||||
|
|
||||||
|
void PluginNotifier::notifyReceivedVoipInvite(const std::string& peer_id)
|
||||||
|
{
|
||||||
|
emit voipInvitationReceived(QString::fromStdString(peer_id)) ;
|
||||||
|
}
|
||||||
|
void PluginNotifier::notifyReceivedVoipData(const std::string& peer_id)
|
||||||
|
{
|
||||||
|
emit voipDataReceived(QString::fromStdString(peer_id)) ;
|
||||||
|
}
|
21
plugins/VOIP/gui/PluginNotifier.h
Normal file
21
plugins/VOIP/gui/PluginNotifier.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// This class is a Qt object to get notification from the plugin's service threads,
|
||||||
|
// and responsible to pass the info the the GUI part.
|
||||||
|
//
|
||||||
|
// Because the GUI part is async-ed with the service, it is crucial to use the
|
||||||
|
// QObject connect system to communicate between the p3Service and the gui part (handled by Qt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class PluginNotifier: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void notifyReceivedVoipData(const std::string& peer_id) ;
|
||||||
|
void notifyReceivedVoipInvite(const std::string& peer_id) ;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void voipInvitationReceived(const QString&) ; // signal emitted when an invitation has been received
|
||||||
|
void voipDataReceived(const QString&) ; // signal emitted when some voip data has been received
|
||||||
|
};
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include "services/p3vors.h"
|
#include "services/p3vors.h"
|
||||||
#include "services/rsvoipitems.h"
|
#include "services/rsvoipitems.h"
|
||||||
|
#include "gui/PluginNotifier.h"
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
@ -142,8 +143,8 @@ static double convert64bitsToTs(uint64_t bits)
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
p3VoRS::p3VoRS(RsPluginHandler *handler)
|
p3VoRS::p3VoRS(RsPluginHandler *handler,PluginNotifier *notifier)
|
||||||
: RsPQIService(RS_SERVICE_TYPE_VOIP_PLUGIN,CONFIG_TYPE_VOIP_PLUGIN,0,handler), mVorsMtx("p3VoRS"), mLinkMgr(handler->getLinkMgr())
|
: RsPQIService(RS_SERVICE_TYPE_VOIP_PLUGIN,CONFIG_TYPE_VOIP_PLUGIN,0,handler), mVorsMtx("p3VoRS"), mLinkMgr(handler->getLinkMgr()) , mNotify(notifier)
|
||||||
{
|
{
|
||||||
addSerialType(new RsVoipSerialiser());
|
addSerialType(new RsVoipSerialiser());
|
||||||
|
|
||||||
|
@ -301,7 +302,19 @@ void p3VoRS::handleProtocol(RsVoipProtocolItem *item)
|
||||||
|
|
||||||
// we notify the notifier that something occurred.
|
// we notify the notifier that something occurred.
|
||||||
|
|
||||||
// mNotify->notifyPluginAction(mPluginId, PluginSignalId, (void *)data_to_send_upward);
|
switch(item->protocol)
|
||||||
|
{
|
||||||
|
case RsVoipProtocolItem::VoipProtocol_Ring: std::cerr << "Received protocol ring item." << std::endl;
|
||||||
|
mNotify->notifyReceivedVoipInvite(item->PeerId());
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case RsVoipProtocolItem::VoipProtocol_Ackn:
|
||||||
|
case RsVoipProtocolItem::VoipProtocol_Close:
|
||||||
|
default:
|
||||||
|
std::cerr << "Received protocol item # " << item->protocol << ": not handled yet ! Sorry" << std::endl;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3VoRS::handleData(RsVoipDataItem *item)
|
void p3VoRS::handleData(RsVoipDataItem *item)
|
||||||
|
@ -321,7 +334,7 @@ void p3VoRS::handleData(RsVoipDataItem *item)
|
||||||
{
|
{
|
||||||
it->second.incoming_queue.push_back(item) ; // be careful with the delete action!
|
it->second.incoming_queue.push_back(item) ; // be careful with the delete action!
|
||||||
|
|
||||||
// notify->notifyPluginAction(mPluginId, PluginSignalId, (void *)data_to_send_upward);
|
mNotify->notifyReceivedVoipData(item->PeerId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <interface/rsvoip.h>
|
#include <interface/rsvoip.h>
|
||||||
|
|
||||||
class p3LinkMgr;
|
class p3LinkMgr;
|
||||||
|
class PluginNotifier ;
|
||||||
|
|
||||||
class VorsPeerInfo
|
class VorsPeerInfo
|
||||||
{
|
{
|
||||||
|
@ -67,7 +68,7 @@ class p3VoRS: public RsPQIService, public RsVoip
|
||||||
//, public p3Config, public pqiMonitor
|
//, public p3Config, public pqiMonitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
p3VoRS(RsPluginHandler *cm);
|
p3VoRS(RsPluginHandler *cm,PluginNotifier *);
|
||||||
|
|
||||||
/***** overloaded from rsVoip *****/
|
/***** overloaded from rsVoip *****/
|
||||||
|
|
||||||
|
@ -152,6 +153,7 @@ class p3VoRS: public RsPQIService, public RsVoip
|
||||||
uint32_t mCounter;
|
uint32_t mCounter;
|
||||||
|
|
||||||
p3LinkMgr *mLinkMgr;
|
p3LinkMgr *mLinkMgr;
|
||||||
|
PluginNotifier *mNotify ;
|
||||||
|
|
||||||
int _atransmit ;
|
int _atransmit ;
|
||||||
int _voice_hold ;
|
int _voice_hold ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue