Unified "simplification" to ASCII only for text messages

Based on the codepage discussion of text messages

* in text message value object still store the unicode string
* the text is only "cleaned" up and Qt "simplified" (do not confuse with conversion to ASCII)
* only place where we simplify to ASCII only is
** in VATLIB
** or the utility
This commit is contained in:
Klaus Basan
2018-12-30 10:50:53 +01:00
committed by Mat Sutcliffe
parent 1e35519a0d
commit cb084427ec
5 changed files with 25 additions and 6 deletions

View File

@@ -415,7 +415,7 @@ namespace BlackCore
if (parser.countParts() < 2) { return false; }
if (!m_network) { return false; }
if (!this->isConnected()) { return false; }
const QString wallopMsg = simplifyAccents(parser.part(1).simplified().trimmed());
const QString wallopMsg = parser.part(1).simplified().trimmed();
m_network->sendWallopMessage(wallopMsg);
return true;
}

View File

@@ -574,7 +574,7 @@ namespace BlackCore
if (message.isEmpty()) {return; }
BLACK_VERIFY_X(this->isConnected(), Q_FUNC_INFO, "Sending wallop, but not connected");
if (!this->isConnected()) { return; }
Vat_SendWallop(m_net.data(), toFSDnoColon(simplifyAccents(message)));
Vat_SendWallop(m_net.data(), toFSDnoColon(simplifyTextMessage(message)));
}
void CNetworkVatlib::sendCustomPacket(const CCallsign &callsign, const QString &packetId, const QStringList &data)
@@ -1528,6 +1528,12 @@ namespace BlackCore
CLogMessage(static_cast<CNetworkVatlib *>(nullptr)).error(errorMessage);
}
QString CNetworkVatlib::simplifyTextMessage(const QString &msg)
{
if (msg.isEmpty()) { return {}; }
return asciiOnlyString(simplifyAccents(msg.simplified().trimmed()));
}
const QJsonObject &CNetworkVatlib::JsonPackets::aircraftConfigRequest()
{
static const QJsonObject jsonObject{ { "request", "full" } };

View File

@@ -190,6 +190,7 @@ namespace BlackCore
static QString convertToUnicodeEscaped(const QString &str);
static VatSimType convertToSimType(BlackMisc::Simulation::CSimulatorPluginInfo &simInfo);
static void networkLogHandler(VatSeverityLevel severity, const char *context, const char *message);
static QString simplifyTextMessage(const QString &msg);
void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data);
//! Default model string