mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #382, reviewed audio context handling
* only init QDbusServer for P2P * changed init order of contexts in runtime * use "fake" signal to call setComVoiceRooms (remote in GUI) * added slot to change voice room callsign * used "org.swift" instead of "net.vatim" (just style) * used const QString for serviceName * added correct copyright header (just style)
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/context_application_impl.h"
|
||||
#include "blackcore/context_application_proxy.h"
|
||||
@@ -14,7 +23,7 @@ using namespace BlackMisc::Settings;
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
IContextApplication *IContextApplication::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn)
|
||||
IContextApplication *IContextApplication::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &connection)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
@@ -22,7 +31,7 @@ namespace BlackCore
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
return (new CContextApplication(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextApplicationProxy(BlackCore::CDBusServer::ServiceName, conn, mode, parent);
|
||||
return new BlackCore::CContextApplicationProxy(BlackCore::CDBusServer::ServiceName(), connection, mode, parent);
|
||||
default:
|
||||
qFatal("Always initialize an application context!");
|
||||
return nullptr;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
/* Copyright (C) 2013 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/. */
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
@@ -10,6 +14,7 @@
|
||||
|
||||
#include "blackcore/context.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
#include "blackmisc/eveventhotkeyfunction.h"
|
||||
#include "blackmisc/evoriginator.h"
|
||||
#include <QObject>
|
||||
@@ -19,7 +24,7 @@
|
||||
//! @{
|
||||
|
||||
//! DBus interface for context
|
||||
#define BLACKCORE_CONTEXTAPPLICATION_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextApplication"
|
||||
#define BLACKCORE_CONTEXTAPPLICATION_INTERFACENAME "org.swift.pilotclient.BlackCore.ContextApplication"
|
||||
|
||||
//! DBus object path for context
|
||||
#define BLACKCORE_CONTEXTAPPLICATION_OBJECTPATH "/Application"
|
||||
@@ -85,11 +90,16 @@ namespace BlackCore
|
||||
void componentChanged(uint component, uint action);
|
||||
|
||||
//! A log message was logged
|
||||
//! \note Used with CLogMessage, do not use directly
|
||||
void messageLogged(const BlackMisc::CStatusMessage &message, const BlackMisc::Event::COriginator &origin);
|
||||
|
||||
//! Work around for audio context, #382
|
||||
void fakedSetComVoiceRoom(const BlackMisc::Audio::CVoiceRoomList &requestedRooms);
|
||||
|
||||
public slots:
|
||||
//! Log a log message
|
||||
//! \note Not pure because it can be called from the base class constructor.
|
||||
//! \note this is the function which relays CLogMessage via DBus
|
||||
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::Event::COriginator &origin) { Q_UNUSED(message); Q_UNUSED(origin); }
|
||||
|
||||
//! \brief Ping a token, used to check if application is alive
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace BlackCore
|
||||
//! Register myself in DBus, fail safe
|
||||
CContextApplication *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) { return this; }
|
||||
server->addObject(IContextApplication::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ namespace BlackCore
|
||||
*/
|
||||
CContextApplicationProxy::CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextApplication(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(serviceName , IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), connection, this);
|
||||
this->m_dBusInterface = new CGenericDBusInterface(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), connection, this);
|
||||
|
||||
// this->m_dBusInterface = new CGenericDBusInterface(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), connection, this);
|
||||
this->relaySignals(serviceName, connection);
|
||||
|
||||
// Enable event forwarding from GUI process to core
|
||||
@@ -33,7 +35,7 @@ namespace BlackCore
|
||||
connect(inputManager, &CInputManager::hotkeyFuncEvent, this, &CContextApplicationProxy::processHotkeyFuncEvent);
|
||||
inputManager->setEventForwarding(true);
|
||||
|
||||
connect(this, &IContextApplication::messageLogged, this, [](const CStatusMessage &message, const Event::COriginator &origin)
|
||||
connect(this, &IContextApplication::messageLogged, this, [](const CStatusMessage & message, const Event::COriginator & origin)
|
||||
{
|
||||
if (!origin.isFromSameProcess())
|
||||
{
|
||||
@@ -43,17 +45,20 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
/*
|
||||
* Workaround for signals
|
||||
* Connect for signals
|
||||
*/
|
||||
void CContextApplicationProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
{
|
||||
// signals originating from impl side
|
||||
bool s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||
"messageLogged", this, SIGNAL(messageLogged(BlackMisc::CStatusMessage,BlackMisc::Event::COriginator)));
|
||||
"messageLogged", this, SIGNAL(messageLogged(BlackMisc::CStatusMessage, BlackMisc::Event::COriginator)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||
"componentChanged", this, SIGNAL(componentChanged(uint, uint)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||
"fakedSetComVoiceRoom", this, SIGNAL(fakedSetComVoiceRoom(BlackMisc::Audio::CVoiceRoomList)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BlackCore
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
return (new CContextAudio(mode, runtime))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new CContextAudioProxy(BlackCore::CDBusServer::ServiceName, conn, mode, runtime);
|
||||
return new CContextAudioProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, runtime);
|
||||
default:
|
||||
return new CContextAudioEmpty(runtime); // audio not mandatory
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
//! @{
|
||||
|
||||
//! DBus interface for context
|
||||
#define BLACKCORE_CONTEXTAUDIO_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextAudio"
|
||||
#define BLACKCORE_CONTEXTAUDIO_INTERFACENAME "org.swift.pilotclient.BlackCore.ContextAudio"
|
||||
|
||||
//! DBus object path for context
|
||||
#define BLACKCORE_CONTEXTAUDIO_OBJECTPATH "/Audio"
|
||||
@@ -36,14 +36,14 @@
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
//! \brief Audio context interface
|
||||
//! Audio context interface
|
||||
class IContextAudio : public CContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
//! Constructor
|
||||
IContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
public:
|
||||
@@ -55,14 +55,14 @@ namespace BlackCore
|
||||
Com2
|
||||
};
|
||||
|
||||
//! \brief Interface name
|
||||
//! Interface name
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTAUDIO_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \brief Object path
|
||||
//! Object path
|
||||
static const QString &ObjectPath()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTAUDIO_OBJECTPATH);
|
||||
@@ -75,7 +75,7 @@ namespace BlackCore
|
||||
//! Factory method
|
||||
static IContextAudio *create(CRuntime *runtime, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn);
|
||||
|
||||
//! \brief Destructor
|
||||
//! Destructor
|
||||
virtual ~IContextAudio() {}
|
||||
|
||||
signals:
|
||||
@@ -110,6 +110,9 @@ namespace BlackCore
|
||||
//! Set voice rooms
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms) = 0;
|
||||
|
||||
//! Own callsign as displayed in voice room
|
||||
virtual void setOwnCallsignForRooms(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
//! Leave all voice rooms
|
||||
virtual void leaveAllVoiceRooms() = 0;
|
||||
|
||||
@@ -123,13 +126,13 @@ namespace BlackCore
|
||||
virtual BlackMisc::Audio::CAudioDeviceInfoList getAudioDevices() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Get current audio device
|
||||
* Get current audio device
|
||||
* \return input and output devices
|
||||
*/
|
||||
virtual BlackMisc::Audio::CAudioDeviceInfoList getCurrentAudioDevices() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Set current audio device
|
||||
* Set current audio device
|
||||
* \param audioDevice can be input or audio device
|
||||
*/
|
||||
virtual void setCurrentAudioDevice(const BlackMisc::Audio::CAudioDeviceInfo &audioDevice) = 0;
|
||||
@@ -150,7 +153,7 @@ namespace BlackCore
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Play notification sound
|
||||
* Play notification sound
|
||||
* \param notification CSoundGenerator::Notification
|
||||
* \param considerSettings consider settings (notification on/off), false means settings ignored
|
||||
*/
|
||||
|
||||
@@ -59,6 +59,13 @@ namespace BlackCore
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextAudio::setOwnCallsignForRooms
|
||||
virtual void setOwnCallsignForRooms(const BlackMisc::Aviation::CCallsign &callsign) override
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextAudio::getRoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getRoomCallsigns(int comUnitValue) const override
|
||||
{
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
/* Copyright (C) 2013 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/. */
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "context_audio_impl.h"
|
||||
#include "context_network.h"
|
||||
@@ -35,17 +39,18 @@ namespace BlackCore
|
||||
IContextAudio(mode, runtime),
|
||||
m_voice(new CVoiceVatlib())
|
||||
{
|
||||
// 1. Init by "voice driver"
|
||||
// own aircraft may or may not be available
|
||||
const CCallsign ownCallsign = (this->getIContextOwnAircraft()) ? getIContextOwnAircraft()->getOwnAircraft().getCallsign() : CCallsign();
|
||||
|
||||
// 2. Register PTT hotkey function
|
||||
// Register PTT hotkey function
|
||||
m_inputManager = CInputManager::getInstance();
|
||||
m_handlePtt = m_inputManager->registerHotkeyFunc(CHotkeyFunction::Ptt(), this, &CContextAudio::ps_setVoiceTransmission);
|
||||
|
||||
m_channel1 = m_voice->createVoiceChannel();
|
||||
m_channel1->setMyAircraftCallsign(getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
m_channel1->setMyAircraftCallsign(ownCallsign);
|
||||
connect(m_channel1.data(), &IVoiceChannel::connectionStatusChanged, this, &CContextAudio::ps_connectionStatusChanged);
|
||||
m_channel2 = m_voice->createVoiceChannel();
|
||||
m_channel2->setMyAircraftCallsign(getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
m_channel2->setMyAircraftCallsign(ownCallsign);
|
||||
connect(m_channel2.data(), &IVoiceChannel::connectionStatusChanged, this, &CContextAudio::ps_connectionStatusChanged);
|
||||
|
||||
m_voiceInputDevice = m_voice->createInputDevice();
|
||||
@@ -62,8 +67,9 @@ namespace BlackCore
|
||||
|
||||
m_audioMixer->makeMixerConnection(IAudioMixer::InputVoiceChannel1, IAudioMixer::OutputOutputDevice1);
|
||||
m_audioMixer->makeMixerConnection(IAudioMixer::InputVoiceChannel2, IAudioMixer::OutputOutputDevice1);
|
||||
this->setVoiceOutputVolume(90);
|
||||
|
||||
// 4. load sounds (init), not possible in own thread
|
||||
// Load sounds (init), not possible in own thread
|
||||
QTimer::singleShot(10 * 1000, this, SLOT(ps_initNotificationSounds()));
|
||||
|
||||
m_unusedVoiceChannels.push_back(m_channel1);
|
||||
@@ -212,9 +218,18 @@ namespace BlackCore
|
||||
void CContextAudio::setVoiceOutputVolume(int volume)
|
||||
{
|
||||
Q_ASSERT(m_voiceOutputDevice);
|
||||
m_outDeviceVolume = volume;
|
||||
if (!isMuted()) { m_voiceOutputDevice->setOutputVolume(m_outDeviceVolume); }
|
||||
bool wasMuted = isMuted();
|
||||
bool changed = m_voiceOutputDevice->getOutputVolume() != volume;
|
||||
if (!changed) { return; }
|
||||
m_voiceOutputDevice->setOutputVolume(volume);
|
||||
m_outVolumeBeforeMute = m_voiceOutputDevice->getOutputVolume();
|
||||
|
||||
emit changedAudioVolume(volume);
|
||||
if ((volume > 0 && wasMuted) || (volume < 1 && !wasMuted))
|
||||
{
|
||||
// inform about muted
|
||||
emit changedMute(volume < 1);
|
||||
}
|
||||
}
|
||||
|
||||
int CContextAudio::getVoiceOutputVolume() const
|
||||
@@ -227,13 +242,24 @@ namespace BlackCore
|
||||
{
|
||||
if (this->isMuted() == muted) { return; } // avoid roundtrips / unnecessary signals
|
||||
|
||||
int newVolume;
|
||||
if (muted)
|
||||
{
|
||||
m_voiceOutputDevice->setOutputVolume(0);
|
||||
Q_ASSERT(this->m_voiceOutputDevice);
|
||||
m_outVolumeBeforeMute = this->m_voiceOutputDevice->getOutputVolume();
|
||||
newVolume = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_voiceOutputDevice->setOutputVolume(m_outDeviceVolume);
|
||||
newVolume = m_outVolumeBeforeMute < MinUnmuteVolume ? MinUnmuteVolume : m_outVolumeBeforeMute;
|
||||
m_outVolumeBeforeMute = newVolume;
|
||||
}
|
||||
|
||||
// do not call setVoiceOutputVolume -> infinite loop
|
||||
if (newVolume != m_voiceOutputDevice->getOutputVolume())
|
||||
{
|
||||
m_voiceOutputDevice->setOutputVolume(newVolume);
|
||||
emit changedAudioVolume(newVolume);
|
||||
}
|
||||
|
||||
// signal
|
||||
@@ -246,7 +272,7 @@ namespace BlackCore
|
||||
bool CContextAudio::isMuted() const
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
return m_voiceOutputDevice->getOutputVolume() == 0;
|
||||
return m_voiceOutputDevice->getOutputVolume() < 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -256,6 +282,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
Q_ASSERT(newRooms.size() == 2);
|
||||
Q_ASSERT(getIContextOwnAircraft());
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms;
|
||||
|
||||
CVoiceRoomList currentRooms = getComVoiceRooms();
|
||||
@@ -263,6 +290,7 @@ namespace BlackCore
|
||||
CVoiceRoom currentRoomCom2 = currentRooms[1];
|
||||
CVoiceRoom newRoomCom1 = newRooms[0];
|
||||
CVoiceRoom newRoomCom2 = newRooms[1];
|
||||
const CCallsign ownCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
|
||||
bool changed = false;
|
||||
|
||||
@@ -289,6 +317,7 @@ namespace BlackCore
|
||||
if (newRoomCom1.isValid())
|
||||
{
|
||||
auto newVoiceChannel = getVoiceChannelBy(newRoomCom1);
|
||||
newVoiceChannel->setMyAircraftCallsign(ownCallsign);
|
||||
bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel);
|
||||
m_voiceChannelMapping.insert(Com1, newVoiceChannel);
|
||||
|
||||
@@ -304,6 +333,7 @@ namespace BlackCore
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// changed rooms? But only compare on "URL", not status as connected etc.
|
||||
if (currentRoomCom2.getVoiceRoomUrl() != newRoomCom2.getVoiceRoomUrl())
|
||||
{
|
||||
@@ -327,6 +357,7 @@ namespace BlackCore
|
||||
if (newRoomCom2.isValid())
|
||||
{
|
||||
auto newVoiceChannel = getVoiceChannelBy(newRoomCom2);
|
||||
newVoiceChannel->setMyAircraftCallsign(ownCallsign);
|
||||
bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel);
|
||||
m_voiceChannelMapping.insert(Com2, newVoiceChannel);
|
||||
|
||||
@@ -348,6 +379,12 @@ namespace BlackCore
|
||||
Q_UNUSED(changed);
|
||||
}
|
||||
|
||||
void CContextAudio::setOwnCallsignForRooms(const CCallsign &callsign)
|
||||
{
|
||||
if (m_channel1) { m_channel1->setMyAircraftCallsign(callsign); }
|
||||
if (m_channel2) { m_channel2->setMyAircraftCallsign(callsign); }
|
||||
}
|
||||
|
||||
CCallsignList CContextAudio::getRoomCallsigns(int comUnitValue) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
|
||||
@@ -60,6 +60,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextAudio::setComVoiceRooms
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &newRooms) override;
|
||||
|
||||
//! \copydoc IContextAudio::setOwnCallsignForRooms
|
||||
virtual void setOwnCallsignForRooms(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
//! \copydoc IContextAudio::getRoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getRoomCallsigns(int comUnitValue) const override;
|
||||
|
||||
@@ -120,7 +123,7 @@ namespace BlackCore
|
||||
//! Register myself in DBus
|
||||
CContextAudio *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) { return this; }
|
||||
server->addObject(IContextAudio::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
@@ -137,9 +140,7 @@ namespace BlackCore
|
||||
void ps_setVoiceTransmission(bool enable);
|
||||
|
||||
private:
|
||||
|
||||
const int MinUnmuteVolume = 20; //!< minimum volume when unmuted
|
||||
const int VoiceRoomEnabledVolume = 95; //!< voice room volume when enabled
|
||||
|
||||
//! Connection in transition
|
||||
bool inTransitionState() const;
|
||||
@@ -151,8 +152,7 @@ namespace BlackCore
|
||||
|
||||
std::unique_ptr<IVoice> m_voice; //!< underlying voice lib
|
||||
std::unique_ptr<IAudioMixer> m_audioMixer;
|
||||
|
||||
int m_outDeviceVolume = 100;
|
||||
int m_outVolumeBeforeMute = 90;
|
||||
|
||||
// For easy access.
|
||||
QSharedPointer<IVoiceChannel> m_channel1;
|
||||
|
||||
@@ -130,6 +130,14 @@ namespace BlackCore
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setComVoiceRooms"), voiceRooms);
|
||||
}
|
||||
|
||||
/*
|
||||
* Own voice room callsign
|
||||
*/
|
||||
void CContextAudioProxy::setOwnCallsignForRooms(const CCallsign &callsign)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setOwnCallsignForRooms"), callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Play SELCAL tone
|
||||
*/
|
||||
|
||||
@@ -63,6 +63,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextAudio::setComVoiceRooms()
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms) override;
|
||||
|
||||
//! \copydoc IContextAudio::setOwnCallsignForRooms
|
||||
virtual void setOwnCallsignForRooms(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
//! \copydoc IContextAudio::getRoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getRoomCallsigns(int comUnitValue) const override;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
IContextNetwork *IContextNetwork::create(CRuntime *runtime, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn)
|
||||
IContextNetwork *IContextNetwork::create(CRuntime *runtime, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &connection)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace BlackCore
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
return (new CContextNetwork(mode, runtime))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new CContextNetworkProxy(BlackCore::CDBusServer::ServiceName, conn, mode, runtime);
|
||||
return new CContextNetworkProxy(BlackCore::CDBusServer::ServiceName(), connection, mode, runtime);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
default:
|
||||
return new CContextNetworkEmpty(runtime);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
//! @{
|
||||
|
||||
//! DBus interface for context
|
||||
#define BLACKCORE_CONTEXTNETWORK_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextNetwork"
|
||||
#define BLACKCORE_CONTEXTNETWORK_INTERFACENAME "org.swift.pilotclient.BlackCore.ContextNetwork"
|
||||
|
||||
//! DBus object path for context
|
||||
#define BLACKCORE_CONTEXTNETWORK_OBJECTPATH "/Network"
|
||||
@@ -62,7 +62,7 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
|
||||
|
||||
//! Factory method
|
||||
static IContextNetwork *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn);
|
||||
static IContextNetwork *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &connection);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextNetwork() {}
|
||||
|
||||
@@ -52,17 +52,17 @@ namespace BlackCore
|
||||
// 2. VATSIM bookings
|
||||
this->m_vatsimBookingReader = new CVatsimBookingReader(this, this->getRuntime()->getIContextSettings()->getNetworkSettings().getBookingServiceUrl());
|
||||
connect(this->m_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CContextNetwork::ps_receivedBookings);
|
||||
this->m_vatsimBookingReader->read(); // first read
|
||||
this->m_vatsimBookingReader->setInterval(180 * 1000);
|
||||
this->m_vatsimBookingReader->start();
|
||||
this->m_vatsimBookingReader->setInterval(180 * 1000);
|
||||
this->m_vatsimBookingReader->readInBackgroundThread(); // first read
|
||||
|
||||
// 3. VATSIM data file
|
||||
const QStringList dataFileUrls = { "http://info.vroute.net/vatsim-data.txt" };
|
||||
this->m_vatsimDataFileReader = new CVatsimDataFileReader(this, dataFileUrls);
|
||||
connect(this->m_vatsimDataFileReader, &CVatsimDataFileReader::dataRead, this, &CContextNetwork::ps_dataFileRead);
|
||||
this->m_vatsimDataFileReader->read(); // first read
|
||||
this->m_vatsimDataFileReader->setInterval(90 * 1000);
|
||||
this->m_vatsimDataFileReader->start();
|
||||
this->m_vatsimDataFileReader->readInBackgroundThread(); // first read
|
||||
this->m_vatsimDataFileReader->setInterval(90 * 1000);
|
||||
|
||||
// 4. Update timer for data (network data such as frequency)
|
||||
this->m_dataUpdateTimer = new QTimer(this);
|
||||
@@ -329,7 +329,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(this->m_vatsimBookingReader);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
this->m_vatsimBookingReader->read();
|
||||
this->m_vatsimBookingReader->readInBackgroundThread();
|
||||
}
|
||||
|
||||
CSimulatedAircraftList CContextNetwork::getAircraftInRange() const
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace BlackCore
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
return (new CContextOwnAircraft(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextOwnAircraftProxy(BlackCore::CDBusServer::ServiceName, conn, mode, parent);
|
||||
return new BlackCore::CContextOwnAircraftProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
default:
|
||||
qFatal("Always initialize an ownAircraft context");
|
||||
return nullptr;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//! @{
|
||||
|
||||
//! DBus interface for context
|
||||
#define BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextOwnAircraft"
|
||||
#define BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME "org.swift.pilotclient.BlackCore.ContextOwnAircraft"
|
||||
|
||||
//! DBus object path for context
|
||||
#define BLACKCORE_CONTEXTOWNAIRCRAFT_OBJECTPATH "/OwnAircraft"
|
||||
@@ -70,6 +70,15 @@ namespace BlackCore
|
||||
//! Changed SELCAL code
|
||||
void changedSelcal(const BlackMisc::Aviation::CSelcal &selcal, const QString &originator);
|
||||
|
||||
//! Own callsign was changed
|
||||
void changedCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Own callsign was changed
|
||||
void changedIcaoData(const BlackMisc::Aviation::CAircraftIcao &icao);
|
||||
|
||||
//! own pilot (aka the swift user) changed
|
||||
void changedPilot(const BlackMisc::Network::CUser &pilot);
|
||||
|
||||
public slots:
|
||||
|
||||
//! Get own aircraft
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "context_ownaircraft_impl.h"
|
||||
#include "context_network.h"
|
||||
#include "context_audio.h"
|
||||
#include "context_application.h"
|
||||
#include "context_runtime.h"
|
||||
#include "context_settings.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
@@ -26,10 +27,6 @@ using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextOwnAircraft::CContextOwnAircraft(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
IContextOwnAircraft(mode, runtime)
|
||||
{
|
||||
@@ -40,9 +37,6 @@ namespace BlackCore
|
||||
this->initOwnAircraft();
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
*/
|
||||
CContextOwnAircraft::~CContextOwnAircraft() { }
|
||||
|
||||
/*
|
||||
@@ -69,19 +63,22 @@ namespace BlackCore
|
||||
this->m_ownAircraft.setCallsign(CCallsign("SWIFT"));
|
||||
this->m_ownAircraft.setIcaoInfo(CAircraftIcao("C172", "L1P", "GA", "GA", "0000ff"));
|
||||
|
||||
// voice rooms
|
||||
this->resolveVoiceRooms();
|
||||
// voice rooms, if network is already available
|
||||
if (this->getIContextNetwork())
|
||||
{
|
||||
this->resolveVoiceRooms();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Resolve voice rooms
|
||||
*/
|
||||
void CContextOwnAircraft::resolveVoiceRooms()
|
||||
{
|
||||
Q_ASSERT(this->getIContextAudio());
|
||||
Q_ASSERT(this->getIContextNetwork());
|
||||
Q_ASSERT(this->getIContextApplication());
|
||||
if (!this->getIContextNetwork() || !this->getIContextAudio() || !this->getIContextAudio()) { return; } // no chance to resolve rooms
|
||||
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
if (this->m_voiceRoom1UrlOverride.isEmpty() && this->m_voiceRoom2UrlOverride.isEmpty() && !this->m_automaticVoiceRoomResolution) { return; }
|
||||
if (!this->getIContextNetwork()) { return; } // no chance to resolve rooms
|
||||
if (!this->getIContextAudio()) { return; } // no place to set rooms
|
||||
if (!this->m_automaticVoiceRoomResolution) { return; } // not responsible
|
||||
|
||||
// requires correct frequencies set
|
||||
@@ -93,12 +90,9 @@ namespace BlackCore
|
||||
if (!this->m_voiceRoom2UrlOverride.isEmpty()) rooms[1] = CVoiceRoom(this->m_voiceRoom2UrlOverride);
|
||||
|
||||
// set the rooms
|
||||
this->getIContextAudio()->setComVoiceRooms(rooms);
|
||||
emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms);
|
||||
}
|
||||
|
||||
/*
|
||||
* Own position
|
||||
*/
|
||||
bool CContextOwnAircraft::updatePosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << position << altitude;
|
||||
@@ -113,9 +107,6 @@ namespace BlackCore
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Own cockpit data
|
||||
*/
|
||||
bool CContextOwnAircraft::updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const QString &originator)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder;
|
||||
@@ -129,9 +120,6 @@ namespace BlackCore
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*
|
||||
* COM frequency
|
||||
*/
|
||||
bool CContextOwnAircraft::updateActiveComFrequency(const CFrequency &frequency, int comUnit, const QString &originator)
|
||||
{
|
||||
CComSystem::ComUnit unit = static_cast<CComSystem::ComUnit>(comUnit);
|
||||
@@ -151,13 +139,11 @@ namespace BlackCore
|
||||
return updateCockpit(com1, com2, xpdr, originator);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pilot
|
||||
*/
|
||||
bool CContextOwnAircraft::updatePilot(const CUser &pilot)
|
||||
{
|
||||
if (this->m_ownAircraft.getPilot() == pilot) { return false; }
|
||||
this->m_ownAircraft.setPilot(pilot);
|
||||
emit changedPilot(pilot);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -165,6 +151,7 @@ namespace BlackCore
|
||||
{
|
||||
if (this->m_ownAircraft.getCallsign() == callsign) { return false; }
|
||||
this->m_ownAircraft.setCallsign(callsign);
|
||||
emit changedCallsign(callsign);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -172,6 +159,7 @@ namespace BlackCore
|
||||
{
|
||||
if (this->m_ownAircraft.getIcaoInfo() == icaoData) { return false; }
|
||||
this->m_ownAircraft.setIcaoInfo(icaoData);
|
||||
emit changedIcaoData(icaoData);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,55 +174,37 @@ namespace BlackCore
|
||||
void CContextOwnAircraft::setAudioOutputVolume(int outputVolume)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << outputVolume;
|
||||
|
||||
if (this->getIContextAudio()) this->getIContextAudio()->setVoiceOutputVolume(outputVolume);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tune in / out voice room
|
||||
*/
|
||||
void CContextOwnAircraft::ps_changedAtcStationOnlineConnectionStatus(const CAtcStation &atcStation, bool connected)
|
||||
{
|
||||
// any of our active frequencies?
|
||||
Q_UNUSED(connected);
|
||||
if (atcStation.getFrequency() != this->m_ownAircraft.getCom1System().getFrequencyActive() &&
|
||||
atcStation.getFrequency() != this->m_ownAircraft.getCom2System().getFrequencyActive()) return;
|
||||
if (atcStation.getFrequency() != this->m_ownAircraft.getCom1System().getFrequencyActive() && atcStation.getFrequency() != this->m_ownAircraft.getCom2System().getFrequencyActive()) { return; }
|
||||
this->resolveVoiceRooms();
|
||||
}
|
||||
|
||||
/*
|
||||
* Voice room URLs
|
||||
*/
|
||||
void CContextOwnAircraft::setAudioVoiceRoomOverrideUrls(const QString &voiceRoom1Url, const QString &voiceRoom2Url)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url;
|
||||
|
||||
this->m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed();
|
||||
this->m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed();
|
||||
this->resolveVoiceRooms();
|
||||
}
|
||||
|
||||
/*
|
||||
* Voice room resolution
|
||||
*/
|
||||
void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enable;
|
||||
this->m_automaticVoiceRoomResolution = enable;
|
||||
}
|
||||
|
||||
/*
|
||||
* Own aircraft
|
||||
*/
|
||||
CSimulatedAircraft CContextOwnAircraft::getOwnAircraft() const
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << this->m_ownAircraft;
|
||||
return this->m_ownAircraft;
|
||||
}
|
||||
|
||||
/*
|
||||
* Command line entered
|
||||
*/
|
||||
bool CContextOwnAircraft::parseCommandLine(const QString &commandLine)
|
||||
{
|
||||
static CSimpleCommandParser parser(
|
||||
@@ -300,9 +270,6 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper
|
||||
*/
|
||||
const CAircraft &CContextOwnAircraft::getAviationAircraft() const
|
||||
{
|
||||
return this->m_ownAircraft;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
/*
|
||||
* Workaround for signals, not working without, but why?
|
||||
* Connect signal / slots
|
||||
*/
|
||||
void CContextOwnAircraftProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ namespace BlackCore
|
||||
"changedAircraftCockpit", this, SIGNAL(changedAircraftCockpit(BlackMisc::Simulation::CSimulatedAircraft, QString)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||
"changedSelcal", this, SIGNAL(changedSelcal(BlackMisc::Aviation::CSelcal, QString)));
|
||||
"fakedVoiceRoomRequest", this, SIGNAL(changedSelcal(BlackMisc::Aviation::CSelcal, QString)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -63,7 +64,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
// DBus
|
||||
if (config.requiresDBusSever()) this->initDBusServer(dbusAddress);
|
||||
if (config.requiresDBusSever()) { this->initDBusServer(dbusAddress); }
|
||||
if (config.requiresDBusConnection())
|
||||
{
|
||||
this->initDBusConnection(dbusAddress);
|
||||
@@ -85,18 +86,18 @@ namespace BlackCore
|
||||
this->m_contextApplication = IContextApplication::create(this, config.getModeApplication(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Application", time.restart());
|
||||
|
||||
this->m_contextOwnAircraft = IContextOwnAircraft::create(this, config.getModeOwnAircraft(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Own aircraft", time.restart());
|
||||
|
||||
this->m_contextAudio = IContextAudio::create(this, config.getModeAudio(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Audio", time.restart());
|
||||
|
||||
this->m_contextSimulator = IContextSimulator::create(this, config.getModeSimulator(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Simulator", time.restart());
|
||||
this->m_contextOwnAircraft = IContextOwnAircraft::create(this, config.getModeOwnAircraft(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Own aircraft", time.restart());
|
||||
|
||||
this->m_contextNetwork = IContextNetwork::create(this, config.getModeNetwork(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Network", time.restart());
|
||||
|
||||
this->m_contextSimulator = IContextSimulator::create(this, config.getModeSimulator(), this->m_dbusServer, this->m_dbusConnection);
|
||||
times.insert("Simulator", time.restart());
|
||||
|
||||
// checks --------------
|
||||
// 1. own aircraft and simulator should reside in same location
|
||||
Q_ASSERT(!this->m_contextSimulator || (this->m_contextOwnAircraft->isUsingImplementingObject() == this->m_contextSimulator->isUsingImplementingObject()));
|
||||
@@ -147,9 +148,10 @@ namespace BlackCore
|
||||
|
||||
void CRuntime::initDBusServer(const QString &dBusAddress)
|
||||
{
|
||||
if (this->m_dbusServer) return;
|
||||
if (this->m_dbusServer) { return; }
|
||||
Q_ASSERT(!dBusAddress.isEmpty());
|
||||
this->m_dbusServer = new CDBusServer(dBusAddress, this);
|
||||
CLogMessage(this).info("DBus server on address: %1") << dBusAddress;
|
||||
}
|
||||
|
||||
void CRuntime::initPostSetup(QMap<QString, int> ×)
|
||||
@@ -208,6 +210,19 @@ namespace BlackCore
|
||||
Q_ASSERT(c);
|
||||
times.insert("Post setup, connects network", time.restart());
|
||||
}
|
||||
|
||||
// fake signals to work around setting values in audio context for local audio with remote core
|
||||
if (this->m_contextAudio && this->m_contextAudio->isUsingImplementingObject())
|
||||
{
|
||||
Q_ASSERT(this->m_contextApplication);
|
||||
Q_ASSERT(this->m_contextOwnAircraft);
|
||||
c = this->connect(this->m_contextApplication, &IContextApplication::fakedSetComVoiceRoom,
|
||||
this->getCContextAudio(), &CContextAudio::setComVoiceRooms);
|
||||
Q_ASSERT(c);
|
||||
c = this->connect(this->m_contextOwnAircraft, &IContextOwnAircraft::changedCallsign, this->getCContextAudio(), &IContextAudio::setOwnCallsignForRooms);
|
||||
Q_ASSERT(c);
|
||||
times.insert("Post setup, connects audio", time.restart());
|
||||
}
|
||||
}
|
||||
|
||||
void CRuntime::gracefulShutdown()
|
||||
@@ -241,14 +256,17 @@ namespace BlackCore
|
||||
}
|
||||
this->getIContextNetwork()->deleteLater();
|
||||
// replace by dummy object avoiding nullptr issues during shutdown phase
|
||||
this->m_contextNetwork = IContextNetwork::create(this, CRuntimeConfig::NotUsed, nullptr, this->m_dbusConnection);
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextNetwork = IContextNetwork::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
if (this->getIContextAudio())
|
||||
{
|
||||
disconnect(this->getIContextAudio());
|
||||
this->getIContextAudio()->deleteLater();
|
||||
this->m_contextAudio = nullptr;
|
||||
// replace by dummy object avoiding nullptr issues during shutdown phase
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextAudio = IContextAudio::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
if (this->getIContextOwnAircraft())
|
||||
@@ -406,12 +424,15 @@ namespace BlackCore
|
||||
|
||||
bool CRuntimeConfig::requiresDBusSever() const
|
||||
{
|
||||
return (this->m_application == LocalInDbusServer ||
|
||||
this->m_audio == LocalInDbusServer ||
|
||||
this->m_network == LocalInDbusServer ||
|
||||
this->m_ownAircraft == LocalInDbusServer ||
|
||||
this->m_settings == LocalInDbusServer ||
|
||||
this->m_simulator == LocalInDbusServer);
|
||||
return (
|
||||
// those 3 should decide whether we are running the server
|
||||
this->m_network == LocalInDbusServer ||
|
||||
this->m_ownAircraft == LocalInDbusServer ||
|
||||
this->m_simulator == LocalInDbusServer ||
|
||||
|
||||
// added as work around
|
||||
this->m_audio == LocalInDbusServer
|
||||
);
|
||||
}
|
||||
|
||||
bool CRuntimeConfig::requiresDBusConnection() const
|
||||
@@ -452,7 +473,7 @@ namespace BlackCore
|
||||
const CRuntimeConfig &CRuntimeConfig::remoteLocalAudio(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
static CRuntimeConfig cfg = CRuntimeConfig(CRuntimeConfig(CRuntimeConfig::Remote, dbusBootstrapAddress));
|
||||
cfg.m_audio = CRuntimeConfig::Local;
|
||||
cfg.m_audio = CRuntimeConfig::LocalInDbusServer;
|
||||
return cfg;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -43,34 +43,49 @@ namespace BlackCore
|
||||
|
||||
//! application mode
|
||||
ContextMode getModeApplication() const { return this->m_application; }
|
||||
|
||||
//! audio mode
|
||||
ContextMode getModeAudio() const { return this->m_audio; }
|
||||
|
||||
//! network mode
|
||||
ContextMode getModeNetwork() const { return this->m_network; }
|
||||
|
||||
//! own aircraft
|
||||
ContextMode getModeOwnAircraft() const { return this->m_ownAircraft; }
|
||||
|
||||
//! settings mode
|
||||
ContextMode getModeSettings() const { return this->m_settings; }
|
||||
|
||||
//! simulator mode
|
||||
ContextMode getModeSimulator() const { return this->m_simulator; }
|
||||
|
||||
//! local settings?
|
||||
bool hasLocalSettings() const { return this->m_settings == Local || this->m_settings == LocalInDbusServer; }
|
||||
|
||||
//! requires server (at least one in server)?
|
||||
bool requiresDBusSever() const;
|
||||
|
||||
//! requires DBus connection (at least one remote)?
|
||||
bool requiresDBusConnection() const;
|
||||
|
||||
//! DBus address
|
||||
QString getDBusAddress() const { return this->m_dbusAddress; }
|
||||
|
||||
//! DBus address?
|
||||
bool hasDBusAddress() const { return !this->m_dbusAddress.isEmpty(); }
|
||||
|
||||
//! predefined for Core
|
||||
static const CRuntimeConfig &forCoreAllLocalInDBus(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined for Core
|
||||
static const CRuntimeConfig &forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined, completely local (e.g. for unit tests)
|
||||
static const CRuntimeConfig &local(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined, completely remote (e.g. for GUI with core)
|
||||
static const CRuntimeConfig &remote(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined, remote with local audio (e.g. Aduio in GUI)
|
||||
static const CRuntimeConfig &remoteLocalAudio(const QString &dbusBootstrapAddress = "");
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BlackCore
|
||||
return contextSettings;
|
||||
}
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextSettingsProxy(BlackCore::CDBusServer::ServiceName, conn, mode, parent);
|
||||
return new BlackCore::CContextSettingsProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
default:
|
||||
qFatal("Always initialize a settings context");
|
||||
return nullptr;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
//! @{
|
||||
|
||||
//! DBus interface for context
|
||||
#define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextSettings"
|
||||
#define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "org.swift.pilotclient.BlackCore.ContextSettings"
|
||||
|
||||
//! DBus object path for context
|
||||
#define BLACKCORE_CONTEXTSETTINGS_OBJECTPATH "/Settings"
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace BlackCore
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
return (new CContextSimulator(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName, conn, mode, parent);
|
||||
return new BlackCore::CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
default:
|
||||
return nullptr; // simulator not mandatory
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
//! @{
|
||||
|
||||
//! DBus interface for context
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextSimulator"
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME "org.swift.pilotclient.BlackCore.ContextSimulator"
|
||||
|
||||
//! DBus object path for context
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_OBJECTPATH "/Simulator"
|
||||
|
||||
@@ -1,43 +1,44 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* 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/. */
|
||||
/* Copyright (C) 2014
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/networkutils.h"
|
||||
#include "dbus_server.h"
|
||||
#include <QDebug>
|
||||
#include <QMetaClassInfo>
|
||||
|
||||
#include "blackmisc/networkutils.h"
|
||||
#include "dbus_server.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
const QString CDBusServer::ServiceName = QString(BLACKCORE_RUNTIME_SERVICENAME);
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* Remark, without the default "unix:tmpdir=/tmp" any refereal to address crashes
|
||||
* see http://download.froglogic.com/public/qt5-squishcoco-report/QtBase/source_241_preprocessed.html
|
||||
* DBus config: http://dbus.freedesktop.org/doc/dbus-daemon.1.html
|
||||
*/
|
||||
CDBusServer::CDBusServer(const QString &service, const QString &address, QObject *parent) :
|
||||
QObject(parent), m_busServer(CDBusServer::isQtDBusAddress(address) ? address : "tcp:host=127.0.0.1,port=45000", // "unix:tmpdir=/tmp",
|
||||
parent), m_serverMode(CDBusServer::SERVERMODE_P2P)
|
||||
CDBusServer::CDBusServer(const QString &service, const QString &address, QObject *parent) : QObject(parent)
|
||||
{
|
||||
ServerMode m = CDBusServer::addressToDBusMode(address);
|
||||
m_busServer.setAnonymousAuthenticationAllowed(true);
|
||||
switch (m)
|
||||
{
|
||||
case SERVERMODE_SESSIONBUS:
|
||||
{
|
||||
// we use a session bus connection instead of a real P2P connection
|
||||
this->m_serverMode = CDBusServer::SERVERMODE_SESSIONBUS;
|
||||
QDBusConnection con = QDBusConnection::sessionBus();
|
||||
if (!con.registerService(service))
|
||||
QDBusConnection connection = QDBusConnection::connectToBus(QDBusConnection::SessionBus, ServiceName());
|
||||
if (!connection.registerService(service))
|
||||
{
|
||||
qCritical() << con.lastError().message();
|
||||
qFatal("Cannot register DBus service, server started? dbus-daemon.exe --session --address=tcp:host=192.168.0.133,port=45000");
|
||||
// registration fails can either mean something wrong with DBus or service already exists
|
||||
CLogMessage(this).warning("DBus registration: %1") << connection.lastError().message();
|
||||
CLogMessage(this).warning("Cannot register DBus service, server started? dbus-daemon.exe --session --address=tcp:host=192.168.0.133,port=45000");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -45,11 +46,12 @@ namespace BlackCore
|
||||
{
|
||||
// we use a system bus connection instead of a real P2P connection
|
||||
this->m_serverMode = CDBusServer::SERVERMODE_SYSTEMBUS;
|
||||
QDBusConnection con = QDBusConnection::systemBus();
|
||||
if (!con.registerService(service))
|
||||
QDBusConnection connection = QDBusConnection::systemBus();
|
||||
if (!connection.registerService(service))
|
||||
{
|
||||
qCritical() << con.lastError().message();
|
||||
qFatal("Cannot register DBus service, server started? dbus-daemon.exe --system --address=tcp:host=192.168.0.133,port=45000");
|
||||
// registration fails can either mean something wrong with DBus or service already exists
|
||||
CLogMessage(this).warning("DBus registration: %1") << connection.lastError().message();
|
||||
CLogMessage(this).warning("Cannot register DBus service, server started? dbus-daemon.exe --session --address=tcp:host=192.168.0.133,port=45000");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -57,21 +59,37 @@ namespace BlackCore
|
||||
default:
|
||||
{
|
||||
this->m_serverMode = CDBusServer::SERVERMODE_P2P;
|
||||
this->m_busServer.reset(
|
||||
new QDBusServer(
|
||||
CDBusServer::isQtDBusAddress(address) ? address : "tcp:host=127.0.0.1,port=45000", // "unix:tmpdir=/tmp"
|
||||
parent)
|
||||
);
|
||||
m_busServer->setAnonymousAuthenticationAllowed(true);
|
||||
|
||||
// Note: P2P has no service name
|
||||
if (!m_busServer.isConnected())
|
||||
if (!m_busServer->isConnected())
|
||||
{
|
||||
qWarning() << m_busServer.lastError().message();
|
||||
CLogMessage(this).warning("DBus P2P connection failed: %1") << this->lastQDBusServerError().message();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Server listening on address: " << m_busServer.address();
|
||||
CLogMessage(this).debug() << "Server listening on address: " << m_busServer->address();
|
||||
}
|
||||
connect(&m_busServer, &QDBusServer::newConnection, this, &CDBusServer::registerObjectsWithConnection);
|
||||
connect(m_busServer.data(), &QDBusServer::newConnection, this, &CDBusServer::ps_registerObjectsWithP2PConnection);
|
||||
}
|
||||
break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
/*
|
||||
* Name of service
|
||||
*/
|
||||
const QString &CDBusServer::ServiceName()
|
||||
{
|
||||
static const QString sn(BLACKCORE_RUNTIME_SERVICENAME);
|
||||
return sn;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for P2P address
|
||||
*/
|
||||
@@ -103,7 +121,7 @@ namespace BlackCore
|
||||
{
|
||||
QMetaClassInfo ci = mo->classInfo(i);
|
||||
QString name(ci.name());
|
||||
if (name == "D-Bus Interface") return QString(ci.value());
|
||||
if (name == "D-Bus Interface") { return QString(ci.value()); }
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -111,21 +129,21 @@ namespace BlackCore
|
||||
/*
|
||||
* Connection established
|
||||
*/
|
||||
bool CDBusServer::registerObjectsWithConnection(const QDBusConnection &connection)
|
||||
bool CDBusServer::ps_registerObjectsWithP2PConnection(const QDBusConnection &connection)
|
||||
{
|
||||
Q_ASSERT(!this->m_objects.isEmpty());
|
||||
QDBusConnection newConnection(connection); // copy, because object will be registered on this connection
|
||||
// insert or replace connection
|
||||
m_DBusConnections.insert(newConnection.name(), newConnection);
|
||||
bool success = true;
|
||||
qDebug() << "New Connection from: " << newConnection.name();
|
||||
CLogMessage(this).debug() << "New Connection from: " << newConnection.name();
|
||||
QMap<QString, QObject *>::ConstIterator i = m_objects.begin();
|
||||
while (i != m_objects.end())
|
||||
{
|
||||
qDebug() << "Adding " << i.key() << CDBusServer::getClassInfo(i.value()) << "to the new connection.";
|
||||
CLogMessage(this).debug() << "Adding " << i.key() << CDBusServer::getClassInfo(i.value()) << "to the new connection.";
|
||||
bool ok = newConnection.registerObject(i.key(), i.value(), CDBusServer::RegisterOptions());
|
||||
Q_ASSERT_X(ok, "CDBusServer::newConnection", "Registration failed");
|
||||
if (!ok) success = false;
|
||||
if (!ok) { success = false; }
|
||||
++i;
|
||||
}
|
||||
return success;
|
||||
@@ -136,23 +154,41 @@ namespace BlackCore
|
||||
*/
|
||||
void CDBusServer::addObject(const QString &path, QObject *object)
|
||||
{
|
||||
if (!object) return;
|
||||
m_objects.insert(path, object); // this will be added when connection is established
|
||||
if (!object) { return; }
|
||||
m_objects.insert(path, object); // For P2P: registered when P2P connection is established
|
||||
|
||||
if (this->m_serverMode == CDBusServer::SERVERMODE_P2P) return;
|
||||
// P2P
|
||||
if (this->m_serverMode == CDBusServer::SERVERMODE_P2P)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
if (this->m_serverMode == CDBusServer::SERVERMODE_SESSIONBUS)
|
||||
{
|
||||
success = QDBusConnection::sessionBus().registerObject(path, object, CDBusServer::RegisterOptions());
|
||||
qDebug() << "Adding " << path << CDBusServer::getClassInfo(object) << "to the session bus.";
|
||||
if (!success) qDebug() << "Error, no success with registration" << this->lastError().message();
|
||||
QDBusConnection connection = QDBusConnection::connectToBus(QDBusConnection::SessionBus, ServiceName());
|
||||
success = connection.registerObject(path, object, CDBusServer::RegisterOptions());
|
||||
if (success)
|
||||
{
|
||||
CLogMessage(this).debug() << "Adding " << path << CDBusServer::getClassInfo(object) << " to session bus.";
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error("Error, no success with session bus registration");
|
||||
}
|
||||
}
|
||||
else if (this->m_serverMode == CDBusServer::SERVERMODE_SYSTEMBUS)
|
||||
{
|
||||
success = QDBusConnection::systemBus().registerObject(path, object, CDBusServer::RegisterOptions());
|
||||
qDebug() << "Adding " << path << CDBusServer::getClassInfo(object) << "to the system bus.";
|
||||
if (!success) qDebug() << "Error, no success with registration" << this->lastError().message();
|
||||
QDBusConnection connection = QDBusConnection::connectToBus(QDBusConnection::SystemBus, ServiceName());
|
||||
success = connection.registerObject(path, object, CDBusServer::RegisterOptions());
|
||||
if (success)
|
||||
{
|
||||
CLogMessage(this).debug() << "Adding " << path << CDBusServer::getClassInfo(object) << " to system bus.";
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error("Error, no success with system bus registration");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -163,9 +199,23 @@ namespace BlackCore
|
||||
/*
|
||||
* Last error
|
||||
*/
|
||||
QDBusError CDBusServer::lastError() const
|
||||
QDBusError CDBusServer::lastQDBusServerError() const
|
||||
{
|
||||
return this->m_busServer.lastError();
|
||||
if (!hasQDBusServer()) { return QDBusError(); }
|
||||
return this->m_busServer->lastError();
|
||||
}
|
||||
|
||||
const QDBusServer *CDBusServer::qDBusServer() const
|
||||
{
|
||||
return this->m_busServer.data();
|
||||
}
|
||||
|
||||
/*
|
||||
* Real server?
|
||||
*/
|
||||
bool CDBusServer::hasQDBusServer() const
|
||||
{
|
||||
return !this->m_busServer.isNull();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -186,9 +236,9 @@ namespace BlackCore
|
||||
break;
|
||||
case CDBusServer::SERVERMODE_P2P:
|
||||
{
|
||||
foreach(QDBusConnection con, this->m_DBusConnections)
|
||||
foreach(QDBusConnection connection, this->m_DBusConnections)
|
||||
{
|
||||
con.unregisterObject(path);
|
||||
connection.unregisterObject(path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -238,12 +288,9 @@ namespace BlackCore
|
||||
CDBusServer::ServerMode CDBusServer::addressToDBusMode(const QString &address)
|
||||
{
|
||||
QString a = address.toLower();
|
||||
if (a == CDBusServer::systemDBusServer())
|
||||
return SERVERMODE_SYSTEMBUS;
|
||||
else if (a == CDBusServer::sessionDBusServer())
|
||||
return SERVERMODE_SESSIONBUS;
|
||||
else
|
||||
return SERVERMODE_P2P;
|
||||
if (a == CDBusServer::systemDBusServer()) { return SERVERMODE_SYSTEMBUS; }
|
||||
else if (a == CDBusServer::sessionDBusServer()) { return SERVERMODE_SESSIONBUS; }
|
||||
else { return SERVERMODE_P2P; }
|
||||
}
|
||||
|
||||
} // namespace BlackCore
|
||||
} // namespace
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* 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/. */
|
||||
/* Copyright (C) 2014
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_DBUSSERVER_H
|
||||
#define BLACKCORE_DBUSSERVER_H
|
||||
@@ -14,15 +20,17 @@
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
|
||||
#define BLACKCORE_RUNTIME_SERVICENAME "net.vatsim.pilotClient"
|
||||
|
||||
//! Service name of DBus service
|
||||
#define BLACKCORE_RUNTIME_SERVICENAME "org.swift.pilotclient"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Custom DBusServer
|
||||
* \details This class implements a custom DBusServer for DBus peer connections, but can also be used as session or system bus
|
||||
* Custom DBusServer
|
||||
* \details This class implements a custom DBusServer for DBus peer connections, but can also be used
|
||||
* with session or system bus. For session / system bus this class represents no real server,
|
||||
* but more a wrapper for \sa QDBusConnection and the registered objects
|
||||
*/
|
||||
class CDBusServer : public QObject
|
||||
{
|
||||
@@ -30,10 +38,10 @@ namespace BlackCore
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_RUNTIME_SERVICENAME)
|
||||
|
||||
public:
|
||||
//! \brief Service name of DBus serve
|
||||
static const QString ServiceName;
|
||||
//! Service name of DBus server
|
||||
static const QString &ServiceName();
|
||||
|
||||
//! \brief Server mode, normally P2P, but can be changed for debugging / testing
|
||||
//! Server mode, normally P2P, but can be changed for debugging / testing
|
||||
enum ServerMode
|
||||
{
|
||||
SERVERMODE_P2P,
|
||||
@@ -41,30 +49,10 @@ namespace BlackCore
|
||||
SERVERMODE_SYSTEMBUS
|
||||
};
|
||||
|
||||
private:
|
||||
QDBusServer m_busServer; //!< QDBusServer implementation
|
||||
ServerMode m_serverMode;
|
||||
QMap<QString, QObject *> m_objects; //!< Mapping of all exposed objects
|
||||
QMap<QString, QDBusConnection> m_DBusConnections; //!< Mapping of all DBusConnection objects
|
||||
|
||||
//! \brief Check if address means a real server with P2P connection
|
||||
static bool isP2P(const QString &address);
|
||||
|
||||
//! \brief Get the class info
|
||||
static const QString getClassInfo(QObject *object);
|
||||
|
||||
//! \brief Register options with connection
|
||||
static const QDBusConnection::RegisterOptions &RegisterOptions()
|
||||
{
|
||||
static QDBusConnection::RegisterOptions opt = QDBusConnection::ExportAdaptors | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAllSlots;
|
||||
return opt;
|
||||
}
|
||||
|
||||
public:
|
||||
//! Construct a server for the BlackCore runtime
|
||||
//! \remarks We are using address and not ServerMode, as on some systems we need to pass in some specific configuration string
|
||||
//! \sa QDBusServer
|
||||
CDBusServer(const QString &address, QObject *parent = nullptr) : CDBusServer(CDBusServer::ServiceName, address, parent) {}
|
||||
CDBusServer(const QString &address, QObject *parent = nullptr) : CDBusServer(CDBusServer::ServiceName(), address, parent) {}
|
||||
|
||||
//! Construct a server for some arbitrary service
|
||||
CDBusServer(const QString &service, const QString &address, QObject *parent = nullptr);
|
||||
@@ -73,13 +61,13 @@ namespace BlackCore
|
||||
void addObject(const QString &name, QObject *object);
|
||||
|
||||
//! Last error
|
||||
QDBusError lastError() const;
|
||||
QDBusError lastQDBusServerError() const;
|
||||
|
||||
//! Connected?
|
||||
bool isConnected() const { return this->m_busServer.isConnected(); }
|
||||
//! DBus server (if avaialable)
|
||||
const QDBusServer *qDBusServer() const;
|
||||
|
||||
//! address
|
||||
QString address() const { return this->m_busServer.address(); }
|
||||
//! With (P2P) DBus server
|
||||
bool hasQDBusServer() const;
|
||||
|
||||
//! Unregister all objects
|
||||
void unregisterAllObjects();
|
||||
@@ -118,10 +106,29 @@ namespace BlackCore
|
||||
//! Qt DBus address, e.g. "unix:tmpdir=/tmp", "tcp:host=127.0.0.1,port=45000"
|
||||
static bool isQtDBusAddress(const QString &address);
|
||||
|
||||
private:
|
||||
ServerMode m_serverMode = SERVERMODE_P2P;
|
||||
QScopedPointer<QDBusServer> m_busServer; //!< QDBusServer implementation
|
||||
QMap<QString, QObject *> m_objects; //!< Mapping of all exposed objects, for P2P registration when connection establishes, also to later unregister objects
|
||||
QMap<QString, QDBusConnection> m_DBusConnections; //!< Mapping of all DBusConnection objects
|
||||
|
||||
//! Check if address means a real server with P2P connection
|
||||
static bool isP2P(const QString &address);
|
||||
|
||||
//! Get the class info
|
||||
static const QString getClassInfo(QObject *object);
|
||||
|
||||
//! Register options with connection
|
||||
static const QDBusConnection::RegisterOptions &RegisterOptions()
|
||||
{
|
||||
static QDBusConnection::RegisterOptions opt = QDBusConnection::ExportAdaptors | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAllSlots;
|
||||
return opt;
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
||||
//! \brief Called when a new DBus client has connected in P2P mode
|
||||
bool registerObjectsWithConnection(const QDBusConnection &connection);
|
||||
//! Called when a new DBus client has connected in P2P mode
|
||||
bool ps_registerObjectsWithP2PConnection(const QDBusConnection &connection);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace BlackCore
|
||||
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_INTERFACE(BlackCore::ISimulatorFactory, "org.swift.PilotClient.BlackCore.SimulatorInterface")
|
||||
Q_DECLARE_INTERFACE(BlackCore::ISimulatorFactory, "org.swift.pilotclient.BlackCore.SimulatorInterface")
|
||||
Q_DECLARE_METATYPE(BlackCore::ISimulator::ConnectionStatus)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -19,10 +19,9 @@ namespace BlackMisc
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CGenericDBusInterface(const QString &serverName, const QString &path, const QString &interfaceName, const QDBusConnection &connection, QObject *parent = 0) :
|
||||
QDBusAbstractInterface(serverName, path, interfaceName.toUtf8().constData(), connection, parent)
|
||||
{
|
||||
}
|
||||
CGenericDBusInterface(const QString &serviceName, const QString &path, const QString &interfaceName, const QDBusConnection &connection, QObject *parent = 0) :
|
||||
QDBusAbstractInterface(serviceName, path, interfaceName.toUtf8().constData(), connection, parent)
|
||||
{ }
|
||||
|
||||
//! Call DBus, no return value
|
||||
template <typename... Args>
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace BlackSimPlugin
|
||||
class CSimulatorFs9Factory : public QObject, public BlackCore::ISimulatorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift.PilotClient.BlackCore.SimulatorInterface")
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface")
|
||||
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
||||
|
||||
public:
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
// TODO: @RW, move this string into CProject please
|
||||
Q_PLUGIN_METADATA(IID "org.swift.PilotClient.BlackCore.SimulatorInterface")
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface")
|
||||
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
||||
|
||||
public:
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace BlackSimPlugin
|
||||
class CSimulatorXPlaneFactory : public QObject, public BlackCore::ISimulatorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift.PilotClient.BlackCore.SimulatorInterface")
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface")
|
||||
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
||||
|
||||
public:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include <QMetaMethod>
|
||||
|
||||
#define XBUS_SERVICE_SERVICENAME "net.vatsim.xbus"
|
||||
#define XBUS_SERVICE_SERVICENAME "org.swift.xbus"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <functional>
|
||||
|
||||
//! \cond PRIVATE
|
||||
#define XBUS_SERVICE_INTERFACENAME "net.vatsim.xbus.service"
|
||||
#define XBUS_SERVICE_INTERFACENAME "org.swift.xbus.service"
|
||||
#define XBUS_SERVICE_OBJECTPATH "/xbus"
|
||||
//! \endcond
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include <QMetaMethod>
|
||||
|
||||
#define XBUS_SERVICENAME "net.vatsim.xbus"
|
||||
#define XBUS_SERVICENAME "org.swift.xbus"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
|
||||
//! \cond PRIVATE
|
||||
#define XBUS_TRAFFIC_INTERFACENAME "net.vatsim.xbus.traffic"
|
||||
#define XBUS_TRAFFIC_INTERFACENAME "org.swift.xbus.traffic"
|
||||
#define XBUS_TRAFFIC_OBJECTPATH "/xbus/traffic"
|
||||
//! \endcond
|
||||
|
||||
|
||||
@@ -49,12 +49,19 @@ BlackGui::CEnableForFramelessWindow::WindowMode CIntroWindow::getWindowMode() co
|
||||
GuiModes::CoreMode CIntroWindow::getCoreMode() const
|
||||
{
|
||||
if (this->ui->rb_CoreExternalVoiceLocal->isChecked())
|
||||
{
|
||||
return GuiModes::CoreExternalAudioLocal;
|
||||
}
|
||||
else if (this->ui->rb_CoreInGuiProcess->isChecked())
|
||||
{
|
||||
return GuiModes::CoreInGuiProcess;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GuiModes::CoreExternal;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DBus server address
|
||||
*/
|
||||
|
||||
@@ -89,17 +89,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
GuiModes::CoreMode coreMode = intro.getCoreMode();
|
||||
windowMode = intro.getWindowMode();
|
||||
QString dbusAddress = BlackCore::CDBusServer::fixAddressToDBusAddress(intro.getDBusAddress());
|
||||
QString dbusAddress = CDBusServer::fixAddressToDBusAddress(intro.getDBusAddress());
|
||||
switch (coreMode)
|
||||
{
|
||||
case GuiModes::CoreExternal:
|
||||
runtimeConfig = BlackCore::CRuntimeConfig::remote(dbusAddress);
|
||||
runtimeConfig = CRuntimeConfig::remote(dbusAddress);
|
||||
break;
|
||||
case GuiModes::CoreInGuiProcess:
|
||||
runtimeConfig = BlackCore::CRuntimeConfig::local(dbusAddress);
|
||||
runtimeConfig = CRuntimeConfig::local(dbusAddress);
|
||||
break;
|
||||
case GuiModes::CoreExternalAudioLocal:
|
||||
runtimeConfig = BlackCore::CRuntimeConfig::remoteLocalAudio(dbusAddress);
|
||||
runtimeConfig = CRuntimeConfig::remoteLocalAudio(dbusAddress);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ XBus::CPlugin *g_plugin;
|
||||
PLUGIN_API int XPluginStart(char *o_name, char *o_sig, char *o_desc)
|
||||
{
|
||||
std::strcpy(o_name, "X-Bus");
|
||||
std::strcpy(o_sig, "net.vatsim.XBus");
|
||||
std::strcpy(o_sig, "org.swift.XBus");
|
||||
std::strcpy(o_desc, "Allows pilot client to connect to X-Plane via D-Bus");
|
||||
|
||||
XBus::CTraffic::initLegacyData();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "service.h"
|
||||
#include "traffic.h"
|
||||
|
||||
#define XBUS_SERVICE_SERVICENAME "net.vatsim.xbus"
|
||||
#define XBUS_SERVICE_SERVICENAME "org.swift.xbus"
|
||||
|
||||
namespace XBus
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
class QTimer;
|
||||
|
||||
//! \cond PRIVATE
|
||||
#define XBUS_SERVICE_INTERFACENAME "net.vatsim.xbus.service"
|
||||
#define XBUS_SERVICE_INTERFACENAME "org.swift.xbus.service"
|
||||
#define XBUS_SERVICE_OBJECTPATH "/xbus"
|
||||
//! \endcond
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "XPMPMultiplayer.h"
|
||||
|
||||
//! \cond PRIVATE
|
||||
#define XBUS_TRAFFIC_INTERFACENAME "net.vatsim.xbus.traffic"
|
||||
#define XBUS_TRAFFIC_INTERFACENAME "org.swift.xbus.traffic"
|
||||
#define XBUS_TRAFFIC_OBJECTPATH "/xbus/traffic"
|
||||
//! \endcond
|
||||
|
||||
|
||||
Reference in New Issue
Block a user