refactor: Remove dev flag from bootstrap json

With this, the database debug flag can only be activated when using swift
with a development build. Setting the development flag in the json also
didn't worked previously as expected because the corresponding function
to get the flag in application.cpp was called before the setup was loaded.
This commit is contained in:
Lars Toenning
2024-02-04 17:23:12 +01:00
parent 5842cb627a
commit da552d60cc
11 changed files with 4 additions and 203 deletions

View File

@@ -8,7 +8,6 @@
"dbRootDirectoryUrl": { "dbRootDirectoryUrl": {
"url": "https://datastore.swift-project.org/" "url": "https://datastore.swift-project.org/"
}, },
"development": false,
"mappingMinimumVersion": "0.9.0", "mappingMinimumVersion": "0.9.0",
"ncepGlobalForecastSystemUrl": { "ncepGlobalForecastSystemUrl": {
"url": "http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl" "url": "http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl"

View File

@@ -686,8 +686,6 @@
{ include: [ "\"dbownmodelsetdialog.h\"", "private", "\"blackgui/components/dbownmodelsetdialog.h\"", "public" ] }, { include: [ "\"dbownmodelsetdialog.h\"", "private", "\"blackgui/components/dbownmodelsetdialog.h\"", "public" ] },
{ include: [ "\"components/settingssimulatorcomponent.h\"", "private", "\"blackgui/components/settingssimulatorcomponent.h\"", "public" ] }, { include: [ "\"components/settingssimulatorcomponent.h\"", "private", "\"blackgui/components/settingssimulatorcomponent.h\"", "public" ] },
{ include: [ "\"settingssimulatorcomponent.h\"", "private", "\"blackgui/components/settingssimulatorcomponent.h\"", "public" ] }, { include: [ "\"settingssimulatorcomponent.h\"", "private", "\"blackgui/components/settingssimulatorcomponent.h\"", "public" ] },
{ include: [ "\"components/dbdebugdatabasesetup.h\"", "private", "\"blackgui/components/dbdebugdatabasesetup.h\"", "public" ] },
{ include: [ "\"dbdebugdatabasesetup.h\"", "private", "\"blackgui/components/dbdebugdatabasesetup.h\"", "public" ] },
{ include: [ "\"components/internalscomponent.h\"", "private", "\"blackgui/components/internalscomponent.h\"", "public" ] }, { include: [ "\"components/internalscomponent.h\"", "private", "\"blackgui/components/internalscomponent.h\"", "public" ] },
{ include: [ "\"internalscomponent.h\"", "private", "\"blackgui/components/internalscomponent.h\"", "public" ] }, { include: [ "\"internalscomponent.h\"", "private", "\"blackgui/components/internalscomponent.h\"", "public" ] },
{ include: [ "\"components/modelmatchercomponent.h\"", "private", "\"blackgui/components/modelmatchercomponent.h\"", "public" ] }, { include: [ "\"components/modelmatchercomponent.h\"", "private", "\"blackgui/components/modelmatchercomponent.h\"", "public" ] },

View File

@@ -533,12 +533,6 @@ namespace BlackCore
const CDistribution d(this->getOwnDistribution()); const CDistribution d(this->getOwnDistribution());
if (d.isRestricted() && this->isSet(m_cmdDevelopment)) { return true; } if (d.isRestricted() && this->isSet(m_cmdDevelopment)) { return true; }
// we can globally set a dev.flag
if (this->isSetupAvailable())
{
// assume value from setup
return this->getGlobalSetup().isDevelopment();
}
return false; return false;
} }

View File

