diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index ce8fadeba..969046e50 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -140,21 +140,24 @@ namespace BlackCore // Init network Q_ASSERT_X(m_accessManager, Q_FUNC_INFO, "Need QAM"); + m_internetAccessTimer.setObjectName("Application::m_internetAccessTimer"); this->m_cookieManager.setParent(this->m_accessManager); this->m_accessManager->setCookieJar(&this->m_cookieManager); - connect(this->m_accessManager, &QNetworkAccessManager::networkAccessibleChanged, this, &CApplication::ps_networkAccessibleChanged); + connect(this->m_accessManager, &QNetworkAccessManager::networkAccessibleChanged, this, &CApplication::networkAccessibleChanged, Qt::QueuedConnection); + connect(&this->m_internetAccessTimer, &QTimer::timeout, this, [this] { this->checkInternetAccessible(true); }); CLogMessage::preformatted(CNetworkUtils::createNetworkReport(this->m_accessManager)); + this->checkInternetAccessible(); // global setup sApp = this; this->m_setupReader.reset(new CSetupReader(this)); - connect(this->m_setupReader.data(), &CSetupReader::setupHandlingCompleted, this, &CApplication::ps_setupHandlingCompleted); + connect(this->m_setupReader.data(), &CSetupReader::setupHandlingCompleted, this, &CApplication::setupHandlingIsCompleted); connect(this->m_setupReader.data(), &CSetupReader::distributionInfoAvailable, this, &CApplication::distributionInfoAvailable); this->m_parser.addOptions(this->m_setupReader->getCmdLineOptions()); // add options from reader // startup done - connect(this, &CApplication::startUpCompleted, this, &CApplication::ps_startupCompleted); + connect(this, &CApplication::startUpCompleted, this, &CApplication::startupCompleted); // notify when app goes down connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CApplication::gracefulShutdown); @@ -336,11 +339,11 @@ namespace BlackCore { QTimer::singleShot(10 * 1000, [ = ] { - #ifdef BLACK_USE_CRASHPAD +#ifdef BLACK_USE_CRASHPAD CRASHPAD_SIMULATE_CRASH(); - #else +#else CLogMessage(this).warning("This compiler or platform does not support crashpad. Cannot simulate crash dump!"); - #endif +#endif }); } @@ -494,6 +497,40 @@ namespace BlackCore return false; } + void CApplication::checkInternetAccessible(bool logWarning) + { + if (this->isShuttingDown()) { return; } + + bool access = false; + if (this->isNetworkAccessible()) + { + QString message1; + static const QString testHost1("www.google.com"); // what else? + access = CNetworkUtils::canConnect(testHost1, 443, message1); + if (!access) + { + QString message2; + static const QString testHost2("www.microsoft.com"); // secondary test + access = CNetworkUtils::canConnect(testHost2, 80, message2); + if (!access && logWarning) { CLogMessage(this).warning("Internet access problems: %1 based on testing '%2'") << message1 << testHost1; } + } + } + else + { + if (logWarning) { CLogMessage(this).warning("No network access"); } + } + + if (m_internetAccessible != access) + { + m_internetAccessible = access; + emit this->internetAccessibleChanged(access); + } + + constexpr int checkAgainSuccess = 60 * 1000; + constexpr int checkAgainFailure = 30 * 1000; + m_internetAccessTimer.start(access ? checkAgainSuccess : checkAgainFailure); + } + void CApplication::setSignalStartupAutomatically(bool enabled) { this->m_signalStartup = enabled; @@ -630,10 +667,15 @@ namespace BlackCore const QNetworkAccessManager::NetworkAccessibility a = this->m_accessManager->networkAccessible(); if (a == QNetworkAccessManager::Accessible) { return true; } - // currently I also accept unknown + // currently I also accept unknown because of that issue with Network Manager return a == QNetworkAccessManager::UnknownAccessibility; } + bool CApplication::isInternetAccessible() const + { + return this->isNetworkAccessible() && m_internetAccessible; + } + bool CApplication::hasSetupReader() const { // m_startSetupReader set to false, if something wrong with parsing @@ -855,7 +897,7 @@ namespace BlackCore this->m_fileLogger->close(); } - void CApplication::ps_setupHandlingCompleted(bool available) + void CApplication::setupHandlingIsCompleted(bool available) { if (available) { @@ -872,12 +914,12 @@ namespace BlackCore } } - void CApplication::ps_startupCompleted() + void CApplication::startupCompleted() { // void } - void CApplication::ps_networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible) + void CApplication::networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible) { switch (accessible) { @@ -892,6 +934,7 @@ namespace BlackCore CLogMessage(this).warning("Network accessibility unknown"); break; } + this->checkInternetAccessible(); } CStatusMessageList CApplication::asyncWebAndContextStart() diff --git a/src/blackcore/application.h b/src/blackcore/application.h index df210b8b3..9d27fcc7b 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -159,6 +159,9 @@ namespace BlackCore //! Network accessible? bool isNetworkAccessible() const; + //! Internet accessible? + bool isInternetAccessible() const; + //! Access to access manager const QNetworkAccessManager *getNetworkAccessManager() const { return m_accessManager; } @@ -408,17 +411,19 @@ namespace BlackCore //! Web data services started void webDataServicesStarted(bool success); - protected slots: - //! Setup read/synchronized - void ps_setupHandlingCompleted(bool available); - - //! Startup completed - virtual void ps_startupCompleted(); - - //! Problem with network access manager - virtual void ps_networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible); + //! Internet accessinility changed + void internetAccessibleChanged(bool access); protected: + //! Setup read/synchronized + void setupHandlingIsCompleted(bool available); + + //! Startup completed + virtual void startupCompleted(); + + //! Problem with network access manager + virtual void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible); + //! Init class, allows to init from BlackGui::CGuiApplication as well (pseudo virtual) void init(bool withMetadata); @@ -480,6 +485,9 @@ namespace BlackCore //! Dev.environment bool initIsRunningInDeveloperEnvironment() const; + //! Check that Internet is accessible + void checkInternetAccessible(bool logWarning = true); + //! Async. start when setup is loaded BlackMisc::CStatusMessageList asyncWebAndContextStart(); @@ -489,25 +497,27 @@ namespace BlackCore int maxRedirects, std::function requestOrPostMethod); - QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager + QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager BlackMisc::CApplicationInfo::Application m_application = BlackMisc::CApplicationInfo::Unknown; //!< Application if specified - QScopedPointer m_coreFacade; //!< core facade if any - QScopedPointer m_setupReader; //!< setup reader - QScopedPointer m_webDataServices; //!< web data services - QScopedPointer m_fileLogger; //!< file logger - CCookieManager m_cookieManager; //!< single cookie manager for our access manager - QString m_applicationName; //!< application name - QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe - CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any - CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used - BlackCore::Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? - std::atomic m_shutdown { false }; //!< is being shutdown? - bool m_useContexts = false; //!< use contexts - bool m_useWebData = false; //!< use web data - bool m_signalStartup = true; //!< signal startup automatically - bool m_devEnv = false; //!< dev. environment - bool m_unitTest = false; //!< is UNIT test - bool m_autoSaveSettings = true;//!< automatically saving all settings + QScopedPointer m_coreFacade; //!< core facade if any + QScopedPointer m_setupReader; //!< setup reader + QScopedPointer m_webDataServices; //!< web data services + QScopedPointer m_fileLogger; //!< file logger + CCookieManager m_cookieManager; //!< single cookie manager for our access manager + QString m_applicationName; //!< application name + QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe + CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any + CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used + BlackCore::Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? + std::atomic m_shutdown { false }; //!< is being shutdown? + QTimer m_internetAccessTimer { this }; + bool m_useContexts = false; //!< use contexts + bool m_useWebData = false; //!< use web data + bool m_signalStartup = true; //!< signal startup automatically + bool m_devEnv = false; //!< dev. environment + bool m_unitTest = false; //!< is UNIT test + bool m_autoSaveSettings = true; //!< automatically saving all settings + bool m_internetAccessible = true; //!< Internet accessible // -------------- crashpad ----------------- BlackMisc::CStatusMessageList initCrashHandler(); diff --git a/src/blackcore/db/airportdatareader.cpp b/src/blackcore/db/airportdatareader.cpp index 31555414d..c4ef9bd6a 100644 --- a/src/blackcore/db/airportdatareader.cpp +++ b/src/blackcore/db/airportdatareader.cpp @@ -203,7 +203,7 @@ namespace BlackCore this->threadAssertCheck(); if (!this->doWorkCheck()) { return; } entity &= CEntityFlags::AirportEntity; - if (!this->isNetworkAccessible()) + if (!this->isInternetAccessible()) { emit this->dataRead(entity, CEntityFlags::ReadSkipped, 0); return; diff --git a/src/blackcore/db/databasereader.cpp b/src/blackcore/db/databasereader.cpp index d943e0f65..0f3d07747 100644 --- a/src/blackcore/db/databasereader.cpp +++ b/src/blackcore/db/databasereader.cpp @@ -198,7 +198,7 @@ namespace BlackCore // ps_read is implemented in the derived classes if (entities == CEntityFlags::NoEntity) { return; } - if (!this->isNetworkAccessible(QString("No network, will not read %1").arg(CEntityFlags::flagToString(entities)))) { return; } + if (!this->isInternetAccessible(QString("No network/internet access, will not read %1").arg(CEntityFlags::flagToString(entities)))) { return; } const bool s = QMetaObject::invokeMethod(this, "ps_read", Q_ARG(BlackMisc::Network::CEntityFlags::Entity, entities), @@ -370,7 +370,7 @@ namespace BlackCore bool CDatabaseReader::requestHeadersOfSharedFiles(CEntityFlags::Entity entities) { - if (!this->isNetworkAccessible(QString("No network, will not read shared file headers for %1").arg(CEntityFlags::flagToString(entities)))) { return false; } + if (!this->isInternetAccessible(QString("No network/internet access, will not read shared file headers for %1").arg(CEntityFlags::flagToString(entities)))) { return false; } CEntityFlags::Entity allEntities(this->maskBySupportedEntities(entities)); CEntityFlags::Entity currentEntity = CEntityFlags::iterateDbEntities(allEntities); diff --git a/src/blackcore/db/icaodatareader.cpp b/src/blackcore/db/icaodatareader.cpp index 23900fb85..1960834f6 100644 --- a/src/blackcore/db/icaodatareader.cpp +++ b/src/blackcore/db/icaodatareader.cpp @@ -134,7 +134,7 @@ namespace BlackCore this->threadAssertCheck(); // runs in background thread if (!this->doWorkCheck()) { return; } entities &= CEntityFlags::AllIcaoAndCountries; - if (!this->isNetworkAccessible()) + if (!this->isInternetAccessible()) { emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0); return; diff --git a/src/blackcore/db/infodatareader.cpp b/src/blackcore/db/infodatareader.cpp index 299d903ca..49b769903 100644 --- a/src/blackcore/db/infodatareader.cpp +++ b/src/blackcore/db/infodatareader.cpp @@ -95,6 +95,7 @@ namespace BlackCore void CInfoDataReader::read() { + if (!this->doWorkCheck()) { return; } const CUrl url(this->getInfoObjectsUrl()); if (!url.isEmpty()) { diff --git a/src/blackcore/db/modeldatareader.cpp b/src/blackcore/db/modeldatareader.cpp index 347ee7401..242535864 100644 --- a/src/blackcore/db/modeldatareader.cpp +++ b/src/blackcore/db/modeldatareader.cpp @@ -154,7 +154,7 @@ namespace BlackCore this->threadAssertCheck(); if (!this->doWorkCheck()) { return; } entities &= CEntityFlags::DistributorLiveryModel; - if (!this->isNetworkAccessible()) + if (!this->isInternetAccessible()) { emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0); return; diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index 115b6abcb..e0d377725 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -208,9 +208,9 @@ namespace BlackCore CStatusMessageList CSetupReader::triggerReadSetup() { if (this->m_shutdown) { return CStatusMessage(this, CStatusMessage::SeverityError, "shutdown"); } - if (!sApp->isNetworkAccessible()) + if (!sApp->isInternetAccessible()) { - const CStatusMessage m(this, CStatusMessage::SeverityInfo, "No network, will try to recover"); + const CStatusMessage m(this, CStatusMessage::SeverityInfo, "No network/internet, will try to recover"); CStatusMessageList msgs(m); msgs.push_back(this->manageSetupAvailability(false, false)); this->setLastSetupReadErrorMessages(msgs); diff --git a/src/blackcore/threadedreader.cpp b/src/blackcore/threadedreader.cpp index 1501e8206..50cfecf28 100644 --- a/src/blackcore/threadedreader.cpp +++ b/src/blackcore/threadedreader.cpp @@ -68,9 +68,9 @@ namespace BlackCore return delta <= timeLastMs; } - bool CThreadedReader::isNetworkAccessible(const QString &logWarningMessage) const + bool CThreadedReader::isInternetAccessible(const QString &logWarningMessage) const { - const bool a = sApp->isNetworkAccessible(); + const bool a = sApp->isInternetAccessible(); if (!a && !logWarningMessage.isEmpty()) { CLogMessage(this).warning(logWarningMessage); @@ -148,6 +148,7 @@ namespace BlackCore { if (!m_unitTest && (!sApp || !sApp->hasWebDataServices())) { return false; } if (!isEnabled()) { return false; } + if (isAbandoned()) { return false; } return true; } diff --git a/src/blackcore/threadedreader.h b/src/blackcore/threadedreader.h index 8241072ce..72d2fdfa9 100644 --- a/src/blackcore/threadedreader.h +++ b/src/blackcore/threadedreader.h @@ -54,7 +54,7 @@ namespace BlackCore //! Network accessible? //! \param logWarningMessage optional warning if not accessible - bool isNetworkAccessible(const QString &logWarningMessage = {}) const; + bool isInternetAccessible(const QString &logWarningMessage = {}) const; //! Is marked as read failed //! \threadsafe diff --git a/src/blackcore/vatsim/vatsimbookingreader.cpp b/src/blackcore/vatsim/vatsimbookingreader.cpp index 76a0c8eb8..06e959028 100644 --- a/src/blackcore/vatsim/vatsimbookingreader.cpp +++ b/src/blackcore/vatsim/vatsimbookingreader.cpp @@ -64,7 +64,7 @@ namespace BlackCore { this->threadAssertCheck(); if (!this->doWorkCheck()) { return; } - if (!this->isNetworkAccessible("No network, cannot read VATSIM bookings")) { return; } + if (!this->isInternetAccessible("No network/internet access, cannot read VATSIM bookings")) { return; } Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application"); const QUrl url(sApp->getGlobalSetup().getVatsimBookingsUrl()); diff --git a/src/blackcore/vatsim/vatsimdatafilereader.cpp b/src/blackcore/vatsim/vatsimdatafilereader.cpp index 841620e2c..ccfe4207c 100644 --- a/src/blackcore/vatsim/vatsimdatafilereader.cpp +++ b/src/blackcore/vatsim/vatsimdatafilereader.cpp @@ -183,7 +183,7 @@ namespace BlackCore { this->threadAssertCheck(); if (!this->doWorkCheck()) { return; } - if (!this->isNetworkAccessible("No network, cannot read VATSIM data file")) { return; } + if (!this->isInternetAccessible("No network/internet access, cannot read VATSIM data file")) { return; } // round robin for load balancing // remark: Don't use QThread to run network operations in the background diff --git a/src/blackcore/vatsim/vatsimmetarreader.cpp b/src/blackcore/vatsim/vatsimmetarreader.cpp index e48426b27..db2e67220 100644 --- a/src/blackcore/vatsim/vatsimmetarreader.cpp +++ b/src/blackcore/vatsim/vatsimmetarreader.cpp @@ -76,7 +76,7 @@ namespace BlackCore { this->threadAssertCheck(); if (!this->doWorkCheck()) { return; } - if (!this->isNetworkAccessible("No network, cannot read METARs")) { return; } + if (!this->isInternetAccessible("No network/internet access, cannot read METARs")) { return; } CFailoverUrlList urls(sApp->getVatsimMetarUrls()); const CUrl url(urls.obtainNextWorkingUrl(true)); diff --git a/src/blackcore/vatsim/vatsimstatusfilereader.cpp b/src/blackcore/vatsim/vatsimstatusfilereader.cpp index 8119642ce..3374905fc 100644 --- a/src/blackcore/vatsim/vatsimstatusfilereader.cpp +++ b/src/blackcore/vatsim/vatsimstatusfilereader.cpp @@ -66,7 +66,7 @@ namespace BlackCore { this->threadAssertCheck(); if (!this->doWorkCheck()) { return; } - if (!this->isNetworkAccessible("No network, cannot read VATSIM status file")) { return; } + if (!this->isInternetAccessible("No network/internet access, cannot read VATSIM status file")) { return; } Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing application"); CFailoverUrlList urls(sApp->getGlobalSetup().getVatsimStatusFileUrls()); diff --git a/src/blackcore/webdataservices.cpp b/src/blackcore/webdataservices.cpp index 0b55642dd..5cc3ba0ad 100644 --- a/src/blackcore/webdataservices.cpp +++ b/src/blackcore/webdataservices.cpp @@ -928,7 +928,14 @@ namespace BlackCore } // and trigger read - QTimer::singleShot(0, m_dbInfoDataReader, [this]() { this->m_dbInfoDataReader->read(); }); + if (sApp->isInternetAccessible()) + { + QTimer::singleShot(0, m_dbInfoDataReader, [this]() { this->m_dbInfoDataReader->read(); }); + } + else + { + CLogMessage(this).warning("No network/internet access, skipping read of info objects"); + } } void CWebDataServices::initSharedInfoObjectReaderAndTriggerRead() @@ -956,7 +963,14 @@ namespace BlackCore } // and trigger read - QTimer::singleShot(0, m_sharedInfoDataReader, [this]() { this->m_sharedInfoDataReader->read(); }); + if (sApp->isInternetAccessible()) + { + QTimer::singleShot(0, m_sharedInfoDataReader, [this]() { this->m_sharedInfoDataReader->read(); }); + } + else + { + CLogMessage(this).warning("No network/internet access, skipping read of shared data"); + } } CDatabaseReader *CWebDataServices::getDbReader(CEntityFlags::Entity entity) const diff --git a/src/blackgui/components/infobarstatuscomponent.cpp b/src/blackgui/components/infobarstatuscomponent.cpp index 64b773515..34bd7e6c4 100644 --- a/src/blackgui/components/infobarstatuscomponent.cpp +++ b/src/blackgui/components/infobarstatuscomponent.cpp @@ -46,21 +46,22 @@ namespace BlackGui this->initLeds(); ui->lbl_Audio->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::ps_customAudioContextMenuRequested); + connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::onCustomAudioContextMenuRequested); if (sGui->getIContextSimulator()) { - connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::ps_onSimulatorStatusChanged); - connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CInfoBarStatusComponent::ps_onMapperReady); + connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::onSimulatorStatusChanged); + connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CInfoBarStatusComponent::onMapperReady); + connect(sGui, &CGuiApplication::internetAccessibleChanged, this, &CInfoBarStatusComponent::onInternetAccessibleChanged); // initial values - this->ps_onMapperReady(); - this->ps_onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus()); + this->onMapperReady(); + this->onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus()); } if (sGui->getIContextNetwork()) { - connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::ps_onNetworkConnectionChanged); + connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::onNetworkConnectionChanged); } if (sGui->getIContextApplication()) @@ -71,7 +72,7 @@ namespace BlackGui if (sGui->getIContextAudio()) { ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted()); - connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::ps_onMuteChanged); + connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::onMuteChanged); } } @@ -89,6 +90,7 @@ namespace BlackGui shape = CLedWidget::Rounded; ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Ptt", "Silence", 18); ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "On", "Muted", 18); + this->onInternetAccessibleChanged(sGui->isInternetAccessible()); } void CInfoBarStatusComponent::setDBusStatus(bool dbus) @@ -101,7 +103,7 @@ namespace BlackGui ui->led_DBus->setOnToolTip(tooltip); } - void CInfoBarStatusComponent::ps_onSimulatorStatusChanged(int status) + void CInfoBarStatusComponent::onSimulatorStatusChanged(int status) { ISimulator::SimulatorStatus simStatus = static_cast(status); if (simStatus.testFlag(ISimulator::Connected)) @@ -112,7 +114,6 @@ namespace BlackGui ISimulator::statusToString(simStatus) ); - if (simStatus.testFlag(ISimulator::Paused)) { ui->led_Simulator->setTriState(); @@ -136,10 +137,10 @@ namespace BlackGui } // simulator status has impact on model set available - this->ps_onMapperReady(); + this->onMapperReady(); } - void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to) + void CInfoBarStatusComponent::onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to) { Q_UNUSED(from); @@ -164,11 +165,11 @@ namespace BlackGui } } - void CInfoBarStatusComponent::ps_customAudioContextMenuRequested(const QPoint &position) + void CInfoBarStatusComponent::onCustomAudioContextMenuRequested(const QPoint &position) { - QWidget *sender = qobject_cast(QWidget::sender()); - Q_ASSERT(sender); - QPoint globalPosition = sender->mapToGlobal(position); + const QWidget *sender = qobject_cast(QWidget::sender()); + Q_ASSERT_X(sender, Q_FUNC_INFO, "Missing sender"); + const QPoint globalPosition = sender->mapToGlobal(position); QMenu menuAudio(this); menuAudio.addAction("Toogle mute"); @@ -178,7 +179,7 @@ namespace BlackGui menuAudio.addAction("Mixer"); } - QAction *selectedItem = menuAudio.exec(globalPosition); + const QAction *selectedItem = menuAudio.exec(globalPosition); if (selectedItem) { // http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html @@ -194,12 +195,12 @@ namespace BlackGui } } - void CInfoBarStatusComponent::ps_onMuteChanged(bool muted) + void CInfoBarStatusComponent::onMuteChanged(bool muted) { ui->led_Audio->setOn(!muted); } - void CInfoBarStatusComponent::ps_onMapperReady() + void CInfoBarStatusComponent::onMapperReady() { if (!sGui || !sGui->getIContextSimulator()) { @@ -212,14 +213,28 @@ namespace BlackGui ui->led_MapperReady->setOn(on); if (on) { - QString m = QString("Mapper with %1 models").arg(models); + const QString m = QString("Mapper with %1 models").arg(models); ui->led_MapperReady->setToolTip(m); } } - void CInfoBarStatusComponent::ps_onPttChanged(bool enabled) + void CInfoBarStatusComponent::onPttChanged(bool enabled) { ui->led_Ptt->setOn(enabled); } + + void CInfoBarStatusComponent::onInternetAccessibleChanged(bool access) + { + if (access) + { + ui->led_Network->setOffColor(CLedWidget::Black); + ui->led_Network->setOffToolTip("Network disconnected"); + } + else + { + ui->led_Network->setOffColor(CLedWidget::Red); + ui->led_Network->setOffToolTip("No network/internet access"); + } + } } // namespace } // namespace diff --git a/src/blackgui/components/infobarstatuscomponent.h b/src/blackgui/components/infobarstatuscomponent.h index f1cee99c5..bcf764f38 100644 --- a/src/blackgui/components/infobarstatuscomponent.h +++ b/src/blackgui/components/infobarstatuscomponent.h @@ -25,14 +25,12 @@ class QPoint; class QWidget; namespace Ui { class CInfoBarStatusComponent; } - namespace BlackGui { namespace Components { //! Info bar displaying status (Network, Simulator, DBus) - class BLACKGUI_EXPORT CInfoBarStatusComponent : - public QFrame + class BLACKGUI_EXPORT CInfoBarStatusComponent : public QFrame { Q_OBJECT @@ -41,7 +39,7 @@ namespace BlackGui explicit CInfoBarStatusComponent(QWidget *parent = nullptr); //!Destructor - ~CInfoBarStatusComponent(); + virtual ~CInfoBarStatusComponent(); //! Init the LEDs void initLeds(); @@ -54,27 +52,29 @@ namespace BlackGui private: QScopedPointer ui; - BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::ps_onPttChanged }; + BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::onPttChanged }; - private slots: //! Simulator connection has been changed - void ps_onSimulatorStatusChanged(int status); + void onSimulatorStatusChanged(int status); //! Network connection has been changed - void ps_onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to); + void onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to); //! Context menu requested - void ps_customAudioContextMenuRequested(const QPoint &position); + void onCustomAudioContextMenuRequested(const QPoint &position); //! Mute changed - void ps_onMuteChanged(bool muted); + void onMuteChanged(bool muted); //! Mapper is ready - void ps_onMapperReady(); + void onMapperReady(); //! Ptt button changed - void ps_onPttChanged(bool enabled); + void onPttChanged(bool enabled); + + //! Internet accessible? + void onInternetAccessibleChanged(bool access); }; - } -} + } // ns +} // ns #endif // guard diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 4293f2cb4..67469db31 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -205,9 +205,9 @@ namespace BlackGui qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); } - void CGuiApplication::ps_startupCompleted() + void CGuiApplication::startupCompleted() { - CApplication::ps_startupCompleted(); + CApplication::startupCompleted(); if (this->m_splashScreen) { this->m_splashScreen->close(); diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index 451165c2b..0cc8ed32f 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -194,7 +194,7 @@ namespace BlackGui protected slots: //! Startup competed - virtual void ps_startupCompleted() override; + virtual void startupCompleted() override; protected: //! \name print messages generated during parsing / cmd handling diff --git a/src/plugins/weatherdata/gfs/weatherdatagfs.cpp b/src/plugins/weatherdata/gfs/weatherdatagfs.cpp index 4b6090fec..2b08313c8 100644 --- a/src/plugins/weatherdata/gfs/weatherdatagfs.cpp +++ b/src/plugins/weatherdata/gfs/weatherdatagfs.cpp @@ -65,9 +65,9 @@ namespace BlackWxPlugin m_maxRange = range; if (m_gribData.isEmpty()) { - if (!sApp->isNetworkAccessible()) + if (!sApp->isInternetAccessible()) { - CLogMessage(this).error("No weather download since network not accessible"); + CLogMessage(this).error("No weather download since network/internet not accessible"); return; }