refs #485, further removed global setup traits from classes with read only

Use global setup from sGui/sApp
This commit is contained in:
Klaus Basan
2016-03-01 01:49:59 +01:00
committed by Mathew Sutcliffe
parent 30b5e5dade
commit aa96731143
20 changed files with 22 additions and 48 deletions

View File

@@ -51,7 +51,7 @@ namespace BlackCore
if (pw.isEmpty()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "No password")); } if (pw.isEmpty()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "No password")); }
if (!msgs.isEmpty()) { return msgs; } if (!msgs.isEmpty()) { return msgs; }
CUrl url(this->m_setup.get().dbLoginServiceUrl()); const CUrl url(sApp->getGlobalSetup().dbLoginServiceUrl());
QString msg; QString msg;
if (!CNetworkUtils::canConnect(url, msg)) if (!CNetworkUtils::canConnect(url, msg))
{ {
@@ -62,7 +62,7 @@ namespace BlackCore
QUrlQuery params; QUrlQuery params;
params.addQueryItem("username", un); params.addQueryItem("username", un);
params.addQueryItem("password", pw); params.addQueryItem("password", pw);
if (m_setup.get().dbDebugFlag()) { CNetworkUtils::addDebugFlag(params); } if (sApp->getGlobalSetup().dbDebugFlag()) { CNetworkUtils::addDebugFlag(params); }
QString query = params.toString(); QString query = params.toString();
const QNetworkRequest request(CNetworkUtils::getNetworkRequest(url, CNetworkUtils::PostUrlEncoded)); const QNetworkRequest request(CNetworkUtils::getNetworkRequest(url, CNetworkUtils::PostUrlEncoded));
@@ -74,7 +74,7 @@ namespace BlackCore
void CDatabaseAuthenticationService::logoff() void CDatabaseAuthenticationService::logoff()
{ {
CUrl url(this->m_setup.get().dbLoginServiceUrl()); CUrl url(sApp->getGlobalSetup().dbLoginServiceUrl());
url.setQuery("logoff=true"); url.setQuery("logoff=true");
QNetworkRequest request(CNetworkUtils::getNetworkRequest(url)); QNetworkRequest request(CNetworkUtils::getNetworkRequest(url));
sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::ps_parseServerResponse }); sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::ps_parseServerResponse });

View File

@@ -59,7 +59,6 @@ namespace BlackCore
void ps_userChanged(); void ps_userChanged();
private: private:
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDatabaseAuthenticationService::ps_userChanged}; BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDatabaseAuthenticationService::ps_userChanged};
bool m_shutdown = false; bool m_shutdown = false;
}; };

View File

@@ -51,7 +51,7 @@ namespace BlackCore
CNetworkUtils::ignoreSslVerification(request); CNetworkUtils::ignoreSslVerification(request);
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType, this); QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType, this);
multiPart->append(CNetworkUtils::getJsonTextMultipart(models.toDatabaseJson())); multiPart->append(CNetworkUtils::getJsonTextMultipart(models.toDatabaseJson()));
if (m_setup.get().dbDebugFlag()) if (sApp->getGlobalSetup().dbDebugFlag())
{ {
multiPart->append(CNetworkUtils::getMultipartWithDebugFlag()); multiPart->append(CNetworkUtils::getMultipartWithDebugFlag());
} }

View File

@@ -47,7 +47,6 @@ namespace BlackCore
void ps_postResponse(QNetworkReply *nwReplyPtr); void ps_postResponse(QNetworkReply *nwReplyPtr);
private: private:
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache
BlackMisc::Network::CUrl m_modelPublishUrl; BlackMisc::Network::CUrl m_modelPublishUrl;
QNetworkReply *m_pendingReply = nullptr; QNetworkReply *m_pendingReply = nullptr;
bool m_shutdown = false; bool m_shutdown = false;

View File

@@ -45,7 +45,7 @@ namespace BlackCore
{ {
this->threadAssertCheck(); this->threadAssertCheck();
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application"); Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application");
QUrl url(m_setup.get().vatsimBookingsUrl()); const QUrl url(sApp->getGlobalSetup().vatsimBookingsUrl());
if (url.isEmpty()) { return; } if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimBookingReader::ps_parseBookings}); sApp->getFromNetwork(url, { this, &CVatsimBookingReader::ps_parseBookings});

