mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #288, added FSD servers to context
* new logging in empty context * formatting
This commit is contained in:
committed by
Roland Winklmeier
parent
a401ce439d
commit
c39b72b12f
@@ -12,14 +12,13 @@
|
||||
|
||||
#include "blackcore/context_runtime_config.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
/*!
|
||||
* \brief Base for all context classes
|
||||
*/
|
||||
//! Base for all context classes
|
||||
class CContext : public QObject
|
||||
{
|
||||
public:
|
||||
@@ -129,6 +128,12 @@ namespace BlackCore
|
||||
return QString(path) + ":" + QString::number(this->getUniqueId());
|
||||
}
|
||||
|
||||
//! Empty context called
|
||||
void logEmptyContextWarning(const QString &functionName) const
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).warning("Empty context called, details: %1") << functionName;
|
||||
}
|
||||
|
||||
//! Standard message when status message is returned in empty context
|
||||
static const BlackMisc::CStatusMessage &statusMessageEmptyContext();
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackCore
|
||||
return new BlackCore::CContextNetworkProxy(BlackCore::CDBusServer::ServiceName, conn, mode, runtime);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
default:
|
||||
return new BlackCore::CContextNetworkEmpty(true, runtime);
|
||||
return new BlackCore::CContextNetworkEmpty(runtime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,9 +137,15 @@ namespace BlackCore
|
||||
//! Information about other clients
|
||||
virtual BlackMisc::Network::CClientList getOtherClients() const = 0;
|
||||
|
||||
//! Clients for given callsign, e.g. to test direct model
|
||||
//! Clients for given callsign, e.g. to test/fetch direct aircraft model
|
||||
virtual BlackMisc::Network::CClientList getOtherClientsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const = 0;
|
||||
|
||||
//! Known voice servers, available when data file was first read
|
||||
virtual BlackMisc::Network::CServerList getVatsimVoiceServers() const = 0;
|
||||
|
||||
//! Known FSD servers, available when data file was first read
|
||||
virtual BlackMisc::Network::CServerList getVatsimFsdServers() const = 0;
|
||||
|
||||
/*!
|
||||
* Connect to Network
|
||||
* \return messages gererated during connecting
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKCORE_CONTEXTNETWORK_EMPTY_H
|
||||
|
||||
#include "context_network.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace BlackCore
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CContextNetworkEmpty(bool log, CRuntime *runtime) : IContextNetwork(CRuntimeConfig::NotUsed, runtime), m_log(log) {}
|
||||
CContextNetworkEmpty(CRuntime *runtime) : IContextNetwork(CRuntimeConfig::NotUsed, runtime) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~CContextNetworkEmpty() {}
|
||||
@@ -35,155 +36,174 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||
virtual void readAtcBookingsFromSource() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CAtcStationList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAtcStationsBooked()
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CAtcStationList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftsInRange()
|
||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CAircraftList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::connectToNetwork()
|
||||
virtual BlackMisc::CStatusMessage connectToNetwork(uint mode) override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << mode; }
|
||||
Q_UNUSED(mode);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return statusMessageEmptyContext();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
||||
virtual BlackMisc::CStatusMessage disconnectFromNetwork() override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return statusMessageEmptyContext();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::isConnected()
|
||||
virtual bool isConnected() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::sendTextMessages()
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << textMessages; }
|
||||
Q_UNUSED(textMessages);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::sendFlightPlan()
|
||||
virtual void sendFlightPlan(const BlackMisc::Aviation::CFlightPlan &flightPlan) override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << flightPlan; }
|
||||
Q_UNUSED(flightPlan);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::loadFlightPlanFromNetwork()
|
||||
virtual BlackMisc::Aviation::CFlightPlan loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << callsign; }
|
||||
Q_UNUSED(callsign);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CFlightPlan();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getMetar
|
||||
virtual BlackMisc::Aviation::CInformationMessage getMetar(const BlackMisc::Aviation::CAirportIcao &airportIcaoCode) override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << airportIcaoCode; }
|
||||
Q_UNUSED(airportIcaoCode);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CInformationMessage();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedVoiceRooms()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getSelectedVoiceRooms() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Audio::CVoiceRoomList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getSelectedAtcStations
|
||||
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CAtcStationList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getUsers()
|
||||
virtual BlackMisc::Network::CUserList getUsers() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CUserList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getUsersForCallsigns
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << callsigns; }
|
||||
Q_UNUSED(callsigns);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CUserList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getUserForCallsign
|
||||
virtual BlackMisc::Network::CUser getUserForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << callsign; }
|
||||
Q_UNUSED(callsign);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CUser();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getOtherClients
|
||||
virtual BlackMisc::Network::CClientList getOtherClients() const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CClientList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getOtherClientForCallsigns
|
||||
virtual BlackMisc::Network::CClientList getOtherClientsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << callsigns; }
|
||||
Q_UNUSED(callsigns);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CClientList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::requestDataUpdates
|
||||
virtual void requestDataUpdates()override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates() override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO ; }
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::testCreateDummyOnlineAtcStations
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << number; }
|
||||
Q_UNUSED(number);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine) override
|
||||
{
|
||||
if (m_log) { qDebug() << Q_FUNC_INFO << commandLine; }
|
||||
Q_UNUSED(commandLine);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getVatsimVoiceServers
|
||||
virtual BlackMisc::Network::CServerList getVatsimVoiceServers() const
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CServerList();
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_log = true;
|
||||
|
||||
//! \copydoc IContextNetwork::getVatsimFsdServers
|
||||
virtual BlackMisc::Network::CServerList getVatsimFsdServers() const
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CServerList();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ namespace BlackCore
|
||||
* Init this context
|
||||
*/
|
||||
CContextNetwork::CContextNetwork(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
IContextNetwork(mode, runtime), m_airspace(nullptr), m_network(nullptr), m_currentStatus(INetwork::Disconnected),
|
||||
m_vatsimBookingReader(nullptr), m_vatsimDataFileReader(nullptr), m_dataUpdateTimer(nullptr)
|
||||
IContextNetwork(mode, runtime)
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getIContextSettings());
|
||||
@@ -259,13 +258,33 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
/*
|
||||
* Other clients
|
||||
* Other clients for callsign
|
||||
*/
|
||||
CClientList CContextNetwork::getOtherClientsForCallsigns(const CCallsignList &callsigns) const
|
||||
{
|
||||
return this->m_airspace->getOtherClientsForCallsigns(callsigns);
|
||||
}
|
||||
|
||||
/*
|
||||
* VATSIM FSD servers
|
||||
*/
|
||||
CServerList CContextNetwork::getVatsimFsdServers() const
|
||||
{
|
||||
Q_ASSERT(this->m_vatsimDataFileReader);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
return this->m_vatsimDataFileReader->getFsdServers();
|
||||
}
|
||||
|
||||
/*
|
||||
* VATSIM Voice servers
|
||||
*/
|
||||
CServerList CContextNetwork::getVatsimVoiceServers() const
|
||||
{
|
||||
Q_ASSERT(this->m_vatsimDataFileReader);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
return this->m_vatsimDataFileReader->getVoiceServers();
|
||||
}
|
||||
|
||||
/*
|
||||
* Connection status changed
|
||||
*/
|
||||
|
||||
@@ -126,6 +126,12 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::getOtherClientForCallsigns
|
||||
virtual BlackMisc::Network::CClientList getOtherClientsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getVatsimFsdServers
|
||||
virtual BlackMisc::Network::CServerList getVatsimFsdServers() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getVatsimVoiceServers
|
||||
virtual BlackMisc::Network::CServerList getVatsimVoiceServers() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::requestDataUpdates
|
||||
virtual void requestDataUpdates()override;
|
||||
|
||||
@@ -151,18 +157,18 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
private:
|
||||
CAirspaceMonitor *m_airspace;
|
||||
BlackCore::INetwork *m_network;
|
||||
INetwork::ConnectionStatus m_currentStatus; //!< used to detect pending connections
|
||||
CAirspaceMonitor *m_airspace = nullptr;
|
||||
BlackCore::INetwork *m_network = nullptr;
|
||||
INetwork::ConnectionStatus m_currentStatus = INetwork::Disconnected; //!< used to detect pending connections
|
||||
|
||||
BlackMisc::CDigestSignal m_dsAtcStationsBookedChanged { this, &IContextNetwork::changedAtcStationsBooked, &IContextNetwork::changedAtcStationsBookedDigest, 750, 2 };
|
||||
BlackMisc::CDigestSignal m_dsAtcStationsOnlineChanged { this, &IContextNetwork::changedAtcStationsOnline, &IContextNetwork::changedAtcStationsOnlineDigest, 750, 4 };
|
||||
BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &IContextNetwork::changedAircraftsInRange, &IContextNetwork::changedAircraftsInRangeDigest, 750, 4 };
|
||||
BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &IContextNetwork::changedAircraftsInRange, &IContextNetwork::changedAircraftsInRangeDigest, 750, 4 };
|
||||
|
||||
// for reading XML and VATSIM data files
|
||||
CVatsimBookingReader *m_vatsimBookingReader;
|
||||
CVatsimDataFileReader *m_vatsimDataFileReader;
|
||||
QTimer *m_dataUpdateTimer; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
|
||||
CVatsimBookingReader *m_vatsimBookingReader = nullptr;
|
||||
CVatsimDataFileReader *m_vatsimDataFileReader = nullptr;
|
||||
QTimer *m_dataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
|
||||
|
||||
//! Get network settings
|
||||
BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const
|
||||
|
||||
@@ -101,6 +101,16 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CClientList>(QLatin1Literal("getOtherClients"));
|
||||
}
|
||||
|
||||
BlackMisc::Network::CServerList CContextNetworkProxy::getVatsimFsdServers() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CServerList>(QLatin1Literal("getVatsimFsdServers"));
|
||||
}
|
||||
|
||||
BlackMisc::Network::CServerList CContextNetworkProxy::getVatsimVoiceServers() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CServerList>(QLatin1Literal("getVatsimVoiceServers"));
|
||||
}
|
||||
|
||||
BlackMisc::Network::CClientList CContextNetworkProxy::getOtherClientsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CClientList>(QLatin1Literal("getOtherClientsForCallsigns"), callsigns);
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/* 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/. */
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTNETWORK_PROXY_H
|
||||
#define BLACKCORE_CONTEXTNETWORK_PROXY_H
|
||||
@@ -101,6 +107,12 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::getOtherClients
|
||||
virtual BlackMisc::Network::CClientList getOtherClients() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getVatsimVoiceServers
|
||||
virtual BlackMisc::Network::CServerList getVatsimVoiceServers() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getVatsimFsdServers
|
||||
virtual BlackMisc::Network::CServerList getVatsimFsdServers() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getOtherClientForCallsigns
|
||||
virtual BlackMisc::Network::CClientList getOtherClientsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user