Server handling

* added tower view as hardcoded
* renamed to predefined servers
* utility functions to add/remove FSD setup flags
This commit is contained in:
Klaus Basan
2018-11-29 00:02:04 +01:00
parent 2dd43226ba
commit 394147dcb9
12 changed files with 132 additions and 82 deletions

View File

@@ -250,10 +250,10 @@ namespace BlackCore
return m_mapUrls;
}
CServerList CGlobalSetup::getFsdTestServersPlusHardcodedServers() const
CServerList CGlobalSetup::getPredefinedServersPlusHardcodedServers() const
{
static const CServerList hardcoded({ CServer::swiftFsdTestServer(), CServer::fscServer() });
CServerList testServers(m_fsdTestServers);
static const CServerList hardcoded({ CServer::swiftFsdTestServer(), CServer::fscServer(), CServer::esTowerView() });
CServerList testServers(m_predefinedServers);
testServers.addIfAddressNotExists(hardcoded);
return testServers;
}
@@ -338,8 +338,8 @@ namespace BlackCore
% getVatsimDataFileUrls().toQString(i18n)
% separator
% QStringLiteral("FSD test servers: ")
% getFsdTestServers().toQString(i18n)
% QStringLiteral("Predefined servers: ")
% getPredefinedServers().toQString(i18n)
% separator
% QStringLiteral("Crash report server: ")
@@ -356,26 +356,27 @@ namespace BlackCore
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDbRootDirectory: return CVariant::fromValue(m_dbRootDirectoryUrl);
case IndexDbHttpPort: return CVariant::fromValue(m_dbHttpPort);
case IndexDbHttpsPort: return CVariant::fromValue(m_dbHttpsPort);
case IndexDbLoginService: return CVariant::fromValue(this->getDbLoginServiceUrl());
case IndexDbClientPingService: return CVariant::fromValue(this->getDbClientPingServiceUrl());
case IndexVatsimStatus: return CVariant::fromValue(m_vatsimStatusFileUrls);
case IndexVatsimData: return CVariant::fromValue(m_vatsimDataFileUrls);
case IndexVatsimBookings: return CVariant::fromValue(m_vatsimDataFileUrls);
case IndexVatsimMetars: return CVariant::fromValue(m_vatsimMetarsUrls);
case IndexBootstrapFileUrls: return CVariant::fromValue(this->getSwiftBootstrapFileUrls());
case IndexUpdateInfoFileUrls: return CVariant::fromValue(this->getSwiftUpdateInfoFileUrls());
case IndexSharedUrls: return CVariant::fromValue(m_sharedUrls);
case IndexNewsUrls: return CVariant::fromValue(m_newsUrls);
case IndexSwiftMapUrls: return CVariant::fromValue(m_mapUrls);
case IndexOnlineHelpUrls: return CVariant::fromValue(m_onlineHelpUrls);
case IndexCrashReportServerUrl: return CVariant::fromValue(m_crashReportServerUrl);
case IndexWasLoadedFromWeb: return CVariant::fromValue(m_wasLoadedFromWeb);
case IndexWasLoadedFromFile: return CVariant::fromValue(m_wasLoadedFromFile);
case IndexDbRootDirectory: return CVariant::fromValue(m_dbRootDirectoryUrl);
case IndexDbHttpPort: return CVariant::fromValue(m_dbHttpPort);
case IndexDbHttpsPort: return CVariant::fromValue(m_dbHttpsPort);
case IndexDbLoginService: return CVariant::fromValue(this->getDbLoginServiceUrl());
case IndexDbClientPingService: return CVariant::fromValue(this->getDbClientPingServiceUrl());
case IndexVatsimStatus: return CVariant::fromValue(m_vatsimStatusFileUrls);
case IndexVatsimData: return CVariant::fromValue(m_vatsimDataFileUrls);
case IndexVatsimBookings: return CVariant::fromValue(m_vatsimDataFileUrls);
case IndexVatsimMetars: return CVariant::fromValue(m_vatsimMetarsUrls);
case IndexBootstrapFileUrls: return CVariant::fromValue(this->getSwiftBootstrapFileUrls());
case IndexUpdateInfoFileUrls: return CVariant::fromValue(this->getSwiftUpdateInfoFileUrls());
case IndexSharedUrls: return CVariant::fromValue(m_sharedUrls);
case IndexNewsUrls: return CVariant::fromValue(m_newsUrls);
case IndexSwiftMapUrls: return CVariant::fromValue(m_mapUrls);
case IndexOnlineHelpUrls: return CVariant::fromValue(m_onlineHelpUrls);
case IndexCrashReportServerUrl: return CVariant::fromValue(m_crashReportServerUrl);
case IndexWasLoadedFromWeb: return CVariant::fromValue(m_wasLoadedFromWeb);
case IndexWasLoadedFromFile: return CVariant::fromValue(m_wasLoadedFromFile);
case IndexMappingMinimumVersion: return CVariant::fromValue(m_mappingMinimumVersion);
default: return CValueObject::propertyByIndex(index);
case IndexPredefinedServers: return CVariant::fromValue(m_predefinedServers);
default: return CValueObject::propertyByIndex(index);
}
}
@@ -391,22 +392,23 @@ namespace BlackCore
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDbRootDirectory: m_dbRootDirectoryUrl.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexDbHttpPort: m_dbHttpPort = variant.toInt(); break;
case IndexDbHttpsPort: m_dbHttpsPort = variant.toInt(); break;
case IndexDbLoginService: break; // cannot be changed
case IndexDbClientPingService: break; // cannot be changed
case IndexVatsimData: m_vatsimDataFileUrls = variant.value<CUrlList>(); break;
case IndexVatsimBookings: m_vatsimBookingsUrl.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexVatsimMetars: m_vatsimMetarsUrls = variant.value<CUrlList>(); break;
case IndexSharedUrls: m_sharedUrls = variant.value<CUrlList>(); break;
case IndexNewsUrls: m_newsUrls = variant.value<CUrlList>(); break;
case IndexOnlineHelpUrls: m_onlineHelpUrls = variant.value<CUrlList>(); break;
case IndexSwiftMapUrls: m_mapUrls = variant.value<CUrlList>(); break;
case IndexCrashReportServerUrl: m_crashReportServerUrl = variant.value<CUrl>(); break;
case IndexWasLoadedFromWeb: m_wasLoadedFromWeb = variant.toBool(); break;
case IndexWasLoadedFromFile: m_wasLoadedFromFile = variant.toBool(); break;
case IndexDbRootDirectory: m_dbRootDirectoryUrl.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexDbHttpPort: m_dbHttpPort = variant.toInt(); break;
case IndexDbHttpsPort: m_dbHttpsPort = variant.toInt(); break;
case IndexDbLoginService: break; // cannot be changed
case IndexDbClientPingService: break; // cannot be changed
case IndexVatsimData: m_vatsimDataFileUrls = variant.value<CUrlList>(); break;
case IndexVatsimBookings: m_vatsimBookingsUrl.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexVatsimMetars: m_vatsimMetarsUrls = variant.value<CUrlList>(); break;
case IndexSharedUrls: m_sharedUrls = variant.value<CUrlList>(); break;
case IndexNewsUrls: m_newsUrls = variant.value<CUrlList>(); break;
case IndexOnlineHelpUrls: m_onlineHelpUrls = variant.value<CUrlList>(); break;
case IndexSwiftMapUrls: m_mapUrls = variant.value<CUrlList>(); break;
case IndexCrashReportServerUrl: m_crashReportServerUrl = variant.value<CUrl>(); break;
case IndexWasLoadedFromWeb: m_wasLoadedFromWeb = variant.toBool(); break;
case IndexWasLoadedFromFile: m_wasLoadedFromFile = variant.toBool(); break;
case IndexMappingMinimumVersion: m_mappingMinimumVersion = variant.toQString(); break;
case IndexPredefinedServers: m_predefinedServers = variant.value<CServerList>(); break;
default: CValueObject::setPropertyByIndex(index, variant); break;
}
}