View File

@@ -54,9 +54,6 @@ namespace BlackCore
//! Do reading //! Do reading
void ps_read(); void ps_read();
private:
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
}; };
} }

View File

@@ -158,9 +158,9 @@ namespace BlackCore
// 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
// see http://qt-project.org/doc/qt-4.7/qnetworkaccessmanager.html // see http://qt-project.org/doc/qt-4.7/qnetworkaccessmanager.html
QUrl url(m_setup.get().vatsimDataFileUrls().getRandomUrl());
if (url.isEmpty()) { return; }
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing application"); Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing application");
const QUrl url(sApp->getGlobalSetup().vatsimDataFileUrls().getRandomUrl());
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimDataFileReader::ps_parseVatsimFile}); sApp->getFromNetwork(url, { this, &CVatsimDataFileReader::ps_parseVatsimFile});
} }

View File

@@ -128,7 +128,6 @@ namespace BlackCore
BlackMisc::Aviation::CAtcStationList m_atcStations; BlackMisc::Aviation::CAtcStationList m_atcStations;
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft; BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CVoiceCapabilities> m_voiceCapabilities; QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CVoiceCapabilities> m_voiceCapabilities;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
//! Split line and assign values to their corresponding attribute names //! Split line and assign values to their corresponding attribute names
static const QMap<QString, QString> clientPartsToMap(const QString &currentLine, const QStringList &clientSectionAttributes); static const QMap<QString, QString> clientPartsToMap(const QString &currentLine, const QStringList &clientSectionAttributes);

View File

@@ -466,7 +466,7 @@ namespace BlackCore
void CWebDataServices::initWriters() void CWebDataServices::initWriters()
{ {
this->m_databaseWriter = new CDatabaseWriter( this->m_databaseWriter = new CDatabaseWriter(
m_setup.get().dbRootDirectoryUrl(), sApp->getGlobalSetup().dbRootDirectoryUrl(),
this); this);
} }

View File

@@ -281,7 +281,6 @@ namespace BlackCore
CWebReaderFlags::WebReader m_readerFlags = CWebReaderFlags::WebReaderFlag::None; //!< which readers are available CWebReaderFlags::WebReader m_readerFlags = CWebReaderFlags::WebReaderFlag::None; //!< which readers are available
CWebReaderFlags::DbReaderHint m_dbHint = CWebReaderFlags::NoHint; //!< how to read DB data CWebReaderFlags::DbReaderHint m_dbHint = CWebReaderFlags::NoHint; //!< how to read DB data
bool m_initialRead = false; //!< Initial read conducted bool m_initialRead = false; //!< Initial read conducted
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CWebDataServices::ps_setupChanged}; //!< setup cache
// for reading XML and VATSIM data files // for reading XML and VATSIM data files
CVatsimBookingReader *m_vatsimBookingReader = nullptr; CVatsimBookingReader *m_vatsimBookingReader = nullptr;

View File

