mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Refactored inheritance hierarchy of ContextAudio (former ContextVoice)
refs #85
This commit is contained in:
@@ -3,232 +3,198 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTVOICE_INTERFACE_H
|
||||
#define BLACKCORE_CONTEXTVOICE_INTERFACE_H
|
||||
#ifndef BLACKCORE_CONTEXTAUDIO_H
|
||||
#define BLACKCORE_CONTEXTAUDIO_H
|
||||
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/audiodevicelist.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include "blackcore/voice_vatlib.h"
|
||||
#include "blackmisc/avcallsignlist.h"
|
||||
#include "blackmisc/avselcal.h"
|
||||
#include <QObject>
|
||||
#include <QDBusAbstractInterface>
|
||||
|
||||
#define BLACKCORE_CONTEXTVOICE_INTERFACENAME "blackcore.contextvoice"
|
||||
#define BLACKCORE_CONTEXTVOICE_SERVICEPATH "/voice"
|
||||
|
||||
// SERVICENAME must contain at least one ".", otherwise generation fails
|
||||
// as this is interpreted in the way comain.somename
|
||||
#define BLACKCORE_CONTEXTAUDIO_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextAudio"
|
||||
#define BLACKCORE_CONTEXTAUDIO_OBJECTPATH "/Audio"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief The IContextVoice class
|
||||
*/
|
||||
class IContextVoice : public QObject
|
||||
//! \brief Audio context interface
|
||||
class IContextAudio : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTVOICE_INTERFACENAME)
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Service name
|
||||
* \brief Interface name
|
||||
* \return
|
||||
*/
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTVOICE_INTERFACENAME);
|
||||
static QString s(BLACKCORE_CONTEXTAUDIO_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Service path
|
||||
* \brief Object path
|
||||
* \return
|
||||
*/
|
||||
static const QString &ServicePath()
|
||||
static const QString &ObjectPath()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTVOICE_SERVICEPATH);
|
||||
static QString s(BLACKCORE_CONTEXTAUDIO_OBJECTPATH);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param serviceName
|
||||
* \param connection
|
||||
* \brief Constructor
|
||||
* \param parent
|
||||
*/
|
||||
IContextVoice(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||
IContextAudio(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
/*!
|
||||
* Destructor
|
||||
*/
|
||||
~IContextVoice() {}
|
||||
virtual ~IContextAudio() {}
|
||||
|
||||
/*!
|
||||
* \brief Using local objects?
|
||||
* \return
|
||||
*/
|
||||
virtual bool usingLocalObjects() const { return false; }
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
/*!
|
||||
* Relay connection signals to local signals
|
||||
* No idea why this has to be wired and is not done automatically
|
||||
* \param connection
|
||||
*/
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief IContextVoice
|
||||
* \param parent
|
||||
*/
|
||||
IContextVoice(QObject *parent = nullptr) : QObject(parent), m_dBusInterface(nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Helper for logging, likely to be removed / changed
|
||||
* \param method
|
||||
* \param m1
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m4
|
||||
*/
|
||||
void log(const QString &method, const QString &m1 = "", const QString &m2 = "", const QString &m3 = "", const QString &m4 = "") const;
|
||||
|
||||
public slots:
|
||||
|
||||
/*!
|
||||
* Set my own identity for the voice rooms.
|
||||
* \remarks Actually at this time the callsign alone was sufficient. But I pass the
|
||||
* whole aircraft object so further information are present if needed any time later.
|
||||
*/
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAiricraft);
|
||||
|
||||
/*!
|
||||
* Get voice rooms for COM1, COM2:
|
||||
* From this connection audio status can be obtained
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const;
|
||||
|
||||
/*!
|
||||
* Get voice rooms for COM1, COM2, but without latest audio status
|
||||
* \return all voice rooms
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const;
|
||||
|
||||
/*!
|
||||
* \brief COM 1 voice room
|
||||
* \param withAudioStatus update audio status
|
||||
* \return
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom1VoiceRoom(bool withAudioStatus) const;
|
||||
|
||||
/*!
|
||||
* \brief COM 2 voice room
|
||||
* \param withAudioStatus update audio status
|
||||
* \return
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom2VoiceRoom(bool withAudioStatus) const;
|
||||
|
||||
/*!
|
||||
* \brief Set voice rooms
|
||||
*/
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2);
|
||||
|
||||
/*!
|
||||
* Leave all voice rooms
|
||||
*/
|
||||
virtual void leaveAllVoiceRooms();
|
||||
|
||||
/*!
|
||||
* \brief COM1 room users callsigns
|
||||
*/
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom1RoomCallsigns() const;
|
||||
|
||||
/*!
|
||||
* \brief COM2 room users callsigns
|
||||
*/
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom2RoomCallsigns() const;
|
||||
|
||||
/*!
|
||||
* \brief COM1 room users
|
||||
*/
|
||||
virtual BlackMisc::Network::CUserList getCom1RoomUsers() const;
|
||||
|
||||
/*!
|
||||
* \brief COM2 room users
|
||||
*/
|
||||
virtual BlackMisc::Network::CUserList getCom2RoomUsers() const;
|
||||
|
||||
/*!
|
||||
* \brief Audio devices
|
||||
*/
|
||||
virtual BlackMisc::Audio::CAudioDeviceList getAudioDevices() const;
|
||||
|
||||
/*!
|
||||
* \brief Get current audio device
|
||||
* \return input and output devices
|
||||
*/
|
||||
virtual BlackMisc::Audio::CAudioDeviceList getCurrentAudioDevices() const;
|
||||
|
||||
/*!
|
||||
* \brief Set current audio device
|
||||
* \param audioDevice can be input or audio device
|
||||
*/
|
||||
virtual void setCurrentAudioDevice(const BlackMisc::Audio::CAudioDevice &audioDevice);
|
||||
|
||||
/*!
|
||||
* \brief Set volumes via com units, also allows to mute
|
||||
* \see BlackMisc::Aviation::CComSystem::setVolumeInput()
|
||||
* \see BlackMisc::Aviation::CComSystem::setVolumeOutput()
|
||||
*/
|
||||
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2);
|
||||
|
||||
/*!
|
||||
* \brief Is muted?
|
||||
*/
|
||||
virtual bool isMuted() const;
|
||||
|
||||
/*!
|
||||
* \brief Play SELCAL tone
|
||||
*/
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const;
|
||||
|
||||
/*!
|
||||
* \brief Play notification sound
|
||||
* \param notification CSoundGenerator::Notification
|
||||
*/
|
||||
virtual void playNotification(uint notification) const;
|
||||
|
||||
/*!
|
||||
* \brief Microphone test
|
||||
*/
|
||||
virtual void runMicrophoneTest();
|
||||
|
||||
/*!
|
||||
* \brief Microphone test
|
||||
*/
|
||||
virtual void runSquelchTest();
|
||||
|
||||
/*!
|
||||
* \brief Get the microphone test result
|
||||
*/
|
||||
virtual QString getMicrophoneTestResult() const;
|
||||
|
||||
/*!
|
||||
* \brief Get the squelch value
|
||||
*/
|
||||
virtual double getSquelchValue() const;
|
||||
virtual bool usingLocalObjects() const = 0;
|
||||
|
||||
signals:
|
||||
/*!
|
||||
* \brief Audio test has been completed
|
||||
*/
|
||||
void audioTestCompleted();
|
||||
|
||||
public slots:
|
||||
|
||||
/*!
|
||||
* Set my own identity for the voice rooms.
|
||||
* \remarks Actually at this time the callsign alone was sufficient. But pass the
|
||||
* whole aircraft object so further information are present if needed any time later.
|
||||
*/
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAiricraft) = 0;
|
||||
|
||||
/*!
|
||||
* Get voice rooms for COM1, COM2:
|
||||
* From this connection audio status can be obtained
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const = 0;
|
||||
|
||||
/*!
|
||||
* Get voice rooms for COM1, COM2, but without latest audio status
|
||||
* \return all voice rooms
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief COM 1 voice room
|
||||
* \param withAudioStatus update audio status
|
||||
* \return
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom1VoiceRoom(bool withAudioStatus) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief COM 2 voice room
|
||||
* \param withAudioStatus update audio status
|
||||
* \return
|
||||
*/
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom2VoiceRoom(bool withAudioStatus) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Set voice rooms
|
||||
*/
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2) = 0;
|
||||
|
||||
/*!
|
||||
* Leave all voice rooms
|
||||
*/
|
||||
virtual void leaveAllVoiceRooms() = 0;
|
||||
|
||||
/*!
|
||||
* \brief COM1 room users callsigns
|
||||
*/
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom1RoomCallsigns() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief COM2 room users callsigns
|
||||
*/
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom2RoomCallsigns() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief COM1 room users
|
||||
*/
|
||||
virtual BlackMisc::Network::CUserList getCom1RoomUsers() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief COM2 room users
|
||||
*/
|
||||
virtual BlackMisc::Network::CUserList getCom2RoomUsers() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Audio devices
|
||||
*/
|
||||
virtual BlackMisc::Audio::CAudioDeviceList getAudioDevices() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Get current audio device
|
||||
* \return input and output devices
|
||||
*/
|
||||
virtual BlackMisc::Audio::CAudioDeviceList getCurrentAudioDevices() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Set current audio device
|
||||
* \param audioDevice can be input or audio device
|
||||
*/
|
||||
virtual void setCurrentAudioDevice(const BlackMisc::Audio::CAudioDevice &audioDevice) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Set volumes via com units, also allows to mute
|
||||
* \see BlackMisc::Aviation::CComSystem::setVolumeInput()
|
||||
* \see BlackMisc::Aviation::CComSystem::setVolumeOutput()
|
||||
*/
|
||||
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Is muted?
|
||||
*/
|
||||
virtual bool isMuted() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Play SELCAL tone
|
||||
*/
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Play notification sound
|
||||
* \param notification CSoundGenerator::Notification
|
||||
*/
|
||||
virtual void playNotification(uint notification) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Microphone test
|
||||
*/
|
||||
virtual void runMicrophoneTest() = 0;
|
||||
|
||||
/*!
|
||||
* \brief Microphone test
|
||||
*/
|
||||
virtual void runSquelchTest() = 0;
|
||||
|
||||
/*!
|
||||
* \brief Get the microphone test result
|
||||
*/
|
||||
virtual QString getMicrophoneTestResult() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Get the squelch value
|
||||
*/
|
||||
virtual double getSquelchValue() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_voice.h"
|
||||
#include "context_audio_impl.h"
|
||||
#include "context_network.h"
|
||||
#include "coreruntime.h"
|
||||
#include "../blacksound/soundgenerator.h"
|
||||
|
||||
#include "blacksound/soundgenerator.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -18,22 +21,20 @@ namespace BlackCore
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextVoice::CContextVoice(CCoreRuntime *runtime) : IContextVoice(runtime), m_voice(nullptr)
|
||||
CContextAudio::CContextAudio(QObject *parent) : IContextAudio(parent), m_voice(nullptr)
|
||||
{
|
||||
Q_ASSERT(runtime);
|
||||
|
||||
// 1. Init by "voice driver"
|
||||
this->m_voice = new CVoiceVatlib(this);
|
||||
|
||||
// 2. Signal / slots
|
||||
connect(this->m_voice, &CVoiceVatlib::micTestFinished, this, &CContextVoice::audioTestCompleted);
|
||||
connect(this->m_voice, &CVoiceVatlib::squelchTestFinished, this, &CContextVoice::audioTestCompleted);
|
||||
connect(this->m_voice, &CVoiceVatlib::micTestFinished, this, &CContextAudio::audioTestCompleted);
|
||||
connect(this->m_voice, &CVoiceVatlib::squelchTestFinished, this, &CContextAudio::audioTestCompleted);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
*/
|
||||
CContextVoice::~CContextVoice()
|
||||
CContextAudio::~CContextAudio()
|
||||
{
|
||||
this->leaveAllVoiceRooms();
|
||||
}
|
||||
@@ -41,7 +42,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Own aircraft
|
||||
*/
|
||||
void CContextVoice::setOwnAircraft(const CAircraft &ownAircraft)
|
||||
void CContextAudio::setOwnAircraft(const CAircraft &ownAircraft)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
this->m_voice->setMyAircraftCallsign(ownAircraft.getCallsign());
|
||||
@@ -50,7 +51,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice rooms for COM
|
||||
*/
|
||||
CVoiceRoomList CContextVoice::getComVoiceRoomsWithAudioStatus() const
|
||||
CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return this->m_voice->getComVoiceRoomsWithAudioStatus();
|
||||
@@ -59,7 +60,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice rooms for COM
|
||||
*/
|
||||
CVoiceRoom CContextVoice::getCom1VoiceRoom(bool withAudioStatus) const
|
||||
CVoiceRoom CContextAudio::getCom1VoiceRoom(bool withAudioStatus) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
if (withAudioStatus)
|
||||
@@ -71,7 +72,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice rooms for COM
|
||||
*/
|
||||
CVoiceRoom CContextVoice::getCom2VoiceRoom(bool withAudioStatus) const
|
||||
CVoiceRoom CContextAudio::getCom2VoiceRoom(bool withAudioStatus) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
if (withAudioStatus)
|
||||
@@ -83,7 +84,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice rooms for COM (const)
|
||||
*/
|
||||
CVoiceRoomList CContextVoice::getComVoiceRooms() const
|
||||
CVoiceRoomList CContextAudio::getComVoiceRooms() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return this->m_voice->getComVoiceRooms();
|
||||
@@ -92,7 +93,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Leave all voice rooms
|
||||
*/
|
||||
void CContextVoice::leaveAllVoiceRooms()
|
||||
void CContextAudio::leaveAllVoiceRooms()
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
this->m_voice->leaveAllVoiceRooms();
|
||||
@@ -101,7 +102,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Audio devices
|
||||
*/
|
||||
CAudioDeviceList CContextVoice::getAudioDevices() const
|
||||
CAudioDeviceList CContextAudio::getAudioDevices() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return this->m_voice->audioDevices();
|
||||
@@ -110,7 +111,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Audio default devices
|
||||
*/
|
||||
CAudioDeviceList CContextVoice::getCurrentAudioDevices() const
|
||||
CAudioDeviceList CContextAudio::getCurrentAudioDevices() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
CAudioDeviceList devices;
|
||||
@@ -122,7 +123,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Set current device
|
||||
*/
|
||||
void CContextVoice::setCurrentAudioDevice(const CAudioDevice &audioDevice)
|
||||
void CContextAudio::setCurrentAudioDevice(const CAudioDevice &audioDevice)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
Q_ASSERT(audioDevice.getType() != CAudioDevice::Unknown);
|
||||
@@ -139,7 +140,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Set volumes
|
||||
*/
|
||||
void CContextVoice::setVolumes(const CComSystem &com1, const CComSystem &com2)
|
||||
void CContextAudio::setVolumes(const CComSystem &com1, const CComSystem &com2)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
this->m_voice->setRoomOutputVolume(IVoice::COM1, com1.getVolumeOutput());
|
||||
@@ -151,7 +152,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Muted?
|
||||
*/
|
||||
bool CContextVoice::isMuted() const
|
||||
bool CContextAudio::isMuted() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return this->m_voice->isMuted();
|
||||
@@ -160,7 +161,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Set voice rooms
|
||||
*/
|
||||
void CContextVoice::setComVoiceRooms(const CVoiceRoom &voiceRoomCom1, const CVoiceRoom &voiceRoomCom2)
|
||||
void CContextAudio::setComVoiceRooms(const CVoiceRoom &voiceRoomCom1, const CVoiceRoom &voiceRoomCom2)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
CVoiceRoomList currentRooms = this->m_voice->getComVoiceRoomsWithAudioStatus();
|
||||
@@ -181,7 +182,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Room 1 callsigns
|
||||
*/
|
||||
CCallsignList CContextVoice::getCom1RoomCallsigns() const
|
||||
CCallsignList CContextAudio::getCom1RoomCallsigns() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return this->m_voice->getVoiceRoomCallsigns(IVoice::COM1);
|
||||
@@ -190,7 +191,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Room 2 callsigns
|
||||
*/
|
||||
CCallsignList CContextVoice::getCom2RoomCallsigns() const
|
||||
CCallsignList CContextAudio::getCom2RoomCallsigns() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return this->m_voice->getVoiceRoomCallsigns(IVoice::COM2);
|
||||
@@ -199,7 +200,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Room 1 users
|
||||
*/
|
||||
Network::CUserList CContextVoice::getCom1RoomUsers() const
|
||||
Network::CUserList CContextAudio::getCom1RoomUsers() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
Q_ASSERT(this->getRuntime());
|
||||
@@ -211,7 +212,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Room 2 users
|
||||
*/
|
||||
Network::CUserList CContextVoice::getCom2RoomUsers() const
|
||||
Network::CUserList CContextAudio::getCom2RoomUsers() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
Q_ASSERT(this->getRuntime());
|
||||
@@ -223,7 +224,7 @@ namespace BlackCore
|
||||
/*
|
||||
* SELCAL tone
|
||||
*/
|
||||
void CContextVoice::playSelcalTone(const CSelcal &selcal) const
|
||||
void CContextAudio::playSelcalTone(const CSelcal &selcal) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
CAudioDevice outputDevice = m_voice->getCurrentOutputDevice();
|
||||
@@ -233,7 +234,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Notification
|
||||
*/
|
||||
void CContextVoice::playNotification(uint notification) const
|
||||
void CContextAudio::playNotification(uint notification) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
BlackSound::CSoundGenerator::playNotificationSound(90, static_cast<BlackSound::CSoundGenerator::Notification>(notification));
|
||||
@@ -242,7 +243,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Mic test.
|
||||
*/
|
||||
void CContextVoice::runMicrophoneTest()
|
||||
void CContextAudio::runMicrophoneTest()
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
this->m_voice->runMicrophoneTest();
|
||||
@@ -251,7 +252,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Squelch test.
|
||||
*/
|
||||
void CContextVoice::runSquelchTest()
|
||||
void CContextAudio::runSquelchTest()
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
this->m_voice->runSquelchTest();
|
||||
@@ -260,7 +261,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Microphone test
|
||||
*/
|
||||
QString CContextVoice::getMicrophoneTestResult() const
|
||||
QString CContextAudio::getMicrophoneTestResult() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return this->m_voice->micTestResultAsString();
|
||||
@@ -269,7 +270,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Squelch value
|
||||
*/
|
||||
double CContextVoice::getSquelchValue() const
|
||||
double CContextAudio::getSquelchValue() const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
return static_cast<double>(this->m_voice->inputSquelch());
|
||||
@@ -3,46 +3,29 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTVOICE_H
|
||||
#define BLACKCORE_CONTEXTVOICE_H
|
||||
#ifndef BLACKCORE_CONTEXTAUDIO_IMPL_H
|
||||
#define BLACKCORE_CONTEXTAUDIO_IMPL_H
|
||||
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/voice_vatlib.h"
|
||||
#include "blackcore/context_voice_interface.h"
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include <QObject>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QTimer>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
|
||||
#define BLACKCORE_CONTEXTVOICE_INTERFACENAME "blackcore.contextvoice"
|
||||
#include "context_audio.h"
|
||||
#include "coreruntime.h"
|
||||
#include "dbus_server.h"
|
||||
#include "voice_vatlib.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
/*!
|
||||
* \brief Network context
|
||||
*/
|
||||
class CContextVoice : public IContextVoice
|
||||
//! \brief Audio context implementation
|
||||
class CContextAudio : public IContextAudio
|
||||
{
|
||||
// Register by same name, make signals sender independent
|
||||
// http://dbus.freedesktop.org/doc/dbus-faq.html#idp48032144
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTVOICE_INTERFACENAME)
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! \brief Constructor
|
||||
CContextVoice(CCoreRuntime *runtime);
|
||||
CContextAudio(QObject *runtime);
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CContextVoice();
|
||||
virtual ~CContextAudio();
|
||||
|
||||
/*!
|
||||
* \brief Register myself in DBus
|
||||
@@ -50,83 +33,90 @@ namespace BlackCore
|
||||
*/
|
||||
void registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
server->addObject(IContextVoice::ServicePath(), this);
|
||||
Q_ASSERT(server);
|
||||
server->addObject(IContextAudio::ObjectPath(), this);
|
||||
}
|
||||
|
||||
//! \brief Runtime
|
||||
CCoreRuntime *getRuntime()
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! \brief Const runtime
|
||||
const CCoreRuntime *getRuntime() const
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! \brief Using local objects?
|
||||
virtual bool usingLocalObjects() const { return true; }
|
||||
//! \copydoc IContextAudio::usingLocalObjects()
|
||||
virtual bool usingLocalObjects() const override { return true; }
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextVoice::setOwnAircraft
|
||||
//! \copydoc IContextAudio::setOwnAircraft()
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||
|
||||
//! \copydoc IContextVoice::getComVoiceRooms()
|
||||
//! \copydoc IContextAudio::getComVoiceRooms()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const override;
|
||||
|
||||
//! \copydoc IContextVoice::getComVoiceRoomsWithAudioStatus()
|
||||
//! \copydoc IContextAudio::getComVoiceRoomsWithAudioStatus()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const override;
|
||||
|
||||
//! \copydoc IContextVoice::getCom1VoiceRoom
|
||||
//! \copydoc IContextAudio::getCom1VoiceRoom
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom1VoiceRoom(bool withAudioStatus) const override;
|
||||
|
||||
//! \copydoc IContextVoice::getCom2VoiceRoom
|
||||
//! \copydoc IContextAudio::getCom2VoiceRoom
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom2VoiceRoom(bool withAudioStatus) const override;
|
||||
|
||||
//! \copydoc IContextVoice::setComVoiceRooms()
|
||||
//! \copydoc IContextAudio::setComVoiceRooms()
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2) override;
|
||||
|
||||
//! \copydoc IContextVoice::getCom1RoomCallsigns()
|
||||
//! \copydoc IContextAudio::getCom1RoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom1RoomCallsigns() const override;
|
||||
|
||||
//! \copydoc IContextVoice::getCom2RoomCallsigns()
|
||||
//! \copydoc IContextAudio::getCom2RoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom2RoomCallsigns() const override;
|
||||
|
||||
//! \copydoc IContextVoice::getCom1RoomUsers()
|
||||
//! \copydoc IContextAudio::getCom1RoomUsers()
|
||||
virtual BlackMisc::Network::CUserList getCom1RoomUsers() const override;
|
||||
|
||||
//! \copydoc IContextVoice::getCom2RoomUsers()
|
||||
//! \copydoc IContextAudio::getCom2RoomUsers()
|
||||
virtual BlackMisc::Network::CUserList getCom2RoomUsers() const override;
|
||||
|
||||
//! \copydoc IContextVoice::leaveAllVoiceRooms
|
||||
//! \copydoc IContextAudio::leaveAllVoiceRooms
|
||||
virtual void leaveAllVoiceRooms() override;
|
||||
|
||||
//! \copydoc IContextVoice::getAudioDevices()
|
||||
//! \copydoc IContextAudio::getAudioDevices()
|
||||
virtual BlackMisc::Audio::CAudioDeviceList getAudioDevices() const override;
|
||||
|
||||
//! \copydoc IContextVoice::getCurrentAudioDevices()
|
||||
//! \copydoc IContextAudio::getCurrentAudioDevices()
|
||||
virtual BlackMisc::Audio::CAudioDeviceList getCurrentAudioDevices() const override;
|
||||
|
||||
//! \copydoc IContextVoice::setCurrentAudioDevice()
|
||||
//! \copydoc IContextAudio::setCurrentAudioDevice()
|
||||
virtual void setCurrentAudioDevice(const BlackMisc::Audio::CAudioDevice &audioDevice) override;
|
||||
|
||||
//! \copydoc IContextVoice::setVolumes()
|
||||
//! \copydoc IContextAudio::setVolumes()
|
||||
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) override;
|
||||
|
||||
//! \copydoc IContextVoice::isMuted()
|
||||
//! \copydoc IContextAudio::isMuted()
|
||||
virtual bool isMuted() const override;
|
||||
|
||||
//! \copydoc IContextVoice::playSelcalTone()
|
||||
//! \copydoc IContextAudio::playSelcalTone()
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override;
|
||||
|
||||
//! \copydoc IContextVoice::playNotification()
|
||||
//! \copydoc IContextAudio::playNotification()
|
||||
virtual void playNotification(uint notification) const override;
|
||||
|
||||
//! \copydoc IContextVoice::runMicrophoneTest()
|
||||
//! \copydoc IContextAudio::runMicrophoneTest()
|
||||
virtual void runMicrophoneTest() override;
|
||||
|
||||
//! \copydoc IContextVoice::runSquelchTest()
|
||||
//! \copydoc IContextAudio::runSquelchTest()
|
||||
virtual void runSquelchTest() override;
|
||||
|
||||
//! \copydoc IContextVoice::getMicrophoneTestResult()
|
||||
//! \copydoc IContextAudio::getMicrophoneTestResult()
|
||||
virtual QString getMicrophoneTestResult() const override;
|
||||
|
||||
//! \copydoc IContextVoice::getSquelchValue()
|
||||
//! \copydoc IContextAudio::getSquelchValue()
|
||||
virtual double getSquelchValue() const override;
|
||||
|
||||
private:
|
||||
@@ -3,8 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "blackcore/context_voice_interface.h"
|
||||
#include <QObject>
|
||||
#include "context_audio_proxy.h"
|
||||
#include <QDBusConnection>
|
||||
|
||||
using namespace BlackMisc::Audio;
|
||||
@@ -17,25 +16,27 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
IContextVoice::IContextVoice(const QString &serviceName, QDBusConnection &connection, QObject *parent) : QObject(parent), m_dBusInterface(0)
|
||||
CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextAudio(parent), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(serviceName , IContextVoice::ServicePath(), IContextVoice::InterfaceName(), connection, this);
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||
connection, this);
|
||||
this->relaySignals(serviceName, connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Workaround for signals, not working without, but why?
|
||||
*/
|
||||
void IContextVoice::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
void CContextAudioProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
{
|
||||
connection.connect(serviceName, IContextVoice::ServicePath(), IContextVoice::InterfaceName(),
|
||||
connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||
"audioTestCompleted", this, SIGNAL(audioTestCompleted()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Own aircraft
|
||||
*/
|
||||
void IContextVoice::setOwnAircraft(const CAircraft &ownAircraft)
|
||||
void CContextAudioProxy::setOwnAircraft(const CAircraft &ownAircraft)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setOwnAircraft"), ownAircraft);
|
||||
}
|
||||
@@ -43,7 +44,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Leave all voice rooms
|
||||
*/
|
||||
void IContextVoice::leaveAllVoiceRooms()
|
||||
void CContextAudioProxy::leaveAllVoiceRooms()
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("leaveAllVoiceRooms"));
|
||||
}
|
||||
@@ -51,7 +52,7 @@ namespace BlackCore
|
||||
/*
|
||||
* COM1 callsigns
|
||||
*/
|
||||
BlackMisc::Aviation::CCallsignList IContextVoice::getCom1RoomCallsigns() const
|
||||
BlackMisc::Aviation::CCallsignList CContextAudioProxy::getCom1RoomCallsigns() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CCallsignList>(QLatin1Literal("getCom1RoomCallsigns"));
|
||||
}
|
||||
@@ -59,7 +60,7 @@ namespace BlackCore
|
||||
/*
|
||||
* COM2 callsigns
|
||||
*/
|
||||
BlackMisc::Aviation::CCallsignList IContextVoice::getCom2RoomCallsigns() const
|
||||
BlackMisc::Aviation::CCallsignList CContextAudioProxy::getCom2RoomCallsigns() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CCallsignList>(QLatin1Literal("getCom2RoomCallsigns"));
|
||||
}
|
||||
@@ -67,7 +68,7 @@ namespace BlackCore
|
||||
/*
|
||||
* COM1 users
|
||||
*/
|
||||
BlackMisc::Network::CUserList IContextVoice::getCom1RoomUsers() const
|
||||
BlackMisc::Network::CUserList CContextAudioProxy::getCom1RoomUsers() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CUserList>(QLatin1Literal("getCom1RoomUsers"));
|
||||
}
|
||||
@@ -75,7 +76,7 @@ namespace BlackCore
|
||||
/*
|
||||
* COM2 users
|
||||
*/
|
||||
BlackMisc::Network::CUserList IContextVoice::getCom2RoomUsers() const
|
||||
BlackMisc::Network::CUserList CContextAudioProxy::getCom2RoomUsers() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CUserList>(QLatin1Literal("getCom2RoomUsers"));
|
||||
}
|
||||
@@ -83,7 +84,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Audio devices
|
||||
*/
|
||||
CAudioDeviceList IContextVoice::getAudioDevices() const
|
||||
CAudioDeviceList CContextAudioProxy::getAudioDevices() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CAudioDeviceList>(QLatin1Literal("getAudioDevices"));
|
||||
}
|
||||
@@ -91,7 +92,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Get current audio devices
|
||||
*/
|
||||
BlackMisc::Audio::CAudioDeviceList IContextVoice::getCurrentAudioDevices() const
|
||||
BlackMisc::Audio::CAudioDeviceList CContextAudioProxy::getCurrentAudioDevices() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CAudioDeviceList>(QLatin1Literal("getCurrentAudioDevices"));
|
||||
}
|
||||
@@ -99,7 +100,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Set current audio device
|
||||
*/
|
||||
void IContextVoice::setCurrentAudioDevice(const CAudioDevice &audioDevice)
|
||||
void CContextAudioProxy::setCurrentAudioDevice(const CAudioDevice &audioDevice)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setCurrentAudioDevice"), audioDevice);
|
||||
}
|
||||
@@ -107,7 +108,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice rooms, with audio status
|
||||
*/
|
||||
CVoiceRoomList IContextVoice::getComVoiceRoomsWithAudioStatus() const
|
||||
CVoiceRoomList CContextAudioProxy::getComVoiceRoomsWithAudioStatus() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CVoiceRoomList>(QLatin1Literal("getComVoiceRoomsWithAudioStatus"));
|
||||
}
|
||||
@@ -115,7 +116,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice rooms, without audio status
|
||||
*/
|
||||
CVoiceRoomList IContextVoice::getComVoiceRooms() const
|
||||
CVoiceRoomList CContextAudioProxy::getComVoiceRooms() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CVoiceRoomList>(QLatin1Literal("getComVoiceRooms"));
|
||||
}
|
||||
@@ -123,7 +124,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice room
|
||||
*/
|
||||
CVoiceRoom IContextVoice::getCom1VoiceRoom(bool withAudioStatus) const
|
||||
CVoiceRoom CContextAudioProxy::getCom1VoiceRoom(bool withAudioStatus) const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CVoiceRoom>(QLatin1Literal("getCom1VoiceRoom"), withAudioStatus);
|
||||
}
|
||||
@@ -131,7 +132,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Voice room
|
||||
*/
|
||||
CVoiceRoom IContextVoice::getCom2VoiceRoom(bool withAudioStatus) const
|
||||
CVoiceRoom CContextAudioProxy::getCom2VoiceRoom(bool withAudioStatus) const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CVoiceRoom>(QLatin1Literal("getCom2VoiceRoom"), withAudioStatus);
|
||||
}
|
||||
@@ -139,7 +140,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Set voice rooms
|
||||
*/
|
||||
void IContextVoice::setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2)
|
||||
void CContextAudioProxy::setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setComVoiceRooms"), voiceRoomCom1, voiceRoomCom2);
|
||||
}
|
||||
@@ -147,7 +148,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Play SELCAL tone
|
||||
*/
|
||||
void IContextVoice::playSelcalTone(const CSelcal &selcal) const
|
||||
void CContextAudioProxy::playSelcalTone(const CSelcal &selcal) const
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("playSelcalTone"), selcal);
|
||||
}
|
||||
@@ -155,7 +156,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Notification sound
|
||||
*/
|
||||
void IContextVoice::playNotification(uint notification) const
|
||||
void CContextAudioProxy::playNotification(uint notification) const
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("playNotification"), notification);
|
||||
}
|
||||
@@ -163,7 +164,7 @@ namespace BlackCore
|
||||
/*
|
||||
* MIC test
|
||||
*/
|
||||
void IContextVoice::runMicrophoneTest()
|
||||
void CContextAudioProxy::runMicrophoneTest()
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("runMicrophoneTest"));
|
||||
}
|
||||
@@ -171,7 +172,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Mic test
|
||||
*/
|
||||
void IContextVoice::runSquelchTest()
|
||||
void CContextAudioProxy::runSquelchTest()
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("runSquelchTest"));
|
||||
}
|
||||
@@ -179,7 +180,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Test result
|
||||
*/
|
||||
QString IContextVoice::getMicrophoneTestResult() const
|
||||
QString CContextAudioProxy::getMicrophoneTestResult() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<QString>(QLatin1Literal("getMicrophoneTestResult"));
|
||||
}
|
||||
@@ -187,7 +188,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Squelch value
|
||||
*/
|
||||
double IContextVoice::getSquelchValue() const
|
||||
double CContextAudioProxy::getSquelchValue() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<double>(QLatin1Literal("getSquelchValue"));
|
||||
}
|
||||
@@ -195,7 +196,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Volumes, by COM systems
|
||||
*/
|
||||
void IContextVoice::setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2)
|
||||
void CContextAudioProxy::setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setVolumes"), com1, com2);
|
||||
}
|
||||
@@ -203,7 +204,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Muted?
|
||||
*/
|
||||
bool IContextVoice::isMuted() const
|
||||
bool CContextAudioProxy::isMuted() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isMuted"));
|
||||
}
|
||||
@@ -211,7 +212,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Logging
|
||||
*/
|
||||
void IContextVoice::log(const QString &method, const QString &m1, const QString &m2, const QString &m3, const QString &m4) const
|
||||
void CContextAudioProxy::log(const QString &method, const QString &m1, const QString &m2, const QString &m3, const QString &m4) const
|
||||
{
|
||||
if (m1.isEmpty())
|
||||
qDebug() << " LOG: " << method;
|
||||
141
src/blackcore/context_audio_proxy.h
Normal file
141
src/blackcore/context_audio_proxy.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/* Copyright (C) 2013x VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTVOICE_PROXY_H
|
||||
#define BLACKCORE_CONTEXTVOICE_PROXY_H
|
||||
|
||||
#include "context_audio.h"
|
||||
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/vaudiodevicelist.h"
|
||||
#include "blackmisc/vvoiceroomlist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
//! \brief Audio context proxy
|
||||
class CContextAudioProxy : public IContextAudio
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param serviceName
|
||||
* \param connection
|
||||
* \param parent
|
||||
*/
|
||||
CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||
|
||||
/*!
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~CContextAudioProxy() {}
|
||||
|
||||
//! \copydoc IContextVoice::usingLocalObjects()
|
||||
virtual bool usingLocalObjects() const override { return false; }
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
/*!
|
||||
* Relay connection signals to local signals
|
||||
* No idea why this has to be wired and is not done automatically
|
||||
* \param connection
|
||||
*/
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief IContextVoice
|
||||
* \param parent
|
||||
*/
|
||||
CContextAudioProxy(QObject *parent = nullptr) : IContextAudio(parent), m_dBusInterface(nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Helper for logging, likely to be removed / changed
|
||||
* \param method
|
||||
* \param m1
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m4
|
||||
*/
|
||||
void log(const QString &method, const QString &m1 = "", const QString &m2 = "", const QString &m3 = "", const QString &m4 = "") const;
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc IContextAudio::setOwnAircraft()
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||
|
||||
//! \copydoc IContextAudio::getComVoiceRooms()
|
||||
virtual BlackMisc::Voice::CVoiceRoomList getComVoiceRooms() const override;
|
||||
|
||||
//! \copydoc IContextAudio::getComVoiceRoomsWithAudioStatus()
|
||||
virtual BlackMisc::Voice::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom1VoiceRoom
|
||||
virtual BlackMisc::Voice::CVoiceRoom getCom1VoiceRoom(bool withAudioStatus) const override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom2VoiceRoom
|
||||
virtual BlackMisc::Voice::CVoiceRoom getCom2VoiceRoom(bool withAudioStatus) const override;
|
||||
|
||||
//! \copydoc IContextAudio::setComVoiceRooms()
|
||||
virtual void setComVoiceRooms(const BlackMisc::Voice::CVoiceRoom &voiceRoomCom1, const BlackMisc::Voice::CVoiceRoom &voiceRoomCom2) override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom1RoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom1RoomCallsigns() const override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom2RoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom2RoomCallsigns() const override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom1RoomUsers()
|
||||
virtual BlackMisc::Network::CUserList getCom1RoomUsers() const override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom2RoomUsers()
|
||||
virtual BlackMisc::Network::CUserList getCom2RoomUsers() const override;
|
||||
|
||||
//! \copydoc IContextAudio::leaveAllVoiceRooms
|
||||
virtual void leaveAllVoiceRooms() override;
|
||||
|
||||
//! \copydoc IContextAudio::getAudioDevices()
|
||||
virtual BlackMisc::Voice::CAudioDeviceList getAudioDevices() const override;
|
||||
|
||||
//! \copydoc IContextAudio::getCurrentAudioDevices()
|
||||
virtual BlackMisc::Voice::CAudioDeviceList getCurrentAudioDevices() const override;
|
||||
|
||||
//! \copydoc IContextAudio::setCurrentAudioDevice()
|
||||
virtual void setCurrentAudioDevice(const BlackMisc::Voice::CAudioDevice &audioDevice) override;
|
||||
|
||||
//! \copydoc IContextAudio::setVolumes()
|
||||
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) override;
|
||||
|
||||
//! \copydoc IContextAudio::isMuted()
|
||||
virtual bool isMuted() const override;
|
||||
|
||||
//! \copydoc IContextAudio::playSelcalTone()
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override;
|
||||
|
||||
//! \copydoc IContextAudio::playNotification()
|
||||
virtual void playNotification(uint notification) const override;
|
||||
|
||||
//! \copydoc IContextAudio::runMicrophoneTest()
|
||||
virtual void runMicrophoneTest() override;
|
||||
|
||||
//! \copydoc IContextAudio::runSquelchTest()
|
||||
virtual void runSquelchTest() override;
|
||||
|
||||
//! \copydoc IContextAudio::getMicrophoneTestResult()
|
||||
virtual QString getMicrophoneTestResult() const override;
|
||||
|
||||
//! \copydoc IContextAudio::getSquelchValue()
|
||||
virtual double getSquelchValue() const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/nwserver.h"
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/context_application_impl.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/context_voice.h"
|
||||
#include "blackcore/context_audio_impl.h"
|
||||
#include "blackcore/context_simulator_impl.h"
|
||||
|
||||
namespace BlackCore
|
||||
@@ -14,7 +14,7 @@ namespace BlackCore
|
||||
*/
|
||||
CCoreRuntime::CCoreRuntime(bool withDbus, QObject *parent) :
|
||||
QObject(parent), m_init(false), m_dbusServer(nullptr),
|
||||
m_contextNetwork(nullptr), m_contextVoice(nullptr),
|
||||
m_contextNetwork(nullptr), m_contextAudio(nullptr),
|
||||
m_contextSettings(nullptr), m_contextApplication(nullptr),
|
||||
m_contextSimulator(nullptr)
|
||||
{
|
||||
@@ -46,8 +46,8 @@ void CCoreRuntime::init(bool withDbus)
|
||||
this->m_contextApplication = new CContextApplication(this);
|
||||
if (withDbus) this->m_contextApplication->registerWithDBus(this->m_dbusServer);
|
||||
|
||||
this->m_contextVoice = new CContextVoice(this);
|
||||
if (withDbus) this->m_contextVoice->registerWithDBus(this->m_dbusServer);
|
||||
this->m_contextAudio = new CContextAudio(this);
|
||||
if (withDbus) this->m_contextAudio->registerWithDBus(this->m_dbusServer);
|
||||
|
||||
this->m_contextSimulator = new CContextSimulator(this);
|
||||
if (withDbus) this->m_contextSimulator->registerWithDBus(this->m_dbusServer);
|
||||
@@ -66,14 +66,14 @@ const IContextNetwork *CCoreRuntime::getIContextNetwork() const
|
||||
return this->m_contextNetwork;
|
||||
}
|
||||
|
||||
IContextVoice *CCoreRuntime::getIContextVoice()
|
||||
IContextAudio *CCoreRuntime::getIContextAudio()
|
||||
{
|
||||
return this->m_contextVoice;
|
||||
return this->m_contextAudio;
|
||||
}
|
||||
|
||||
const IContextVoice *CCoreRuntime::getIContextVoice() const
|
||||
const IContextAudio *CCoreRuntime::getIContextAudio() const
|
||||
{
|
||||
return this->m_contextVoice;
|
||||
return this->m_contextAudio;
|
||||
}
|
||||
|
||||
IContextSettings *CCoreRuntime::getIContextSettings()
|
||||
|
||||
@@ -9,12 +9,12 @@ namespace BlackCore
|
||||
// https://dev.vatsim-germany.org/boards/22/topics/1350?r=1359#message-1359
|
||||
class CDBusServer;
|
||||
class CContextNetwork;
|
||||
class CContextVoice;
|
||||
class CContextAudio;
|
||||
class CContextSettings;
|
||||
class CContextApplication;
|
||||
class CContextSimulator;
|
||||
class IContextNetwork;
|
||||
class IContextVoice;
|
||||
class IContextAudio;
|
||||
class IContextSettings;
|
||||
class IContextApplication;
|
||||
class IContextSimulator;
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
bool m_init; /*!< flag */
|
||||
CDBusServer *m_dbusServer;
|
||||
CContextNetwork *m_contextNetwork;
|
||||
CContextVoice *m_contextVoice;
|
||||
CContextAudio *m_contextAudio;
|
||||
CContextSettings *m_contextSettings;
|
||||
CContextApplication *m_contextApplication;
|
||||
CContextSimulator *m_contextSimulator;
|
||||
@@ -79,13 +79,13 @@ public:
|
||||
* \brief Context for network
|
||||
* \return
|
||||
*/
|
||||
IContextVoice *getIContextVoice();
|
||||
IContextAudio *getIContextAudio();
|
||||
|
||||
/*!
|
||||
* \brief Context for network
|
||||
* \return
|
||||
*/
|
||||
const IContextVoice *getIContextVoice() const;
|
||||
const IContextAudio *getIContextAudio() const;
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user