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