@@ -10,6 +10,7 @@
#include "dblogincomponent.h" #include "dblogincomponent.h"
#include "ui_dblogincomponent.h" #include "ui_dblogincomponent.h"
#include "blackgui/overlaymessagesframe.h" #include "blackgui/overlaymessagesframe.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/verify.h" #include "blackmisc/verify.h"
#include "blackmisc/network/url.h" #include "blackmisc/network/url.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
@@ -28,7 +29,11 @@ namespace BlackGui
{ {
ui->setupUi(this); ui->setupUi(this);
this->setModeLogin(true); this->setModeLogin(true);
this->ps_setupChanged(); CUrl url(sGui->getGlobalSetup().dbHomePageUrl());
ui->lbl_SwiftDB->setText("<a href=\"" + url.getFullUrl() + "\">swift DB@" + url.getHost() + "</a>");
ui->lbl_SwiftDB->setTextFormat(Qt::RichText);
ui->lbl_SwiftDB->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_SwiftDB->setOpenExternalLinks(true);
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked); connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked); connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked);
@@ -89,15 +94,6 @@ namespace BlackGui
} }
} }
void CDbLoginComponent::ps_setupChanged()
{
CUrl url(m_setup.get().dbHomePageUrl());
ui->lbl_SwiftDB->setText("<a href=\"" + url.getFullUrl() + "\">swift DB@" + url.getHost() + "</a>");
ui->lbl_SwiftDB->setTextFormat(Qt::RichText);
ui->lbl_SwiftDB->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_SwiftDB->setOpenExternalLinks(true);
}
void CDbLoginComponent::setModeLogin(bool modeLogin) void CDbLoginComponent::setModeLogin(bool modeLogin)
{ {
this->ui->fr_Login->setVisible(modeLogin); this->ui->fr_Login->setVisible(modeLogin);

View File

@@ -39,9 +39,8 @@ namespace BlackGui
~CDbLoginComponent(); ~CDbLoginComponent();
private: private:
QScopedPointer<Ui::CDbLoginComponent> ui; QScopedPointer<Ui::CDbLoginComponent> ui;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CDbLoginComponent::ps_setupChanged}; //!< data cache BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service
BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service
//! Overlay messages //! Overlay messages
void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs); void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs);
@@ -59,8 +58,6 @@ namespace BlackGui
//! User authentication completed //! User authentication completed
void ps_AuthenticationFinished(const BlackMisc::Network::CAuthenticatedUser &user, const BlackMisc::CStatusMessageList &status); void ps_AuthenticationFinished(const BlackMisc::Network::CAuthenticatedUser &user, const BlackMisc::CStatusMessageList &status);
//! Setup changed
void ps_setupChanged();
}; };
} // ns } // ns
} // ns } // ns

View File

@@ -108,7 +108,7 @@ namespace BlackGui
// add a testserver when no servers can be loaded // add a testserver when no servers can be loaded
if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CProject::isBetaTest())) if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CProject::isBetaTest()))
{ {
otherServers.push_back(m_setup.get().fsdTestServersPlusHardcodedServers()); otherServers.push_back(sGui->getGlobalSetup().fsdTestServersPlusHardcodedServers());
CLogMessage(this).info("Added servers for testing"); CLogMessage(this).info("Added servers for testing");
} }
this->ui->cbp_OtherServers->setServers(otherServers); this->ui->cbp_OtherServers->setServers(otherServers);

View File

@@ -143,7 +143,6 @@ namespace BlackGui
const int LogoffIntervalSeconds = 10; const int LogoffIntervalSeconds = 10;
QTimer *m_logoffCountdownTimer { nullptr }; QTimer *m_logoffCountdownTimer { nullptr };
BlackMisc::CSetting<BlackCore::Settings::Network::TrafficServers> m_otherTrafficNetworkServers { this, &CLoginComponent::ps_reloadSettings }; BlackMisc::CSetting<BlackCore::Settings::Network::TrafficServers> m_otherTrafficNetworkServers { this, &CLoginComponent::ps_reloadSettings };
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
}; };
} // namespace } // namespace

View File

@@ -55,7 +55,7 @@ namespace BlackGui
// this is debug/bootstrap feature we can continue to test when something goes wrong // this is debug/bootstrap feature we can continue to test when something goes wrong
if (serverList.isEmpty() && (CProject::isBetaTest() || sGui->isRunningInDeveloperEnvironment())) if (serverList.isEmpty() && (CProject::isBetaTest() || sGui->isRunningInDeveloperEnvironment()))
{ {
serverList.push_back(m_setup.get().fsdTestServersPlusHardcodedServers()); serverList.push_back(sGui->getGlobalSetup().fsdTestServersPlusHardcodedServers());
this->ui->tvp_Servers->updateContainer(serverList); this->ui->tvp_Servers->updateContainer(serverList);
} }
} }

View File