View File

@@ -61,7 +61,8 @@ namespace BlackCore
IndexWasLoadedFromWeb,
IndexWasLoadedFromFile,
IndexSharedUrls,
IndexMappingMinimumVersion
IndexMappingMinimumVersion,
IndexPredefinedServers
};
//! Add info when pinging
@@ -189,11 +190,11 @@ namespace BlackCore
//! swift map URLs
const BlackMisc::Network::CUrlList &getSwiftMapUrls() const;
//! FSD test servers
const BlackMisc::Network::CServerList &getFsdTestServers() const { return m_fsdTestServers; }
//! Predefined servers
const BlackMisc::Network::CServerList &getPredefinedServers() const { return m_predefinedServers; }
//! FSD test servers plus hardcoded
BlackMisc::Network::CServerList getFsdTestServersPlusHardcodedServers() const;
//! Predefined plus hardcoded
BlackMisc::Network::CServerList getPredefinedServersPlusHardcodedServers() const;
//! Is server a development server?
bool isDevelopment() const { return m_development; }
@@ -239,7 +240,7 @@ namespace BlackCore
private:
bool m_wasLoadedFromWeb = false; //!< Loaded from web
bool m_wasLoadedFromFile = false; //!< Loaded from local file
int m_dbHttpPort = 80; //!< port
int m_dbHttpPort = 80; //!< port
int m_dbHttpsPort = 443; //!< SSL port
bool m_development = false; //!< dev. version?
QString m_mappingMinimumVersion; //!< minimum version
@@ -253,7 +254,7 @@ namespace BlackCore
BlackMisc::Network::CUrlList m_newsUrls; //!< where we can obtain latest news
BlackMisc::Network::CUrlList m_onlineHelpUrls; //!< online help URLs
BlackMisc::Network::CUrlList m_mapUrls; //!< swift map URLs
BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers loaded from setup file
BlackMisc::Network::CServerList m_predefinedServers; //!< Predefined servers loaded from setup file
BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl; //!< NCEP GFS url
// transient members, to be switched on/off via GUI or set from reader
@@ -279,7 +280,7 @@ namespace BlackCore
BLACK_METAMEMBER(newsUrls),
BLACK_METAMEMBER(onlineHelpUrls),
BLACK_METAMEMBER(mapUrls),
BLACK_METAMEMBER(fsdTestServers),
BLACK_METAMEMBER(predefinedServers),
BLACK_METAMEMBER(development),
BLACK_METAMEMBER(mappingMinimumVersion),
BLACK_METAMEMBER(ncepGlobalForecastSystemUrl),

