mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added toasters for incoming audio/video call to voip plugin (patch from Phenom)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8295 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c1061a1e9d
commit
cee1819b7d
@ -62,6 +62,7 @@ class RsPQIService ;
|
||||
class RsAutoUpdatePage ;
|
||||
class SoundEvents;
|
||||
class FeedNotify;
|
||||
class ToasterNotify;
|
||||
class ChatWidget;
|
||||
class ChatWidgetHolder;
|
||||
// for gxs based plugins
|
||||
@ -178,6 +179,7 @@ class RsPlugin
|
||||
//================================== Notify ==================================//
|
||||
//
|
||||
virtual FeedNotify *qt_feedNotify() { return NULL; }
|
||||
virtual ToasterNotify *qt_toasterNotify() { return NULL; }
|
||||
|
||||
//
|
||||
//========================== Plugin Description ==============================//
|
||||
|
@ -45,7 +45,9 @@ SOURCES = VOIPPlugin.cpp \
|
||||
gui/QVideoDevice.cpp \
|
||||
gui/VOIPChatWidgetHolder.cpp \
|
||||
gui/VOIPGUIHandler.cpp \
|
||||
gui/VOIPNotify.cpp
|
||||
gui/VOIPNotify.cpp \
|
||||
gui/VOIPToasterItem.cpp \
|
||||
gui/VOIPToasterNotify.cpp
|
||||
|
||||
HEADERS = VOIPPlugin.h \
|
||||
services/p3VOIP.h \
|
||||
@ -60,11 +62,14 @@ HEADERS = VOIPPlugin.h \
|
||||
gui/VOIPChatWidgetHolder.h \
|
||||
gui/VOIPGUIHandler.h \
|
||||
gui/VOIPNotify.h \
|
||||
gui/VOIPToasterItem.h \
|
||||
gui/VOIPToasterNotify.h \
|
||||
interface/rsVOIP.h
|
||||
|
||||
FORMS = gui/AudioInputConfig.ui \
|
||||
gui/AudioStats.ui \
|
||||
gui/AudioWizard.ui
|
||||
gui/AudioWizard.ui \
|
||||
gui/VOIPToasterItem.ui
|
||||
|
||||
TARGET = VOIP
|
||||
|
||||
|
@ -78,20 +78,22 @@ void VOIPPlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_r
|
||||
|
||||
VOIPPlugin::VOIPPlugin()
|
||||
{
|
||||
qRegisterMetaType<RsPeerId>("RsPeerId");
|
||||
mVOIP = NULL ;
|
||||
mPlugInHandler = NULL;
|
||||
mPeers = NULL;
|
||||
config_page = NULL ;
|
||||
mIcon = NULL ;
|
||||
mVOIPToasterNotify = NULL ;
|
||||
|
||||
mVOIPGUIHandler = new VOIPGUIHandler ;
|
||||
mVOIPNotify = new VOIPNotify ;
|
||||
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const QString&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipDataReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedVoipData(const QString&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipAcceptReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedVoipAccept(const QString&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const QString&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipBandwidthInfoReceived(const QString&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const QString&,int)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipDataReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipData(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipAcceptReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipAccept(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipBandwidthInfoReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const RsPeerId&,int)),Qt::QueuedConnection) ;
|
||||
}
|
||||
|
||||
void VOIPPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||
@ -135,7 +137,7 @@ ChatWidgetHolder *VOIPPlugin::qt_get_chat_widget_holder(ChatWidget *chatWidget)
|
||||
{
|
||||
switch (chatWidget->chatType()) {
|
||||
case ChatWidget::CHATTYPE_PRIVATE:
|
||||
return new VOIPChatWidgetHolder(chatWidget);
|
||||
return new VOIPChatWidgetHolder(chatWidget, mVOIPNotify);
|
||||
case ChatWidget::CHATTYPE_UNKNOWN:
|
||||
case ChatWidget::CHATTYPE_LOBBY:
|
||||
case ChatWidget::CHATTYPE_DISTANT:
|
||||
@ -201,3 +203,10 @@ void VOIPPlugin::qt_sound_events(SoundEvents &/*events*/) const
|
||||
{
|
||||
// events.addEvent(QApplication::translate("VOIP", "VOIP"), QApplication::translate("VOIP", "Incoming call"), VOIP_SOUND_INCOMING_CALL);
|
||||
}
|
||||
|
||||
ToasterNotify *VOIPPlugin::qt_toasterNotify(){
|
||||
if (!mVOIPToasterNotify) {
|
||||
mVOIPToasterNotify = new VOIPToasterNotify(mVOIP, mVOIPNotify);
|
||||
}
|
||||
return mVOIPToasterNotify;
|
||||
}
|
||||
|
@ -20,9 +20,13 @@
|
||||
****************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <retroshare/rsplugin.h>
|
||||
/*VOIP*/
|
||||
#include "gui/VOIPToasterNotify.h"
|
||||
#include "services/p3VOIP.h"
|
||||
|
||||
/*libretroshare"*/
|
||||
#include <retroshare/rsplugin.h>
|
||||
|
||||
class VOIPGUIHandler ;
|
||||
class VOIPNotify ;
|
||||
|
||||
@ -51,6 +55,9 @@ class VOIPPlugin: public RsPlugin
|
||||
virtual std::string getPluginName() const;
|
||||
virtual void setInterfaces(RsPlugInInterfaces& interfaces);
|
||||
|
||||
//================================== RsPlugin Notify ==================================//
|
||||
virtual ToasterNotify *qt_toasterNotify();
|
||||
|
||||
private:
|
||||
mutable p3VOIP *mVOIP ;
|
||||
mutable RsPluginHandler *mPlugInHandler;
|
||||
@ -60,5 +67,6 @@ class VOIPPlugin: public RsPlugin
|
||||
|
||||
VOIPNotify *mVOIPNotify ;
|
||||
VOIPGUIHandler *mVOIPGUIHandler ;
|
||||
VOIPToasterNotify *mVOIPToasterNotify ;
|
||||
};
|
||||
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2012 RetroShare Team
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "CallToaster.h"
|
||||
#include "gui/chat/ChatDialog.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
CallToaster::CallToaster(const RsPeerId &peerId) : QWidget(NULL)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
this->peerId = peerId;
|
||||
|
||||
/* connect buttons */
|
||||
connect(ui.toasterButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
|
||||
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
|
||||
|
||||
/* set informations */
|
||||
ui.textLabel->setText(QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
|
||||
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
|
||||
ui.avatarWidget->setId(peerId);
|
||||
}
|
||||
|
||||
void CallToaster::chatButtonSlot()
|
||||
{
|
||||
ChatDialog::chatFriend(peerId);
|
||||
hide();
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2013 RetroShare Team
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef CALLTOASTER_H
|
||||
#define CALLTOASTER_H
|
||||
|
||||
#include "ui_CallToaster.h"
|
||||
|
||||
/**
|
||||
* Shows a toaster when friend is Calling you .
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CallToaster : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CallToaster(const RsPeerId &peerId);
|
||||
|
||||
private slots:
|
||||
void chatButtonSlot();
|
||||
|
||||
private:
|
||||
RsPeerId peerId;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CallToaster ui;
|
||||
};
|
||||
|
||||
#endif //MESSAGETOASTER_H
|
@ -41,8 +41,8 @@
|
||||
#define CALL_HOLD ":/images/call-hold.png"
|
||||
|
||||
|
||||
VOIPChatWidgetHolder::VOIPChatWidgetHolder(ChatWidget *chatWidget)
|
||||
: QObject(), ChatWidgetHolder(chatWidget)
|
||||
VOIPChatWidgetHolder::VOIPChatWidgetHolder(ChatWidget *chatWidget, VOIPNotify *notify)
|
||||
: QObject(), ChatWidgetHolder(chatWidget), mVOIPNotify(notify)
|
||||
{
|
||||
QIcon icon ;
|
||||
icon.addPixmap(QPixmap(":/images/audio-volume-muted.png")) ;
|
||||
@ -284,12 +284,11 @@ void VOIPChatWidgetHolder::toggleVideoCapture()
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPChatWidgetHolder::addVideoData(const QString name, QByteArray* array)
|
||||
void VOIPChatWidgetHolder::addVideoData(const RsPeerId &peer_id, QByteArray* array)
|
||||
{
|
||||
outputVideoProcessor->receiveEncodedData((unsigned char *)array->data(),array->size()) ;
|
||||
if (!videoCaptureToggleButton->isChecked()) {
|
||||
if (mChatWidget) {
|
||||
QString buttonName = name;
|
||||
QString buttonName = QString::fromStdString(peer_id.toStdString());
|
||||
if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId
|
||||
button_map::iterator it = buttonMapTakeVideo.find(buttonName);
|
||||
if (it == buttonMapTakeVideo.end()){
|
||||
@ -315,6 +314,13 @@ void VOIPChatWidgetHolder::addVideoData(const QString name, QByteArray* array)
|
||||
buttonMapTakeVideo.insert(buttonName, button);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO make a sound for the incoming call
|
||||
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
|
||||
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipVideoCall(peer_id);
|
||||
|
||||
} else {
|
||||
outputVideoProcessor->receiveEncodedData((unsigned char *)array->data(),array->size()) ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,12 +356,12 @@ void VOIPChatWidgetHolder::botMouseLeave()
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPChatWidgetHolder::setAcceptedBandwidth(const QString name, uint32_t bytes_per_sec)
|
||||
void VOIPChatWidgetHolder::setAcceptedBandwidth(uint32_t bytes_per_sec)
|
||||
{
|
||||
inputVideoProcessor->setMaximumFrameRate(bytes_per_sec) ;
|
||||
}
|
||||
|
||||
void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
|
||||
void VOIPChatWidgetHolder::addAudioData(const RsPeerId &peer_id, QByteArray* array)
|
||||
{
|
||||
if (!audioCaptureToggleButton->isChecked()) {
|
||||
//launch an animation. Don't launch it if already animating
|
||||
@ -374,7 +380,7 @@ void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
|
||||
}
|
||||
|
||||
if (mChatWidget) {
|
||||
QString buttonName = name;
|
||||
QString buttonName = QString::fromStdString(peer_id.toStdString());
|
||||
if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId
|
||||
button_map::iterator it = buttonMapTakeVideo.find(buttonName);
|
||||
if (it == buttonMapTakeVideo.end()){
|
||||
@ -402,11 +408,12 @@ void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
|
||||
}
|
||||
}
|
||||
|
||||
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
|
||||
|
||||
audioCaptureToggleButton->setToolTip(tr("Answer"));
|
||||
|
||||
//TODO make a toaster and a sound for the incoming call
|
||||
//TODO make a sound for the incoming call
|
||||
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
|
||||
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipAudioCall(peer_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -432,7 +439,7 @@ void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
|
||||
outputAudioDevice->setBufferSize(20);
|
||||
outputAudioDevice->start(outputAudioProcessor);
|
||||
}
|
||||
outputAudioProcessor->putNetworkPacket(name, *array);
|
||||
outputAudioProcessor->putNetworkPacket(QString::fromStdString(peer_id.toStdString()), *array);
|
||||
|
||||
//check the input device for errors
|
||||
if (inputAudioDevice && inputAudioDevice->error() != QAudio::NoError) {
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gui/VOIPNotify.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QGraphicsEffect>
|
||||
#include <gui/SpeexProcessor.h>
|
||||
@ -42,29 +44,29 @@ class VOIPChatWidgetHolder : public QObject, public ChatWidgetHolder
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VOIPChatWidgetHolder(ChatWidget *chatWidget);
|
||||
VOIPChatWidgetHolder(ChatWidget *chatWidget, VOIPNotify *notify);
|
||||
virtual ~VOIPChatWidgetHolder();
|
||||
|
||||
virtual void updateStatus(int status);
|
||||
|
||||
void addAudioData(const QString name, QByteArray* array) ;
|
||||
void addVideoData(const QString name, QByteArray* array) ;
|
||||
void setAcceptedBandwidth(const QString name, uint32_t bytes_per_sec) ;
|
||||
void addAudioData(const RsPeerId &peer_id, QByteArray* array) ;
|
||||
void addVideoData(const RsPeerId &peer_id, QByteArray* array) ;
|
||||
void setAcceptedBandwidth(uint32_t bytes_per_sec) ;
|
||||
|
||||
public slots:
|
||||
void sendAudioData();
|
||||
void sendVideoData();
|
||||
void startAudioCapture();
|
||||
void startVideoCapture();
|
||||
|
||||
private slots:
|
||||
void toggleAudioListen();
|
||||
void toggleAudioCapture();
|
||||
void toggleVideoCapture();
|
||||
void startVideoCapture();
|
||||
void startAudioCapture();
|
||||
void hangupCall() ;
|
||||
void botMouseEnter();
|
||||
void botMouseLeave();
|
||||
|
||||
public slots:
|
||||
void sendAudioData();
|
||||
void sendVideoData();
|
||||
|
||||
protected:
|
||||
// Audio input/output
|
||||
QAudioInput* inputAudioDevice;
|
||||
@ -91,5 +93,7 @@ protected:
|
||||
|
||||
typedef QMap<QString, RSButtonOnText*> button_map;
|
||||
button_map buttonMapTakeVideo;
|
||||
|
||||
VOIPNotify *mVOIPNotify;
|
||||
};
|
||||
|
||||
|
@ -21,31 +21,29 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <interface/rsVOIP.h>
|
||||
#include "VOIPGUIHandler.h"
|
||||
#include <gui/chat/ChatDialog.h>
|
||||
#include <gui/VOIPChatWidgetHolder.h>
|
||||
#include "gui/chat/ChatWidget.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
void VOIPGUIHandler::ReceivedInvitation(const QString& /*peer_id*/)
|
||||
void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &/*peer_id*/)
|
||||
{
|
||||
std::cerr << "****** VOIPGUIHandler: received Invitation!" << std::endl;
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipHangUp(const QString& /*peer_id*/)
|
||||
void VOIPGUIHandler::ReceivedVoipHangUp(const RsPeerId &/*peer_id*/)
|
||||
{
|
||||
std::cerr << "****** VOIPGUIHandler: received HangUp!" << std::endl;
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipAccept(const QString& /*peer_id*/)
|
||||
void VOIPGUIHandler::ReceivedVoipAccept(const RsPeerId &/*peer_id*/)
|
||||
{
|
||||
std::cerr << "****** VOIPGUIHandler: received VoipAccept!" << std::endl;
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipData(const QString& qpeer_id)
|
||||
void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
|
||||
{
|
||||
RsPeerId peer_id(qpeer_id.toStdString()) ;
|
||||
std::vector<RsVOIPDataChunk> chunks ;
|
||||
|
||||
if(!rsVOIP->getIncomingData(peer_id,chunks))
|
||||
@ -70,9 +68,9 @@ void VOIPGUIHandler::ReceivedVoipData(const QString& qpeer_id)
|
||||
QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
|
||||
|
||||
if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_AUDIO)
|
||||
acwh->addAudioData(QString::fromStdString(peer_id.toStdString()),&qb);
|
||||
acwh->addAudioData(peer_id, &qb);
|
||||
else if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO)
|
||||
acwh->addVideoData(QString::fromStdString(peer_id.toStdString()),&qb);
|
||||
acwh->addVideoData(peer_id, &qb);
|
||||
else
|
||||
std::cerr << "VOIPGUIHandler: Unknown data type received. type=" << chunks[chunkIndex].type << std::endl;
|
||||
}
|
||||
@ -89,13 +87,11 @@ void VOIPGUIHandler::ReceivedVoipData(const QString& qpeer_id)
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const QString& qpeer_id,int bytes_per_sec)
|
||||
void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int bytes_per_sec)
|
||||
{
|
||||
RsPeerId peer_id(qpeer_id.toStdString()) ;
|
||||
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
|
||||
std::cerr << "VOIPGUIHandler::received bw info for peer " << qpeer_id.toStdString() << ": " << bytes_per_sec << " Bps" << std::endl;
|
||||
std::cerr << "VOIPGUIHandler::received bw info for peer " << peer_id.toStdString() << ": " << bytes_per_sec << " Bps" << std::endl;
|
||||
if(!di)
|
||||
{
|
||||
std::cerr << "VOIPGUIHandler Error: received bandwidth info for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
@ -115,6 +111,50 @@ void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const QString& qpeer_id,int bytes
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if (acwh)
|
||||
acwh->setAcceptedBandwidth(QString::fromStdString(peer_id.toStdString()),bytes_per_sec);
|
||||
acwh->setAcceptedBandwidth(bytes_per_sec);
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::AnswerAudioCall(const RsPeerId &peer_id)
|
||||
{
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
if (di) {
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if(cw) {
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
|
||||
{
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if (acwh)
|
||||
acwh->startAudioCapture();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler Error: answer audio call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::AnswerVideoCall(const RsPeerId &peer_id)
|
||||
{
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
if (di) {
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if(cw) {
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
|
||||
{
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if (acwh)
|
||||
acwh->startVideoCapture();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler Error: answer video call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,17 +28,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <interface/rsVOIP.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <QObject>
|
||||
|
||||
class VOIPGUIHandler: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static void AnswerAudioCall(const RsPeerId &peer_id) ;
|
||||
static void AnswerVideoCall(const RsPeerId &peer_id) ;
|
||||
|
||||
public slots:
|
||||
void ReceivedInvitation(const QString& peer_id) ;
|
||||
void ReceivedVoipData(const QString& peer_id) ;
|
||||
void ReceivedVoipHangUp(const QString& peer_id) ;
|
||||
void ReceivedVoipAccept(const QString& peer_id) ;
|
||||
void ReceivedVoipBandwidthInfo(const QString& peer_id,int) ;
|
||||
void ReceivedInvitation(const RsPeerId &peer_id) ;
|
||||
void ReceivedVoipData(const RsPeerId &peer_id) ;
|
||||
void ReceivedVoipHangUp(const RsPeerId &peer_id) ;
|
||||
void ReceivedVoipAccept(const RsPeerId &peer_id) ;
|
||||
void ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int) ;
|
||||
};
|
||||
|
@ -21,23 +21,33 @@
|
||||
|
||||
#include "VOIPNotify.h"
|
||||
|
||||
void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id)
|
||||
{
|
||||
emit voipInvitationReceived(QString::fromStdString(peer_id.toStdString())) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipData(const RsPeerId &peer_id)
|
||||
{
|
||||
emit voipDataReceived(QString::fromStdString(peer_id.toStdString())) ;
|
||||
}
|
||||
//Call qRegisterMetaType<RsPeerId>("RsPeerId"); to enable these SIGNALs
|
||||
|
||||
void VOIPNotify::notifyReceivedVoipAccept(const RsPeerId& peer_id)
|
||||
{
|
||||
emit voipAcceptReceived(QString::fromStdString(peer_id.toStdString())) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id)
|
||||
{
|
||||
emit voipHangUpReceived(QString::fromStdString(peer_id.toStdString())) ;
|
||||
emit voipAcceptReceived(peer_id) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipBandwidth(const RsPeerId &peer_id,uint32_t bytes_per_sec)
|
||||
{
|
||||
emit voipBandwidthInfoReceived(QString::fromStdString(peer_id.toStdString()),bytes_per_sec) ;
|
||||
emit voipBandwidthInfoReceived(peer_id, bytes_per_sec) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipData(const RsPeerId &peer_id)
|
||||
{
|
||||
emit voipDataReceived(peer_id) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id)
|
||||
{
|
||||
emit voipHangUpReceived(peer_id) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id)
|
||||
{
|
||||
emit voipInvitationReceived(peer_id) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipAudioCall(const RsPeerId &peer_id)
|
||||
{
|
||||
emit voipAudioCallReceived(peer_id) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipVideoCall(const RsPeerId &peer_id)
|
||||
{
|
||||
emit voipVideoCallReceived(peer_id) ;
|
||||
}
|
||||
|
@ -28,25 +28,32 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
/*libretroshare*/
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class VOIPNotify: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void notifyReceivedVoipData(const RsPeerId& peer_id) ;
|
||||
void notifyReceivedVoipInvite(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipHangUp(const RsPeerId& peer_id) ;
|
||||
void notifyReceivedVoipAccept(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipBandwidth(const RsPeerId &peer_id,uint32_t bytes_per_sec) ;
|
||||
void notifyReceivedVoipAccept(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipBandwidth(const RsPeerId &peer_id, uint32_t bytes_per_sec) ;
|
||||
void notifyReceivedVoipData(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipHangUp(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipInvite(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipAudioCall(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipVideoCall(const RsPeerId &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
|
||||
void voipHangUpReceived(const QString& peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipAcceptReceived(const QString& peer_id) ; // emitted when the peer accepts the call
|
||||
void voipBandwidthInfoReceived(const QString& peer_id,int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
|
||||
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
|
||||
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
|
||||
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
|
||||
|
||||
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
|
||||
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
|
||||
};
|
||||
|
||||
|
107
plugins/VOIP/gui/VOIPToasterItem.cpp
Normal file
107
plugins/VOIP/gui/VOIPToasterItem.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2015 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
/*VOIP*/
|
||||
#include "VOIPToasterItem.h"
|
||||
#include "VOIPGUIHandler.h"
|
||||
|
||||
/*libRetroshare*/
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
/*Retroshare-Gui*/
|
||||
#include "gui/chat/ChatDialog.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "util/HandleRichText.h"
|
||||
|
||||
VOIPToasterItem::VOIPToasterItem(const RsPeerId &peer_id, const QString &msg, const voipToasterItem_Type type)
|
||||
: QWidget(NULL), mPeerId(peer_id), mMsg(msg), mType(type)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
||||
switch (mType){
|
||||
case AudioCall:
|
||||
toasterButton->setIcon(QIcon("://images/call-start.png"));
|
||||
break;
|
||||
case VideoCall:
|
||||
toasterButton->setIcon(QIcon("://images/video-icon-on.png"));
|
||||
break;
|
||||
default:
|
||||
ChatDialog::chatFriend(ChatId(mPeerId));
|
||||
}
|
||||
|
||||
connect(toasterButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
|
||||
connect(closeButton, SIGNAL(clicked()), SLOT(hide()));
|
||||
|
||||
/* set informations */
|
||||
textLabel->setText(RsHtml().formatText(NULL, msg, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
|
||||
toasterLabel->setText(QString::fromUtf8(rsPeers->getPeerName(mPeerId).c_str()));
|
||||
avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
|
||||
avatarWidget->setId(ChatId(mPeerId));
|
||||
}
|
||||
|
||||
VOIPToasterItem::~VOIPToasterItem()
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::chatButtonSlot()
|
||||
{
|
||||
switch (mType){
|
||||
case AudioCall:
|
||||
VOIPGUIHandler::AnswerAudioCall(mPeerId);
|
||||
break;
|
||||
case VideoCall:
|
||||
VOIPGUIHandler::AnswerVideoCall(mPeerId);
|
||||
break;
|
||||
default:
|
||||
ChatDialog::chatFriend(ChatId(mPeerId));
|
||||
}
|
||||
hide();
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipAcceptReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipBandwidthInfoReceived(const RsPeerId &, int )
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipDataReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipHangUpReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipInvitationReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipAudioCallReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipVideoCallReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
61
plugins/VOIP/gui/VOIPToasterItem.h
Normal file
61
plugins/VOIP/gui/VOIPToasterItem.h
Normal file
@ -0,0 +1,61 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2015 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_VOIPToasterItem.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class VOIPToasterItem : public QWidget, private Ui::VOIPToasterItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef enum{ Accept
|
||||
, BandwidthInfo
|
||||
, Data
|
||||
, HangUp
|
||||
, Invitation
|
||||
, AudioCall
|
||||
, VideoCall
|
||||
} voipToasterItem_Type;
|
||||
|
||||
VOIPToasterItem(const RsPeerId &peer_id, const QString &msg, const voipToasterItem_Type type);
|
||||
~VOIPToasterItem();
|
||||
|
||||
private slots:
|
||||
void chatButtonSlot();
|
||||
|
||||
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
|
||||
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
|
||||
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
|
||||
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
|
||||
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
|
||||
|
||||
private:
|
||||
RsPeerId mPeerId;
|
||||
QString mMsg;
|
||||
voipToasterItem_Type mType;
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CallToaster</class>
|
||||
<widget class="QWidget" name="CallToaster">
|
||||
<class>VOIPToasterItem</class>
|
||||
<widget class="QWidget" name="VOIPToasterItem">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -22,27 +22,27 @@
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="windowFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
<enum>QFrame::WinPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
@ -70,7 +70,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/images/rstray3.png</pixmap>
|
||||
<pixmap resource="../images.qrc">:/images/logo/logo_16.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
@ -79,13 +79,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="toasterLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
@ -119,7 +112,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/closenormal.png</normaloff>:/images/closenormal.png</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
@ -130,24 +123,18 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="AvatarWidget" name="avatarWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
<layout class="QGridLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="toasterButton">
|
||||
<property name="text">
|
||||
<string>Show Chat</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="textLabel">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@ -160,48 +147,18 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="toasterButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Answer</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="VOIP_images.qrc">
|
||||
<normaloff>:/images/call-start-22.png</normaloff>:/images/call-start-22.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="AvatarWidget" name="avatarWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
<width>70</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Decline</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="VOIP_images.qrc">
|
||||
<normaloff>:/images/call-stop-22.png</normaloff>:/images/call-stop-22.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
<width>70</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
@ -222,7 +179,8 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="VOIP_images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
401
plugins/VOIP/gui/VOIPToasterNotify.cpp
Normal file
401
plugins/VOIP/gui/VOIPToasterNotify.cpp
Normal file
@ -0,0 +1,401 @@
|
||||
/****************************************************************
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
/*VOIP*/
|
||||
#include "gui/VOIPToasterNotify.h"
|
||||
#include "gui/VOIPToasterItem.h"
|
||||
|
||||
/*retroshare-gui*/
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/toaster/ToasterItem.h"
|
||||
|
||||
/*libretroshare*/
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
VOIPToasterNotify::VOIPToasterNotify(RsVOIP *VOIP, VOIPNotify *notify, QObject *parent)
|
||||
: ToasterNotify(parent), mVOIP(VOIP), mVOIPNotify(notify)
|
||||
{
|
||||
mMutex = new QMutex();
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
connect(mVOIPNotify, SIGNAL(voipAcceptReceived(const RsPeerId&)), this, SLOT(voipAcceptReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipBandwidthInfoReceived(const RsPeerId&, int)), this, SLOT(voipBandwidthInfoReceived(RsPeerId&, int)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipDataReceived(const RsPeerId&)), this, SLOT(voipDataReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipHangUpReceived(const RsPeerId&)), this, SLOT(voipHangUpReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipInvitationReceived(const RsPeerId&)), this, SLOT(voipInvitationReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
#endif
|
||||
connect(mVOIPNotify, SIGNAL(voipAudioCallReceived(const RsPeerId&)), this, SLOT(voipAudioCallReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipVideoCallReceived(const RsPeerId&)), this, SLOT(voipVideoCallReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
VOIPToasterNotify::~VOIPToasterNotify()
|
||||
{
|
||||
delete(mMutex);
|
||||
}
|
||||
|
||||
bool VOIPToasterNotify::hasSettings(QString &mainName, QMap<QString, QString> &tagAndTexts)
|
||||
{
|
||||
mainName = tr("VOIP");
|
||||
//gAndTexts.insert("Tag" , tr("Text"));
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
tagAndTexts.insert("Accept" , tr("Accept"));
|
||||
tagAndTexts.insert("BandwidthInfo", tr("Bandwidth Information"));
|
||||
tagAndTexts.insert("Data" , tr("Audio or Video Data"));
|
||||
tagAndTexts.insert("HangUp" , tr("HangUp"));
|
||||
tagAndTexts.insert("Invitation" , tr("Invitation"));
|
||||
#endif
|
||||
tagAndTexts.insert("AudioCall" , tr("Audio Call"));
|
||||
tagAndTexts.insert("VideoCall" , tr("Video Call"));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VOIPToasterNotify::notifyEnabled(QString tag)
|
||||
{
|
||||
return Settings->valueFromGroup("VOIP", QString("ToasterNotifyEnable").append(tag), false).toBool();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::setNotifyEnabled(QString tag, bool enabled)
|
||||
{
|
||||
Settings->setValueToGroup("VOIP", QString("ToasterNotifyEnable").append(tag), enabled);
|
||||
|
||||
if (!enabled) {
|
||||
/* remove pending Toaster items */
|
||||
mMutex->lock();
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
if(tag == "Accept") mPendingToasterAccept.clear();
|
||||
if(tag == "BandwidthInfo") mPendingToasterBandwidthInfo.clear();
|
||||
if(tag == "Data") mPendingToasterData.clear();
|
||||
if(tag == "HangUp") mPendingToasterHangUp.clear();
|
||||
if(tag == "Invitation") mPendingToasterInvitation.clear();
|
||||
#endif
|
||||
if(tag == "AudioCall") mPendingToasterAudioCall.clear();
|
||||
if(tag == "VideoCall") mPendingToasterVideoCall.clear();
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
ToasterItem *VOIPToasterNotify::toasterItem()
|
||||
{
|
||||
ToasterItem *toasterItem = NULL;
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
if (!mPendingToasterAccept.empty() && !toasterItem) {
|
||||
mMutex->lock();
|
||||
ToasterItemData toasterItemData = mPendingToasterAccept.takeFirst();
|
||||
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::Accept);
|
||||
toasterItem= new ToasterItem(voipToasterItem);
|
||||
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedAccept(ToasterItem*)));
|
||||
mToasterAccept.insert(toasterItemData.mPeerId, toasterItem);
|
||||
mMutex->unlock();
|
||||
}
|
||||
if (!mPendingToasterBandwidthInfo.empty() && !toasterItem) {
|
||||
mMutex->lock();
|
||||
ToasterItemData toasterItemData = mPendingToasterBandwidthInfo.takeFirst();
|
||||
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::BandwidthInfo);
|
||||
toasterItem = new ToasterItem(voipToasterItem);
|
||||
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedBandwidthInfo(ToasterItem*)));
|
||||
mToasterBandwidthInfo.insert(toasterItemData.mPeerId, toasterItem);
|
||||
mMutex->unlock();
|
||||
}
|
||||
if (!mPendingToasterData.empty() && !toasterItem) {
|
||||
mMutex->lock();
|
||||
ToasterItemData toasterItemData = mPendingToasterData.takeFirst();
|
||||
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::Data);
|
||||
toasterItem = new ToasterItem(voipToasterItem);
|
||||
toasterItem->timeToLive = 10000;
|
||||
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedData(ToasterItem*)));
|
||||
mToasterData.insert(toasterItemData.mPeerId, toasterItem);
|
||||
mMutex->unlock();
|
||||
}
|
||||
if (!mPendingToasterHangUp.empty() && !toasterItem) {
|
||||
mMutex->lock();
|
||||
ToasterItemData toasterItemData = mPendingToasterHangUp.takeFirst();
|
||||
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::HangUp);
|
||||
toasterItem = new ToasterItem(voipToasterItem);
|
||||
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedHangUp(ToasterItem*)));
|
||||
mToasterHangUp.insert(toasterItemData.mPeerId, toasterItem);
|
||||
mMutex->unlock();
|
||||
}
|
||||
if (!mPendingToasterInvitation.empty() && !toasterItem) {
|
||||
mMutex->lock();
|
||||
ToasterItemData toasterItemData = mPendingToasterInvitation.takeFirst();
|
||||
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::Invitation);
|
||||
toasterItem = new ToasterItem(voipToasterItem);
|
||||
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedInvitation(ToasterItem*)));
|
||||
mToasterInvitation.insert(toasterItemData.mPeerId, toasterItem);
|
||||
mMutex->unlock();
|
||||
}
|
||||
#endif
|
||||
if (!mPendingToasterAudioCall.empty() && !toasterItem) {
|
||||
mMutex->lock();
|
||||
ToasterItemData toasterItemData = mPendingToasterAudioCall.takeFirst();
|
||||
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::AudioCall);
|
||||
toasterItem = new ToasterItem(voipToasterItem);
|
||||
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedAudioCall(ToasterItem*)));
|
||||
mToasterAudioCall.insert(toasterItemData.mPeerId, toasterItem);
|
||||
mMutex->unlock();
|
||||
}
|
||||
if (!mPendingToasterVideoCall.empty() && !toasterItem) {
|
||||
mMutex->lock();
|
||||
ToasterItemData toasterItemData = mPendingToasterVideoCall.takeFirst();
|
||||
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::VideoCall);
|
||||
toasterItem = new ToasterItem(voipToasterItem);
|
||||
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedVideoCall(ToasterItem*)));
|
||||
mToasterVideoCall.insert(toasterItemData.mPeerId, toasterItem);
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
return toasterItem;
|
||||
}
|
||||
|
||||
ToasterItem* VOIPToasterNotify::testToasterItem(QString tag)
|
||||
{
|
||||
ToasterItem* toaster = NULL;
|
||||
RsPeerId ownId = rsPeers->getOwnId();
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
if (tag == "Accept") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Accept"), VOIPToasterItem::Accept));
|
||||
if (tag == "BandwidthInfo") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP BandwidthInfo"), VOIPToasterItem::BandwidthInfo));
|
||||
if (tag == "Data") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Data"), VOIPToasterItem::Data));
|
||||
if (tag == "HangUp") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP HangUp"), VOIPToasterItem::HangUp));
|
||||
if (tag == "Invitation") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Invitation"), VOIPToasterItem::Invitation));
|
||||
#endif
|
||||
if (tag == "AudioCall") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Audio Call"), VOIPToasterItem::AudioCall));
|
||||
if (tag == "VideoCall") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Video Call"), VOIPToasterItem::VideoCall));
|
||||
|
||||
return toaster;
|
||||
}
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void VOIPToasterNotify::voipAcceptReceived(const RsPeerId &peer_id)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notifyEnabled("Accept")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMutex->lock();
|
||||
|
||||
if (!mToasterAccept.contains(peer_id)){
|
||||
ToasterItemData toasterItemData;
|
||||
toasterItemData.mPeerId = peer_id;
|
||||
toasterItemData.mMsg = tr("Accept received from this peer.");
|
||||
|
||||
mPendingToasterAccept.push_back(toasterItemData);
|
||||
mToasterAccept.insert(peer_id, NULL);
|
||||
}
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::voipBandwidthInfoReceived(const RsPeerId &peer_id,int bytes_per_sec)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notifyEnabled("BandwidthInfo")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMutex->lock();
|
||||
|
||||
if (!mToasterBandwidthInfo.contains(peer_id)){
|
||||
ToasterItemData toasterItemData;
|
||||
toasterItemData.mPeerId = peer_id;
|
||||
toasterItemData.mMsg = tr("Bandwidth Info received from this peer:%1").arg(bytes_per_sec);
|
||||
|
||||
mPendingToasterBandwidthInfo.push_back(toasterItemData);
|
||||
mToasterBandwidthInfo.insert(peer_id, NULL);
|
||||
}
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::voipDataReceived(const RsPeerId &peer_id)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notifyEnabled("Data")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMutex->lock();
|
||||
|
||||
if (!mToasterData.contains(peer_id)){
|
||||
ToasterItemData toasterItemData;
|
||||
toasterItemData.mPeerId = peer_id;
|
||||
toasterItemData.mMsg = tr("Audio or Video Data received from this peer.");
|
||||
|
||||
mPendingToasterData.push_back(toasterItemData);
|
||||
mToasterData.insert(peer_id, NULL);
|
||||
}
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notifyEnabled("HangUp")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMutex->lock();
|
||||
|
||||
if (!mToasterHangUp.contains(peer_id)){
|
||||
ToasterItemData toasterItemData;
|
||||
toasterItemData.mPeerId = peer_id;
|
||||
toasterItemData.mMsg = tr("HangUp received from this peer.");
|
||||
|
||||
mPendingToasterHangUp.push_back(toasterItemData);
|
||||
mToasterHangUp.insert(peer_id, NULL);
|
||||
}
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::voipInvitationReceived(const RsPeerId &peer_id)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notifyEnabled("Invitation")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMutex->lock();
|
||||
|
||||
if (!mToasterInvitation.contains(peer_id)){
|
||||
ToasterItemData toasterItemData;
|
||||
toasterItemData.mPeerId = peer_id;
|
||||
toasterItemData.mMsg = tr("Invitation received from this peer.");
|
||||
|
||||
mPendingToasterInvitation.push_back(toasterItemData);
|
||||
mToasterInvitation.insert(peer_id, NULL);
|
||||
}
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
void VOIPToasterNotify::voipAudioCallReceived(const RsPeerId &peer_id)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notifyEnabled("AudioCall")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMutex->lock();
|
||||
|
||||
if (!mToasterAudioCall.contains(peer_id)){
|
||||
ToasterItemData toasterItemData;
|
||||
toasterItemData.mPeerId = peer_id;
|
||||
toasterItemData.mMsg = tr("Audio Call received from this peer.");
|
||||
|
||||
mPendingToasterAudioCall.push_back(toasterItemData);
|
||||
mToasterAudioCall.insert(peer_id, NULL);
|
||||
}
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::voipVideoCallReceived(const RsPeerId &peer_id)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!notifyEnabled("VideoCall")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMutex->lock();
|
||||
|
||||
if (!mToasterVideoCall.contains(peer_id)){
|
||||
ToasterItemData toasterItemData;
|
||||
toasterItemData.mPeerId = peer_id;
|
||||
toasterItemData.mMsg = tr("Video Call received from this peer.");
|
||||
|
||||
mPendingToasterVideoCall.push_back(toasterItemData);
|
||||
mToasterVideoCall.insert(peer_id, NULL);
|
||||
}
|
||||
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void VOIPToasterNotify::toasterItemDestroyedAccept(ToasterItem *toasterItem)
|
||||
{
|
||||
RsPeerId key = mToasterAccept.key(toasterItem, RsPeerId());
|
||||
if (!key.isNull()) mToasterAccept.remove(key);
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::toasterItemDestroyedBandwidthInfo(ToasterItem *toasterItem)
|
||||
{
|
||||
RsPeerId key = mToasterBandwidthInfo.key(toasterItem, RsPeerId());
|
||||
if (!key.isNull()) mToasterBandwidthInfo.remove(key);
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::toasterItemDestroyedData(ToasterItem *toasterItem)
|
||||
{
|
||||
RsPeerId key = mToasterData.key(toasterItem, RsPeerId());
|
||||
if (!key.isNull()) mToasterData.remove(key);
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::toasterItemDestroyedHangUp(ToasterItem *toasterItem)
|
||||
{
|
||||
RsPeerId key = mToasterHangUp.key(toasterItem, RsPeerId());
|
||||
if (!key.isNull()) mToasterHangUp.remove(key);
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::toasterItemDestroyedInvitation(ToasterItem *toasterItem)
|
||||
{
|
||||
RsPeerId key = mToasterInvitation.key(toasterItem, RsPeerId());
|
||||
if (!key.isNull()) mToasterInvitation.remove(key);
|
||||
}
|
||||
#endif
|
||||
|
||||
void VOIPToasterNotify::toasterItemDestroyedAudioCall(ToasterItem *toasterItem)
|
||||
{
|
||||
RsPeerId key = mToasterAudioCall.key(toasterItem, RsPeerId());
|
||||
if (!key.isNull()) mToasterAudioCall.remove(key);
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::toasterItemDestroyedVideoCall(ToasterItem *toasterItem)
|
||||
{
|
||||
RsPeerId key = mToasterVideoCall.key(toasterItem, RsPeerId());
|
||||
if (!key.isNull()) mToasterVideoCall.remove(key);
|
||||
}
|
||||
|
112
plugins/VOIP/gui/VOIPToasterNotify.h
Normal file
112
plugins/VOIP/gui/VOIPToasterNotify.h
Normal file
@ -0,0 +1,112 @@
|
||||
/****************************************************************
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gui/VOIPNotify.h"
|
||||
#include "gui/VOIPToasterItem.h"
|
||||
#include "interface/rsVOIP.h"
|
||||
|
||||
#include "gui/common/ToasterNotify.h"
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
//#define VOIPTOASTERNOTIFY_ALL //To get all notification
|
||||
|
||||
class VOIPToasterNotify : public ToasterNotify
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
class ToasterItemData
|
||||
{
|
||||
public:
|
||||
ToasterItemData() {}
|
||||
|
||||
public:
|
||||
RsPeerId mPeerId;
|
||||
QString mMsg;
|
||||
};
|
||||
|
||||
public:
|
||||
VOIPToasterNotify(RsVOIP *VOIP, VOIPNotify *notify, QObject *parent = 0);
|
||||
~VOIPToasterNotify();
|
||||
|
||||
/// From ToasterNotify ///
|
||||
virtual bool hasSettings(QString &mainName, QMap<QString,QString> &tagAndTexts);
|
||||
virtual bool notifyEnabled(QString tag);
|
||||
virtual void setNotifyEnabled(QString tag, bool enabled);
|
||||
virtual ToasterItem *toasterItem();
|
||||
virtual ToasterItem *testToasterItem(QString tag);
|
||||
|
||||
private slots:
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
|
||||
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
|
||||
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
|
||||
#endif
|
||||
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
|
||||
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void toasterItemDestroyedAccept(ToasterItem *toasterItem) ;
|
||||
void toasterItemDestroyedBandwidthInfo(ToasterItem *toasterItem) ;
|
||||
void toasterItemDestroyedData(ToasterItem *toasterItem) ;
|
||||
void toasterItemDestroyedHangUp(ToasterItem *toasterItem) ;
|
||||
void toasterItemDestroyedInvitation(ToasterItem *toasterItem) ;
|
||||
#endif
|
||||
void toasterItemDestroyedAudioCall(ToasterItem *toasterItem) ;
|
||||
void toasterItemDestroyedVideoCall(ToasterItem *toasterItem) ;
|
||||
|
||||
private:
|
||||
RsVOIP *mVOIP;
|
||||
VOIPNotify *mVOIPNotify;
|
||||
|
||||
// comment electron: i don't think the mutex is needed, because everything happens in the GUI thread
|
||||
// (Qt signals are send to slots in the gui thread)
|
||||
// i'm leaving it here to no destroy something
|
||||
// note: FeedReaderFeedNotify has a similar mutex
|
||||
// maybe it has historic reasons. NotifyQt still contains commented lines QMutexLocker lock(&waitingToasterMutex);
|
||||
QMutex *mMutex;
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
QList<ToasterItemData> mPendingToasterAccept;
|
||||
QList<ToasterItemData> mPendingToasterBandwidthInfo;
|
||||
QList<ToasterItemData> mPendingToasterData;
|
||||
QList<ToasterItemData> mPendingToasterHangUp;
|
||||
QList<ToasterItemData> mPendingToasterInvitation;
|
||||
#endif
|
||||
QList<ToasterItemData> mPendingToasterAudioCall;
|
||||
QList<ToasterItemData> mPendingToasterVideoCall;
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
QMap<RsPeerId, ToasterItem *> mToasterAccept;
|
||||
QMap<RsPeerId, ToasterItem *> mToasterBandwidthInfo;
|
||||
QMap<RsPeerId, ToasterItem *> mToasterData;
|
||||
QMap<RsPeerId, ToasterItem *> mToasterHangUp;
|
||||
QMap<RsPeerId, ToasterItem *> mToasterInvitation;
|
||||
#endif
|
||||
QMap<RsPeerId, ToasterItem *> mToasterAudioCall;
|
||||
QMap<RsPeerId, ToasterItem *> mToasterVideoCall;
|
||||
};
|
||||
|
@ -13,6 +13,7 @@ class VideoDecoder
|
||||
{
|
||||
public:
|
||||
VideoDecoder() ;
|
||||
virtual ~VideoDecoder() {}
|
||||
|
||||
// Gets the next image to be displayed. Once returned, the image should
|
||||
// be cleared from the incoming queue.
|
||||
@ -49,6 +50,7 @@ class VideoEncoder
|
||||
{
|
||||
public:
|
||||
VideoEncoder() {}
|
||||
virtual ~VideoEncoder() {}
|
||||
|
||||
// Takes the next image to be encoded.
|
||||
//
|
||||
|
74
retroshare-gui/src/gui/common/ToasterNotify.cpp
Normal file
74
retroshare-gui/src/gui/common/ToasterNotify.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2015 RetroShare Team
|
||||
*
|
||||
* 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 "ToasterNotify.h"
|
||||
|
||||
ToasterNotify::ToasterNotify(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ToasterNotify::~ToasterNotify()
|
||||
{
|
||||
}
|
||||
|
||||
bool ToasterNotify::hasSetting(QString &/*name*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToasterNotify::notifyEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void ToasterNotify::setNotifyEnabled(bool /*enabled*/)
|
||||
{
|
||||
}
|
||||
|
||||
ToasterItem *ToasterNotify::toasterItem()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ToasterItem *ToasterNotify::testToasterItem()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ToasterNotify::hasSettings(QString &/*name*/, QMap<QString,QString> &/*tagAndTexts*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToasterNotify::notifyEnabled(QString /*tag*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void ToasterNotify::setNotifyEnabled(QString /*tag*/, bool /*enabled*/)
|
||||
{
|
||||
}
|
||||
|
||||
ToasterItem *ToasterNotify::testToasterItem(QString /*tag*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
51
retroshare-gui/src/gui/common/ToasterNotify.h
Normal file
51
retroshare-gui/src/gui/common/ToasterNotify.h
Normal file
@ -0,0 +1,51 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2015 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef TOASTERNOTIFY_H
|
||||
#define TOASTERNOTIFY_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
class ToasterItem;
|
||||
|
||||
class ToasterNotify : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ToasterNotify(QObject *parent = 0);
|
||||
~ToasterNotify();
|
||||
|
||||
virtual bool hasSetting(QString &/*name*/);
|
||||
virtual bool notifyEnabled();
|
||||
virtual void setNotifyEnabled(bool /*enabled*/);
|
||||
virtual ToasterItem *toasterItem();
|
||||
virtual ToasterItem *testToasterItem();
|
||||
|
||||
//For Plugin with differents Toasters
|
||||
virtual bool hasSettings(QString &/*mainName*/, QMap<QString,QString> &/*tagAndTexts*/);
|
||||
virtual bool notifyEnabled(QString /*tag*/);
|
||||
virtual void setNotifyEnabled(QString /*tag*/, bool /*enabled*/);
|
||||
virtual ToasterItem *testToasterItem(QString /*tag*/);
|
||||
};
|
||||
|
||||
#endif // TOASTERNOTIFY_H
|
@ -41,6 +41,8 @@
|
||||
#include "toaster/GroupChatToaster.h"
|
||||
#include "toaster/ChatLobbyToaster.h"
|
||||
#include "toaster/FriendRequestToaster.h"
|
||||
#include "toaster/ToasterItem.h"
|
||||
#include "common/ToasterNotify.h"
|
||||
|
||||
#include "chat/ChatDialog.h"
|
||||
#include "chat/ChatLobbyDialog.h"
|
||||
@ -49,53 +51,12 @@
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "SoundManager.h"
|
||||
|
||||
#include "retroshare/rsplugin.h"
|
||||
|
||||
/*****
|
||||
* #define NOTIFY_DEBUG
|
||||
****/
|
||||
|
||||
class Toaster
|
||||
{
|
||||
public:
|
||||
Toaster(QWidget *widget)
|
||||
{
|
||||
this->widget = widget;
|
||||
|
||||
/* Values from settings */
|
||||
position = Settings->getToasterPosition();
|
||||
Settings->getToasterMargin();
|
||||
|
||||
|
||||
/* Standard values */
|
||||
timeToShow = 500;
|
||||
timeToLive = 3000;
|
||||
timeToHide = 500;
|
||||
|
||||
/* Calculated values */
|
||||
elapsedTimeToShow = 0;
|
||||
elapsedTimeToLive = 0;
|
||||
elapsedTimeToHide = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
QWidget *widget;
|
||||
|
||||
/* Values from settings */
|
||||
RshareSettings::enumToasterPosition position;
|
||||
QPoint margin;
|
||||
|
||||
/* Standard values */
|
||||
int timeToShow;
|
||||
int timeToLive;
|
||||
int timeToHide;
|
||||
|
||||
/* Calculated values */
|
||||
QPoint startPos;
|
||||
QPoint endPos;
|
||||
int elapsedTimeToShow;
|
||||
int elapsedTimeToLive;
|
||||
int elapsedTimeToHide;
|
||||
};
|
||||
|
||||
/*static*/ NotifyQt *NotifyQt::_instance = NULL;
|
||||
/*static*/ bool NotifyQt::_disableAllToaster = false;
|
||||
|
||||
@ -820,13 +781,12 @@ void NotifyQt::UpdateGUI()
|
||||
uint32_t type;
|
||||
std::string title, id, msg;
|
||||
|
||||
/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
|
||||
ToasterItem *toaster = NULL;
|
||||
if (rsNotify->NotifyPopupMessage(type, id, title, msg))
|
||||
{
|
||||
uint popupflags = Settings->getNotifyFlags();
|
||||
|
||||
/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
|
||||
Toaster *toaster = NULL;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case RS_POPUP_ENCRYPTED_MSG:
|
||||
@ -834,7 +794,7 @@ void NotifyQt::UpdateGUI()
|
||||
|
||||
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
|
||||
{
|
||||
toaster = new Toaster(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
|
||||
toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_MSG:
|
||||
@ -842,7 +802,7 @@ void NotifyQt::UpdateGUI()
|
||||
|
||||
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
|
||||
{
|
||||
toaster = new Toaster(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
|
||||
toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_CONNECT:
|
||||
@ -850,7 +810,7 @@ void NotifyQt::UpdateGUI()
|
||||
|
||||
if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster)
|
||||
{
|
||||
toaster = new Toaster(new OnlineToaster(RsPeerId(id)));
|
||||
toaster = new ToasterItem(new OnlineToaster(RsPeerId(id)));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_DOWNLOAD:
|
||||
@ -859,7 +819,7 @@ void NotifyQt::UpdateGUI()
|
||||
if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
|
||||
{
|
||||
/* id = file hash */
|
||||
toaster = new Toaster(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
|
||||
toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_CHAT:
|
||||
@ -872,7 +832,7 @@ void NotifyQt::UpdateGUI()
|
||||
// do not show when active
|
||||
break;
|
||||
}
|
||||
toaster = new Toaster(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
|
||||
toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_GROUPCHAT:
|
||||
@ -887,7 +847,7 @@ void NotifyQt::UpdateGUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
toaster = new Toaster(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
|
||||
toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_CHATLOBBY:
|
||||
@ -914,7 +874,7 @@ void NotifyQt::UpdateGUI()
|
||||
if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(RsGxsId(title)))
|
||||
break; // participant is muted
|
||||
|
||||
toaster = new Toaster(new ChatLobbyToaster(lobby_id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
|
||||
toaster = new ToasterItem(new ChatLobbyToaster(lobby_id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_CONNECT_ATTEMPT:
|
||||
@ -923,21 +883,36 @@ void NotifyQt::UpdateGUI()
|
||||
// id = gpgid
|
||||
// title = ssl name
|
||||
// msg = peer id
|
||||
toaster = new Toaster(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg)));
|
||||
toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (toaster) {
|
||||
/* init attributes */
|
||||
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
|
||||
/* add toaster to waiting list */
|
||||
//QMutexLocker lock(&waitingToasterMutex);
|
||||
waitingToasterList.push_back(toaster);
|
||||
/*Now check Plugins*/
|
||||
if (!toaster) {
|
||||
int pluginCount = rsPlugins->nbPlugins();
|
||||
for (int i = 0; i < pluginCount; ++i) {
|
||||
RsPlugin *rsPlugin = rsPlugins->plugin(i);
|
||||
if (rsPlugin) {
|
||||
ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify();
|
||||
if (toasterNotify) {
|
||||
toaster = toasterNotify->toasterItem();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toaster) {
|
||||
/* init attributes */
|
||||
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
|
||||
/* add toaster to waiting list */
|
||||
//QMutexLocker lock(&waitingToasterMutex);
|
||||
waitingToasterList.push_back(toaster);
|
||||
}
|
||||
|
||||
if (rsNotify->NotifySysMessage(sysid, type, title, msg))
|
||||
{
|
||||
/* make a warning message */
|
||||
@ -980,7 +955,7 @@ void NotifyQt::UpdateGUI()
|
||||
startWaitingToasters();
|
||||
}
|
||||
|
||||
void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
|
||||
void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
|
||||
{
|
||||
QString title = tr("Test");
|
||||
QString message = tr("This is a test.");
|
||||
@ -995,33 +970,33 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi
|
||||
notifyFlags &= ~(1 << pos);
|
||||
++pos;
|
||||
|
||||
Toaster *toaster = NULL;
|
||||
ToasterItem *toaster = NULL;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case RS_POPUP_ENCRYPTED_MSG:
|
||||
toaster = new Toaster(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message"))));
|
||||
toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message"))));
|
||||
break;
|
||||
case RS_POPUP_MSG:
|
||||
toaster = new Toaster(new MessageToaster(id.toStdString(), title, message));
|
||||
toaster = new ToasterItem(new MessageToaster(id.toStdString(), title, message));
|
||||
break;
|
||||
case RS_POPUP_CONNECT:
|
||||
toaster = new Toaster(new OnlineToaster(id));
|
||||
toaster = new ToasterItem(new OnlineToaster(id));
|
||||
break;
|
||||
case RS_POPUP_DOWNLOAD:
|
||||
toaster = new Toaster(new DownloadToaster(RsFileHash::random(), title));
|
||||
toaster = new ToasterItem(new DownloadToaster(RsFileHash::random(), title));
|
||||
break;
|
||||
case RS_POPUP_CHAT:
|
||||
toaster = new Toaster(new ChatToaster(id, message));
|
||||
toaster = new ToasterItem(new ChatToaster(id, message));
|
||||
break;
|
||||
case RS_POPUP_GROUPCHAT:
|
||||
toaster = new Toaster(new GroupChatToaster(id, message));
|
||||
toaster = new ToasterItem(new GroupChatToaster(id, message));
|
||||
break;
|
||||
case RS_POPUP_CHATLOBBY:
|
||||
toaster = new Toaster(new ChatLobbyToaster(0, title, message));
|
||||
toaster = new ToasterItem(new ChatLobbyToaster(0, title, message));
|
||||
break;
|
||||
case RS_POPUP_CONNECT_ATTEMPT:
|
||||
toaster = new Toaster(new FriendRequestToaster(pgpid, title, id));
|
||||
toaster = new ToasterItem(new FriendRequestToaster(pgpid, title, id));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1038,6 +1013,48 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyQt::testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
|
||||
{
|
||||
|
||||
if (!toasterNotify) {
|
||||
return;
|
||||
}
|
||||
|
||||
ToasterItem *toaster = toasterNotify->testToasterItem();
|
||||
|
||||
if (toaster) {
|
||||
/* init attributes */
|
||||
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
toaster->position = (RshareSettings::enumToasterPosition) position;
|
||||
toaster->margin = margin;
|
||||
|
||||
/* add toaster to waiting list */
|
||||
//QMutexLocker lock(&waitingToasterMutex);
|
||||
waitingToasterList.push_back(toaster);
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyQt::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
|
||||
{
|
||||
|
||||
if (!toasterNotify) {
|
||||
return;
|
||||
}
|
||||
|
||||
ToasterItem *toaster = toasterNotify->testToasterItem(tag);
|
||||
|
||||
if (toaster) {
|
||||
/* init attributes */
|
||||
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
toaster->position = (RshareSettings::enumToasterPosition) position;
|
||||
toaster->margin = margin;
|
||||
|
||||
/* add toaster to waiting list */
|
||||
//QMutexLocker lock(&waitingToasterMutex);
|
||||
waitingToasterList.push_back(toaster);
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyQt::notifyChatFontChanged()
|
||||
{
|
||||
{
|
||||
@ -1084,7 +1101,7 @@ void NotifyQt::startWaitingToasters()
|
||||
}
|
||||
}
|
||||
|
||||
Toaster *toaster = NULL;
|
||||
ToasterItem *toaster = NULL;
|
||||
|
||||
{
|
||||
//QMutexLocker lock(&waitingToasterMutex);
|
||||
@ -1149,9 +1166,9 @@ void NotifyQt::runningTick()
|
||||
int interval = runningToasterTimer->interval();
|
||||
QPoint diff;
|
||||
|
||||
QList<Toaster*>::iterator it = runningToasterList.begin();
|
||||
QList<ToasterItem*>::iterator it = runningToasterList.begin();
|
||||
while (it != runningToasterList.end()) {
|
||||
Toaster *toaster = *it;
|
||||
ToasterItem *toaster = *it;
|
||||
|
||||
bool visible = true;
|
||||
if (toaster->elapsedTimeToShow) {
|
||||
@ -1192,7 +1209,7 @@ void NotifyQt::runningTick()
|
||||
} else {
|
||||
/* Toaster is hidden, delete it */
|
||||
it = runningToasterList.erase(it);
|
||||
delete(toaster->widget);
|
||||
//delete(toaster->widget);
|
||||
delete(toaster);
|
||||
continue;
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ class ChatDialog;
|
||||
class MessagesDialog;
|
||||
class ChannelsDialog;
|
||||
class MessengerWindow;
|
||||
class Toaster;
|
||||
class ToasterItem;
|
||||
class ToasterNotify;
|
||||
class SignatureEventData ;
|
||||
struct TurtleFileInfo;
|
||||
|
||||
@ -90,7 +91,9 @@ class NotifyQt: public QObject, public NotifyClient
|
||||
void notifyChatFontChanged();
|
||||
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||
|
||||
void testToaster(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||
void testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||
void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||
void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||
|
||||
void notifySettingsChanged();
|
||||
|
||||
@ -169,10 +172,10 @@ class NotifyQt: public QObject, public NotifyClient
|
||||
void startWaitingToasters();
|
||||
|
||||
// QMutex waitingToasterMutex; // for lock of the waiting toaster list
|
||||
QList<Toaster*> waitingToasterList;
|
||||
QList<ToasterItem*> waitingToasterList;
|
||||
|
||||
QTimer *runningToasterTimer;
|
||||
QList<Toaster*> runningToasterList;
|
||||
QList<ToasterItem*> runningToasterList;
|
||||
|
||||
bool _enabled ;
|
||||
QMutex _mutex ;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/common/UserNotify.h"
|
||||
#include "gui/common/FeedNotify.h"
|
||||
#include "gui/common/ToasterNotify.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/NewsFeed.h"
|
||||
|
||||
@ -39,8 +40,8 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.notifyButton, SIGNAL(clicked()), this, SLOT(testNotify()));
|
||||
connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster()));
|
||||
connect(ui.testFeedButton, SIGNAL(clicked()), this, SLOT(testFeed()));
|
||||
connect(ui.testToasterButton, SIGNAL(clicked()), this, SLOT(testToaster()));
|
||||
connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool)));
|
||||
connect(NotifyQt::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool)));
|
||||
connect(ui.chatLobbies_CountFollowingText,SIGNAL(toggled(bool)),ui.chatLobbies_TextToNotify,SLOT(setEnabled(bool))) ;
|
||||
@ -49,8 +50,9 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
|
||||
QFont font = ui.notify_Peers->font(); // use font from existing checkbox
|
||||
|
||||
/* add feed notify */
|
||||
int row = 0;
|
||||
/* add feed and Toaster notify */
|
||||
int rowFeed = 0;
|
||||
int rowToaster = 0;
|
||||
int pluginCount = rsPlugins->nbPlugins();
|
||||
for (int i = 0; i < pluginCount; ++i) {
|
||||
RsPlugin *rsPlugin = rsPlugins->plugin(i);
|
||||
@ -58,15 +60,48 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
FeedNotify *feedNotify = rsPlugin->qt_feedNotify();
|
||||
if (feedNotify) {
|
||||
QString name;
|
||||
if (!feedNotify->hasSetting(name)) {
|
||||
continue;
|
||||
if (feedNotify->hasSetting(name)) {
|
||||
|
||||
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
|
||||
enabledCheckBox->setFont(font);
|
||||
ui.feedLayout->addWidget(enabledCheckBox, rowFeed++);
|
||||
|
||||
mFeedNotifySettingList.push_back(FeedNotifySetting(feedNotify, enabledCheckBox));
|
||||
}
|
||||
}
|
||||
|
||||
ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify();
|
||||
if (toasterNotify) {
|
||||
QString name;
|
||||
if (toasterNotify->hasSetting(name)) {
|
||||
|
||||
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
|
||||
enabledCheckBox->setFont(font);
|
||||
ui.toasterLayout->addWidget(enabledCheckBox, rowToaster++);
|
||||
|
||||
mToasterNotifySettingList.push_back(ToasterNotifySetting(toasterNotify, enabledCheckBox));
|
||||
}
|
||||
|
||||
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
|
||||
enabledCheckBox->setFont(font);
|
||||
ui.feedLayout->addWidget(enabledCheckBox, row++);
|
||||
|
||||
mFeedNotifySettingList.push_back(FeedNotifySetting(feedNotify, enabledCheckBox));
|
||||
QMap<QString, QString> map;
|
||||
if (toasterNotify->hasSettings(name, map)) {
|
||||
if (!map.empty()){
|
||||
QWidget* widget = new QWidget();
|
||||
QVBoxLayout* vbLayout = new QVBoxLayout(widget);
|
||||
QLabel *label = new QLabel(name, this);
|
||||
QFont fontBold = QFont(font);
|
||||
fontBold.setBold(true);
|
||||
label->setFont(fontBold);
|
||||
vbLayout->addWidget(label);
|
||||
for (QMap<QString, QString>::const_iterator it = map.begin(); it != map.end(); ++it){
|
||||
QCheckBox *enabledCheckBox = new QCheckBox(it.value(), this);
|
||||
enabledCheckBox->setAccessibleName(it.key());
|
||||
enabledCheckBox->setFont(font);
|
||||
vbLayout->addWidget(enabledCheckBox);
|
||||
mToasterNotifySettingList.push_back(ToasterNotifySetting(toasterNotify, enabledCheckBox));
|
||||
}
|
||||
ui.toasterLayout->addWidget(widget, rowToaster++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,7 +109,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
/* add user notify */
|
||||
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
|
||||
QList<UserNotify*>::const_iterator it;
|
||||
row = 0;
|
||||
rowFeed = 0;
|
||||
mChatLobbyUserNotify = 0;
|
||||
for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) {
|
||||
UserNotify *userNotify = *it;
|
||||
@ -86,16 +121,16 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
|
||||
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
|
||||
enabledCheckBox->setFont(font);
|
||||
ui.notifyLayout->addWidget(enabledCheckBox, row, 0, 0);
|
||||
ui.notifyLayout->addWidget(enabledCheckBox, rowFeed, 0, 0);
|
||||
connect(enabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(notifyToggled()));
|
||||
|
||||
QCheckBox *combinedCheckBox = new QCheckBox(tr("Combined"), this);
|
||||
combinedCheckBox->setFont(font);
|
||||
ui.notifyLayout->addWidget(combinedCheckBox, row, 1);
|
||||
ui.notifyLayout->addWidget(combinedCheckBox, rowFeed, 1);
|
||||
|
||||
QCheckBox *blinkCheckBox = new QCheckBox(tr("Blink"), this);
|
||||
blinkCheckBox->setFont(font);
|
||||
ui.notifyLayout->addWidget(blinkCheckBox, row++, 2);
|
||||
ui.notifyLayout->addWidget(blinkCheckBox, rowFeed++, 2);
|
||||
|
||||
mUserNotifySettingList.push_back(UserNotifySetting(userNotify, enabledCheckBox, combinedCheckBox, blinkCheckBox));
|
||||
|
||||
@ -188,6 +223,16 @@ NotifyPage::save(QString &/*errmsg*/)
|
||||
feedNotifyIt->mFeedNotify->setNotifyEnabled(feedNotifyIt->mEnabledCheckBox->isChecked());
|
||||
}
|
||||
|
||||
/* save toaster notify */
|
||||
QList<ToasterNotifySetting>::iterator toasterNotifyIt;
|
||||
for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) {
|
||||
if(toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()){
|
||||
toasterNotifyIt->mToasterNotify->setNotifyEnabled(toasterNotifyIt->mEnabledCheckBox->isChecked()) ;
|
||||
} else {
|
||||
toasterNotifyIt->mToasterNotify->setNotifyEnabled(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mEnabledCheckBox->isChecked()) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* save user notify */
|
||||
QList<UserNotifySetting>::iterator notifyIt;
|
||||
for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) {
|
||||
@ -284,6 +329,16 @@ void NotifyPage::load()
|
||||
feedNotifyIt->mEnabledCheckBox->setChecked(feedNotifyIt->mFeedNotify->notifyEnabled());
|
||||
}
|
||||
|
||||
/* load toaster notify */
|
||||
QList<ToasterNotifySetting>::iterator toasterNotifyIt;
|
||||
for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) {
|
||||
if (toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()) {
|
||||
toasterNotifyIt->mEnabledCheckBox->setChecked(toasterNotifyIt->mToasterNotify->notifyEnabled()) ;
|
||||
} else {
|
||||
toasterNotifyIt->mEnabledCheckBox->setChecked(toasterNotifyIt->mToasterNotify->notifyEnabled(toasterNotifyIt->mEnabledCheckBox->accessibleName())) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* load user notify */
|
||||
QList<UserNotifySetting>::iterator userNotifyIt;
|
||||
for (userNotifyIt = mUserNotifySettingList.begin(); userNotifyIt != mUserNotifySettingList.end(); ++userNotifyIt) {
|
||||
@ -321,7 +376,7 @@ void NotifyPage::notifyToggled()
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyPage::testNotify()
|
||||
void NotifyPage::testFeed()
|
||||
{
|
||||
NewsFeed::testFeeds(getNewsFlags());
|
||||
|
||||
@ -336,5 +391,19 @@ void NotifyPage::testNotify()
|
||||
|
||||
void NotifyPage::testToaster()
|
||||
{
|
||||
NotifyQt::getInstance()->testToaster(getNotifyFlags(), (RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(ui.comboBoxToasterPosition->currentIndex()).toInt(), QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value()));
|
||||
RshareSettings::enumToasterPosition pos = (RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(ui.comboBoxToasterPosition->currentIndex()).toInt();
|
||||
QPoint margin = QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value());
|
||||
NotifyQt::getInstance()->testToasters(getNotifyFlags(), pos, margin);
|
||||
|
||||
/* notify of plugins */
|
||||
QList<ToasterNotifySetting>::iterator toasterNotifyIt;
|
||||
for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) {
|
||||
if (toasterNotifyIt->mEnabledCheckBox->isChecked()){
|
||||
if (toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()){
|
||||
NotifyQt::getInstance()->testToaster(toasterNotifyIt->mToasterNotify, pos, margin) ;
|
||||
} else {
|
||||
NotifyQt::getInstance()->testToaster(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mToasterNotify, pos, margin) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,11 @@
|
||||
#include <retroshare-gui/configpage.h>
|
||||
#include "ui_NotifyPage.h"
|
||||
|
||||
#include "gui/chat/ChatLobbyUserNotify.h"
|
||||
|
||||
#include "gui/chat/ChatLobbyUserNotify.h"
|
||||
|
||||
class UserNotify;
|
||||
class FeedNotify;
|
||||
class ToasterNotify;
|
||||
|
||||
class UserNotifySetting
|
||||
{
|
||||
@ -54,6 +55,17 @@ public:
|
||||
: mFeedNotify(feedNotify), mEnabledCheckBox(enabledCheckBox) {}
|
||||
};
|
||||
|
||||
class ToasterNotifySetting
|
||||
{
|
||||
public:
|
||||
ToasterNotify *mToasterNotify;
|
||||
QCheckBox *mEnabledCheckBox;
|
||||
|
||||
public:
|
||||
ToasterNotifySetting(ToasterNotify *toasterNotify, QCheckBox *enabledCheckBox)
|
||||
: mToasterNotify(toasterNotify), mEnabledCheckBox(enabledCheckBox) {}
|
||||
};
|
||||
|
||||
class NotifyPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -76,14 +88,15 @@ public:
|
||||
private slots:
|
||||
void notifyToggled();
|
||||
void testToaster();
|
||||
void testNotify();
|
||||
void testFeed();
|
||||
|
||||
private:
|
||||
uint getNewsFlags();
|
||||
uint getNotifyFlags();
|
||||
ChatLobbyUserNotify* mChatLobbyUserNotify;
|
||||
ChatLobbyUserNotify* mChatLobbyUserNotify;
|
||||
|
||||
QList<FeedNotifySetting> mFeedNotifySettingList;
|
||||
QList<ToasterNotifySetting> mToasterNotifySettingList;
|
||||
QList<UserNotifySetting> mUserNotifySettingList;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
|
@ -14,7 +14,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabFeed">
|
||||
<attribute name="title">
|
||||
@ -99,7 +99,7 @@
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QPushButton" name="notifyButton">
|
||||
<widget class="QPushButton" name="testFeedButton">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
@ -237,12 +237,15 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="toasterLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QPushButton" name="toasterButton">
|
||||
<widget class="QPushButton" name="testToasterButton">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
|
49
retroshare-gui/src/gui/toaster/ToasterItem.cpp
Normal file
49
retroshare-gui/src/gui/toaster/ToasterItem.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2015 RetroShare Team
|
||||
*
|
||||
* 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 "ToasterItem.h"
|
||||
|
||||
/** Constructor */
|
||||
ToasterItem::ToasterItem(QWidget *child) : QObject(NULL)
|
||||
{
|
||||
/* Set widget */
|
||||
widget = child;
|
||||
|
||||
/* Values from settings */
|
||||
position = Settings->getToasterPosition();
|
||||
margin = Settings->getToasterMargin();
|
||||
|
||||
/* Standard values */
|
||||
timeToShow = 500;
|
||||
timeToLive = 3000;
|
||||
timeToHide = 500;
|
||||
|
||||
/* Calculated values */
|
||||
elapsedTimeToShow = 0;
|
||||
elapsedTimeToLive = 0;
|
||||
elapsedTimeToHide = 0;
|
||||
}
|
||||
|
||||
ToasterItem::~ToasterItem()
|
||||
{
|
||||
emit toasterItemDestroyed(this);
|
||||
delete widget;
|
||||
}
|
61
retroshare-gui/src/gui/toaster/ToasterItem.h
Normal file
61
retroshare-gui/src/gui/toaster/ToasterItem.h
Normal file
@ -0,0 +1,61 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2015 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _TOASTER_ITEM_H
|
||||
#define _TOASTER_ITEM_H
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ToasterItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
ToasterItem(QWidget *child = 0);
|
||||
/** Default Destructor */
|
||||
virtual ~ToasterItem();
|
||||
|
||||
QWidget *widget;
|
||||
|
||||
/* Values from settings */
|
||||
RshareSettings::enumToasterPosition position;
|
||||
QPoint margin;
|
||||
|
||||
/* Standard values */
|
||||
int timeToShow;
|
||||
int timeToLive;
|
||||
int timeToHide;
|
||||
|
||||
/* Calculated values */
|
||||
QPoint startPos;
|
||||
QPoint endPos;
|
||||
int elapsedTimeToShow;
|
||||
int elapsedTimeToLive;
|
||||
int elapsedTimeToHide;
|
||||
|
||||
signals:
|
||||
void toasterItemDestroyed(ToasterItem *toasterItem);//Can't use QObject::detroyed() signal as it's emitted after this class was destroyed.
|
||||
};
|
||||
|
||||
#endif //_TOASTER_ITEM_H
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user