@@ -50,7 +50,6 @@ namespace BlackGui
private: private:
QScopedPointer<Ui::CSettingsNetworkServersComponent> ui; QScopedPointer<Ui::CSettingsNetworkServersComponent> ui;
BlackMisc::CSetting<BlackCore::Settings::Network::TrafficServers> m_trafficNetworkServers { this, &CSettingsNetworkServersComponent::ps_reloadSettings }; BlackMisc::CSetting<BlackCore::Settings::Network::TrafficServers> m_trafficNetworkServers { this, &CSettingsNetworkServersComponent::ps_reloadSettings };
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
}; };
} // ns } // ns
} // ns } // ns

View File

@@ -63,9 +63,6 @@ private slots:
//! Menu clicked //! Menu clicked
void ps_onMenuClicked(); void ps_onMenuClicked();
//! Setup has been changed
void ps_setupChanged();
private: private:
void init(); void init();
void initLogDisplay(); void initLogDisplay();
@@ -79,7 +76,6 @@ private:
QScopedPointer<Ui::CSwiftData> ui; QScopedPointer<Ui::CSwiftData> ui;
BlackGui::CManagedStatusBar m_statusBar; BlackGui::CManagedStatusBar m_statusBar;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CSwiftData::ps_setupChanged}; //!< setup cache
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this }; //!< download / version data BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this }; //!< download / version data
}; };

View File

@@ -105,7 +105,7 @@ void CSwiftData::ps_onMenuClicked()
} }
else if (sender == this->ui->menu_JsonBootstrapTemplate) else if (sender == this->ui->menu_JsonBootstrapTemplate)
{ {
QString json(m_setup.get().toJsonString()); QString json(sApp->getGlobalSetup().toJsonString());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(json); this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(json);
this->displayConsole(); this->displayConsole();
} }
@@ -123,7 +123,7 @@ void CSwiftData::ps_onMenuClicked()
} }
else if (sender == this->ui->menu_InternalsSetup) else if (sender == this->ui->menu_InternalsSetup)
{ {
QString setup(this->m_setup.get().convertToQString("\n", true)); QString setup(sApp->getGlobalSetup().convertToQString("\n", true));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(setup); this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(setup);
this->displayConsole(); this->displayConsole();
} }
@@ -135,11 +135,6 @@ void CSwiftData::ps_onMenuClicked()
} }
} }
void CSwiftData::ps_setupChanged()
{
CLogMessage(this).debug() << "Setup changed";
}
void CSwiftData::initDynamicMenus() void CSwiftData::initDynamicMenus()
{ {
Q_ASSERT_X(this->ui->menu_InfoAreas, Q_FUNC_INFO, "missing info areas"); Q_ASSERT_X(this->ui->menu_InfoAreas, Q_FUNC_INFO, "missing info areas");

View File

@@ -134,7 +134,7 @@ void CSwiftLauncher::initStyleSheet()
void CSwiftLauncher::displayLatestNews() void CSwiftLauncher::displayLatestNews()
{ {
#ifndef Q_CC_MINGW #ifndef Q_CC_MINGW
CFailoverUrlList newsUrls(this->m_setup.get().swiftLatestNewsUrls()); CFailoverUrlList newsUrls(sGui->getGlobalSetup().swiftLatestNewsUrls());
QUrl newUrl(newsUrls.obtainNextWorkingUrl()); QUrl newUrl(newsUrls.obtainNextWorkingUrl());
Q_UNUSED(newUrl); Q_UNUSED(newUrl);
@@ -343,7 +343,7 @@ void CSwiftLauncher::ps_startButtonPressed()
} }
else if (sender == this->ui->tb_Database) else if (sender == this->ui->tb_Database)
{ {
CUrl homePage(this->m_setup.get().dbHomePageUrl()); const CUrl homePage(sApp->getGlobalSetup().dbHomePageUrl());
QDesktopServices::openUrl(homePage); QDesktopServices::openUrl(homePage);
} }
} }

View File

@@ -60,7 +60,6 @@ protected:
private: private:
QScopedPointer<Ui::CSwiftLauncher> ui; QScopedPointer<Ui::CSwiftLauncher> ui;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup { this, &CSwiftLauncher::ps_changedCache }; //!< setup cache
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache
QString m_executable; QString m_executable;
QStringList m_executableArgs; QStringList m_executableArgs;