mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 11:45:40 +08:00
Add DBus implementation for IContextSimulator
This class implements the DBus version off simulator context. When one of its methods is called, it forwards it to the configured DBus session/server. refs #135
This commit is contained in:
@@ -57,19 +57,17 @@ namespace BlackCore
|
|||||||
return static_cast<CCoreRuntime *>(this->parent());
|
return static_cast<CCoreRuntime *>(this->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \copydoc IContextSimulator::usingLocalObjects()
|
||||||
* \brief Using local objects?
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual bool usingLocalObjects() const override { return true; }
|
virtual bool usingLocalObjects() const override { return true; }
|
||||||
|
|
||||||
virtual BlackMisc::Aviation::CAircraft ownAircraft() const override;
|
virtual BlackMisc::Aviation::CAircraft ownAircraft() const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
//! \copydoc IContextSimulator::isConnected()
|
||||||
virtual bool isConnected() const override;
|
virtual bool isConnected() const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
//! \copydoc IContextSimulator::updateOwnAircraft()
|
||||||
virtual void updateOwnAircraft();
|
virtual void updateOwnAircraft();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
43
src/blackcore/context_simulator_proxy.cpp
Normal file
43
src/blackcore/context_simulator_proxy.cpp
Normal file
@@ -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 <QObject>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
|
||||||
|
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<bool>(QLatin1Literal("isConnected"));
|
||||||
|
}
|
||||||
|
|
||||||
|
BlackMisc::Aviation::CAircraft CContextSimulatorProxy::ownAircraft() const
|
||||||
|
{
|
||||||
|
return m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraft>(QLatin1Literal("ownAircraft"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace BlackCore
|
||||||
68
src/blackcore/context_simulator_proxy.h
Normal file
68
src/blackcore/context_simulator_proxy.h
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user