mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
refactor: clang format line length
This commit is contained in:
@@ -20,44 +20,41 @@ namespace swift::misc::network
|
||||
{
|
||||
const QList<int> &CServer::allServerTypes()
|
||||
{
|
||||
static const QList<int> all({ FSDServerVatsim, VoiceServerVatsim, FSDServer, VoiceServer, WebService, Unspecified });
|
||||
static const QList<int> all(
|
||||
{ FSDServerVatsim, VoiceServerVatsim, FSDServer, VoiceServer, WebService, Unspecified });
|
||||
return all;
|
||||
}
|
||||
|
||||
CServer::CServer(const QString &name, const QString &description, const QString &address, int port, const CUser &user,
|
||||
const CFsdSetup &fsdSetup, const CEcosystem &ecosytem, ServerType serverType, bool isAcceptingConnections)
|
||||
: m_name(CObfuscation::decode(name)), m_description(CObfuscation::decode(description)), m_address(CObfuscation::decode(address)), m_port(port), m_user(user),
|
||||
m_ecosystem(ecosytem),
|
||||
m_serverType(serverType), m_isAcceptingConnections(isAcceptingConnections),
|
||||
m_fsdSetup(fsdSetup)
|
||||
CServer::CServer(const QString &name, const QString &description, const QString &address, int port,
|
||||
const CUser &user, const CFsdSetup &fsdSetup, const CEcosystem &ecosytem, ServerType serverType,
|
||||
bool isAcceptingConnections)
|
||||
: m_name(CObfuscation::decode(name)), m_description(CObfuscation::decode(description)),
|
||||
m_address(CObfuscation::decode(address)), m_port(port), m_user(user), m_ecosystem(ecosytem),
|
||||
m_serverType(serverType), m_isAcceptingConnections(isAcceptingConnections), m_fsdSetup(fsdSetup)
|
||||
{}
|
||||
|
||||
CServer::CServer(
|
||||
const QString &address, int port, const CUser &user)
|
||||
CServer::CServer(const QString &address, int port, const CUser &user)
|
||||
: m_name("no name"), m_description("min.configuration"), m_address(address), m_port(port), m_user(user)
|
||||
{}
|
||||
|
||||
CServer::CServer(const CEcosystem &ecosystem)
|
||||
{
|
||||
this->setEcosystem(ecosystem);
|
||||
}
|
||||
CServer::CServer(const CEcosystem &ecosystem) { this->setEcosystem(ecosystem); }
|
||||
|
||||
CServer::CServer(CServer::ServerType serverType)
|
||||
{
|
||||
this->setServerType(serverType);
|
||||
}
|
||||
CServer::CServer(CServer::ServerType serverType) { this->setServerType(serverType); }
|
||||
|
||||
QString CServer::convertToQString(bool i18n) const
|
||||
{
|
||||
return QStringLiteral("%1 %2 %3:%4 %5 %6 accepting: %7 FSD: %8 con.since: %9").arg(m_name, m_description, m_address).arg(m_port).arg(m_user.toQString(i18n), m_ecosystem.getSystemString(), boolToYesNo(m_isAcceptingConnections), m_fsdSetup.toQString(i18n), this->isConnected() ? this->getFormattedUtcTimestampHms() : "not con.");
|
||||
return QStringLiteral("%1 %2 %3:%4 %5 %6 accepting: %7 FSD: %8 con.since: %9")
|
||||
.arg(m_name, m_description, m_address)
|
||||
.arg(m_port)
|
||||
.arg(m_user.toQString(i18n), m_ecosystem.getSystemString(), boolToYesNo(m_isAcceptingConnections),
|
||||
m_fsdSetup.toQString(i18n), this->isConnected() ? this->getFormattedUtcTimestampHms() : "not con.");
|
||||
}
|
||||
|
||||
const CServer &CServer::fscFsdServer()
|
||||
{
|
||||
static const CServer fsc = [] {
|
||||
CServer s = CServer("FSC", "FSC e.V.", "OBF:AwJIKfgkQDJEIRnno29DJlB+UK0=", 6809,
|
||||
CUser(),
|
||||
CFsdSetup(), CEcosystem(CEcosystem::privateFsd()), CServer::FSDServer);
|
||||
CServer s = CServer("FSC", "FSC e.V.", "OBF:AwJIKfgkQDJEIRnno29DJlB+UK0=", 6809, CUser(), CFsdSetup(),
|
||||
CEcosystem(CEcosystem::privateFsd()), CServer::FSDServer);
|
||||
s.removeSendReceiveDetails(CFsdSetup::AllInterimPositions);
|
||||
return s;
|
||||
}();
|
||||
@@ -66,28 +63,25 @@ namespace swift::misc::network
|
||||
|
||||
const CServer &CServer::esTowerView()
|
||||
{
|
||||
static const CServer s = CServer("ES Tower", "Euroscope Tower view", "localhost", 6809,
|
||||
CUser(),
|
||||
CFsdSetup::vatsimStandard(), CEcosystem(CEcosystem::vatsim()), CServer::VoiceServerVatsim);
|
||||
static const CServer s =
|
||||
CServer("ES Tower", "Euroscope Tower view", "localhost", 6809, CUser(), CFsdSetup::vatsimStandard(),
|
||||
CEcosystem(CEcosystem::vatsim()), CServer::VoiceServerVatsim);
|
||||
return s;
|
||||
}
|
||||
|
||||
bool CServer::matchesName(const QString &name) const
|
||||
{
|
||||
return m_name.length() == name.length() &&
|
||||
m_name.startsWith(name, Qt::CaseInsensitive);
|
||||
return m_name.length() == name.length() && m_name.startsWith(name, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
bool CServer::matchesAddressPort(const CServer &server) const
|
||||
{
|
||||
return server.getPort() == this->getPort() &&
|
||||
server.matchesAddress(this->getAddress());
|
||||
return server.getPort() == this->getPort() && server.matchesAddress(this->getAddress());
|
||||
}
|
||||
|
||||
bool CServer::matchesAddress(const QString &address) const
|
||||
{
|
||||
return m_address.length() == address.length() &&
|
||||
m_address.startsWith(address, Qt::CaseInsensitive);
|
||||
return m_address.length() == address.length() && m_address.startsWith(address, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
bool CServer::setEcosystem(const CEcosystem &ecosystem)
|
||||
@@ -106,15 +100,11 @@ namespace swift::misc::network
|
||||
return m_user.hasCredentials() && this->hasAddressAndPort() && this->isAcceptingConnections();
|
||||
}
|
||||
|
||||
bool CServer::hasAddressAndPort() const
|
||||
{
|
||||
return m_port > 0 && !m_address.isEmpty();
|
||||
}
|
||||
bool CServer::hasAddressAndPort() const { return m_port > 0 && !m_address.isEmpty(); }
|
||||
|
||||
bool CServer::isFsdServer() const
|
||||
{
|
||||
return (this->getServerType() == FSDServerVatsim ||
|
||||
this->getServerType() == FSDServer);
|
||||
return (this->getServerType() == FSDServerVatsim || this->getServerType() == FSDServer);
|
||||
}
|
||||
|
||||
bool CServer::setServerType(CServer::ServerType serverType)
|
||||
@@ -125,34 +115,34 @@ namespace swift::misc::network
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CServer::hasUnspecifiedServerType() const
|
||||
{
|
||||
return this->getServerType() == Unspecified;
|
||||
}
|
||||
bool CServer::hasUnspecifiedServerType() const { return this->getServerType() == Unspecified; }
|
||||
|
||||
const QString &CServer::getServerTypeAsString() const
|
||||
{
|
||||
return CServer::serverTypeToString(getServerType());
|
||||
}
|
||||
const QString &CServer::getServerTypeAsString() const { return CServer::serverTypeToString(getServerType()); }
|
||||
|
||||
bool CServer::isConnected() const
|
||||
{
|
||||
return m_timestampMSecsSinceEpoch >= 0;
|
||||
}
|
||||
bool CServer::isConnected() const { return m_timestampMSecsSinceEpoch >= 0; }
|
||||
|
||||
bool CServer::isNull() const
|
||||
{
|
||||
return this->hasUnspecifiedServerType() && !this->hasName() && m_port < 0;
|
||||
}
|
||||
bool CServer::isNull() const { return this->hasUnspecifiedServerType() && !this->hasName() && m_port < 0; }
|
||||
|
||||
CStatusMessageList CServer::validate() const
|
||||
{
|
||||
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||
CStatusMessageList msgs;
|
||||
if (this->getName().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing name")); }
|
||||
if (this->getAddress().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing address")); }
|
||||
if (this->getDescription().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityWarning, u"Missing description")); }
|
||||
if (this->getPort() < 1 || this->getPort() > 65535) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Wrong port")); }
|
||||
if (this->getName().isEmpty())
|
||||
{
|
||||
msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing name"));
|
||||
}
|
||||
if (this->getAddress().isEmpty())
|
||||
{
|
||||
msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing address"));
|
||||
}
|
||||
if (this->getDescription().isEmpty())
|
||||
{
|
||||
msgs.push_back(CStatusMessage(CStatusMessage::SeverityWarning, u"Missing description"));
|
||||
}
|
||||
if (this->getPort() < 1 || this->getPort() > 65535)
|
||||
{
|
||||
msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Wrong port"));
|
||||
}
|
||||
msgs.push_back(this->getUser().validate());
|
||||
msgs.push_back(this->getFsdSetup().validate());
|
||||
msgs.addCategories(cats);
|
||||
@@ -165,7 +155,11 @@ namespace swift::misc::network
|
||||
const bool isConnected = this->isConnected();
|
||||
if (onlyConnected && !isConnected) { return {}; }
|
||||
static const QString session("%1 %2 %3:%4 [%5] %6 %7");
|
||||
return session.arg(isConnected ? u"connected" : u"disconnected").arg(this->getName(), this->getAddress()).arg(this->getPort()).arg(this->getEcosystem().getSystemString(), this->getUser().getRealName(), this->getFormattedUtcTimestampHms());
|
||||
return session.arg(isConnected ? u"connected" : u"disconnected")
|
||||
.arg(this->getName(), this->getAddress())
|
||||
.arg(this->getPort())
|
||||
.arg(this->getEcosystem().getSystemString(), this->getUser().getRealName(),
|
||||
this->getFormattedUtcTimestampHms());
|
||||
}
|
||||
|
||||
QVariant CServer::propertyByIndex(CPropertyIndexRef index) const
|
||||
@@ -222,18 +216,25 @@ namespace swift::misc::network
|
||||
int CServer::comparePropertyByIndex(CPropertyIndexRef index, const CServer &compareValue) const
|
||||
{
|
||||
if (index.isMyself()) { return this->getName().compare(compareValue.getName()); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(index, compareValue); }
|
||||
if (ITimestampBased::canHandleIndex(index))
|
||||
{
|
||||
return ITimestampBased::comparePropertyByIndex(index, compareValue);
|
||||
}
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
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 IndexDescription:
|
||||
return this->getDescription().compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
case IndexFsdSetup:
|
||||
return m_fsdSetup.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFsdSetup());
|
||||
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 IndexEcosystem:
|
||||
return this->getEcosystem().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getEcosystem());
|
||||
case IndexIsAcceptingConnections:
|
||||
return Compare::compare(this->isAcceptingConnections(), compareValue.isAcceptingConnections());
|
||||
case IndexServerType:
|
||||
case IndexServerTypeAsString:
|
||||
return this->getServerTypeAsString().compare(compareValue.getServerTypeAsString(), Qt::CaseInsensitive);
|
||||
@@ -264,15 +265,9 @@ namespace swift::misc::network
|
||||
}
|
||||
}
|
||||
|
||||
void CServer::setAddress(const QString &address)
|
||||
{
|
||||
m_address = CObfuscation::decode(address);
|
||||
}
|
||||
void CServer::setAddress(const QString &address) { m_address = CObfuscation::decode(address); }
|
||||
|
||||
void CServer::setName(const QString &name)
|
||||
{
|
||||
m_name = CObfuscation::decode(name);
|
||||
}
|
||||
void CServer::setName(const QString &name) { m_name = CObfuscation::decode(name); }
|
||||
|
||||
void CServer::setDescription(const QString &description)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user