19 namespace swift::misc::network
23 static const QList<int> all(
24 { FSDServerVatsim, VoiceServerVatsim, FSDServer, VoiceServer, WebService, Unspecified });
28 CServer::CServer(
const QString &name,
const QString &description,
const QString &address,
int port,
30 bool isAcceptingConnections)
32 m_address(
CObfuscation::decode(address)), m_port(port), m_user(user), m_ecosystem(ecosytem),
33 m_serverType(serverType), m_isAcceptingConnections(isAcceptingConnections), m_fsdSetup(fsdSetup)
37 : m_name(
"no name"), m_description(
"min.configuration"), m_address(address), m_port(port), m_user(user)
46 return QStringLiteral(
"%1 %2 %3:%4 %5 %6 accepting: %7 FSD: %8 con.since: %9")
47 .arg(m_name, m_description, m_address)
50 m_fsdSetup.
toQString(i18n), this->isConnected() ? this->getFormattedUtcTimestampHms() :
"not con.");
74 return m_name.length() == name.length() && m_name.startsWith(name, Qt::CaseInsensitive);
84 return m_address.length() == address.length() && m_address.startsWith(address, Qt::CaseInsensitive);
89 if (m_ecosystem == ecosystem) {
return false; }
90 m_ecosystem = ecosystem;
112 if (m_serverType == serverType) {
return false; }
114 m_serverType =
static_cast<int>(serverType);
157 static const QString session(
"%1 %2 %3:%4 [%5] %6 %7");
158 return session.arg(
isConnected ? u
"connected" : u
"disconnected")
167 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
173 case IndexAddress:
return QVariant::fromValue(m_address);
174 case IndexDescription:
return QVariant::fromValue(m_description);
175 case IndexName:
return QVariant::fromValue(m_name);
176 case IndexPort:
return QVariant::fromValue(m_port);
180 case IndexIsAcceptingConnections:
return QVariant::fromValue(m_isAcceptingConnections);
181 case IndexServerType:
return QVariant::fromValue(m_serverType);
191 (*this) = variant.value<
CServer>();
203 case IndexAddress: this->
setAddress(variant.value<QString>());
break;
204 case IndexPort: this->
setPort(variant.value<qint32>());
break;
205 case IndexDescription: this->
setDescription(variant.value<QString>());
break;
206 case IndexName: this->
setName(variant.value<QString>());
break;
226 case IndexAddress:
return this->
getAddress().compare(compareValue.
getAddress(), Qt::CaseInsensitive);
227 case IndexDescription:
231 case IndexName:
return this->
getName().compare(compareValue.
getName(), Qt::CaseInsensitive);
232 case IndexPort:
return Compare::compare(this->
getPort(), compareValue.
getPort());
236 case IndexIsAcceptingConnections:
238 case IndexServerType:
239 case IndexServerTypeAsString:
249 static const QString fsdVatsim(
"FSD [VATSIM]");
250 static const QString voiceVatsim(
"voice [VATSIM]");
251 static const QString fsdLegacy(
"FSD (legacy)");
252 static const QString voice(
"voice");
253 static const QString webService(
"web service");
254 static const QString unspecified(
"unspecified");
258 case FSDServerVatsim:
return fsdVatsim;
259 case VoiceServerVatsim:
return voiceVatsim;
260 case FSDServer:
return fsdLegacy;
261 case VoiceServer:
return voice;
262 case WebService:
return webService;
264 default:
return unspecified;
A sequence of log categories.
Utility class to obfuscate strings in the source code to make them unreadable.
static QString decode(const QString &inString, bool trimmed=true)
Decode string if it has the prefix, otherwise do nothing with it.
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
QString toQString(bool i18n=false) const
Cast as QString.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
void push_back(const T &value)
Appends an element at the end of the sequence.
Streamable status message, e.g.
constexpr static auto SeverityError
Status severities.
constexpr static auto SeverityWarning
Status severities.
Status messages, e.g. from Core -> GUI.
void addCategories(const CLogCategoryList &categories)
Add some categories to all messages in the list.
void sortBySeverity()
Sort by severity, lowest first.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const ITimestampBased &compareValue) const
Compare for index.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled.
qint64 m_timestampMSecsSinceEpoch
timestamp value
QString getFormattedUtcTimestampHms() const
As hh:mm:ss.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
ColumnIndex
Base class enums.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString toQString(bool i18n=false) const
Cast as QString.
Ecosystem of server belonging together.
@ SwiftTest
swift test server
int comparePropertyByIndex(CPropertyIndexRef index, const CEcosystem &compareValue) const
Compare for index.
static const CEcosystem & vatsim()
VATSIM eco system.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool isSystem(System s) const
Is system?
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
static const CEcosystem & privateFsd()
FSD private.
const QString & getSystemString() const
Get the system string.
Value object for a FSD setup.
static const CFsdSetup & vatsimStandard()
Standard FSD setup for official VATSIM servers.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const CFsdSetup &compareValue) const
Compare for index.
@ AllInterimPositions
all interim positions
Value object encapsulating information of a server.
bool hasAddressAndPort() const
Address and port?
void setName(const QString &name)
Set name.
void setDescription(const QString &description)
Set description.
void setAddress(const QString &address)
Set address (e.g. myserver.foo.com)
bool setServerType(ServerType serverType)
Set server type.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString convertToQString(bool i18n=false) const
Cast as QString.
const QString & getDescription() const
Get description.
const QString & getServerTypeAsString() const
Get server type as string.
bool matchesAddress(const QString &address) const
Same address?
bool hasName() const
Has name?
static const CServer & esTowerView()
ES tower server.
int getPort() const
Get port.
bool isConnected() const
Is connected?
bool matchesName(const QString &name) const
Matches server name?
CStatusMessageList validate() const
Validate, provide details about issues.
bool matchesAddressPort(const CServer &server) const
Same address and port?
bool isValidForLogin() const
Is valid for login?
const QString & getName() const
Get name.
const CFsdSetup & getFsdSetup() const
Get FSD setup.
static const QList< int > & allServerTypes()
Allows to iterate over all ServerType.
void setIsAcceptingConnections(bool value)
Set whether server is accepting connections (allows to disable server temporarily or generally)
static const QString & serverTypeToString(ServerType server)
Enum to string.
int comparePropertyByIndex(CPropertyIndexRef index, const CServer &compareValue) const
Compare for index.
const QString & getAddress() const
Get address.
void setPort(int port)
Set port.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
const CEcosystem & getEcosystem() const
Get the ecosystem.
void removeSendReceiveDetails(CFsdSetup::SendReceiveDetails sendReceive)
Remove send / receive details.
static const CServer & fscFsdServer()
FSC server.
CServer()
Default constructor.
bool isAcceptingConnections() const
Server is accepting connections (allows to disable server temporarily or generally)
bool setEcosystem(const CEcosystem &ecosystem)
Set the ecosystem.
const CUser & getUser() const
Get user.
bool isFsdServer() const
A FSD server?
bool hasUnspecifiedServerType() const
Unspecified?
ServerType getServerType() const
Get server type.
QString getServerSessionId(bool onlyConnected) const
Identifying a session, if not connected empty.
Value object encapsulating information of a user.
int comparePropertyByIndex(CPropertyIndexRef index, const CUser &compareValue) const
Compare for index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool hasCredentials() const
Valid credentials?
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.