swift
networksetup.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include "config/buildconfig.h"
7 #include "core/application.h"
8 
9 using namespace swift::config;
10 using namespace swift::misc;
11 using namespace swift::misc::network;
12 
13 namespace swift::core::data
14 {
15  CNetworkSetup::CNetworkSetup() {}
16 
17  CServer CNetworkSetup::getLastVatsimServer() const { return m_lastVatsimServer.get(); }
18 
19  CStatusMessage CNetworkSetup::setLastVatsimServer(const CServer &server) { return m_lastVatsimServer.set(server); }
20 
21  CServer CNetworkSetup::getLastServer() const { return m_lastServer.get(); }
22 
23  CStatusMessage CNetworkSetup::setLastServer(const CServer &server) { return m_lastServer.set(server); }
24 
25  CServerList CNetworkSetup::getOtherServers() const { return m_otherTrafficNetworkServers.get(); }
26 
27  CServerList CNetworkSetup::getOtherServersPlusPredefinedServers() const
28  {
29  // add a testserver when no servers can be loaded
30  CServerList otherServers(this->getOtherServers());
31  if (sApp)
32  {
33  if (otherServers.isEmpty() && CBuildConfig::isLocalDeveloperDebugBuild())
34  {
36  }
38  }
39  return otherServers;
40  }
41 
42  CEcosystem CNetworkSetup::getLastEcosystem() const { return this->getLastServer().getEcosystem(); }
43 
44  bool CNetworkSetup::wasLastUsedWithVatsim() const { return (this->getLastEcosystem() == CEcosystem::vatsim()); }
45 
46  bool CNetworkSetup::wasLastUsedWithOtherServer() const
47  {
48  const CServer server(this->getLastServer());
49  if (server.isNull()) { return false; }
50  return server.getEcosystem() == CEcosystem::privateFsd() || server.getEcosystem() == CEcosystem::swiftTest() ||
51  server.getEcosystem() == CEcosystem::swift();
52  }
53 
54  void CNetworkSetup::onSettingsChanged() { emit this->setupChanged(); }
55 } // namespace swift::core::data
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
Definition: application.cpp:71
static bool isLocalDeveloperDebugBuild()
Local build for developers.
data::CGlobalSetup getGlobalSetup() const
Global setup.
swift::misc::network::CServerList getPredefinedServersPlusHardcodedServers() const
Predefined plus hardcoded.
Definition: globalsetup.cpp:77
const swift::misc::network::CServerList & getPredefinedServers() const
Predefined servers.
Definition: globalsetup.h:117
bool isEmpty() const
Synonym for empty.
Definition: sequence.h:285
Streamable status message, e.g.
Ecosystem of server belonging together.
Definition: ecosystem.h:21
Value object encapsulating information of a server.
Definition: server.h:28
const CEcosystem & getEcosystem() const
Get the ecosystem.
Definition: server.h:122
bool isNull() const
NULL?
Definition: server.cpp:124
Value object encapsulating a list of servers.
Definition: serverlist.h:23
void addIfAddressNotExists(const CServer &server)
Add if address not already exists.
Definition: serverlist.cpp:51
Core data traits (aka cached values) and classes.
Free functions in swift::misc.