mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T272, skip VATSIM readers if (for sure) connected to an other eco system
Remark: This requires the server (=> ecosystem) to be connected, otherwise VATSIM data (before that connection) are still read as default
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
#include <QPointer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -43,41 +44,47 @@ namespace BlackCore
|
|||||||
namespace Vatsim
|
namespace Vatsim
|
||||||
{
|
{
|
||||||
CVatsimBookingReader::CVatsimBookingReader(QObject *owner) :
|
CVatsimBookingReader::CVatsimBookingReader(QObject *owner) :
|
||||||
CThreadedReader(owner, "CVatsimBookingReader")
|
CThreadedReader(owner, "CVatsimBookingReader"),
|
||||||
|
CEcosystemAware(CEcosystemAware::providerIfPossible(owner))
|
||||||
{
|
{
|
||||||
settingsChanged();
|
settingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimBookingReader::readInBackgroundThread()
|
void CVatsimBookingReader::readInBackgroundThread()
|
||||||
{
|
{
|
||||||
bool s = QMetaObject::invokeMethod(this, "ps_read");
|
QPointer<CVatsimBookingReader> myself(this);
|
||||||
Q_ASSERT(s);
|
QTimer::singleShot(0, this, [ = ]
|
||||||
Q_UNUSED(s);
|
{
|
||||||
|
if (!myself) { return; }
|
||||||
|
myself->read();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimBookingReader::doWorkImpl()
|
void CVatsimBookingReader::doWorkImpl()
|
||||||
{
|
{
|
||||||
ps_read();
|
this->read();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimBookingReader::ps_read()
|
void CVatsimBookingReader::read()
|
||||||
{
|
{
|
||||||
this->threadAssertCheck();
|
this->threadAssertCheck();
|
||||||
if (!this->doWorkCheck()) { return; }
|
if (!this->doWorkCheck()) { return; }
|
||||||
if (!this->isInternetAccessible("No network/internet access, cannot read VATSIM bookings")) { return; }
|
if (!this->isInternetAccessible("No network/internet access, cannot read VATSIM bookings")) { return; }
|
||||||
|
if (this->isNotVATSIMEcosystem()) { return; }
|
||||||
|
|
||||||
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application");
|
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application");
|
||||||
const QUrl url(sApp->getGlobalSetup().getVatsimBookingsUrl());
|
const QUrl url(sApp->getGlobalSetup().getVatsimBookingsUrl());
|
||||||
if (url.isEmpty()) { return; }
|
if (url.isEmpty()) { return; }
|
||||||
this->getFromNetworkAndLog(url, { this, &CVatsimBookingReader::ps_parseBookings});
|
this->getFromNetworkAndLog(url, { this, &CVatsimBookingReader::parseBookings});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimBookingReader::ps_parseBookings(QNetworkReply *nwReplyPtr)
|
void CVatsimBookingReader::parseBookings(QNetworkReply *nwReplyPtr)
|
||||||
{
|
{
|
||||||
// wrap pointer, make sure any exit cleans up reply
|
// wrap pointer, make sure any exit cleans up reply
|
||||||
// required to use delete later as object is created in a different thread
|
// required to use delete later as object is created in a different thread
|
||||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||||
this->threadAssertCheck();
|
this->threadAssertCheck();
|
||||||
|
if (this->isNotVATSIMEcosystem()) { return; }
|
||||||
|
|
||||||
// Worker thread, make sure to write no members here od do it threadsafe
|
// Worker thread, make sure to write no members here od do it threadsafe
|
||||||
if (!this->doWorkCheck())
|
if (!this->doWorkCheck())
|
||||||
@@ -119,8 +126,8 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomNode atc = doc.elementsByTagName("atcs").at(0);
|
const QDomNode atc = doc.elementsByTagName("atcs").at(0);
|
||||||
QDomNodeList bookingNodes = atc.toElement().elementsByTagName("booking");
|
const QDomNodeList bookingNodes = atc.toElement().elementsByTagName("booking");
|
||||||
int size = bookingNodes.size();
|
int size = bookingNodes.size();
|
||||||
CAtcStationList bookedStations;
|
CAtcStationList bookedStations;
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
@@ -132,8 +139,8 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pase nodes
|
// pase nodes
|
||||||
QDomNode bookingNode = bookingNodes.at(i);
|
const QDomNode bookingNode = bookingNodes.at(i);
|
||||||
QDomNodeList bookingNodeValues = bookingNode.childNodes();
|
const QDomNodeList bookingNodeValues = bookingNode.childNodes();
|
||||||
CAtcStation bookedStation;
|
CAtcStation bookedStation;
|
||||||
CUser user;
|
CUser user;
|
||||||
for (int v = 0; v < bookingNodeValues.size(); v++)
|
for (int v = 0; v < bookingNodeValues.size(); v++)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "blackcore/blackcoreexport.h"
|
#include "blackcore/blackcoreexport.h"
|
||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
|
#include "blackmisc/network/ecosystemprovider.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/entityflags.h"
|
||||||
#include "blackcore/threadedreader.h"
|
#include "blackcore/threadedreader.h"
|
||||||
|
|
||||||
@@ -26,7 +27,9 @@ namespace BlackCore
|
|||||||
namespace Vatsim
|
namespace Vatsim
|
||||||
{
|
{
|
||||||
//! Read bookings from VATSIM
|
//! Read bookings from VATSIM
|
||||||
class BLACKCORE_EXPORT CVatsimBookingReader : public BlackCore::CThreadedReader
|
class BLACKCORE_EXPORT CVatsimBookingReader :
|
||||||
|
public BlackCore::CThreadedReader,
|
||||||
|
public BlackMisc::Network::CEcosystemAware
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -53,15 +56,14 @@ namespace BlackCore
|
|||||||
virtual void doWorkImpl() override;
|
virtual void doWorkImpl() override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
//! Bookings have been read
|
//! Bookings have been read
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
void ps_parseBookings(QNetworkReply *nwReply);
|
void parseBookings(QNetworkReply *nwReply);
|
||||||
|
|
||||||
//! Do reading
|
//! Do reading
|
||||||
void ps_read();
|
void read();
|
||||||
|
|
||||||
private:
|
|
||||||
//! Settings changed
|
//! Settings changed
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <QWriteLocker>
|
#include <QWriteLocker>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
@@ -57,7 +58,8 @@ namespace BlackCore
|
|||||||
namespace Vatsim
|
namespace Vatsim
|
||||||
{
|
{
|
||||||
CVatsimDataFileReader::CVatsimDataFileReader(QObject *owner) :
|
CVatsimDataFileReader::CVatsimDataFileReader(QObject *owner) :
|
||||||
CThreadedReader(owner, "CVatsimDataFileReader")
|
CThreadedReader(owner, "CVatsimDataFileReader"),
|
||||||
|
CEcosystemAware(CEcosystemAware::providerIfPossible(owner))
|
||||||
{
|
{
|
||||||
this->reloadSettings();
|
this->reloadSettings();
|
||||||
}
|
}
|
||||||
@@ -168,21 +170,25 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CVatsimDataFileReader::readInBackgroundThread()
|
void CVatsimDataFileReader::readInBackgroundThread()
|
||||||
{
|
{
|
||||||
const bool s = QMetaObject::invokeMethod(this, "ps_read");
|
QPointer<CVatsimDataFileReader> myself(this);
|
||||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Invoke failed");
|
QTimer::singleShot(0, this, [ = ]
|
||||||
Q_UNUSED(s);
|
{
|
||||||
|
if (!myself) { return; }
|
||||||
|
myself->read();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimDataFileReader::doWorkImpl()
|
void CVatsimDataFileReader::doWorkImpl()
|
||||||
{
|
{
|
||||||
this->ps_read();
|
this->read();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimDataFileReader::ps_read()
|
void CVatsimDataFileReader::read()
|
||||||
{
|
{
|
||||||
this->threadAssertCheck();
|
this->threadAssertCheck();
|
||||||
if (!this->doWorkCheck()) { return; }
|
if (!this->doWorkCheck()) { return; }
|
||||||
if (!this->isInternetAccessible("No network/internet access, cannot read VATSIM data file")) { return; }
|
if (!this->isInternetAccessible("No network/internet access, cannot read VATSIM data file")) { return; }
|
||||||
|
if (this->isNotVATSIMEcosystem()) { return; }
|
||||||
|
|
||||||
// round robin for load balancing
|
// round robin for load balancing
|
||||||
// remark: Don't use QThread to run network operations in the background
|
// remark: Don't use QThread to run network operations in the background
|
||||||
@@ -191,15 +197,16 @@ namespace BlackCore
|
|||||||
CFailoverUrlList urls(sApp->getVatsimDataFileUrls());
|
CFailoverUrlList urls(sApp->getVatsimDataFileUrls());
|
||||||
const QUrl url(urls.obtainNextWorkingUrl(true));
|
const QUrl url(urls.obtainNextWorkingUrl(true));
|
||||||
if (url.isEmpty()) { return; }
|
if (url.isEmpty()) { return; }
|
||||||
this->getFromNetworkAndLog(url, { this, &CVatsimDataFileReader::ps_parseVatsimFile});
|
this->getFromNetworkAndLog(url, { this, &CVatsimDataFileReader::parseVatsimFile});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimDataFileReader::ps_parseVatsimFile(QNetworkReply *nwReplyPtr)
|
void CVatsimDataFileReader::parseVatsimFile(QNetworkReply *nwReplyPtr)
|
||||||
{
|
{
|
||||||
// wrap pointer, make sure any exit cleans up reply
|
// wrap pointer, make sure any exit cleans up reply
|
||||||
// required to use delete later as object is created in a different thread
|
// required to use delete later as object is created in a different thread
|
||||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||||
this->threadAssertCheck();
|
this->threadAssertCheck();
|
||||||
|
if (this->isNotVATSIMEcosystem()) { return; }
|
||||||
|
|
||||||
// Worker thread, make sure to write only synced here!
|
// Worker thread, make sure to write only synced here!
|
||||||
if (!this->doWorkCheck())
|
if (!this->doWorkCheck())
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "blackmisc/aviation/callsignset.h"
|
#include "blackmisc/aviation/callsignset.h"
|
||||||
#include "blackmisc/aviation/flightplan.h"
|
#include "blackmisc/aviation/flightplan.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/entityflags.h"
|
||||||
|
#include "blackmisc/network/ecosystemprovider.h"
|
||||||
#include "blackmisc/network/serverlist.h"
|
#include "blackmisc/network/serverlist.h"
|
||||||
#include "blackmisc/network/userlist.h"
|
#include "blackmisc/network/userlist.h"
|
||||||
#include "blackmisc/network/voicecapabilities.h"
|
#include "blackmisc/network/voicecapabilities.h"
|
||||||
@@ -41,7 +42,9 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
//! Read vatsim data file
|
//! Read vatsim data file
|
||||||
//! \sa http://info.vroute.net/vatsim-data.txt
|
//! \sa http://info.vroute.net/vatsim-data.txt
|
||||||
class BLACKCORE_EXPORT CVatsimDataFileReader : public CThreadedReader
|
class BLACKCORE_EXPORT CVatsimDataFileReader :
|
||||||
|
public CThreadedReader,
|
||||||
|
public BlackMisc::Network::CEcosystemAware
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -133,13 +136,6 @@ namespace BlackCore
|
|||||||
virtual void doWorkImpl() override;
|
virtual void doWorkImpl() override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private slots:
|
|
||||||
//! Data have been read, parse VATSIM file
|
|
||||||
void ps_parseVatsimFile(QNetworkReply *nwReply);
|
|
||||||
|
|
||||||
//! Read / re-read data file
|
|
||||||
void ps_read();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Section in file
|
//! Section in file
|
||||||
enum Section
|
enum Section
|
||||||
@@ -157,6 +153,12 @@ namespace BlackCore
|
|||||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimDataFile> m_settings { this, &CVatsimDataFileReader::reloadSettings };
|
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimDataFile> m_settings { this, &CVatsimDataFileReader::reloadSettings };
|
||||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlanRemarks> m_flightPlanRemarks; //!< cache for flight plan remarks
|
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlanRemarks> m_flightPlanRemarks; //!< cache for flight plan remarks
|
||||||
|
|
||||||
|
//! Data have been read, parse VATSIM file
|
||||||
|
void parseVatsimFile(QNetworkReply *nwReply);
|
||||||
|
|
||||||
|
//! Read / re-read data file
|
||||||
|
void read();
|
||||||
|
|
||||||
//! Reload the reader settings
|
//! Reload the reader settings
|
||||||
void reloadSettings();
|
void reloadSettings();
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ namespace BlackCore
|
|||||||
namespace Vatsim
|
namespace Vatsim
|
||||||
{
|
{
|
||||||
CVatsimMetarReader::CVatsimMetarReader(QObject *owner) :
|
CVatsimMetarReader::CVatsimMetarReader(QObject *owner) :
|
||||||
CThreadedReader(owner, "CVatsimMetarReader")
|
CThreadedReader(owner, "CVatsimMetarReader"),
|
||||||
|
CEcosystemAware(CEcosystemAware::providerIfPossible(owner))
|
||||||
{
|
{
|
||||||
reloadSettings();
|
reloadSettings();
|
||||||
}
|
}
|
||||||
@@ -77,6 +78,7 @@ namespace BlackCore
|
|||||||
this->threadAssertCheck();
|
this->threadAssertCheck();
|
||||||
if (!this->doWorkCheck()) { return; }
|
if (!this->doWorkCheck()) { return; }
|
||||||
if (!this->isInternetAccessible("No network/internet access, cannot read METARs")) { return; }
|
if (!this->isInternetAccessible("No network/internet access, cannot read METARs")) { return; }
|
||||||
|
if (this->isNotVATSIMEcosystem()) { return; }
|
||||||
|
|
||||||
CFailoverUrlList urls(sApp->getVatsimMetarUrls());
|
CFailoverUrlList urls(sApp->getVatsimMetarUrls());
|
||||||
const CUrl url(urls.obtainNextWorkingUrl(true));
|
const CUrl url(urls.obtainNextWorkingUrl(true));
|
||||||
@@ -93,6 +95,8 @@ namespace BlackCore
|
|||||||
|
|
||||||
// Worker thread, make sure to write thread safe!
|
// Worker thread, make sure to write thread safe!
|
||||||
this->threadAssertCheck();
|
this->threadAssertCheck();
|
||||||
|
if (this->isNotVATSIMEcosystem()) { return; }
|
||||||
|
|
||||||
if (!this->doWorkCheck())
|
if (!this->doWorkCheck())
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Terminated METAR decoding process"); // for users
|
CLogMessage(this).info("Terminated METAR decoding process"); // for users
|
||||||
|
|||||||
@@ -13,12 +13,13 @@
|
|||||||
#define BLACKCORE_VATSIM_VATSIMMETARREADER_H
|
#define BLACKCORE_VATSIM_VATSIMMETARREADER_H
|
||||||
|
|
||||||
#include "blackcore/blackcoreexport.h"
|
#include "blackcore/blackcoreexport.h"
|
||||||
#include "blackmisc/aviation/airporticaocode.h"
|
|
||||||
#include "blackmisc/network/entityflags.h"
|
|
||||||
#include "blackcore/threadedreader.h"
|
|
||||||
#include "blackmisc/weather/metar.h"
|
#include "blackmisc/weather/metar.h"
|
||||||
#include "blackmisc/weather/metardecoder.h"
|
#include "blackmisc/weather/metardecoder.h"
|
||||||
#include "blackmisc/weather/metarlist.h"
|
#include "blackmisc/weather/metarlist.h"
|
||||||
|
#include "blackmisc/network/ecosystemprovider.h"
|
||||||
|
#include "blackmisc/network/entityflags.h"
|
||||||
|
#include "blackmisc/aviation/airporticaocode.h"
|
||||||
|
#include "blackcore/threadedreader.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
@@ -29,7 +30,9 @@ namespace BlackCore
|
|||||||
namespace Vatsim
|
namespace Vatsim
|
||||||
{
|
{
|
||||||
//! Read bookings from VATSIM
|
//! Read bookings from VATSIM
|
||||||
class BLACKCORE_EXPORT CVatsimMetarReader : public BlackCore::CThreadedReader
|
class BLACKCORE_EXPORT CVatsimMetarReader :
|
||||||
|
public BlackCore::CThreadedReader,
|
||||||
|
public BlackMisc::Network::CEcosystemAware
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ namespace BlackCore
|
|||||||
CFailoverUrlList urls(sApp->getGlobalSetup().getVatsimStatusFileUrls());
|
CFailoverUrlList urls(sApp->getGlobalSetup().getVatsimStatusFileUrls());
|
||||||
const CUrl url(urls.obtainNextWorkingUrl(true)); // random working URL
|
const CUrl url(urls.obtainNextWorkingUrl(true)); // random working URL
|
||||||
if (url.isEmpty()) { return; }
|
if (url.isEmpty()) { return; }
|
||||||
this->getFromNetworkAndLog(url, { this, &CVatsimStatusFileReader::ps_parseVatsimFile});
|
this->getFromNetworkAndLog(url, { this, &CVatsimStatusFileReader::parseVatsimFile});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimStatusFileReader::ps_parseVatsimFile(QNetworkReply *nwReplyPtr)
|
void CVatsimStatusFileReader::parseVatsimFile(QNetworkReply *nwReplyPtr)
|
||||||
{
|
{
|
||||||
// wrap pointer, make sure any exit cleans up reply
|
// wrap pointer, make sure any exit cleans up reply
|
||||||
// required to use delete later as object is created in a different thread
|
// required to use delete later as object is created in a different thread
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ namespace BlackCore
|
|||||||
void dataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number);
|
void dataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Data have been read, parse VATSIM file
|
|
||||||
void ps_parseVatsimFile(QNetworkReply *nwReply);
|
|
||||||
|
|
||||||
//! Read / re-read data file
|
//! Read / re-read data file
|
||||||
void ps_read();
|
void ps_read();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Data have been read, parse VATSIM file
|
||||||
|
void parseVatsimFile(QNetworkReply *nwReply);
|
||||||
|
|
||||||
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_lastGoodSetup { this };
|
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_lastGoodSetup { this };
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -1454,7 +1454,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CWebDataServices::onConnectedNetworkServerChanged(const CServer &server)
|
void CWebDataServices::onConnectedNetworkServerChanged(const CServer &server)
|
||||||
{
|
{
|
||||||
Q_UNUSED(server);
|
const CEcosystem es(server.getEcosystem());
|
||||||
|
this->setCurrentEcosystem(es);
|
||||||
|
CLogMessage(this).info("Changed data service ecosystem to '%1'") << es.toQString(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWebDataServices::writeDbDataToDisk(const QString &dir) const
|
bool CWebDataServices::writeDbDataToDisk(const QString &dir) const
|
||||||
|
|||||||
@@ -22,10 +22,11 @@
|
|||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
#include "blackmisc/aviation/liverylist.h"
|
#include "blackmisc/aviation/liverylist.h"
|
||||||
#include "blackmisc/countrylist.h"
|
#include "blackmisc/countrylist.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/ecosystemprovider.h"
|
||||||
#include "blackmisc/network/serverlist.h"
|
#include "blackmisc/network/serverlist.h"
|
||||||
#include "blackmisc/network/urllist.h"
|
#include "blackmisc/network/urllist.h"
|
||||||
#include "blackmisc/network/userlist.h"
|
#include "blackmisc/network/userlist.h"
|
||||||
|
#include "blackmisc/network/entityflags.h"
|
||||||
#include "blackmisc/network/voicecapabilities.h"
|
#include "blackmisc/network/voicecapabilities.h"
|
||||||
#include "blackmisc/restricted.h"
|
#include "blackmisc/restricted.h"
|
||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
@@ -78,9 +79,12 @@ namespace BlackCore
|
|||||||
/*!
|
/*!
|
||||||
* Encapsulates reading data from web sources
|
* Encapsulates reading data from web sources
|
||||||
*/
|
*/
|
||||||
class BLACKCORE_EXPORT CWebDataServices : public QObject
|
class BLACKCORE_EXPORT CWebDataServices :
|
||||||
|
public QObject,
|
||||||
|
public BlackMisc::Network::IEcosystemProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(BlackMisc::Network::IEcosystemProvider)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Log categories
|
//! Log categories
|
||||||
@@ -581,6 +585,7 @@ namespace BlackCore
|
|||||||
void onCoreFacadeStarted();
|
void onCoreFacadeStarted();
|
||||||
|
|
||||||
//! \copydoc BlackCore::Context::IContextNetwork::connectedServerChanged
|
//! \copydoc BlackCore::Context::IContextNetwork::connectedServerChanged
|
||||||
|
//! \remark sets the ecosystem
|
||||||
void onConnectedNetworkServerChanged(const BlackMisc::Network::CServer &server);
|
void onConnectedNetworkServerChanged(const BlackMisc::Network::CServer &server);
|
||||||
|
|
||||||
CWebReaderFlags::WebReader m_readers = CWebReaderFlags::WebReaderFlag::None; //!< which readers are available
|
CWebReaderFlags::WebReader m_readers = CWebReaderFlags::WebReaderFlag::None; //!< which readers are available
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ namespace BlackMisc
|
|||||||
return this->getCurrentEcosystem() == system;
|
return this->getCurrentEcosystem() == system;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IEcosystemProvider::isCurrentEcosystemVATSIM() const
|
||||||
|
{
|
||||||
|
return this->isCurrentEcosystem(CEcosystem::vatsim());
|
||||||
|
}
|
||||||
|
|
||||||
bool IEcosystemProvider::isLastEcosystem(const CEcosystem &system) const
|
bool IEcosystemProvider::isLastEcosystem(const CEcosystem &system) const
|
||||||
{
|
{
|
||||||
return this->getLastEcosystem() == system;
|
return this->getLastEcosystem() == system;
|
||||||
@@ -70,10 +75,29 @@ namespace BlackMisc
|
|||||||
return this->provider()->isCurrentEcosystem(system);
|
return this->provider()->isCurrentEcosystem(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CEcosystemAware::isCurrentEcosystemVATSIM() const
|
||||||
|
{
|
||||||
|
return this->isCurrentEcosystem(CEcosystem::vatsim());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CEcosystemAware::isNotVATSIMEcosystem() const
|
||||||
|
{
|
||||||
|
if (!this->hasProvider()) { return false; }
|
||||||
|
if (this->isCurrentEcosystemVATSIM()) { return false; }
|
||||||
|
if (this->isCurrentEcosystem(CEcosystem::swiftTest())) { return false; } // our test server is supposed to be I VATSIM system
|
||||||
|
return !this->getCurrentEcosystem().isUnspecified(); // other know system which is specified
|
||||||
|
}
|
||||||
|
|
||||||
bool CEcosystemAware::isLastEcosystem(const CEcosystem &system) const
|
bool CEcosystemAware::isLastEcosystem(const CEcosystem &system) const
|
||||||
{
|
{
|
||||||
if (!this->hasProvider()) { return this->getLastEcosystem() == system; }
|
if (!this->hasProvider()) { return this->getLastEcosystem() == system; }
|
||||||
return this->provider()->isLastEcosystem(system);
|
return this->provider()->isLastEcosystem(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEcosystemProvider *CEcosystemAware::providerIfPossible(QObject *object)
|
||||||
|
{
|
||||||
|
IEcosystemProvider *p = qobject_cast<IEcosystemProvider *>(object);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
bool isCurrentEcosystem(const CEcosystem &system) const;
|
bool isCurrentEcosystem(const CEcosystem &system) const;
|
||||||
|
|
||||||
|
//! Current ecosystem VATSIM?
|
||||||
|
//! \threadsafe
|
||||||
|
bool isCurrentEcosystemVATSIM() const;
|
||||||
|
|
||||||
//! Last known ecosystem?
|
//! Last known ecosystem?
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
bool isLastEcosystem(const CEcosystem &system) const;
|
bool isLastEcosystem(const CEcosystem &system) const;
|
||||||
@@ -72,9 +76,19 @@ namespace BlackMisc
|
|||||||
//! \copydoc IEcosystemProvider::isCurrentEcosystem
|
//! \copydoc IEcosystemProvider::isCurrentEcosystem
|
||||||
bool isCurrentEcosystem(const CEcosystem &system) const;
|
bool isCurrentEcosystem(const CEcosystem &system) const;
|
||||||
|
|
||||||
|
//! \copydoc IEcosystemProvider::isCurrentEcosystemVATSIM
|
||||||
|
bool isCurrentEcosystemVATSIM() const;
|
||||||
|
|
||||||
|
//! Connected with other system than VATSIM?
|
||||||
|
//! \remark use this function to skip VATSIM specific provider tasks etc.
|
||||||
|
bool isNotVATSIMEcosystem() const;
|
||||||
|
|
||||||
//! \copydoc IEcosystemProvider::isLastEcosystem
|
//! \copydoc IEcosystemProvider::isLastEcosystem
|
||||||
bool isLastEcosystem(const CEcosystem &system) const;
|
bool isLastEcosystem(const CEcosystem &system) const;
|
||||||
|
|
||||||
|
//! Cast as provider if possible
|
||||||
|
static IEcosystemProvider *providerIfPossible(QObject *object);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CEcosystemAware(IEcosystemProvider *EcosystemProvider) : IProviderAware(EcosystemProvider) { Q_ASSERT(EcosystemProvider); }
|
CEcosystemAware(IEcosystemProvider *EcosystemProvider) : IProviderAware(EcosystemProvider) { Q_ASSERT(EcosystemProvider); }
|
||||||
|
|||||||
Reference in New Issue
Block a user