2012-02-18 10:56:37 -05:00
|
|
|
#include <retroshare/rsplugin.h>
|
2015-01-14 18:26:51 -05:00
|
|
|
#include <retroshare/rsversion.h>
|
2012-02-21 16:53:25 -05:00
|
|
|
#include <retroshare-gui/RsAutoUpdatePage.h>
|
2012-02-18 10:56:37 -05:00
|
|
|
#include <QTranslator>
|
|
|
|
#include <QApplication>
|
2012-02-21 16:53:25 -05:00
|
|
|
#include <QString>
|
2012-08-15 09:54:00 -04:00
|
|
|
#include <QIcon>
|
2013-10-19 20:56:34 -04:00
|
|
|
#include <QMessageBox>
|
2012-02-18 10:56:37 -05:00
|
|
|
|
|
|
|
#include "VOIPPlugin.h"
|
2012-02-19 10:07:47 -05:00
|
|
|
#include "interface/rsvoip.h"
|
2012-02-21 16:53:25 -05:00
|
|
|
|
2012-02-19 10:07:47 -05:00
|
|
|
#include "gui/AudioInputConfig.h"
|
2014-07-13 09:57:25 -04:00
|
|
|
#include "gui/VOIPChatWidgetHolder.h"
|
2012-02-25 13:15:36 -05:00
|
|
|
#include "gui/PluginGUIHandler.h"
|
|
|
|
#include "gui/PluginNotifier.h"
|
2012-10-21 17:38:55 -04:00
|
|
|
#include "gui/SoundManager.h"
|
2014-01-01 19:56:46 -05:00
|
|
|
#include "gui/chat/ChatWidget.h"
|
2012-02-18 10:56:37 -05:00
|
|
|
|
2012-08-15 09:54:00 -04:00
|
|
|
#define IMAGE_VOIP ":/images/talking_on.svg"
|
|
|
|
|
2012-02-18 15:30:10 -05:00
|
|
|
static void *inited = new VOIPPlugin() ;
|
2012-02-18 10:56:37 -05:00
|
|
|
|
|
|
|
extern "C" {
|
2012-02-25 13:15:36 -05:00
|
|
|
|
2012-09-04 17:57:10 -04:00
|
|
|
// This is *the* functions required by RS plugin system to give RS access to the plugin.
|
2012-02-25 13:15:36 -05:00
|
|
|
// Be careful to:
|
|
|
|
// - always respect the C linkage convention
|
|
|
|
// - always return an object of type RsPlugin*
|
|
|
|
//
|
2012-02-18 10:56:37 -05:00
|
|
|
void *RETROSHARE_PLUGIN_provide()
|
|
|
|
{
|
|
|
|
static VOIPPlugin *p = new VOIPPlugin() ;
|
|
|
|
|
|
|
|
return (void*)p ;
|
|
|
|
}
|
2012-09-04 17:57:10 -04:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
//
|
2015-01-14 18:26:51 -05:00
|
|
|
uint32_t RETROSHARE_PLUGIN_revision = RS_REVISION_NUMBER ;
|
2012-09-09 09:59:21 -04:00
|
|
|
|
|
|
|
// 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 ;
|
2012-02-18 10:56:37 -05:00
|
|
|
}
|
|
|
|
|
2015-01-14 18:26:51 -05:00
|
|
|
void VOIPPlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_rev) const
|
2012-02-18 10:56:37 -05:00
|
|
|
{
|
2015-01-14 18:26:51 -05:00
|
|
|
major = RS_MAJOR_VERSION ;
|
|
|
|
minor = RS_MINOR_VERSION ;
|
|
|
|
build = RS_BUILD_NUMBER ;
|
|
|
|
svn_rev = RS_REVISION_NUMBER ;
|
2012-02-18 10:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VOIPPlugin::VOIPPlugin()
|
|
|
|
{
|
|
|
|
mVoip = NULL ;
|
|
|
|
mPlugInHandler = NULL;
|
|
|
|
mPeers = NULL;
|
2012-02-18 15:30:10 -05:00
|
|
|
config_page = NULL ;
|
2012-08-15 09:54:00 -04:00
|
|
|
mIcon = NULL ;
|
2012-02-25 13:15:36 -05:00
|
|
|
|
|
|
|
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) ;
|
2012-02-26 10:49:07 -05:00
|
|
|
QObject::connect(mPluginNotifier,SIGNAL(voipAcceptReceived(const QString&)),mPluginGUIHandler,SLOT(ReceivedVoipAccept(const QString&)),Qt::QueuedConnection) ;
|
|
|
|
QObject::connect(mPluginNotifier,SIGNAL(voipHangUpReceived(const QString&)),mPluginGUIHandler,SLOT(ReceivedVoipHangUp(const QString&)),Qt::QueuedConnection) ;
|
2014-07-20 16:50:36 -04:00
|
|
|
QObject::connect(mPluginNotifier,SIGNAL(voipBandwidthInfoReceived(const QString&,int)),mPluginGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const QString&,int)),Qt::QueuedConnection) ;
|
2012-02-18 10:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void VOIPPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
|
|
|
{
|
|
|
|
mPeers = interfaces.mPeers;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigPage *VOIPPlugin::qt_config_page() const
|
|
|
|
{
|
2014-07-13 09:57:25 -04:00
|
|
|
// The config pages are deleted when config is closed, so it's important not to static the
|
|
|
|
// created object.
|
|
|
|
//
|
2012-02-19 10:07:47 -05:00
|
|
|
return new AudioInputConfig() ;
|
2012-02-18 10:56:37 -05:00
|
|
|
}
|
|
|
|
|
2012-09-04 17:57:10 -04:00
|
|
|
QDialog *VOIPPlugin::qt_about_page() const
|
|
|
|
{
|
|
|
|
static QMessageBox *about_dialog = NULL ;
|
|
|
|
|
|
|
|
if(about_dialog == NULL)
|
|
|
|
{
|
|
|
|
about_dialog = new QMessageBox() ;
|
|
|
|
|
|
|
|
QString text ;
|
|
|
|
text += QObject::tr("<h3>RetroShare VOIP plugin</h3><br/> * Contributors: Cyril Soler, Josselin Jacquard<br/>") ;
|
|
|
|
text += QObject::tr("<br/>The VOIP plugin adds VOIP to the private chat window of RetroShare. to use it, proceed as follows:<UL>") ;
|
|
|
|
text += QObject::tr("<li> setup microphone levels using the configuration panel</li>") ;
|
|
|
|
text += QObject::tr("<li> check your microphone by looking at the VU-metters</li>") ;
|
|
|
|
text += QObject::tr("<li> in the private chat, enable sound input/output by clicking on the two VOIP icons</li></ul>") ;
|
|
|
|
text += QObject::tr("Your friend needs to run the plugin to talk/listen to you, or course.") ;
|
|
|
|
text += QObject::tr("<br/><br/>This is an experimental feature. Don't hesitate to send comments and suggestion to the RS dev team.") ;
|
|
|
|
|
|
|
|
about_dialog->setText(text) ;
|
|
|
|
about_dialog->setStandardButtons(QMessageBox::Ok) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
return about_dialog ;
|
|
|
|
}
|
|
|
|
|
2014-01-01 19:56:46 -05:00
|
|
|
ChatWidgetHolder *VOIPPlugin::qt_get_chat_widget_holder(ChatWidget *chatWidget) const
|
2012-02-25 07:18:40 -05:00
|
|
|
{
|
2014-01-01 19:56:46 -05:00
|
|
|
switch (chatWidget->chatType()) {
|
|
|
|
case ChatWidget::CHATTYPE_PRIVATE:
|
2014-07-13 09:57:25 -04:00
|
|
|
return new VOIPChatWidgetHolder(chatWidget);
|
2014-01-01 19:56:46 -05:00
|
|
|
case ChatWidget::CHATTYPE_UNKNOWN:
|
|
|
|
case ChatWidget::CHATTYPE_LOBBY:
|
|
|
|
case ChatWidget::CHATTYPE_DISTANT:
|
|
|
|
break;
|
|
|
|
}
|
2012-02-25 16:03:06 -05:00
|
|
|
|
2014-01-01 19:56:46 -05:00
|
|
|
return NULL;
|
2012-02-25 07:18:40 -05:00
|
|
|
}
|
|
|
|
|
2014-08-26 18:16:32 -04:00
|
|
|
p3Service *VOIPPlugin::p3_service() const
|
2012-02-18 10:56:37 -05:00
|
|
|
{
|
2014-04-20 10:21:53 -04:00
|
|
|
if(mVoip == NULL)
|
|
|
|
rsVoip = mVoip = new p3VoRS(mPlugInHandler,mPluginNotifier) ; // , 3600 * 24 * 30 * 6); // 6 Months
|
2012-02-18 10:56:37 -05:00
|
|
|
|
|
|
|
return mVoip ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VOIPPlugin::setPlugInHandler(RsPluginHandler *pgHandler)
|
|
|
|
{
|
|
|
|
mPlugInHandler = pgHandler;
|
|
|
|
}
|
|
|
|
|
2012-08-15 09:54:00 -04:00
|
|
|
QIcon *VOIPPlugin::qt_icon() const
|
|
|
|
{
|
|
|
|
if (mIcon == NULL) {
|
|
|
|
Q_INIT_RESOURCE(VOIP_images);
|
|
|
|
|
|
|
|
mIcon = new QIcon(IMAGE_VOIP);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mIcon;
|
|
|
|
}
|
|
|
|
|
2012-02-18 10:56:37 -05:00
|
|
|
std::string VOIPPlugin::getShortPluginDescription() const
|
|
|
|
{
|
|
|
|
return QApplication::translate("VOIP", "This plugin provides voice communication between friends in RetroShare.").toUtf8().constData();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string VOIPPlugin::getPluginName() const
|
|
|
|
{
|
|
|
|
return QApplication::translate("VOIPPlugin", "VOIP").toUtf8().constData();
|
|
|
|
}
|
|
|
|
|
2012-10-12 14:44:02 -04:00
|
|
|
QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& languageCode, const QString& externalDir) const
|
2012-02-18 10:56:37 -05:00
|
|
|
{
|
|
|
|
if (languageCode == "en") {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-07-15 17:37:35 -04:00
|
|
|
QTranslator* translator = new QTranslator();
|
2012-10-11 19:46:54 -04:00
|
|
|
|
2012-10-12 14:44:02 -04:00
|
|
|
if (translator->load(externalDir + "/VOIP_" + languageCode + ".qm")) {
|
2012-10-11 19:46:54 -04:00
|
|
|
return translator;
|
|
|
|
} else if (translator->load(":/lang/VOIP_" + languageCode + ".qm")) {
|
2012-02-18 10:56:37 -05:00
|
|
|
return translator;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete(translator);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-10-21 17:38:55 -04:00
|
|
|
void VOIPPlugin::qt_sound_events(SoundEvents &/*events*/) const
|
|
|
|
{
|
|
|
|
// events.addEvent(QApplication::translate("VOIP", "VOIP"), QApplication::translate("VOIP", "Incoming call"), VOIP_SOUND_INCOMING_CALL);
|
|
|
|
}
|