View File

@@ -52,13 +52,20 @@ namespace BlackCore
return m_otherTrafficNetworkServers.get();
}
CServerList CNetworkSetup::getOtherServersPlusTestServers() const
CServerList CNetworkSetup::getOtherServersPlusPredefinedServers() const
{
// add a testserver when no servers can be loaded
CServerList otherServers(this->getOtherServers());
if (otherServers.isEmpty() && CBuildConfig::isLocalDeveloperDebugBuild())
if (sApp)
{
otherServers.push_back(sApp->getGlobalSetup().getFsdTestServersPlusHardcodedServers());
if (otherServers.isEmpty() && CBuildConfig::isLocalDeveloperDebugBuild())
{
otherServers.addIfAddressNotExists(sApp->getGlobalSetup().getPredefinedServersPlusHardcodedServers());
}
else
{
otherServers.addIfAddressNotExists(sApp->getGlobalSetup().getPredefinedServers());
}
}
return otherServers;
}

View File

@@ -64,7 +64,7 @@ namespace BlackCore
BlackMisc::Network::CServerList getOtherServers() const;
//! The other servers plus test servers
BlackMisc::Network::CServerList getOtherServersPlusTestServers() const;
BlackMisc::Network::CServerList getOtherServersPlusPredefinedServers() const;
//! Last used with VATSIM?
bool wasLastUsedWithVatsim() const;

View File

@@ -73,7 +73,7 @@ namespace BlackCore
//! Set all URLs and indicate if something has changed
bool setUrls(const BlackMisc::Network::CUrlList &dataFileUrls, const BlackMisc::Network::CUrlList &serverFileUrls, const BlackMisc::Network::CUrlList &metarFileUrls);
//! FSD test servers
//! FSD servers
const BlackMisc::Network::CServerList &getFsdServers() const { return m_fsdServers; }
//! Set FSD servers

View File

@@ -154,7 +154,7 @@ namespace BlackGui
this->validateAircraftValues();
ui->form_Pilot->validate();
this->onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1);
const CServerList otherServers(m_networkSetup.getOtherServersPlusTestServers());
const CServerList otherServers(m_networkSetup.getOtherServersPlusPredefinedServers());
ui->comp_OtherServers->setServers(otherServers);
ui->cb_AutoLogoff->setChecked(m_networkSetup.useAutoLogoff());

View File

