refs #497, changed and improved handling of bootstrap files

* changed global setup (port, root directory)
* version for bootstrap files
This commit is contained in:
Klaus Basan
2015-10-28 17:04:49 +01:00
committed by Mathew Sutcliffe
parent 23856bbc57
commit 03f4aa6889
10 changed files with 150 additions and 80 deletions

View File

@@ -9,6 +9,7 @@
#include "globalsetup.h"
#include "blackmisc/math/mathutils.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include <QStringList>
using namespace BlackMisc;
@@ -21,29 +22,55 @@ namespace BlackCore
{
CGlobalSetup::CGlobalSetup() :
ITimestampBased(0),
m_dbIcaoReader("http://ubuntu12/vatrep/public"),
m_dbModelReader("http://ubuntu12/vatrep/public"),
m_dbRootDirectory("http://ubuntu12/swiftdatastore/public"),
m_dbHttpPort(80),
m_dbHttpsPort(443),
m_vatsimBookings("http://vatbook.euroutepro.com/xml2.php"),
m_vatsimMetars("http://metar.vatsim.net/metar.php"),
m_vatsimDataFile(QStringList({ "http://info.vroute.net/vatsim-data.txt" })),
m_bootstrap(QStringList({ "https://vatsim-germany.org:50443/mapping/public/bootstrap", "http://ubuntu12/public/bootstrap"})),
m_swiftDbDataFiles(QStringList({ })),
m_swiftDbDataFiles(QStringList({})),
m_fsdTestServers({ CServer("swift", "swift Testserver", "vatsim-germany.org", 6809, CUser("1234567", "swift Test User", "", "123456"), true) })
{ }
CUrl CGlobalSetup::dbIcaoReader() const
{
return dbRootDirectory();
}
CUrl CGlobalSetup::dbModelReader() const
{
return dbRootDirectory();
}
CUrl CGlobalSetup::dbHomePage() const
{
return dbModelReader().withAppendedPath("/page/index.php");
return dbRootDirectory().withAppendedPath("/page/index.php");
}
CUrl CGlobalSetup::dbLoginService() const
{
return dbModelReader().withAppendedPath("/service/index.php");
return dbRootDirectory().
withAppendedPath("/service/jsonauthenticate.php").
withSwitchedScheme("https", m_dbHttpsPort);
}
bool CGlobalSetup::hasSameType(const QString &type) const
bool CGlobalSetup::dbDebugFlag() const
{
return getType() == type.trimmed().toUpper();
if (!m_dbDebugFlag) { return false; }
// further checks could go here
return isDevelopment();
}
void CGlobalSetup::setServerDebugFlag(bool debug)
{
m_dbDebugFlag = debug;
}
bool CGlobalSetup::hasSameType(CGlobalSetup &otherSetup) const
{
return this->isDevelopment() == otherSetup.isDevelopment();
}
CUrl CGlobalSetup::vatsimMetars() const
@@ -61,12 +88,19 @@ namespace BlackCore
QString s("timestamp: ");
s.append(this->getFormattedUtcTimestampYmdhms());
s.append(separator);
s.append("For development: ");
s.append(boolToYesNo(isDevelopment()));
s.append(separator);
s.append("DB root directory: ");
s.append(dbRootDirectory().convertToQString(i18n));
s.append(separator);
s.append("ICAO DB reader: ");
s.append(dbIcaoReader().convertToQString(i18n));
s.append(separator);
s.append("Model DB reader: ");
s.append(dbModelReader().convertToQString(i18n));
s.append(separator);
s.append("DB home page: ");
s.append(dbHomePage().convertToQString(i18n));
s.append(separator);
@@ -101,12 +135,12 @@ namespace BlackCore
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDbIcaoReader:
return CVariant::fromValue(this->m_dbIcaoReader);
case IndexDbModelReader:
return CVariant::fromValue(this->m_dbModelReader);
case IndexDbHomePage:
return CVariant::fromValue(this->dbHomePage());
case IndexDbRootDirectory:
return CVariant::fromValue(this->m_dbRootDirectory);
case IndexDbHttpPort:
return CVariant::fromValue(this->m_dbHttpPort);
case IndexDbHttpsPort:
return CVariant::fromValue(this->m_dbHttpsPort);
case IndexDbLoginService:
return CVariant::fromValue(this->dbLoginService());
case IndexVatsimData:
@@ -136,13 +170,15 @@ namespace BlackCore
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDbIcaoReader:
this->m_dbIcaoReader.setPropertyByIndex(variant, index.copyFrontRemoved());
case IndexDbRootDirectory:
this->m_dbRootDirectory.setPropertyByIndex(variant, index.copyFrontRemoved());
break;
case IndexDbModelReader:
this->m_dbModelReader.setPropertyByIndex(variant, index.copyFrontRemoved());
case IndexDbHttpPort:
this->m_dbHttpPort = variant.toInt();
break;
case IndexDbHttpsPort:
this->m_dbHttpsPort = variant.toInt();
break;
case IndexDbHomePage:
case IndexDbLoginService:
break;
case IndexVatsimData:
@@ -165,5 +201,11 @@ namespace BlackCore
break;
}
}
const QString &CGlobalSetup::versionString()
{
static const QString v("0.6");
return v;
}
} // ns
} // ns

View File