@@ -171,11 +171,7 @@ namespace BlackCore::Data
bool CGlobalSetup::dbDebugFlag() const bool CGlobalSetup::dbDebugFlag() const
{ {
if (!m_dbDebugFlag) { return false; } return m_dbDebugFlag && CBuildConfig::isLocalDeveloperDebugBuild();
// further checks could go here
const bool f = this->isDevelopment() || CBuildConfig::isLocalDeveloperDebugBuild();
return f;
} }
void CGlobalSetup::setServerDebugFlag(bool debug) void CGlobalSetup::setServerDebugFlag(bool debug)
@@ -183,11 +179,6 @@ namespace BlackCore::Data
m_dbDebugFlag = debug; m_dbDebugFlag = debug;
} }
bool CGlobalSetup::hasSameType(const CGlobalSetup &otherSetup) const
{
return this->isDevelopment() == otherSetup.isDevelopment();
}
QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate) QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate)
{ {
if (candidate.isEmpty()) return {}; // not possible if (candidate.isEmpty()) return {}; // not possible
@@ -268,8 +259,6 @@ namespace BlackCore::Data
QString s = QString s =
u"timestamp: " % this->getFormattedUtcTimestampYmdhms() % separator % u"Global setup loaded: " % boolToYesNo(this->wasLoadedFromFile()) % separator u"timestamp: " % this->getFormattedUtcTimestampYmdhms() % separator % u"Global setup loaded: " % boolToYesNo(this->wasLoadedFromFile()) % separator
% u"For development: " % boolToYesNo(isDevelopment()) % separator
% u"Mapping min.version: " % this->getMappingMinimumVersionString() % separator % u"Mapping min.version: " % this->getMappingMinimumVersionString() % separator
% u"Distribution URLs: " % getSwiftUpdateInfoFileUrls().toQString(i18n) % separator % u"Bootstrap URLs: " % getSwiftBootstrapFileUrls().toQString(i18n) % separator % u"Help URLs: " % m_onlineHelpUrls.toQString(i18n) % separator; % u"Distribution URLs: " % getSwiftUpdateInfoFileUrls().toQString(i18n) % separator % u"Bootstrap URLs: " % getSwiftBootstrapFileUrls().toQString(i18n) % separator % u"Help URLs: " % m_onlineHelpUrls.toQString(i18n) % separator;

View File

@@ -93,9 +93,6 @@ namespace BlackCore::Data
//! Set debug flag //! Set debug flag
void setServerDebugFlag(bool debug); void setServerDebugFlag(bool debug);
//! Same type?
bool hasSameType(const CGlobalSetup &otherSetup) const;
//! Crash report server url //! Crash report server url
//! \deprecated NOT used anymore as by RR's info: https://discordapp.com/channels/539048679160676382/539925070550794240/586879411002015756 //! \deprecated NOT used anymore as by RR's info: https://discordapp.com/channels/539048679160676382/539925070550794240/586879411002015756
BlackMisc::Network::CUrl getCrashReportServerUrl() const { return m_crashReportServerUrl; } BlackMisc::Network::CUrl getCrashReportServerUrl() const { return m_crashReportServerUrl; }
@@ -184,9 +181,6 @@ namespace BlackCore::Data
//! Predefined plus hardcoded //! Predefined plus hardcoded
BlackMisc::Network::CServerList getPredefinedServersPlusHardcodedServers() const; BlackMisc::Network::CServerList getPredefinedServersPlusHardcodedServers() const;
//! Is server a development server?
bool isDevelopment() const { return m_development; }
//! Creating mappings requires at least this version or higher //! Creating mappings requires at least this version or higher
//! \remark only valid if wasLoaded() is \c true //! \remark only valid if wasLoaded() is \c true
const QString &getMappingMinimumVersionString() const { return m_mappingMinimumVersion; } const QString &getMappingMinimumVersionString() const { return m_mappingMinimumVersion; }
@@ -195,9 +189,6 @@ namespace BlackCore::Data
//! \remark only valid if wasLoaded() is \c true //! \remark only valid if wasLoaded() is \c true
bool isSwiftVersionMinimumMappingVersion() const; bool isSwiftVersionMinimumMappingVersion() const;
//! Productive settings?
void setDevelopment(bool development) { m_development = development; }
//! NCEP GFS Forecasts (0.50 degree grid) data url //! NCEP GFS Forecasts (0.50 degree grid) data url
BlackMisc::Network::CUrl getNcepGlobalForecastSystemUrl() const { return m_ncepGlobalForecastSystemUrl; } BlackMisc::Network::CUrl getNcepGlobalForecastSystemUrl() const { return m_ncepGlobalForecastSystemUrl; }
@@ -239,7 +230,6 @@ namespace BlackCore::Data
int m_dbHttpPort = 80; //!< port int m_dbHttpPort = 80; //!< port
int m_dbHttpsPort = 443; //!< SSL port int m_dbHttpsPort = 443; //!< SSL port
qint64 m_pingIntervalSecs = 180; //!< seconds between datastore pings qint64 m_pingIntervalSecs = 180; //!< seconds between datastore pings
bool m_development = false; //!< dev. version?
QString m_mappingMinimumVersion; //!< minimum version QString m_mappingMinimumVersion; //!< minimum version
BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server
BlackMisc::Network::CUrl m_dbRootDirectoryUrl; //!< Root directory of DB BlackMisc::Network::CUrl m_dbRootDirectoryUrl; //!< Root directory of DB
@@ -255,9 +245,7 @@ namespace BlackCore::Data
BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl25; //!< NCEP GFS url 0.25 degree resolution BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl25; //!< NCEP GFS url 0.25 degree resolution
BlackMisc::Network::CUrl m_comNavEquipmentHelpUrl; //!< Help URL for COM/NAV equipment codes BlackMisc::Network::CUrl m_comNavEquipmentHelpUrl; //!< Help URL for COM/NAV equipment codes
BlackMisc::Network::CUrl m_ssrEquipmentHelpUrl; //!< Help URL for SSR equipment codes BlackMisc::Network::CUrl m_ssrEquipmentHelpUrl; //!< Help URL for SSR equipment codes
bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing. Only works with CBuildConfig::isLocalDeveloperDebugBuild
// transient members, to be switched on/off via GUI or set from reader
bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing
//! Set the default URLs //! Set the default URLs
void initDefaultValues(); void initDefaultValues();
@@ -279,13 +267,12 @@ namespace BlackCore::Data
BLACK_METAMEMBER(sharedUrls), BLACK_METAMEMBER(sharedUrls),
BLACK_METAMEMBER(onlineHelpUrls), BLACK_METAMEMBER(onlineHelpUrls),
BLACK_METAMEMBER(predefinedServers), BLACK_METAMEMBER(predefinedServers),
BLACK_METAMEMBER(development),
BLACK_METAMEMBER(mappingMinimumVersion), BLACK_METAMEMBER(mappingMinimumVersion),
BLACK_METAMEMBER(ncepGlobalForecastSystemUrl), BLACK_METAMEMBER(ncepGlobalForecastSystemUrl),
BLACK_METAMEMBER(ncepGlobalForecastSystemUrl25), BLACK_METAMEMBER(ncepGlobalForecastSystemUrl25),
BLACK_METAMEMBER(comNavEquipmentHelpUrl), BLACK_METAMEMBER(comNavEquipmentHelpUrl),
BLACK_METAMEMBER(ssrEquipmentHelpUrl), BLACK_METAMEMBER(ssrEquipmentHelpUrl),
BLACK_METAMEMBER(dbDebugFlag, BlackMisc::DisabledForJson) BLACK_METAMEMBER(dbDebugFlag)
); );
}; };