@@ -62,7 +62,7 @@ namespace BlackGui
// this is debug/bootstrap feature we can continue to test when something goes wrong
if (serverList.isEmpty() && CBuildConfig::isLocalDeveloperDebugBuild())
{
serverList.push_back(sGui->getGlobalSetup().getFsdTestServersPlusHardcodedServers());
serverList.push_back(sGui->getGlobalSetup().getPredefinedServersPlusHardcodedServers());
}
ui->tvp_Servers->updateContainer(serverList);
}

View File

@@ -53,6 +53,7 @@ namespace BlackMisc
AllParts = SendAircraftParts | ReceiveAircraftParts, //!< send/receive parts
AllSendingWithoutGnd = SendAircraftParts | SendInterimPositions, //!< all out, but no gnd.flag
AllReceiveWithoutGnd = ReceiveAircraftParts | ReceiveInterimPositions, //!< all in, but no gnd.flag
AllInterimPositions = SendInterimPositions | ReceiveInterimPositions, //!< all interim positions
AllWithoutGnd = AllReceiveWithoutGnd | AllSendingWithoutGnd, //!< all, but no gnd.flag
VATSIMDefault = AllParts | Force3LetterAirlineICAO
};
@@ -86,6 +87,12 @@ namespace BlackMisc
//! Set send / receive details
void setSendReceiveDetails(SendReceiveDetails sendReceive) { m_sendReceive = sendReceive; }
//! Add send / receive details
void addSendReceiveDetails(SendReceiveDetails sendReceive) { m_sendReceive |= sendReceive; }
//! Remove send / receive details
void removeSendReceiveDetails(SendReceiveDetails sendReceive) { m_sendReceive &= ~sendReceive; }
//! Set send / receive details
void setSendReceiveDetails(bool partsSend, bool partsReceive, bool gndSend, bool gndReceive, bool interimSend, bool interimReceive);

View File