@@ -33,9 +33,9 @@ namespace BlackCore
//! Properties by index
enum ColumnIndex
{
IndexDbIcaoReader = BlackMisc::CPropertyIndex::GlobalIndexCGlobalSetup,
IndexDbModelReader,
IndexDbHomePage,
IndexDbRootDirectory = BlackMisc::CPropertyIndex::GlobalIndexCGlobalSetup,
IndexDbHttpPort,
IndexDbHttpsPort,
IndexDbLoginService,
IndexVatsimBookings,
IndexVatsimMetars,
@@ -50,11 +50,20 @@ namespace BlackCore
//! Destructor.
~CGlobalSetup() {}
//! Root directory of DB
const BlackMisc::Network::CUrl &dbRootDirectory() const { return m_dbRootDirectory; }
//! ICAO Reader location
const BlackMisc::Network::CUrl &dbIcaoReader() const { return m_dbIcaoReader; }
BlackMisc::Network::CUrl dbIcaoReader() const;
//! Model Reader protocol
const BlackMisc::Network::CUrl &dbModelReader() const { return m_dbModelReader; }
BlackMisc::Network::CUrl dbModelReader() const;
//! Http port
int dbHttpPort() const { return m_dbHttpPort; }
//! Https port
int dbHttpsPort() const { return m_dbHttpsPort; }
//! Home page url
BlackMisc::Network::CUrl dbHomePage() const;
@@ -62,17 +71,17 @@ namespace BlackCore
//! Login service
BlackMisc::Network::CUrl dbLoginService() const;
//! Debug flag
bool dbDebugFlag() const;
//! Set debug flag
void setServerDebugFlag(bool debug);
//! URL to read VATSIM bookings
const BlackMisc::Network::CUrl &vatsimBookings() const { return m_vatsimBookings; }
//! Type (development, productive)?
const QString &getType() const { return m_type; }
//! Set type
void setType(const QString &type) { m_type = type.trimmed().toUpper(); }
//! Same type?
bool hasSameType(const QString &type) const;
bool hasSameType(CGlobalSetup &otherSetup) const;
//! VATSIM METAR URL
BlackMisc::Network::CUrl vatsimMetars() const;
@@ -89,6 +98,12 @@ namespace BlackCore
//! FSD test servers
const BlackMisc::Network::CServerList &fsdTestServers() const { return m_fsdTestServers; }
//! Productive settings?
bool isDevelopment() const { return m_development; }
//! Productive settings?
void setDevelopment(bool development) { m_development = development; }
//! \copydoc CValueObject::convertToQString
QString convertToQString(bool i18n = false) const;
@@ -101,18 +116,25 @@ namespace BlackCore
//! \copydoc CValueObject::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index);
//! Schema version
static const QString &versionString();
private:
BLACK_ENABLE_TUPLE_CONVERSION(BlackCore::Data::CGlobalSetup)
QString m_type; //!< dev./productive?
BlackMisc::Network::CUrl m_dbIcaoReader; //!< direct DB ICAO reader
BlackMisc::Network::CUrl m_dbModelReader; //!< direct DB model reader
BlackMisc::Network::CUrl m_vatsimBookings; //!< ATC bookings
BlackMisc::Network::CUrl m_vatsimMetars; //!< METAR data
BlackMisc::Network::CUrlList m_vatsimDataFile; //!< Overall VATSIM data file
BlackMisc::Network::CUrlList m_bootstrap; //!< where we can obtain downloads of these data
BlackMisc::Network::CUrlList m_swiftDbDataFiles; //!< alternative locations of the DB files, if DB is not available
BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers
BlackMisc::Network::CUrl m_dbRootDirectory; //!< Root directory
int m_dbHttpPort = 80; //!< port
int m_dbHttpsPort = 443; //!< SSL port
BlackMisc::Network::CUrl m_vatsimBookings; //!< ATC bookings
BlackMisc::Network::CUrl m_vatsimMetars; //!< METAR data
BlackMisc::Network::CUrlList m_vatsimDataFile; //!< Overall VATSIM data file
BlackMisc::Network::CUrlList m_bootstrap; //!< where we can obtain downloads of these data
BlackMisc::Network::CUrlList m_swiftDbDataFiles; //!< alternative locations of the DB files, if DB is not available
BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers
bool m_development = false; //!< dev. version?
// 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 hat you are doing
};
//! Trait for for global setup data
@@ -135,15 +157,16 @@ namespace BlackCore
Q_DECLARE_METATYPE(BlackCore::Data::CGlobalSetup)
BLACK_DECLARE_TUPLE_CONVERSION(BlackCore::Data::CGlobalSetup, (
attr(o.m_timestampMSecsSinceEpoch),
attr(o.m_type),
attr(o.m_dbIcaoReader),
attr(o.m_dbModelReader),
attr(o.m_dbRootDirectory),
attr(o.m_dbHttpPort),
attr(o.m_dbHttpsPort),
attr(o.m_vatsimBookings),
attr(o.m_vatsimMetars),
attr(o.m_vatsimDataFile),
attr(o.m_bootstrap),
attr(o.m_swiftDbDataFiles),
attr(o.m_fsdTestServers)
attr(o.m_fsdTestServers),
attr(o.m_development),
attr(o.m_dbDebugFlag, flags < DisabledForJson > ())
))
#endif // guard