mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #199 , adjusted context classes
* removed usingLocalObjects() now in CContext * removed getRuntime() now in CContext * Constructors no longer public, context can only be obtained via runtime object * runtime class is friend class
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#ifndef BLACKCORE_CONTEXTAPPLICATION_H
|
||||
#define BLACKCORE_CONTEXTAPPLICATION_H
|
||||
|
||||
#include "blackcore/context.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include <QObject>
|
||||
|
||||
@@ -14,15 +15,20 @@
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Application context interface
|
||||
*/
|
||||
class IContextApplication : public QObject
|
||||
class IContextApplication : public CContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAPPLICATION_INTERFACENAME)
|
||||
|
||||
protected:
|
||||
friend class CRuntime;
|
||||
|
||||
//! Constructor
|
||||
IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
public:
|
||||
|
||||
//! Service name
|
||||
@@ -39,11 +45,6 @@ namespace BlackCore
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param parent
|
||||
*/
|
||||
IContextApplication(QObject *parent = nullptr) : QObject(parent) {}
|
||||
//! Destructor
|
||||
virtual ~IContextApplication() {}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_application_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -15,7 +15,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextApplication::CContextApplication(QObject *parent) : IContextApplication(parent)
|
||||
CContextApplication::CContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextApplication(mode, runtime)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
#define BLACKCORE_CONTEXTAPPLICATION_IMPL_H
|
||||
|
||||
#include "context_application.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
#include "dbus_server.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
class CCoreRuntime;
|
||||
class CRuntime;
|
||||
|
||||
/*!
|
||||
* \brief Application context
|
||||
@@ -24,11 +24,8 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* Context
|
||||
* \param parent
|
||||
*/
|
||||
CContextApplication(QObject *parent = nullptr);
|
||||
//! Constructor
|
||||
CContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CContextApplication() {}
|
||||
@@ -37,24 +34,7 @@ namespace BlackCore
|
||||
CContextApplication *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
server->addObject(IContextApplication::ObjectPath(), this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Runtime
|
||||
* \return
|
||||
*/
|
||||
CCoreRuntime *getRuntime()
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Const runtime
|
||||
* \return
|
||||
*/
|
||||
const CCoreRuntime *getRuntime() const
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
return this;
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
CContextApplicationProxy::CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextApplication(parent), m_dBusInterface(nullptr)
|
||||
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->relaySignals(serviceName, connection);
|
||||
|
||||
@@ -20,19 +20,11 @@ namespace BlackCore
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param serviceName
|
||||
* \param connection
|
||||
* \param parent
|
||||
*/
|
||||
CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CContextApplicationProxy() {}
|
||||
|
||||
private:
|
||||
friend class CRuntime;
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
//! Relay connection signals to local signals
|
||||
@@ -40,11 +32,11 @@ namespace BlackCore
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief IContextApplication
|
||||
* \param parent
|
||||
*/
|
||||
CContextApplicationProxy(QObject *parent = nullptr) : IContextApplication(parent), m_dBusInterface(nullptr) {}
|
||||
//! Constructor
|
||||
CContextApplicationProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextApplication(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
//! DBus version constructor
|
||||
CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef BLACKCORE_CONTEXTAUDIO_H
|
||||
#define BLACKCORE_CONTEXTAUDIO_H
|
||||
|
||||
#include "blackcore/context.h"
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/audiodevicelist.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
@@ -22,11 +23,15 @@ namespace BlackCore
|
||||
{
|
||||
|
||||
//! \brief Audio context interface
|
||||
class IContextAudio : public QObject
|
||||
class IContextAudio : public CContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
IContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
public:
|
||||
//! \brief Interface name
|
||||
static const QString &InterfaceName()
|
||||
@@ -42,15 +47,9 @@ namespace BlackCore
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \brief Constructor
|
||||
IContextAudio(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~IContextAudio() {}
|
||||
|
||||
//! \brief Using local objects?
|
||||
virtual bool usingLocalObjects() const = 0;
|
||||
|
||||
signals:
|
||||
//! \brief Audio test has been completed
|
||||
void audioTestCompleted();
|
||||
|
||||
@@ -22,11 +22,10 @@ namespace BlackCore
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextAudio::CContextAudio(QObject *parent) :
|
||||
IContextAudio(parent),
|
||||
m_voice(nullptr),
|
||||
m_keyboard(nullptr),
|
||||
m_contextSettings(nullptr)
|
||||
CContextAudio::CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
IContextAudio(mode, runtime),
|
||||
m_voice(nullptr),
|
||||
m_keyboard(nullptr)
|
||||
{
|
||||
// 1. Init by "voice driver"
|
||||
this->m_voice = new CVoiceVatlib(this);
|
||||
@@ -288,11 +287,13 @@ namespace BlackCore
|
||||
return static_cast<double>(this->m_voice->inputSquelch());
|
||||
}
|
||||
|
||||
void CContextAudio::settingsChanged(IContextSettings::SettingsType type)
|
||||
void CContextAudio::settingsChanged(uint typeValue)
|
||||
{
|
||||
if (!this->getRuntime()->getIContextSettings()) return;
|
||||
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
|
||||
if (type == IContextSettings::SettingsHotKeys)
|
||||
{
|
||||
CKeyboardKeyList hotKeys = m_contextSettings->getHotkeys();
|
||||
CKeyboardKeyList hotKeys = this->getRuntime()->getIContextSettings()->getHotkeys();
|
||||
CKeyboardKey pttKey = hotKeys.findBy(&BlackMisc::Hardware::CKeyboardKey::getFunction, BlackMisc::Hardware::CKeyboardKey::HotkeyPtt).front();
|
||||
m_keyboard->unregisterHotkey(m_handlePtt);
|
||||
m_handlePtt = m_keyboard->registerHotkey(pttKey, m_voice, &CVoiceVatlib::handlePushToTalk);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "context_audio.h"
|
||||
#include "context_settings.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
#include "dbus_server.h"
|
||||
#include "voice_vatlib.h"
|
||||
#include "blackcore/keyboard.h"
|
||||
@@ -23,9 +23,6 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
|
||||
//! \brief Constructor
|
||||
CContextAudio(QObject *runtime);
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CContextAudio();
|
||||
|
||||
@@ -34,22 +31,9 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(server);
|
||||
server->addObject(IContextAudio::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
//! \brief Runtime
|
||||
CCoreRuntime *getRuntime()
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! \brief Const runtime
|
||||
const CCoreRuntime *getRuntime() const
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! \copydoc IContextAudio::usingLocalObjects()
|
||||
virtual bool usingLocalObjects() const override { return true; }
|
||||
|
||||
//! \brief Initialize voice context
|
||||
void init();
|
||||
@@ -121,15 +105,18 @@ namespace BlackCore
|
||||
//! \copydoc IContextAudio::getSquelchValue()
|
||||
virtual double getSquelchValue() const override;
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
private slots:
|
||||
void settingsChanged(IContextSettings::SettingsType type);
|
||||
friend class CRuntime;
|
||||
void settingsChanged(uint typeValue);
|
||||
|
||||
private:
|
||||
CVoiceVatlib *m_voice; //!< underlying voice lib
|
||||
IKeyboard *m_keyboard;
|
||||
IKeyboard::RegistrationHandle m_handlePtt;
|
||||
IContextSettings *m_contextSettings;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextAudio(parent), m_dBusInterface(nullptr)
|
||||
CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||
|
||||
@@ -25,21 +25,11 @@ namespace BlackCore
|
||||
|
||||
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:
|
||||
friend class CRuntime;
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
//! Relay connection signals to local signals
|
||||
@@ -47,11 +37,11 @@ namespace BlackCore
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief IContextVoice
|
||||
* \param parent
|
||||
*/
|
||||
CContextAudioProxy(QObject *parent = nullptr) : IContextAudio(parent), m_dBusInterface(nullptr) {}
|
||||
//! Contructor
|
||||
CContextAudioProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
//! DBus version constructor
|
||||
CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
/*!
|
||||
* \brief Helper for logging, likely to be removed / changed
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
#ifndef BLACKCORE_CONTEXTNETWORK_H
|
||||
#define BLACKCORE_CONTEXTNETWORK_H
|
||||
|
||||
#include "blackcore/context.h"
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/nwtextmessagelist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
#include <QObject>
|
||||
#include "blackcore/network.h"
|
||||
|
||||
#define BLACKCORE_CONTEXTNETWORK_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextNetwork"
|
||||
#define BLACKCORE_CONTEXTNETWORK_OBJECTPATH "/Network"
|
||||
@@ -21,33 +22,26 @@ namespace BlackCore
|
||||
{
|
||||
|
||||
//! \brief Network context proxy
|
||||
class IContextNetwork : public QObject
|
||||
class IContextNetwork : public CContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(ConnectionStatus)
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||
|
||||
public:
|
||||
//! \brief DBus interface name
|
||||
//! DBus interface name
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTNETWORK_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \brief DBus object path
|
||||
//! DBus object path
|
||||
static const QString &ObjectPath()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTNETWORK_OBJECTPATH);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param parent
|
||||
*/
|
||||
IContextNetwork(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextNetwork() {}
|
||||
|
||||
@@ -56,16 +50,10 @@ namespace BlackCore
|
||||
|
||||
signals:
|
||||
|
||||
/*!
|
||||
* \brief Send status message
|
||||
* \param message
|
||||
*/
|
||||
//! Send status message
|
||||
void statusMessage(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
/*!
|
||||
* \brief Send status messages
|
||||
* \param messages
|
||||
*/
|
||||
//! Send status messages
|
||||
void statusMessages(const BlackMisc::CStatusMessageList &messages);
|
||||
|
||||
//! ATC station (online) list has been changed
|
||||
@@ -180,6 +168,14 @@ namespace BlackCore
|
||||
|
||||
//! Request ATIS updates (for all stations)
|
||||
virtual void requestAtisUpdates() = 0;
|
||||
|
||||
protected:
|
||||
friend class CRuntime;
|
||||
|
||||
//! Constructor
|
||||
IContextNetwork(CRuntimeConfig::ContextMode mode, CRuntime *runtime = nullptr) : CContext(mode, runtime) {}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_network_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
#include "vatsimbookingreader.h"
|
||||
#include "vatsimdatafilereader.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "context_network_impl.h"
|
||||
#include "vatsimbookingreader.h"
|
||||
#include "vatsimdatafilereader.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_network_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
#include "context_settings.h"
|
||||
#include "network_vatlib.h"
|
||||
#include "vatsimbookingreader.h"
|
||||
@@ -28,8 +28,8 @@ namespace BlackCore
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextNetwork::CContextNetwork(QObject *parent) :
|
||||
IContextNetwork(parent), m_network(nullptr), m_vatsimBookingReader(nullptr), m_vatsimDataFileReader(nullptr), m_dataUpdateTimer(nullptr)
|
||||
CContextNetwork::CContextNetwork(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
IContextNetwork(mode, runtime), m_network(nullptr), m_vatsimBookingReader(nullptr), m_vatsimDataFileReader(nullptr), m_dataUpdateTimer(nullptr)
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getIContextSettings());
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
@@ -30,33 +30,27 @@ namespace BlackCore
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||
|
||||
public:
|
||||
|
||||
//! \brief Constructor, with link to runtime
|
||||
CContextNetwork(QObject *parent = nullptr);
|
||||
|
||||
//! \brief Destructor
|
||||
//! Destructor
|
||||
virtual ~CContextNetwork();
|
||||
|
||||
/*!
|
||||
* \brief Register myself in DBus
|
||||
* \param server DBus server
|
||||
*/
|
||||
void registerWithDBus(CDBusServer *server)
|
||||
//! Register myself in DBus
|
||||
CContextNetwork *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
Q_ASSERT(server);
|
||||
server->addObject(IContextNetwork::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
//! \brief Runtime
|
||||
CCoreRuntime *getRuntime()
|
||||
//! Runtime
|
||||
CRuntime *getRuntime()
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
return static_cast<CRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! \brief Const runtime
|
||||
const CCoreRuntime *getRuntime() const
|
||||
const CRuntime *getRuntime() const
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
return static_cast<CRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::usingLocalObjects()
|
||||
@@ -67,20 +61,14 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||
virtual void readAtcBookingsFromSource() const override;
|
||||
|
||||
/*!
|
||||
* \copydoc IContextNetwork::getAtcStationsOnline()
|
||||
* \todo If I make this &getAtcStations XML is not generated correctly, needs to be crosschecked with the latest version of Qt
|
||||
*/
|
||||
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
return m_atcStationsOnline;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \copydoc IContextNetwork::getAtcStationsBooked()
|
||||
* \todo If I make this &getAtcStations XML is not generated correctly
|
||||
*/
|
||||
//! \copydoc IContextNetwork::getAtcStationsBooked()
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
@@ -142,7 +130,12 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates() override;
|
||||
|
||||
protected:
|
||||
//! Constructor, with link to runtime
|
||||
CContextNetwork(CRuntimeConfig::ContextMode, CRuntime *runtime);
|
||||
|
||||
private:
|
||||
friend class CRuntime;
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsOnline;
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsBooked;
|
||||
BlackMisc::Aviation::CAircraftList m_aircraftsInRange;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
CContextNetworkProxy::CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextNetwork(parent), m_dBusInterface(nullptr)
|
||||
CContextNetworkProxy::CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
|
||||
@@ -27,14 +27,6 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param serviceName
|
||||
* \param connection
|
||||
* \param parent
|
||||
*/
|
||||
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CContextNetworkProxy() {}
|
||||
|
||||
@@ -42,6 +34,7 @@ namespace BlackCore
|
||||
virtual bool usingLocalObjects() const override { return false; }
|
||||
|
||||
private:
|
||||
friend class CRuntime;
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface; /*!< DBus interface */
|
||||
|
||||
//! \brief Relay connection signals to local signals.
|
||||
@@ -49,7 +42,10 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
CContextNetworkProxy(QObject *parent = nullptr) : IContextNetwork(parent), m_dBusInterface(nullptr) {}
|
||||
CContextNetworkProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
//! \brief DBus version constructor
|
||||
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
/*!
|
||||
* \brief Helper for logging, likely to be removed / changed
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_network_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace BlackCore
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Context settings interface
|
||||
* Context settings interface
|
||||
*/
|
||||
class IContextSettings : public QObject
|
||||
class IContextSettings : public CContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
||||
@@ -40,9 +40,12 @@ namespace BlackCore
|
||||
SettingsNetwork
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Service name
|
||||
*/
|
||||
protected:
|
||||
//! DBus version constructor
|
||||
IContextSettings(CRuntimeConfig::ContextMode mode, CRuntime *runtime = nullptr) : CContext(mode, runtime)
|
||||
{}
|
||||
|
||||
public:
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTSETTINGS_INTERFACENAME);
|
||||
@@ -88,14 +91,7 @@ namespace BlackCore
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
*/
|
||||
IContextSettings(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
/*!
|
||||
* Destructor
|
||||
*/
|
||||
//! Destructor
|
||||
virtual ~IContextSettings() {}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_settings_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_runtime.h"
|
||||
|
||||
#include "blackmisc/settingutilities.h"
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace BlackCore
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextSettings::CContextSettings(QObject *parent) : IContextSettings(parent)
|
||||
CContextSettings::CContextSettings(CRuntimeConfig::ContextMode mode, CRuntime *parent) : IContextSettings(mode, parent) {}
|
||||
|
||||
{
|
||||
// create some dummy settings
|
||||
// this would actually be reading the settings from disk ..
|
||||
|
||||
@@ -25,31 +25,25 @@ namespace BlackCore
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
CContextSettings(QObject *runtime = nullptr);
|
||||
CContextSettings(CRuntimeConfig::ContextMode mode, CRuntime *runtime = nullptr);
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CContextSettings() {}
|
||||
|
||||
//! \brief Register myself in DBus
|
||||
void registerWithDBus(CDBusServer *server)
|
||||
CContextSettings *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
server->addObject(IContextSettings::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
//! \brief Runtime
|
||||
CCoreRuntime *getRuntime()
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
//! \brief settings file
|
||||
const QString &getSettingsDirectory() const { return BlackMisc::Settings::CSettingUtilities::getSettingsDirectory(); }
|
||||
|
||||
//! \brief Runtime
|
||||
const CCoreRuntime *getRuntime() const
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
//! \copydoc IContextSettings::value()
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSettings::getNetworkSettings()
|
||||
@@ -62,6 +56,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value) override;
|
||||
|
||||
private:
|
||||
friend class CRuntime;
|
||||
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
|
||||
BlackMisc::Hardware::CKeyboardKeyList m_hotkeys;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
CContextSettingsProxy::CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextSettings(parent), m_dBusInterface(nullptr)
|
||||
CContextSettingsProxy::CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSettings(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextSettings::ObjectPath(), IContextSettings::InterfaceName(),
|
||||
|
||||
@@ -28,10 +28,6 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
*/
|
||||
CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||
//! \brief Destructor
|
||||
virtual ~CContextSettingsProxy() {}
|
||||
|
||||
@@ -49,6 +45,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value) override;
|
||||
|
||||
private:
|
||||
friend class CRuntime;
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
//! Relay connection signals to local signals
|
||||
@@ -56,11 +53,11 @@ namespace BlackCore
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief IContextSettings
|
||||
* \param parent
|
||||
*/
|
||||
CContextSettingsProxy(QObject *parent = nullptr) : IContextSettings(parent), m_dBusInterface(nullptr) {}
|
||||
//! \brief DBus version constructor
|
||||
CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
//! \brief Constructor
|
||||
CContextSettingsProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSettings(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextSimulator"
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_OBJECTPATH "/Simulator"
|
||||
|
||||
#include "context.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
//! \brief Network context
|
||||
class IContextSimulator : public QObject
|
||||
class IContextSimulator : public CContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME)
|
||||
@@ -38,18 +39,9 @@ namespace BlackCore
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \brief Constructor
|
||||
IContextSimulator(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextSimulator() {}
|
||||
|
||||
/*!
|
||||
* \brief Using local objects?
|
||||
* \return
|
||||
*/
|
||||
virtual bool usingLocalObjects() const = 0;
|
||||
|
||||
signals:
|
||||
//! Emitted when the simulator connection changes
|
||||
void connectionChanged(bool value);
|
||||
@@ -59,9 +51,14 @@ namespace BlackCore
|
||||
//! Returns true when simulator is connected and available
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
/*!
|
||||
//! Get user aircraft value object
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0;
|
||||
|
||||
protected:
|
||||
friend class CRuntime;
|
||||
|
||||
//! \brief Constructor
|
||||
IContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
};
|
||||
|
||||
} // namespace BlackCore
|
||||
|
||||
@@ -4,8 +4,12 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_simulator_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include <QPluginLoader>
|
||||
#include "context_runtime.h"
|
||||
|
||||
#ifdef BLACK_WITH_FSX
|
||||
#include "fsx/simulator_fsx.h"
|
||||
#endif
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -15,27 +19,19 @@ using namespace BlackMisc::Geo;
|
||||
namespace BlackCore
|
||||
{
|
||||
// Init this context
|
||||
CContextSimulator::CContextSimulator(QObject *parent) :
|
||||
IContextSimulator(parent),
|
||||
m_simulator(nullptr),
|
||||
m_updateTimer(nullptr),
|
||||
m_contextNetwork(nullptr)
|
||||
CContextSimulator::CContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime),
|
||||
m_simulator(nullptr), m_updateTimer(nullptr)
|
||||
{
|
||||
m_updateTimer = new QTimer(this);
|
||||
|
||||
connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::updateOwnAircraft);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
CContextSimulator::~CContextSimulator()
|
||||
{
|
||||
}
|
||||
CContextSimulator::~CContextSimulator() {}
|
||||
|
||||
bool CContextSimulator::isConnected() const
|
||||
{
|
||||
if (!m_simulator)
|
||||
return false;
|
||||
|
||||
if (!m_simulator) return false;
|
||||
return m_simulator->isConnected();
|
||||
}
|
||||
|
||||
@@ -60,15 +56,9 @@ namespace BlackCore
|
||||
|
||||
void CContextSimulator::updateOwnAircraft()
|
||||
{
|
||||
if (!m_simulator)
|
||||
return;
|
||||
|
||||
m_ownAircraft = m_simulator->getOwnAircraft();
|
||||
|
||||
|
||||
|
||||
m_contextNetwork->updateOwnSituation(m_ownAircraft.getSituation());
|
||||
m_contextNetwork->updateOwnCockpit(m_ownAircraft.getCom1System(), m_ownAircraft.getCom2System(), m_ownAircraft.getTransponder());
|
||||
getNetworkContext()->updateOwnSituation(m_ownAircraft.getSituation());
|
||||
getNetworkContext()->updateOwnCockpit(m_ownAircraft.getCom1System(), m_ownAircraft.getCom2System(), m_ownAircraft.getTransponder());
|
||||
}
|
||||
|
||||
void CContextSimulator::setConnectionStatus(bool value)
|
||||
@@ -104,6 +94,12 @@ namespace BlackCore
|
||||
qDebug() << loader.errorString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IContextNetwork *CContextSimulator::getNetworkContext()
|
||||
{
|
||||
Q_ASSERT(this->getRuntime()->getIContextNetwork());
|
||||
return getRuntime()->getIContextNetwork();
|
||||
}
|
||||
|
||||
} // namespace BlackCore
|
||||
|
||||
@@ -25,43 +25,19 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
//! \brief Constructor
|
||||
CContextSimulator(QObject *parent = nullptr);
|
||||
CContextSimulator(CRuntimeConfig::ContextMode, CRuntime *runtime);
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CContextSimulator();
|
||||
|
||||
/*!
|
||||
//! Register myself in DBus
|
||||
CContextSimulator *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
Q_ASSERT(server);
|
||||
server->addObject(CContextSimulator::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Runtime
|
||||
* \return
|
||||
*/
|
||||
const CCoreRuntime *getRuntime() const
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Runtime
|
||||
* \return
|
||||
*/
|
||||
CCoreRuntime *getRuntime()
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! \brief Initialze the context
|
||||
void init();
|
||||
|
||||
//! \copydoc IContextSimulator::usingLocalObjects()
|
||||
virtual bool usingLocalObjects() const override { return true; }
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSimulator::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
@@ -69,8 +45,6 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
//! \copydoc IContextSimulator::updateOwnAircraft()
|
||||
virtual void updateOwnAircraft();
|
||||
@@ -79,23 +53,20 @@ namespace BlackCore
|
||||
void setConnectionStatus(bool value);
|
||||
|
||||
private:
|
||||
|
||||
/*!
|
||||
* \brief Load any kind of plugins
|
||||
* \todo Currently it goes through the plugins folder and creates an instance for any plugin it may find
|
||||
* In case an FSX and an X-Plane are in that folder, m_simulator will always point to X-Plane in the end.
|
||||
*/
|
||||
void loadPlugins();
|
||||
|
||||
BlackMisc::Aviation::CAircraft m_ownAircraft;
|
||||
BlackCore::ISimulator *m_simulator;
|
||||
|
||||
QTimer *m_updateTimer;
|
||||
BlackCore::IContextNetwork *m_contextNetwork;
|
||||
|
||||
QDir m_pluginsDir;
|
||||
IContextNetwork *getNetworkContext();
|
||||
};
|
||||
|
||||
} // namespace BlackCore
|
||||
|
||||
#endif // BLACKCORE_CONTEXTSIMULATOR_IMPL_H
|
||||
#endif // guard
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BlackCore
|
||||
{
|
||||
|
||||
// Constructor for DBus
|
||||
CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextSimulator(parent), m_dBusInterface(nullptr)
|
||||
CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
@@ -27,8 +27,7 @@ namespace BlackCore
|
||||
|
||||
// Workaround for signals, not working without, but why?
|
||||
void CContextSimulatorProxy::relaySignals(const QString &/*serviceName*/, QDBusConnection &/*connection*/)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
bool CContextSimulatorProxy::isConnected() const
|
||||
{
|
||||
|
||||
@@ -16,40 +16,24 @@ namespace BlackCore
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param serviceName
|
||||
* \param connection
|
||||
* \param parent
|
||||
*/
|
||||
CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent = 0);
|
||||
|
||||
//! Destructor
|
||||
~CContextSimulatorProxy() {}
|
||||
|
||||
/*!
|
||||
* \brief Using local objects?
|
||||
* \return
|
||||
*/
|
||||
virtual bool usingLocalObjects() const override { return false; }
|
||||
|
||||
private:
|
||||
friend class CRuntime;
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
//! Relay connection signals to local signals
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief CContextNetworkProxy
|
||||
* \param parent
|
||||
*/
|
||||
CContextSimulatorProxy(QObject *parent = nullptr) : IContextSimulator(parent), m_dBusInterface(0) {}
|
||||
//! Constructor
|
||||
CContextSimulatorProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(0) {}
|
||||
|
||||
signals:
|
||||
//! \brief DBus version constructor
|
||||
CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc IContextSimulator::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
|
||||
@@ -59,4 +43,4 @@ namespace BlackCore
|
||||
|
||||
} // namespace BlackCore
|
||||
|
||||
#endif // BLACKCORE_CONTEXTSIMULATOR_PROXY_H
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user