@@ -79,12 +79,25 @@ namespace BlackMisc
const CServer &CServer::fscServer()
{
static const CServer fsc("FSC", "FSC e.V.", "OBF:AwJIKfgkQDJEIRnno29DJlB+UK0=", 6809,
CUser(),
CFsdSetup(), CVoiceSetup(), CEcosystem(CEcosystem::privateFsd()), CServer::FSDServer);
static const CServer fsc = []
{
CServer s = CServer("FSC", "FSC e.V.", "OBF:AwJIKfgkQDJEIRnno29DJlB+UK0=", 6809,
CUser(),
CFsdSetup(), CVoiceSetup(), CEcosystem(CEcosystem::privateFsd()), CServer::FSDServer);
s.removeSendReceiveDetails(CFsdSetup::AllInterimPositions);
return s;
}();
return fsc;
}
const CServer &CServer::esTowerView()
{
static const CServer s = CServer("ES Tower", "Euroscope Tower view", "localhost", 6809,
CUser(),
CFsdSetup::vatsimStandard(), CVoiceSetup::vatsimStandard(), CEcosystem(CEcosystem::vatsim()), CServer::VoiceServerVatsim);
return s;
}
bool CServer::matchesName(const QString &name) const
{
return m_name.length() == name.length() &&
@@ -189,17 +202,17 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexAddress: return CVariant::fromValue(m_address);
case IndexDescription: return CVariant::fromValue(m_description);
case IndexName: return CVariant::fromValue(m_name);
case IndexPort: return CVariant::fromValue(m_port);
case IndexUser: return m_user.propertyByIndex(index.copyFrontRemoved());
case IndexFsdSetup: return m_fsdSetup.propertyByIndex(index.copyFrontRemoved());
case IndexVoiceSetup: return m_voiceSetup.propertyByIndex(index.copyFrontRemoved());
case IndexEcosystem: return m_ecosystem.propertyByIndex(index.copyFrontRemoved());
case IndexAddress: return CVariant::fromValue(m_address);
case IndexDescription: return CVariant::fromValue(m_description);
case IndexName: return CVariant::fromValue(m_name);
case IndexPort: return CVariant::fromValue(m_port);
case IndexUser: return m_user.propertyByIndex(index.copyFrontRemoved());
case IndexFsdSetup: return m_fsdSetup.propertyByIndex(index.copyFrontRemoved());
case IndexVoiceSetup: return m_voiceSetup.propertyByIndex(index.copyFrontRemoved());
case IndexEcosystem: return m_ecosystem.propertyByIndex(index.copyFrontRemoved());
case IndexIsAcceptingConnections: return CVariant::fromValue(m_isAcceptingConnections);
case IndexServerType: return CVariant::fromValue(m_serverType);
case IndexServerTypeAsString: return CVariant::fromValue(getServerTypeAsString());
case IndexServerType: return CVariant::fromValue(m_serverType);
case IndexServerTypeAsString: return CVariant::fromValue(getServerTypeAsString());
default: return CValueObject::propertyByIndex(index);
}
}
@@ -212,16 +225,16 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexAddress: this->setAddress(variant.value<QString>()); break;
case IndexPort: this->setPort(variant.value<qint32>()); break;
case IndexAddress: this->setAddress(variant.value<QString>()); break;
case IndexPort: this->setPort(variant.value<qint32>()); break;
case IndexDescription: this->setDescription(variant.value<QString>()); break;
case IndexName: this->setName(variant.value<QString>()); break;
case IndexUser: m_user.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexFsdSetup: m_fsdSetup.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexVoiceSetup: m_voiceSetup.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexEcosystem: m_ecosystem.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexName: this->setName(variant.value<QString>()); break;
case IndexUser: m_user.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexFsdSetup: m_fsdSetup.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexVoiceSetup: m_voiceSetup.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexEcosystem: m_ecosystem.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexServerType: this->setServerType(static_cast<ServerType>(variant.toInt())); break;
case IndexIsAcceptingConnections: this->setIsAcceptingConnections(variant.value<bool>()); break;
case IndexServerType: this->setServerType(static_cast<ServerType>(variant.toInt())); break;
default: CValueObject::setPropertyByIndex(index, variant); break;
}
}
@@ -233,15 +246,15 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexAddress: return this->getAddress().compare(compareValue.getAddress(), Qt::CaseInsensitive);
case IndexAddress: return this->getAddress().compare(compareValue.getAddress(), Qt::CaseInsensitive);
case IndexDescription: return this->getDescription().compare(compareValue.getDescription(), Qt::CaseInsensitive);
case IndexFsdSetup: return m_fsdSetup.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFsdSetup());
case IndexVoiceSetup: return m_voiceSetup.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getVoiceSetup());
case IndexName: return this->getName().compare(compareValue.getName(), Qt::CaseInsensitive);
case IndexFsdSetup: return m_fsdSetup.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFsdSetup());
case IndexVoiceSetup: return m_voiceSetup.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getVoiceSetup());
case IndexName: return this->getName().compare(compareValue.getName(), Qt::CaseInsensitive);
case IndexPort: return Compare::compare(this->getPort(), compareValue.getPort());
case IndexUser: return this->getUser().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getUser());
case IndexEcosystem: return this->getEcosystem().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getEcosystem());
case IndexIsAcceptingConnections: return Compare::compare(this->isAcceptingConnections(), compareValue.isAcceptingConnections());
case IndexPort: return Compare::compare(this->getPort(), compareValue.getPort());
case IndexUser: return this->getUser().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getUser());
case IndexEcosystem: return this->getEcosystem().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getEcosystem());
case IndexServerType:
case IndexServerTypeAsString:
return this->getServerTypeAsString().compare(compareValue.getServerTypeAsString(), Qt::CaseInsensitive);

View File

@@ -157,6 +157,12 @@ namespace BlackMisc
//! Set FSD setup
void setFsdSetup(const CFsdSetup &setup) { m_fsdSetup = setup; }
//! Add send / receive details
void addSendReceiveDetails(CFsdSetup::SendReceiveDetails sendReceive) { m_fsdSetup.addSendReceiveDetails(sendReceive); }
//! Remove send / receive details
void removeSendReceiveDetails(CFsdSetup::SendReceiveDetails sendReceive) { m_fsdSetup.removeSendReceiveDetails(sendReceive); }
//! A FSD server?
bool isFsdServer() const;
@@ -217,6 +223,9 @@ namespace BlackMisc
//! FSC server
static const CServer &fscServer();
//! ES tower server
static const CServer &esTowerView();
private:
QString m_name;
QString m_description;

View File

@@ -43,6 +43,14 @@ namespace BlackMisc
return removed;
}
void CServerList::removeUsers()
{
for (CServer &s : *this)
{
s.setUser(CUser());
}
}
bool CServerList::containsAddressPort(const CServer &server)
{
for (const CServer &s : *this)

View File

@@ -45,6 +45,9 @@ namespace BlackMisc
//! Remove by name
bool removeByName(const QString &name);
//! Remove passwords
void removeUsers();
//! Contains server with same address/port
bool containsAddressPort(const CServer &server);