mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-04 22:33:12 -05:00
Modified the patch from electron.
Moved the calls to the plugin to ChatWidget for use with all types of chats (private chat, chat lobby and distant chat). Recompile needed git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6980 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7b0a6afa56
commit
92fabf4c56
15 changed files with 222 additions and 237 deletions
|
|
@ -32,7 +32,7 @@ SOURCES = services/p3vors.cc \
|
|||
gui/SpeexProcessor.cpp \
|
||||
gui/audiodevicehelper.cpp \
|
||||
gui/VoipStatistics.cpp \
|
||||
gui/AudioPopupChatDialog.cpp \
|
||||
gui/AudioChatWidgetHolder.cpp \
|
||||
gui/PluginGUIHandler.cpp \
|
||||
gui/PluginNotifier.cpp \
|
||||
VOIPPlugin.cpp
|
||||
|
|
@ -45,7 +45,7 @@ HEADERS = services/p3vors.h \
|
|||
gui/SpeexProcessor.h \
|
||||
gui/audiodevicehelper.h \
|
||||
gui/VoipStatistics.h \
|
||||
gui/AudioPopupChatDialog.h \
|
||||
gui/AudioChatWidgetHolder.h \
|
||||
gui/PluginGUIHandler.h \
|
||||
gui/PluginNotifier.h \
|
||||
interface/rsvoip.h \
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@
|
|||
|
||||
#include "gui/VoipStatistics.h"
|
||||
#include "gui/AudioInputConfig.h"
|
||||
#include "gui/AudioPopupChatDialog.h"
|
||||
#include "gui/AudioChatWidgetHolder.h"
|
||||
#include "gui/PluginGUIHandler.h"
|
||||
#include "gui/PluginNotifier.h"
|
||||
#include "gui/SoundManager.h"
|
||||
#include "gui/chat/ChatWidget.h"
|
||||
|
||||
#define IMAGE_VOIP ":/images/talking_on.svg"
|
||||
|
||||
|
|
@ -106,17 +107,25 @@ QDialog *VOIPPlugin::qt_about_page() const
|
|||
return about_dialog ;
|
||||
}
|
||||
|
||||
PopupChatDialog_WidgetsHolder *VOIPPlugin::qt_allocate_new_popup_chat_dialog_widgets() const
|
||||
ChatWidgetHolder *VOIPPlugin::qt_get_chat_widget_holder(ChatWidget *chatWidget) const
|
||||
{
|
||||
AudioPopupChatDialogWidgetsHolder *ap = new AudioPopupChatDialogWidgetsHolder() ;
|
||||
switch (chatWidget->chatType()) {
|
||||
case ChatWidget::CHATTYPE_PRIVATE:
|
||||
return new AudioChatWidgetHolder(chatWidget);
|
||||
case ChatWidget::CHATTYPE_UNKNOWN:
|
||||
case ChatWidget::CHATTYPE_LOBBY:
|
||||
case ChatWidget::CHATTYPE_DISTANT:
|
||||
break;
|
||||
}
|
||||
|
||||
return ap ;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string VOIPPlugin::qt_transfers_tab_name() const
|
||||
{
|
||||
return QObject::tr("RTT Statistics").toUtf8().constData() ;
|
||||
}
|
||||
|
||||
RsAutoUpdatePage *VOIPPlugin::qt_transfers_tab() const
|
||||
{
|
||||
return new VoipStatistics ;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class VOIPPlugin: public RsPlugin
|
|||
virtual QDialog *qt_about_page() const ;
|
||||
virtual RsAutoUpdatePage *qt_transfers_tab() const ;
|
||||
virtual std::string qt_transfers_tab_name() const ;
|
||||
virtual PopupChatDialog_WidgetsHolder *qt_allocate_new_popup_chat_dialog_widgets() const ;
|
||||
virtual ChatWidgetHolder *qt_get_chat_widget_holder(ChatWidget *chatWidget) const ;
|
||||
|
||||
virtual QIcon *qt_icon() const;
|
||||
virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode, const QString& externalDir) const;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
#include <QToolButton>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QIcon>
|
||||
#include "AudioPopupChatDialog.h"
|
||||
|
||||
#include "AudioChatWidgetHolder.h"
|
||||
#include <gui/audiodevicehelper.h>
|
||||
#include "interface/rsvoip.h"
|
||||
#include "gui/SoundManager.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/chat/ChatWidget.h"
|
||||
|
||||
#include <retroshare/rsstatus.h>
|
||||
|
||||
#define CALL_START ":/images/call-start-22.png"
|
||||
|
|
@ -13,7 +17,8 @@
|
|||
#define CALL_HOLD ":/images/call-hold-22.png"
|
||||
|
||||
|
||||
AudioPopupChatDialogWidgetsHolder::AudioPopupChatDialogWidgetsHolder()
|
||||
AudioChatWidgetHolder::AudioChatWidgetHolder(ChatWidget *chatWidget)
|
||||
: QObject(), ChatWidgetHolder(chatWidget)
|
||||
{
|
||||
audioListenToggleButton = new QToolButton ;
|
||||
audioListenToggleButton->setMinimumSize(QSize(28,28)) ;
|
||||
|
|
@ -21,7 +26,7 @@ AudioPopupChatDialogWidgetsHolder::AudioPopupChatDialogWidgetsHolder()
|
|||
audioListenToggleButton->setText(QString()) ;
|
||||
audioListenToggleButton->setToolTip(tr("Mute yourself"));
|
||||
|
||||
std::cerr << "****** VOIPLugin: Creating new AudioPopupChatDialog !!" << std::endl;
|
||||
std::cerr << "****** VOIPLugin: Creating new AudioChatWidgetHolder !!" << std::endl;
|
||||
|
||||
QIcon icon ;
|
||||
icon.addPixmap(QPixmap(":/images/audio-volume-muted-22.png")) ;
|
||||
|
|
@ -67,28 +72,23 @@ AudioPopupChatDialogWidgetsHolder::AudioPopupChatDialogWidgetsHolder()
|
|||
connect(audioMuteCaptureToggleButton, SIGNAL(clicked()), this , SLOT(toggleAudioMuteCapture()));
|
||||
connect(hangupButton, SIGNAL(clicked()), this , SLOT(hangupCall()));
|
||||
|
||||
mChatWidget->addChatBarWidget(audioListenToggleButton) ;
|
||||
mChatWidget->addChatBarWidget(audioMuteCaptureToggleButton) ;
|
||||
mChatWidget->addChatBarWidget(hangupButton) ;
|
||||
|
||||
outputProcessor = NULL ;
|
||||
outputDevice = NULL ;
|
||||
inputProcessor = NULL ;
|
||||
inputDevice = NULL ;
|
||||
}
|
||||
|
||||
void AudioPopupChatDialogWidgetsHolder::init(const std::string &peerId, const QString &title, ChatWidget* chatWidget)
|
||||
AudioChatWidgetHolder::~AudioChatWidgetHolder()
|
||||
{
|
||||
this->peerId = peerId;
|
||||
this->chatWidget = chatWidget;
|
||||
if(inputDevice != NULL)
|
||||
inputDevice->stop() ;
|
||||
}
|
||||
|
||||
std::vector<QWidget*> AudioPopupChatDialogWidgetsHolder::getWidgets()
|
||||
{
|
||||
std::vector<QWidget*> v;
|
||||
v.push_back(audioListenToggleButton);
|
||||
v.push_back(audioMuteCaptureToggleButton);
|
||||
v.push_back(hangupButton);
|
||||
return v;
|
||||
}
|
||||
|
||||
void AudioPopupChatDialogWidgetsHolder::toggleAudioListen()
|
||||
void AudioChatWidgetHolder::toggleAudioListen()
|
||||
{
|
||||
std::cerr << "******** VOIPLugin: Toggling audio listen!" << std::endl;
|
||||
if (audioListenToggleButton->isChecked()) {
|
||||
|
|
@ -102,7 +102,7 @@ void AudioPopupChatDialogWidgetsHolder::toggleAudioListen()
|
|||
}
|
||||
}
|
||||
|
||||
void AudioPopupChatDialogWidgetsHolder::hangupCall()
|
||||
void AudioChatWidgetHolder::hangupCall()
|
||||
{
|
||||
std::cerr << "******** VOIPLugin: Hangup call!" << std::endl;
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ void AudioPopupChatDialogWidgetsHolder::hangupCall()
|
|||
audioMuteCaptureToggleButton->setChecked(false);
|
||||
}
|
||||
|
||||
void AudioPopupChatDialogWidgetsHolder::toggleAudioMuteCapture()
|
||||
void AudioChatWidgetHolder::toggleAudioMuteCapture()
|
||||
{
|
||||
std::cerr << "******** VOIPLugin: Toggling audio mute capture!" << std::endl;
|
||||
if (audioMuteCaptureToggleButton->isChecked()) {
|
||||
|
|
@ -139,8 +139,8 @@ void AudioPopupChatDialogWidgetsHolder::toggleAudioMuteCapture()
|
|||
connect(inputProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
|
||||
inputDevice->start(inputProcessor);
|
||||
|
||||
if (chatWidget) {
|
||||
chatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Call is started..."), ChatWidget::TYPE_SYSTEM);
|
||||
if (mChatWidget) {
|
||||
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Call is started..."), ChatWidget::MSGTYPE_SYSTEM);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -149,13 +149,10 @@ void AudioPopupChatDialogWidgetsHolder::toggleAudioMuteCapture()
|
|||
inputDevice->stop();
|
||||
}
|
||||
audioMuteCaptureToggleButton->setToolTip(tr("Resume Call"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AudioPopupChatDialogWidgetsHolder::addAudioData(const QString name, QByteArray* array)
|
||||
void AudioChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
|
||||
{
|
||||
if (!audioMuteCaptureToggleButton->isChecked()) {
|
||||
//launch an animation. Don't launch it if already animating
|
||||
|
|
@ -214,28 +211,28 @@ void AudioPopupChatDialogWidgetsHolder::addAudioData(const QString name, QByteAr
|
|||
}
|
||||
}
|
||||
|
||||
void AudioPopupChatDialogWidgetsHolder::sendAudioData() {
|
||||
void AudioChatWidgetHolder::sendAudioData()
|
||||
{
|
||||
while(inputProcessor && inputProcessor->hasPendingPackets()) {
|
||||
QByteArray qbarray = inputProcessor->getNetworkPacket();
|
||||
RsVoipDataChunk chunk;
|
||||
chunk.size = qbarray.size();
|
||||
chunk.data = (void*)qbarray.constData();
|
||||
rsVoip->sendVoipData(peerId,chunk);
|
||||
rsVoip->sendVoipData(mChatWidget->getPeerId(),chunk);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioPopupChatDialogWidgetsHolder::updateStatus(int status)
|
||||
void AudioChatWidgetHolder::updateStatus(int status)
|
||||
{
|
||||
audioListenToggleButton->setEnabled(true);
|
||||
audioMuteCaptureToggleButton->setEnabled(true);
|
||||
hangupButton->setEnabled(true);
|
||||
hangupButton->setEnabled(true);
|
||||
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
audioListenToggleButton->setEnabled(false);
|
||||
audioMuteCaptureToggleButton->setEnabled(false);
|
||||
hangupButton->setEnabled(false);
|
||||
case RS_STATUS_OFFLINE:
|
||||
audioListenToggleButton->setEnabled(false);
|
||||
audioMuteCaptureToggleButton->setEnabled(false);
|
||||
hangupButton->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
plugins/VOIP/gui/AudioChatWidgetHolder.h
Normal file
41
plugins/VOIP/gui/AudioChatWidgetHolder.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include <QObject>
|
||||
#include <QGraphicsEffect>
|
||||
#include <gui/SpeexProcessor.h>
|
||||
#include <gui/chat/ChatWidget.h>
|
||||
|
||||
class QToolButton;
|
||||
class QAudioInput;
|
||||
class QAudioOutput;
|
||||
|
||||
#define VOIP_SOUND_INCOMING_CALL "VOIP_incoming_call"
|
||||
|
||||
class AudioChatWidgetHolder : public QObject, public ChatWidgetHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioChatWidgetHolder(ChatWidget *chatWidget);
|
||||
virtual ~AudioChatWidgetHolder();
|
||||
|
||||
virtual void updateStatus(int status);
|
||||
|
||||
void addAudioData(const QString name, QByteArray* array) ;
|
||||
|
||||
private slots:
|
||||
void toggleAudioListen();
|
||||
void toggleAudioMuteCapture();
|
||||
void hangupCall() ;
|
||||
|
||||
public slots:
|
||||
void sendAudioData();
|
||||
|
||||
protected:
|
||||
QAudioInput* inputDevice;
|
||||
QAudioOutput* outputDevice;
|
||||
QtSpeex::SpeexInputProcessor* inputProcessor;
|
||||
QtSpeex::SpeexOutputProcessor* outputProcessor;
|
||||
|
||||
QToolButton *audioListenToggleButton ;
|
||||
QToolButton *audioMuteCaptureToggleButton ;
|
||||
QToolButton *hangupButton ;
|
||||
};
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#include <QObject>
|
||||
#include <QGraphicsEffect>
|
||||
#include <gui/SpeexProcessor.h>
|
||||
#include <gui/chat/PopupChatDialog.h>
|
||||
#include <gui/audiodevicehelper.h>
|
||||
|
||||
class QToolButton;
|
||||
|
||||
#define VOIP_SOUND_INCOMING_CALL "VOIP_incoming_call"
|
||||
|
||||
class AudioPopupChatDialogWidgetsHolder: public QObject, public PopupChatDialog_WidgetsHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioPopupChatDialogWidgetsHolder();
|
||||
|
||||
virtual void init(const std::string &peerId, const QString &title, ChatWidget* chatWidget);
|
||||
virtual std::vector<QWidget*> getWidgets();
|
||||
virtual void updateStatus(int status);
|
||||
|
||||
virtual ~AudioPopupChatDialogWidgetsHolder()
|
||||
{
|
||||
if(inputDevice != NULL)
|
||||
inputDevice->stop() ;
|
||||
}
|
||||
|
||||
void addAudioData(const QString name, QByteArray* array) ;
|
||||
private slots:
|
||||
void toggleAudioListen();
|
||||
void toggleAudioMuteCapture();
|
||||
void hangupCall() ;
|
||||
|
||||
|
||||
public slots:
|
||||
void sendAudioData();
|
||||
|
||||
protected:
|
||||
QAudioInput* inputDevice;
|
||||
QAudioOutput* outputDevice;
|
||||
QtSpeex::SpeexInputProcessor* inputProcessor;
|
||||
QtSpeex::SpeexOutputProcessor* outputProcessor;
|
||||
|
||||
std::string peerId;
|
||||
ChatWidget* chatWidget;
|
||||
|
||||
QToolButton *audioListenToggleButton ;
|
||||
QToolButton *audioMuteCaptureToggleButton ;
|
||||
QToolButton *hangupButton ;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -4,7 +4,8 @@
|
|||
#include <interface/rsvoip.h>
|
||||
#include "PluginGUIHandler.h"
|
||||
#include <gui/chat/ChatDialog.h>
|
||||
#include <gui/AudioPopupChatDialog.h>
|
||||
#include <gui/AudioChatWidgetHolder.h>
|
||||
#include "gui/chat/ChatWidget.h"
|
||||
|
||||
void PluginGUIHandler::ReceivedInvitation(const QString& /*peer_id*/)
|
||||
{
|
||||
|
|
@ -33,31 +34,32 @@ void PluginGUIHandler::ReceivedVoipData(const QString& peer_id)
|
|||
return ;
|
||||
}
|
||||
|
||||
ChatDialog *cd = ChatDialog::getExistingChat(peer_id.toStdString()) ;
|
||||
ChatDialog *di = ChatDialog::getExistingChat(peer_id.toStdString()) ;
|
||||
if (di) {
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if (cw) {
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
|
||||
PopupChatDialog *pcd = dynamic_cast<PopupChatDialog*>(cd);
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList) {
|
||||
AudioChatWidgetHolder *acwh = dynamic_cast<AudioChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if(pcd != NULL)
|
||||
{
|
||||
std::vector<PopupChatDialog_WidgetsHolder*> whs = pcd->getWidgets();
|
||||
for(unsigned int whIndex=0; whIndex<whs.size(); whIndex++)
|
||||
{
|
||||
AudioPopupChatDialogWidgetsHolder* apcdwh;
|
||||
if((apcdwh = dynamic_cast<AudioPopupChatDialogWidgetsHolder*>(whs[whIndex])))
|
||||
{
|
||||
for(unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
|
||||
QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
|
||||
apcdwh->addAudioData(peer_id,&qb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error: received audio data for a chat dialog that does not stand Audio (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
for(unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
|
||||
free(chunks[chunkIndex].data);
|
||||
}
|
||||
if (acwh) {
|
||||
for (unsigned int i = 0; i < chunks.size(); ++i) {
|
||||
for (unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
|
||||
QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
|
||||
acwh->addAudioData(peer_id,&qb);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Error: received audio data for a chat dialog that does not stand Audio (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
|
||||
for(unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
|
||||
free(chunks[chunkIndex].data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue