mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -6,240 +6,174 @@
|
||||
#ifndef BLACKCORE_CONTEXTNETWORK_H
|
||||
#define BLACKCORE_CONTEXTNETWORK_H
|
||||
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/network_vatlib.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackcore/vatsimbookingreader.h"
|
||||
#include "blackcore/vatsimdatafilereader.h"
|
||||
#include "blackcore/context_network_interface.h"
|
||||
#include "blackcore/context_settings_interface.h"
|
||||
#include "blackmisc/avcallsignlist.h"
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/nwtextmessagelist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/vvoiceroomlist.h"
|
||||
#include <QObject>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
#define BLACKCORE_CONTEXTNETWORK_INTERFACENAME "blackcore.contextnetwork"
|
||||
#define BLACKCORE_CONTEXTNETWORK_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextNetwork"
|
||||
#define BLACKCORE_CONTEXTNETWORK_OBJECTPATH "/Network"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
//! \brief Network context
|
||||
class CContextNetwork : public IContextNetwork
|
||||
|
||||
//! \brief Network context proxy
|
||||
class IContextNetwork : public QObject
|
||||
{
|
||||
// Register by same name, make signals sender independent
|
||||
// http://dbus.freedesktop.org/doc/dbus-faq.html#idp48032144
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||
Q_OBJECT
|
||||
Q_ENUMS(ConnectionStatus)
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||
|
||||
public:
|
||||
//! \brief Constructor, with link to runtime
|
||||
CContextNetwork(CCoreRuntime *runtime);
|
||||
//! \brief DBus interface name
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTNETWORK_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CContextNetwork();
|
||||
//! \brief DBus object path
|
||||
static const QString &ObjectPath()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTNETWORK_OBJECTPATH);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register myself in DBus
|
||||
* \param server DBus server
|
||||
* \brief Constructor
|
||||
* \param parent
|
||||
*/
|
||||
void registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
Q_ASSERT(server);
|
||||
server->addObject(IContextNetwork::ServicePath(), this);
|
||||
}
|
||||
IContextNetwork(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
//! \brief Runtime
|
||||
const CCoreRuntime *getRuntime() const
|
||||
{
|
||||
return static_cast<CCoreRuntime *>(this->parent());
|
||||
}
|
||||
//! Destructor
|
||||
virtual ~IContextNetwork() {}
|
||||
|
||||
//! \brief Using local objects?
|
||||
virtual bool usingLocalObjects() const override { return true; }
|
||||
virtual bool usingLocalObjects() const = 0;
|
||||
|
||||
signals:
|
||||
|
||||
/*!
|
||||
* \brief Send status message
|
||||
* \param message
|
||||
*/
|
||||
void statusMessage(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
/*!
|
||||
* \brief Send status messages
|
||||
* \param messages
|
||||
*/
|
||||
void statusMessages(const BlackMisc::CStatusMessageList &messages);
|
||||
|
||||
//! \brief ATC station (online) list has been changed
|
||||
void changedAtcStationsOnline();
|
||||
|
||||
//! \brief ATC station (booked) list has been changed
|
||||
void changedAtcStationsBooked();
|
||||
|
||||
//! \brief Aircraft list has been changed
|
||||
void changedAircraftsInRange();
|
||||
|
||||
//! \brief Terminated connection
|
||||
void connectionTerminated();
|
||||
|
||||
/*!
|
||||
* \brief Connection status changed
|
||||
* \param from old status
|
||||
* \param to new status
|
||||
* \remarks If I use the enum, adaptor / interface are not created correctly
|
||||
* \see INetwork::ConnectionStatus
|
||||
*/
|
||||
void connectionStatusChanged(uint from, uint to);
|
||||
|
||||
/*!
|
||||
* \brief Text messages (also private chat messages)
|
||||
* \param textMessages message list
|
||||
*/
|
||||
void textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages);
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||
virtual void readAtcBookingsFromSource() override;
|
||||
//! \brief Reload bookings from booking service
|
||||
virtual void readAtcBookingsFromSource() const = 0;
|
||||
|
||||
/*!
|
||||
* \copydoc IContextNetwork::getAtcStationsOnline()
|
||||
* \todo If I make this &getAtcStations XML is not generated correctly, needs to be crosschecked with the latest version of Qt
|
||||
* \brief The ATC list with online ATC controllers
|
||||
* \remarks If I make this &getAtcStations XML is not generated correctly
|
||||
*/
|
||||
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
|
||||
*/
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
return m_atcStationsBooked;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftsInRange()
|
||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
return m_aircraftsInRange;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::connectToNetwork()
|
||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint mode) override;
|
||||
|
||||
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork() override;
|
||||
|
||||
//! \copydoc IContextNetwork::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::setOwnAircraft()
|
||||
virtual BlackMisc::CStatusMessageList setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnPosition()
|
||||
virtual void updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnSituation()
|
||||
virtual void updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnCockpit()
|
||||
virtual void updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::sendTextMessages()
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getMetar()
|
||||
virtual BlackMisc::Aviation::CInformationMessage getMetar(const QString &airportIcaoCode) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedVoiceRooms()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getSelectedVoiceRooms() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedAtcStations
|
||||
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getUsers()
|
||||
virtual BlackMisc::Network::CUserList getUsers() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getUsersForCallsigns
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const override;
|
||||
|
||||
//! \copydoc IContextNetwork::requestDataUpdates
|
||||
virtual void requestDataUpdates()override;
|
||||
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates() override;
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsOnline;
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsBooked;
|
||||
BlackMisc::Aviation::CAircraftList m_aircraftsInRange;
|
||||
BlackCore::INetwork *m_network;
|
||||
BlackMisc::Aviation::CAircraft m_ownAircraft;
|
||||
QMap<QString, BlackMisc::Aviation::CInformationMessage> m_metarCache /*!< Keep METARs for a while */;
|
||||
|
||||
// for reading XML and VATSIM data files
|
||||
CVatsimBookingReader *m_vatsimBookingReader;
|
||||
CVatsimDataFileReader *m_vatsimDataFileReader;
|
||||
QTimer *m_dataUpdateTimer; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
|
||||
|
||||
//! \brief Replace value by new values
|
||||
void setAtcStationsBooked(const BlackMisc::Aviation::CAtcStationList &newStations);
|
||||
|
||||
//! \brief Replace value by new values
|
||||
void setAtcStationsOnline(const BlackMisc::Aviation::CAtcStationList &newStations);
|
||||
|
||||
//! \brief The "central" ATC list with online ATC controllers
|
||||
BlackMisc::Aviation::CAtcStationList &atcStationsOnline()
|
||||
{
|
||||
return m_atcStationsOnline;
|
||||
}
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const = 0;
|
||||
|
||||
//! \brief ATC list, with booked controllers
|
||||
BlackMisc::Aviation::CAtcStationList &atcStationsBooked()
|
||||
{
|
||||
return m_atcStationsBooked;
|
||||
}
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const = 0 ;
|
||||
|
||||
//! \brief Init my very onw aircraft
|
||||
void initOwnAircraft();
|
||||
//! \brief Aircraft list
|
||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const = 0;
|
||||
|
||||
//! \brief Get network settings
|
||||
BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getIContextSettings());
|
||||
return this->getRuntime()->getIContextSettings()->getNetworkSettings();
|
||||
}
|
||||
//! \brief Get all users
|
||||
virtual BlackMisc::Network::CUserList getUsers() const = 0;
|
||||
|
||||
private slots:
|
||||
//! \brief ATC bookings received
|
||||
void psReceivedBookings(BlackMisc::Aviation::CAtcStationList bookedStations);
|
||||
//! \brief Users for given callsigns, e.g. for voice room resolution
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const = 0;
|
||||
|
||||
//! \brief Data file has been read
|
||||
void psDataFileRead();
|
||||
//! \brief Get own aircraft
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Connection status changed?
|
||||
* \param from old status
|
||||
* \param to new status
|
||||
* \brief Connect to Network
|
||||
* \return messages gererated during connecting
|
||||
* \see INetwork::LoginMode
|
||||
*/
|
||||
void psFsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to);
|
||||
|
||||
//! \brief ATC position update
|
||||
void psFsdAtcPositionUpdate(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range);
|
||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint loginMode) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Controller disconnected
|
||||
* \param callsign callsign of controller
|
||||
* \brief Disconnect from network
|
||||
* \return messages generated during disconnecting
|
||||
*/
|
||||
void psFsdAtcControllerDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork() = 0;
|
||||
|
||||
//! \brief ATIS received
|
||||
void psFsdAtisQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &atisMessage);
|
||||
//! \brief Network connected?
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief ATIS received (voice room part)
|
||||
* \param callsign station callsign
|
||||
* \param url voice room's URL
|
||||
* Set own aircraft
|
||||
* \param aircraft
|
||||
* \return message list, as aircraft can only be set prior connecting
|
||||
*/
|
||||
void psFsdAtisVoiceRoomQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url);
|
||||
virtual BlackMisc::CStatusMessageList setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft) = 0;
|
||||
|
||||
//! \brief Own position, be aware height is terrain height
|
||||
virtual void updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) = 0;
|
||||
|
||||
//! \brief Complete situation update
|
||||
virtual void updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation) = 0;
|
||||
|
||||
//! \brief Update own cockpit
|
||||
virtual void updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder) = 0;
|
||||
|
||||
//! \brief Text messages (radio and private chat messages)
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) = 0;
|
||||
|
||||
/*!
|
||||
* \brief ATIS received (logoff time part)
|
||||
* \param callsign station callsign
|
||||
* \param zuluTime UTC time, when controller will logoff
|
||||
* \brief Get METAR, if not available request it
|
||||
* \param airportIcaoCode such as EDDF, KLAX
|
||||
* \return
|
||||
*/
|
||||
void psFsdAtisLogoffTimeQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &zuluTime);
|
||||
virtual BlackMisc::Aviation::CInformationMessage getMetar(const QString &airportIcaoCode) = 0;
|
||||
|
||||
//! \brief METAR received
|
||||
void psFsdMetarReceived(const QString &metarMessage);
|
||||
//! \brief Use the selected COM1/2 frequencies, and get the corresponding voice room for it
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getSelectedVoiceRooms() const = 0;
|
||||
|
||||
//! \brief Realname recevied
|
||||
void psFsdRealNameReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &realname);
|
||||
//! \brief Use the selected COM1/2 frequencies, and get the corresponding ATC stations for it
|
||||
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const = 0;
|
||||
|
||||
//! \brief Plane ICAO codes received
|
||||
void psFsdIcaoCodesReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftIcao &icaoData);
|
||||
//! \brief Request data updates (pilot's frequencies, ATIS, ..)
|
||||
virtual void requestDataUpdates() = 0;
|
||||
|
||||
//! \brief Aircraft position update received
|
||||
void psFsdAircraftUpdateReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
|
||||
|
||||
//! \brief Pilot disconnected
|
||||
void psFsdPilotDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! \brief Frequency received
|
||||
void psFsdFrequencyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! \brief Radio text messages received
|
||||
void psFsdTextMessageReceived(const BlackMisc::Network::CTextMessageList &messages);
|
||||
//! \brief Request ATIS updates (for all stations)
|
||||
virtual void requestAtisUpdates() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
* 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 "context_network.h"
|
||||
#include "context_network_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include "vatsimbookingreader.h"
|
||||
#include "vatsimdatafilereader.h"
|
||||
|
||||
#include "blackmisc/predicates.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
* 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 "context_network.h"
|
||||
#include "context_network_impl.h"
|
||||
#include "vatsimbookingreader.h"
|
||||
#include "vatsimdatafilereader.h"
|
||||
#include "coreruntime.h"
|
||||
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
|
||||
#include <QMetaEnum>
|
||||
#include <QUrl>
|
||||
#include <QNetworkRequest>
|
||||
@@ -28,7 +32,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Reload bookings
|
||||
*/
|
||||
void CContextNetwork::readAtcBookingsFromSource()
|
||||
void CContextNetwork::readAtcBookingsFromSource() const
|
||||
{
|
||||
Q_ASSERT(this->m_vatsimBookingReader);
|
||||
this->m_vatsimBookingReader->read();
|
||||
|
||||
@@ -3,11 +3,16 @@
|
||||
* 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 "context_network.h"
|
||||
#include "context_network_impl.h"
|
||||
#include "coreruntime.h"
|
||||
#include "context_settings.h"
|
||||
#include "network_vatlib.h"
|
||||
#include "vatsimbookingreader.h"
|
||||
#include "vatsimdatafilereader.h"
|
||||
|
||||
#include "blackmisc/networkchecks.h"
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackcore/context_settings_interface.h"
|
||||
|
||||
#include <QtXml/QDomElement>
|
||||
#include <QNetworkReply>
|
||||
|
||||
@@ -23,8 +28,8 @@ namespace BlackCore
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextNetwork::CContextNetwork(CCoreRuntime *runtime) :
|
||||
IContextNetwork(runtime), m_network(nullptr), m_vatsimBookingReader(nullptr), m_vatsimDataFileReader(nullptr), m_dataUpdateTimer(nullptr)
|
||||
CContextNetwork::CContextNetwork(QObject *parent) :
|
||||
IContextNetwork(parent), m_network(nullptr), m_vatsimBookingReader(nullptr), m_vatsimDataFileReader(nullptr), m_dataUpdateTimer(nullptr)
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getIContextSettings());
|
||||
250
src/blackcore/context_network_impl.h
Normal file
250
src/blackcore/context_network_impl.h
Normal file
@@ -0,0 +1,250 @@
|
||||
/* 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_CONTEXTNETWORK_IMPL_H
|
||||
#define BLACKCORE_CONTEXTNETWORK_IMPL_H
|
||||
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackmisc/setnetwork.h"
|
||||
|
||||
#include <QMap>
|
||||
|
||||
class QTimer;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
class CVatsimBookingReader;
|
||||
class CVatsimDataFileReader;
|
||||
|
||||
//! \brief Network context implementation
|
||||
class CContextNetwork : public IContextNetwork
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||
|
||||
public:
|
||||
|
||||
//! \brief Constructor, with link to runtime
|
||||
CContextNetwork(QObject *parent = nullptr);
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CContextNetwork();
|
||||
|
||||
/*!
|
||||
* \brief Register myself in DBus
|
||||
* \param server DBus server
|
||||
*/
|
||||
void registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
Q_ASSERT(server);
|
||||
server->addObject(IContextNetwork::ObjectPath(), 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 IContextNetwork::usingLocalObjects()
|
||||
virtual bool usingLocalObjects() const override { return true; }
|
||||
|
||||
public slots: // IContextNetwork overrides
|
||||
|
||||
//! \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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
return m_atcStationsBooked;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftsInRange()
|
||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
return m_aircraftsInRange;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::connectToNetwork()
|
||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint mode) override;
|
||||
|
||||
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork() override;
|
||||
|
||||
//! \copydoc IContextNetwork::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::setOwnAircraft()
|
||||
virtual BlackMisc::CStatusMessageList setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnPosition()
|
||||
virtual void updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnSituation()
|
||||
virtual void updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnCockpit()
|
||||
virtual void updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::sendTextMessages()
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getMetar()
|
||||
virtual BlackMisc::Aviation::CInformationMessage getMetar(const QString &airportIcaoCode) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedVoiceRooms()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getSelectedVoiceRooms() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedAtcStations
|
||||
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getUsers()
|
||||
virtual BlackMisc::Network::CUserList getUsers() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getUsersForCallsigns
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const override;
|
||||
|
||||
//! \copydoc IContextNetwork::requestDataUpdates
|
||||
virtual void requestDataUpdates()override;
|
||||
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates() override;
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsOnline;
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsBooked;
|
||||
BlackMisc::Aviation::CAircraftList m_aircraftsInRange;
|
||||
BlackCore::INetwork *m_network;
|
||||
BlackMisc::Aviation::CAircraft m_ownAircraft;
|
||||
QMap<QString, BlackMisc::Aviation::CInformationMessage> m_metarCache /*!< Keep METARs for a while */;
|
||||
|
||||
// for reading XML and VATSIM data files
|
||||
CVatsimBookingReader *m_vatsimBookingReader;
|
||||
CVatsimDataFileReader *m_vatsimDataFileReader;
|
||||
QTimer *m_dataUpdateTimer; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
|
||||
|
||||
//! \brief Replace value by new values
|
||||
void setAtcStationsBooked(const BlackMisc::Aviation::CAtcStationList &newStations);
|
||||
|
||||
//! \brief Replace value by new values
|
||||
void setAtcStationsOnline(const BlackMisc::Aviation::CAtcStationList &newStations);
|
||||
|
||||
//! \brief The "central" ATC list with online ATC controllers
|
||||
BlackMisc::Aviation::CAtcStationList &atcStationsOnline()
|
||||
{
|
||||
return m_atcStationsOnline;
|
||||
}
|
||||
|
||||
//! \brief ATC list, with booked controllers
|
||||
BlackMisc::Aviation::CAtcStationList &atcStationsBooked()
|
||||
{
|
||||
return m_atcStationsBooked;
|
||||
}
|
||||
|
||||
//! \brief Init my very onw aircraft
|
||||
void initOwnAircraft();
|
||||
|
||||
//! \brief Get network settings
|
||||
BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getIContextSettings());
|
||||
return this->getRuntime()->getIContextSettings()->getNetworkSettings();
|
||||
}
|
||||
|
||||
private slots:
|
||||
//! \brief ATC bookings received
|
||||
void psReceivedBookings(BlackMisc::Aviation::CAtcStationList bookedStations);
|
||||
|
||||
//! \brief Data file has been read
|
||||
void psDataFileRead();
|
||||
|
||||
/*!
|
||||
* \brief Connection status changed?
|
||||
* \param from old status
|
||||
* \param to new status
|
||||
*/
|
||||
void psFsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to);
|
||||
|
||||
//! \brief ATC position update
|
||||
void psFsdAtcPositionUpdate(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range);
|
||||
|
||||
/*!
|
||||
* \brief Controller disconnected
|
||||
* \param callsign callsign of controller
|
||||
*/
|
||||
void psFsdAtcControllerDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! \brief ATIS received
|
||||
void psFsdAtisQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &atisMessage);
|
||||
|
||||
/*!
|
||||
* \brief ATIS received (voice room part)
|
||||
* \param callsign station callsign
|
||||
* \param url voice room's URL
|
||||
*/
|
||||
void psFsdAtisVoiceRoomQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url);
|
||||
|
||||
/*!
|
||||
* \brief ATIS received (logoff time part)
|
||||
* \param callsign station callsign
|
||||
* \param zuluTime UTC time, when controller will logoff
|
||||
*/
|
||||
void psFsdAtisLogoffTimeQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &zuluTime);
|
||||
|
||||
//! \brief METAR received
|
||||
void psFsdMetarReceived(const QString &metarMessage);
|
||||
|
||||
//! \brief Realname recevied
|
||||
void psFsdRealNameReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &realname);
|
||||
|
||||
//! \brief Plane ICAO codes received
|
||||
void psFsdIcaoCodesReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftIcao &icaoData);
|
||||
|
||||
//! \brief Aircraft position update received
|
||||
void psFsdAircraftUpdateReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
|
||||
|
||||
//! \brief Pilot disconnected
|
||||
void psFsdPilotDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! \brief Frequency received
|
||||
void psFsdFrequencyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! \brief Radio text messages received
|
||||
void psFsdTextMessageReceived(const BlackMisc::Network::CTextMessageList &messages);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -1,204 +0,0 @@
|
||||
/* 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_CONTEXTNETWORK_INTERFACE_H
|
||||
#define BLACKCORE_CONTEXTNETWORK_INTERFACE_H
|
||||
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/nwtextmessagelist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackcore/network_vatlib.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QDBusAbstractInterface>
|
||||
|
||||
#define BLACKCORE_CONTEXTNETWORK_INTERFACENAME "blackcore.contextnetwork"
|
||||
#define BLACKCORE_CONTEXTNETWORK_SERVICEPATH "/network"
|
||||
|
||||
// SERVICENAME must contain at least one ".", otherwise generation fails
|
||||
// as this is interpreted in the way comain.somename
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief The IContextNetwork class
|
||||
*/
|
||||
class IContextNetwork : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(ConnectionStatus)
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||
|
||||
public:
|
||||
//! \brief Service name
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTNETWORK_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \brief Service path
|
||||
static const QString &ServicePath()
|
||||
{
|
||||
static QString s(BLACKCORE_CONTEXTNETWORK_SERVICEPATH);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param serviceName
|
||||
* \param connection
|
||||
* \param parent
|
||||
*/
|
||||
IContextNetwork(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~IContextNetwork() {}
|
||||
|
||||
//! \brief Using local objects?
|
||||
virtual bool usingLocalObjects() const { return false; }
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface; /*!< DBus interface */
|
||||
|
||||
//! \brief Relay connection signals to local signals.
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
IContextNetwork(QObject *parent = nullptr) : QObject(parent), m_dBusInterface(0) {}
|
||||
|
||||
/*!
|
||||
* \brief Helper for logging, likely to be removed / changed
|
||||
* \param method
|
||||
* \param m1
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m4
|
||||
*/
|
||||
void log(const QString &method, const QString &m1 = "", const QString &m2 = "", const QString &m3 = "", const QString &m4 = "") const;
|
||||
|
||||
signals:
|
||||
|
||||
//! \brief Send status message
|
||||
void statusMessage(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! \brief Send status messages
|
||||
void statusMessages(const BlackMisc::CStatusMessageList &messages);
|
||||
|
||||
//! \brief ATC station (online) list has been changed
|
||||
void changedAtcStationsOnline();
|
||||
|
||||
//! \brief ATC station (booked) list has been changed
|
||||
void changedAtcStationsBooked();
|
||||
|
||||
//! \brief Aircraft list has been changed
|
||||
void changedAircraftsInRange();
|
||||
|
||||
//! \brief Terminated connection
|
||||
void connectionTerminated();
|
||||
|
||||
/*!
|
||||
* \brief Connection status changed
|
||||
* \param from old status
|
||||
* \param to new status
|
||||
* \remarks If I use the enum, adaptor / interface are not created correctly
|
||||
* \see INetwork::ConnectionStatus
|
||||
*/
|
||||
void connectionStatusChanged(uint from, uint to);
|
||||
|
||||
//! \brief Text messages (also private chat messages)
|
||||
void textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages);
|
||||
|
||||
public slots:
|
||||
|
||||
/*!
|
||||
* \brief Reload bookings from booking service
|
||||
*/
|
||||
virtual void readAtcBookingsFromSource();
|
||||
|
||||
/*!
|
||||
* \brief The ATC list with online ATC controllers
|
||||
* \remarks If I make this &getAtcStations XML is not generated correctly
|
||||
*/
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const;
|
||||
|
||||
//! \brief ATC list, with booked controllers
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const;
|
||||
|
||||
//! \brief Aircraft list
|
||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const;
|
||||
|
||||
//! \brief Get all users
|
||||
virtual BlackMisc::Network::CUserList getUsers() const;
|
||||
|
||||
//! \brief Users for given callsigns, e.g. for voice room resolution
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const;
|
||||
|
||||
//! \brief Get own aircraft
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const;
|
||||
|
||||
/*!
|
||||
* \brief Connect to Network
|
||||
* \return messages gererated during connecting
|
||||
* \see INetwork::LoginMode
|
||||
*/
|
||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint loginMode);
|
||||
|
||||
/*!
|
||||
* \brief Disconnect from network
|
||||
* \return messages generated during disconnecting
|
||||
*/
|
||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork();
|
||||
|
||||
//! \brief Network connected?
|
||||
virtual bool isConnected() const;
|
||||
|
||||
/*!
|
||||
* Set own aircraft
|
||||
* \param aircraft
|
||||
* \return message list, as aircraft can only be set prior connecting
|
||||
*/
|
||||
virtual BlackMisc::CStatusMessageList setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft);
|
||||
|
||||
//! \brief Own position, be aware height is terrain height
|
||||
virtual void updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude);
|
||||
|
||||
//! \brief Complete situation update
|
||||
virtual void updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! \brief Update own cockpit
|
||||
virtual void updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder);
|
||||
|
||||
//! \brief Text messages (radio and private chat messages)
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages);
|
||||
|
||||
/*!
|
||||
* \brief Get METAR, if not available request it
|
||||
* \param airportIcaoCode such as EDDF, KLAX
|
||||
* \return
|
||||
*/
|
||||
virtual BlackMisc::Aviation::CInformationMessage getMetar(const QString &airportIcaoCode);
|
||||
|
||||
//! \brief Use the selected COM1/2 frequencies, and get the corresponding voice room for it
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getSelectedVoiceRooms() const;
|
||||
|
||||
//! \brief Use the selected COM1/2 frequencies, and get the corresponding ATC stations for it
|
||||
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const;
|
||||
|
||||
//! \brief Request data updates (pilot's frequencies, ATIS, ..)
|
||||
virtual void requestDataUpdates();
|
||||
|
||||
//! \brief Request ATIS updates (for all stations)
|
||||
virtual void requestAtisUpdates();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -3,7 +3,7 @@
|
||||
* 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_network_interface.h"
|
||||
#include "blackcore/context_network_proxy.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
#include <QObject>
|
||||
#include <QMetaEnum>
|
||||
@@ -15,10 +15,10 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
IContextNetwork::IContextNetwork(const QString &serviceName, QDBusConnection &connection, QObject *parent) : QObject(parent), m_dBusInterface(0)
|
||||
CContextNetworkProxy::CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextNetwork(parent), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
serviceName , IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
connection, this);
|
||||
this->relaySignals(serviceName, connection);
|
||||
}
|
||||
@@ -26,28 +26,28 @@ namespace BlackCore
|
||||
/*
|
||||
* Workaround for signals, not working without, but why?
|
||||
*/
|
||||
void IContextNetwork::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
void CContextNetworkProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||
{
|
||||
connection.connect(serviceName, IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"connectionStatusChanged", this, SIGNAL(connectionStatusChanged(uint, uint)));
|
||||
connection.connect(serviceName, IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"changedAtcStationsBooked", this, SIGNAL(changedAtcStationsBooked()));
|
||||
connection.connect(serviceName, IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"changedAtcStationsOnline", this, SIGNAL(changedAtcStationsOnline()));
|
||||
connection.connect(serviceName, IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"connectionTerminated", this, SIGNAL(connectionTerminated()));
|
||||
connection.connect(serviceName, IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"statusMessage", this, SIGNAL(statusMessage(BlackMisc::CStatusMessage)));
|
||||
connection.connect(serviceName, IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList)));
|
||||
connection.connect(serviceName, IContextNetwork::ServicePath(), IContextNetwork::InterfaceName(),
|
||||
connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
"textMessagesReceived", this, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Logging
|
||||
*/
|
||||
void IContextNetwork::log(const QString &method, const QString &m1, const QString &m2, const QString &m3, const QString &m4) const
|
||||
void CContextNetworkProxy::log(const QString &method, const QString &m1, const QString &m2, const QString &m3, const QString &m4) const
|
||||
{
|
||||
if (m1.isEmpty())
|
||||
qDebug() << " LOG: " << method;
|
||||
@@ -61,102 +61,102 @@ namespace BlackCore
|
||||
qDebug() << " LOG: " << method << m1 << m2 << m3 << m4;
|
||||
}
|
||||
|
||||
void IContextNetwork::readAtcBookingsFromSource()
|
||||
void CContextNetworkProxy::readAtcBookingsFromSource() const
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("readAtcBookingsFromSource"));
|
||||
}
|
||||
|
||||
const BlackMisc::Aviation::CAtcStationList IContextNetwork::getAtcStationsOnline() const
|
||||
const BlackMisc::Aviation::CAtcStationList CContextNetworkProxy::getAtcStationsOnline() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAtcStationList>(QLatin1Literal("getAtcStationsOnline"));
|
||||
}
|
||||
|
||||
const BlackMisc::Aviation::CAtcStationList IContextNetwork::getAtcStationsBooked() const
|
||||
const BlackMisc::Aviation::CAtcStationList CContextNetworkProxy::getAtcStationsBooked() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAtcStationList>(QLatin1Literal("getAtcStationsBooked"));
|
||||
}
|
||||
|
||||
const BlackMisc::Aviation::CAircraftList IContextNetwork::getAircraftsInRange() const
|
||||
const BlackMisc::Aviation::CAircraftList CContextNetworkProxy::getAircraftsInRange() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraftList>(QLatin1Literal("getAircraftsInRange"));
|
||||
}
|
||||
|
||||
BlackMisc::Network::CUserList IContextNetwork::getUsers() const
|
||||
BlackMisc::Network::CUserList CContextNetworkProxy::getUsers() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CUserList>(QLatin1Literal("getUsers"));
|
||||
}
|
||||
|
||||
BlackMisc::Network::CUserList IContextNetwork::getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const
|
||||
BlackMisc::Network::CUserList CContextNetworkProxy::getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CUserList>(QLatin1Literal("getUsersForCallsigns"), callsigns);
|
||||
}
|
||||
|
||||
BlackMisc::Audio::CVoiceRoomList IContextNetwork::getSelectedVoiceRooms() const
|
||||
BlackMisc::Audio::CVoiceRoomList CContextNetworkProxy::getSelectedVoiceRooms() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Audio::CVoiceRoomList>(QLatin1Literal("getSelectedVoiceRooms"));
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CAtcStationList IContextNetwork::getSelectedAtcStations() const
|
||||
BlackMisc::Aviation::CAtcStationList CContextNetworkProxy::getSelectedAtcStations() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAtcStationList>(QLatin1Literal("getSelectedAtcStations"));
|
||||
}
|
||||
|
||||
void IContextNetwork::requestDataUpdates()
|
||||
void CContextNetworkProxy::requestDataUpdates()
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("requestDataUpdates"));
|
||||
}
|
||||
|
||||
void IContextNetwork::requestAtisUpdates()
|
||||
void CContextNetworkProxy::requestAtisUpdates()
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("requestAtisUpdates"));
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CAircraft IContextNetwork::getOwnAircraft() const
|
||||
BlackMisc::Aviation::CAircraft CContextNetworkProxy::getOwnAircraft() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraft>(QLatin1Literal("getOwnAircraft"));
|
||||
}
|
||||
|
||||
BlackMisc::CStatusMessageList IContextNetwork::connectToNetwork(uint loginMode)
|
||||
BlackMisc::CStatusMessageList CContextNetworkProxy::connectToNetwork(uint loginMode)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("connectToNetwork"), loginMode);
|
||||
}
|
||||
|
||||
BlackMisc::CStatusMessageList IContextNetwork::disconnectFromNetwork()
|
||||
BlackMisc::CStatusMessageList CContextNetworkProxy::disconnectFromNetwork()
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("disconnectFromNetwork"));
|
||||
}
|
||||
|
||||
bool IContextNetwork::isConnected() const
|
||||
bool CContextNetworkProxy::isConnected() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isConnected"));
|
||||
}
|
||||
|
||||
BlackMisc::CStatusMessageList IContextNetwork::setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft)
|
||||
BlackMisc::CStatusMessageList CContextNetworkProxy::setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("setOwnAircraft"), aircraft);
|
||||
}
|
||||
|
||||
void IContextNetwork::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude)
|
||||
void CContextNetworkProxy::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("updateOwnPosition"), position, altitude);
|
||||
}
|
||||
|
||||
void IContextNetwork::updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation)
|
||||
void CContextNetworkProxy::updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("updateOwnSituation"), situation);
|
||||
}
|
||||
|
||||
void IContextNetwork::updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder)
|
||||
void CContextNetworkProxy::updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("updateOwnCockpit"), com1, com2, transponder);
|
||||
}
|
||||
|
||||
void IContextNetwork::sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages)
|
||||
void CContextNetworkProxy::sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("sendTextMessages"), textMessages);
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CInformationMessage IContextNetwork::getMetar(const QString &airportIcaoCode)
|
||||
BlackMisc::Aviation::CInformationMessage CContextNetworkProxy::getMetar(const QString &airportIcaoCode)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CInformationMessage>(QLatin1Literal("getMetar"), airportIcaoCode);
|
||||
}
|
||||
134
src/blackcore/context_network_proxy.h
Normal file
134
src/blackcore/context_network_proxy.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/* 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_CONTEXTNETWORK_PROXY_H
|
||||
#define BLACKCORE_CONTEXTNETWORK_PROXY_H
|
||||
|
||||
#include "context_network.h"
|
||||
#include "network_vatlib.h"
|
||||
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/nwtextmessagelist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
//! \brief Network context proxy
|
||||
class CContextNetworkProxy : public IContextNetwork
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief DBus version constructor
|
||||
* \param serviceName
|
||||
* \param connection
|
||||
* \param parent
|
||||
*/
|
||||
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CContextNetworkProxy() {}
|
||||
|
||||
//! \copydoc IContextNetwork::usingLocalObjects()
|
||||
virtual bool usingLocalObjects() const override { return false; }
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface; /*!< DBus interface */
|
||||
|
||||
//! \brief Relay connection signals to local signals.
|
||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
CContextNetworkProxy(QObject *parent = nullptr) : IContextNetwork(parent), m_dBusInterface(nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Helper for logging, likely to be removed / changed
|
||||
* \param method
|
||||
* \param m1
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m4
|
||||
*/
|
||||
void log(const QString &method, const QString &m1 = "", const QString &m2 = "", const QString &m3 = "", const QString &m4 = "") const;
|
||||
|
||||
public slots: // IContextNetwork overrides
|
||||
|
||||
//! \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
|
||||
*/
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override;
|
||||
|
||||
/*!
|
||||
* \copydoc IContextNetwork::getAtcStationsBooked()
|
||||
* \todo If I make this &getAtcStations XML is not generated correctly
|
||||
*/
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftsInRange()
|
||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::connectToNetwork()
|
||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint mode) override;
|
||||
|
||||
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork() override;
|
||||
|
||||
//! \copydoc IContextNetwork::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::setOwnAircraft()
|
||||
virtual BlackMisc::CStatusMessageList setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnPosition()
|
||||
virtual void updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnSituation()
|
||||
virtual void updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||
|
||||
//! \copydoc IContextNetwork::updateOwnCockpit()
|
||||
virtual void updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::sendTextMessages()
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getMetar()
|
||||
virtual BlackMisc::Aviation::CInformationMessage getMetar(const QString &airportIcaoCode) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedVoiceRooms()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getSelectedVoiceRooms() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedAtcStations
|
||||
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getUsers()
|
||||
virtual BlackMisc::Network::CUserList getUsers() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getUsersForCallsigns
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const override;
|
||||
|
||||
//! \copydoc IContextNetwork::requestDataUpdates
|
||||
virtual void requestDataUpdates()override;
|
||||
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates() override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -3,7 +3,7 @@
|
||||
* 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 "context_network.h"
|
||||
#include "context_network_impl.h"
|
||||
#include "coreruntime.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_IMPL_H
|
||||
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/context_network_interface.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/simulator.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/nwserver.h"
|
||||
#include "blackcore/context_application_impl.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_network_impl.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/context_audio_impl.h"
|
||||
#include "blackcore/context_simulator_impl.h"
|
||||
|
||||
Reference in New Issue
Block a user