diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index c8d0c85ba..e2d0ed630 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -57,19 +57,17 @@ namespace BlackCore return static_cast(this->parent()); } - /*! - * \brief Using local objects? - * \return - */ + //! \copydoc IContextSimulator::usingLocalObjects() virtual bool usingLocalObjects() const override { return true; } virtual BlackMisc::Aviation::CAircraft ownAircraft() const override; public slots: - + //! \copydoc IContextSimulator::isConnected() virtual bool isConnected() const override; private slots: + //! \copydoc IContextSimulator::updateOwnAircraft() virtual void updateOwnAircraft(); /*! diff --git a/src/blackcore/context_simulator_proxy.cpp b/src/blackcore/context_simulator_proxy.cpp new file mode 100644 index 000000000..2ac24230b --- /dev/null +++ b/src/blackcore/context_simulator_proxy.cpp @@ -0,0 +1,43 @@ +/* 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/. */ + +#include "blackcore/context_simulator_proxy.h" +#include +#include +#include + +using namespace BlackMisc; +using namespace BlackMisc::PhysicalQuantities; +using namespace BlackMisc::Aviation; +using namespace BlackMisc::Geo; + +namespace BlackCore +{ + + // Constructor for DBus + CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextSimulator(parent), m_dBusInterface(0) + { + this->m_dBusInterface = new BlackMisc::CGenericDBusInterface( + serviceName , IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), + connection, this); + this->relaySignals(serviceName, connection); + } + + // Workaround for signals, not working without, but why? + void CContextSimulatorProxy::relaySignals(const QString &/*serviceName*/, QDBusConnection &/*connection*/) + { + } + + bool CContextSimulatorProxy::isConnected() const + { + return m_dBusInterface->callDBusRet(QLatin1Literal("isConnected")); + } + + BlackMisc::Aviation::CAircraft CContextSimulatorProxy::ownAircraft() const + { + return m_dBusInterface->callDBusRet(QLatin1Literal("ownAircraft")); + } + +} // namespace BlackCore diff --git a/src/blackcore/context_simulator_proxy.h b/src/blackcore/context_simulator_proxy.h new file mode 100644 index 000000000..243605cb9 --- /dev/null +++ b/src/blackcore/context_simulator_proxy.h @@ -0,0 +1,68 @@ +/* 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/. */ + +#ifndef BLACKCORE_CONTEXTSIMULATOR_PROXY_H +#define BLACKCORE_CONTEXTSIMULATOR_PROXY_H + +#include "blackcore/context_simulator.h" +#include "blackmisc/genericdbusinterface.h" + +namespace BlackCore +{ + //! \brief DBus proxy for Simulator Context + class CContextSimulatorProxy : public IContextSimulator + { + 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; } + + virtual BlackMisc::Aviation::CAircraft ownAircraft() const override; + + private: + BlackMisc::CGenericDBusInterface *m_dBusInterface; + + /*! + * Relay connection signals to local signals + * No idea why this has to be wired and is not done automatically + * \param connection + */ + void relaySignals(const QString &serviceName, QDBusConnection &connection); + + protected: + /*! + * \brief CContextNetworkProxy + * \param parent + */ + CContextSimulatorProxy(QObject *parent = nullptr) : IContextSimulator(parent), m_dBusInterface(0) {} + + signals: + + public slots: + + //! \copydoc IContextSimulator::isConnected() + virtual bool isConnected() const override; + + //virtual void ownAircraftUpdateReceived(BlackMisc::Aviation::CAircraft aircraft) override; + + }; + +} // namespace BlackCore + +#endif // BLACKCORE_CONTEXTSIMULATOR_PROXY_H