View File

@@ -364,7 +364,6 @@ add_library(gui SHARED
components/autopublishcomponent.h components/autopublishcomponent.h
components/audioadvanceddistributeddialog.ui components/audioadvanceddistributeddialog.ui
components/settingsadvancedcomponent.h components/settingsadvancedcomponent.h
components/dbdebugdatabasesetup.h
components/copyconfigurationcomponent.h components/copyconfigurationcomponent.h
components/airportdialog.h components/airportdialog.h
components/settingsmatchingdialog.cpp components/settingsmatchingdialog.cpp
@@ -537,7 +536,6 @@ add_library(gui SHARED
components/interpolationcomponent.ui components/interpolationcomponent.ui
components/dbownmodelsetformdialog.h components/dbownmodelsetformdialog.h
components/airportcompleter.cpp components/airportcompleter.cpp
components/dbdebugdatabasesetup.cpp
components/modelmatcherlogenable.h components/modelmatcherlogenable.h
components/updateinfocomponent.h components/updateinfocomponent.h
components/countryselector.cpp components/countryselector.cpp
@@ -648,7 +646,6 @@ add_library(gui SHARED
components/settingsviewupdatetimes.ui components/settingsviewupdatetimes.ui
components/airportcompleter.h components/airportcompleter.h
components/cockpitinfoareacomponent.cpp components/cockpitinfoareacomponent.cpp
components/dbdebugdatabasesetup.ui
components/cockpittranspondermodeledscomponent.cpp components/cockpittranspondermodeledscomponent.cpp
components/installfsxterrainprobecomponent.h components/installfsxterrainprobecomponent.h
components/interpolationlogdisplay.h components/interpolationlogdisplay.h

View File

@@ -1,41 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
#include "blackgui/components/dbdebugdatabasesetup.h"
#include "blackgui/guiapplication.h"
#include "ui_dbdebugdatabasesetup.h"
#include <QCheckBox>
using namespace BlackCore::Data;
using namespace BlackMisc;
namespace BlackGui::Components
{
CDbDebugDatabaseSetup::CDbDebugDatabaseSetup(QWidget *parent) : QFrame(parent),
ui(new Ui::CDbDebugDatabaseSetup)
{
ui->setupUi(this);
const bool enabled = sGui->isDeveloperFlagSet();
this->setEnabled(enabled);
if (!enabled)
{
this->setToolTip("Disabled, cannot be set!");
}
else
{
connect(ui->cb_EnableServerDebugging, &QCheckBox::toggled, this, &CDbDebugDatabaseSetup::onDebugChanged);
}
}
CDbDebugDatabaseSetup::~CDbDebugDatabaseSetup()
{}
void CDbDebugDatabaseSetup::onDebugChanged(bool set)
{
CGlobalSetup gs(m_setup.getThreadLocal());
gs.setServerDebugFlag(set);
m_setup.set(gs);
}
} // ns

View File

@@ -1,47 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
//! \file
#ifndef BLACKGUI_COMPONENTS_DBDEBUGDATABASESETUP_H
#define BLACKGUI_COMPONENTS_DBDEBUGDATABASESETUP_H
#include "blackcore/data/globalsetup.h"
#include "blackgui/blackguiexport.h"
#include "blackmisc/datacache.h"
#include <QFrame>
#include <QObject>
#include <QScopedPointer>
namespace Ui
{
class CDbDebugDatabaseSetup;
}
namespace BlackGui::Components
{
/*!
* Debug settings for DB (only to be used as developer)
* \remarks Disabled when not runnig in dev.environment
*/
class BLACKGUI_EXPORT CDbDebugDatabaseSetup : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CDbDebugDatabaseSetup(QWidget *parent = nullptr);
//! Dstructor
~CDbDebugDatabaseSetup();
private:
//! Changed the debug checkbox
void onDebugChanged(bool set);
QScopedPointer<Ui::CDbDebugDatabaseSetup> ui;
BlackMisc::CData<BlackCore::Data::TGlobalSetup> m_setup { this }; //!< data cache
};
} // ns
#endif // guard

View File

@@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbDebugDatabaseSetup</class>
<widget class="QFrame" name="CDbDebugDatabaseSetup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>176</width>
<height>40</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="lbl_EnableWebServerDebugging">
<property name="text">
<string>Server debug flag:</string>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignLeft">
<widget class="QCheckBox" name="cb_EnableServerDebugging">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="hs_DebugDatabaseSetup">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -49,9 +49,6 @@ namespace BlackGui::Components
ui->tbr_InfoAndHints->setHtml(html); ui->tbr_InfoAndHints->setHtml(html);
ui->tbr_InfoAndHints->setOpenExternalLinks(true); ui->tbr_InfoAndHints->setOpenExternalLinks(true);
const bool devEnv = sGui->isDeveloperFlagSet();
ui->comp_DebugSetup->setVisible(devEnv);
const QString dbUrl = sGui->getGlobalSetup().getDbHomePageUrl().toQString(); const QString dbUrl = sGui->getGlobalSetup().getDbHomePageUrl().toQString();
ui->lbl_DatabaseName->setText(asHyperlink(dbUrl)); ui->lbl_DatabaseName->setText(asHyperlink(dbUrl));
ui->lbl_DatabaseName->setTextFormat(Qt::RichText); ui->lbl_DatabaseName->setTextFormat(Qt::RichText);

View File

@@ -88,16 +88,6 @@
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="5" column="0" colspan="3">
<widget class="BlackGui::Components::CDbDebugDatabaseSetup" name="comp_DebugSetup">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item row="3" column="2"> <item row="3" column="2">
<widget class="QWidget" name="wi_Button" native="true"> <widget class="QWidget" name="wi_Button" native="true">
<layout class="QHBoxLayout" name="hl_LoginFrame"> <layout class="QHBoxLayout" name="hl_LoginFrame">
@@ -152,7 +142,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="6" column="0"> <item row="5" column="0">
<spacer name="vs_FrameLogin"> <spacer name="vs_FrameLogin">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@@ -406,14 +396,6 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CDbDebugDatabaseSetup</class>
<extends>QFrame</extends>
<header>blackgui/components/dbdebugdatabasesetup.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops> <tabstops>
<tabstop>tb_LoginToDbAndHints</tabstop> <tabstop>tb_LoginToDbAndHints</tabstop>
<tabstop>le_Username</tabstop> <tabstop>le_Username</tabstop>