This commit is contained in:
Klaus Basan
2019-10-18 01:01:32 +02:00
parent f81fc31da6
commit a8c7575d9d
6 changed files with 40 additions and 38 deletions

View File

@@ -18,11 +18,14 @@
class CAfvClientBridge : public QObject class CAfvClientBridge : public QObject
{ {
Q_OBJECT Q_OBJECT
//! Bridge properties @{
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU) Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU) Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged) Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged) Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged)
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged) Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged)
//! @}
public: public:
//! Ctor //! Ctor

View File

@@ -9,8 +9,9 @@
//! \file //! \file
#include "input.h" #include "input.h"
#include "blackmisc/logmessage.h"
#include "blacksound/audioutilities.h" #include "blacksound/audioutilities.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/verify.h"
#include <QtGlobal> #include <QtGlobal>
#include <QStringBuilder> #include <QStringBuilder>

View File

@@ -48,11 +48,14 @@ namespace BlackCore
class BLACKCORE_EXPORT CAfvClient final : public BlackMisc::CContinuousWorker class BLACKCORE_EXPORT CAfvClient final : public BlackMisc::CContinuousWorker
{ {
Q_OBJECT Q_OBJECT
//! AFV client properties @{
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU) Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU) Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged) Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged) Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged)
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged) Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged)
//! @}
public: public:
//! Categories //! Categories

View File

@@ -827,8 +827,7 @@ namespace BlackCore
{ {
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "not in main thread"); Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "not in main thread");
if (!this->isConnectedAndNotShuttingDown()) { return; } if (!this->isConnectedAndNotShuttingDown()) { return; }
if (CBuildConfig::isLocalDeveloperDebugBuild()) { BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign"); }
BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign");
if (!callsign.isValid()) { return; } if (!callsign.isValid()) { return; }
const ReverseLookupLogging reverseLookupEnabled = this->isReverseLookupMessagesEnabled(); const ReverseLookupLogging reverseLookupEnabled = this->isReverseLookupMessagesEnabled();
CStatusMessageList reverseLookupMessages; CStatusMessageList reverseLookupMessages;
@@ -1204,7 +1203,7 @@ namespace BlackCore
void CAirspaceMonitor::onConnectionStatusChanged(CConnectionStatus oldStatus, CConnectionStatus newStatus) void CAirspaceMonitor::onConnectionStatusChanged(CConnectionStatus oldStatus, CConnectionStatus newStatus)
{ {
Q_UNUSED(oldStatus); Q_UNUSED(oldStatus)
if (newStatus.isDisconnected()) { clear(); } if (newStatus.isDisconnected()) { clear(); }
} }

View File

@@ -507,7 +507,7 @@ namespace BlackCore
QStringList receivers; QStringList receivers;
for (const int &frequency : frequencies) for (const int &frequency : frequencies)
{ {
receivers.push_back(QString("@%1").arg(frequency - 100000)); receivers.push_back(QStringLiteral("@%1").arg(frequency - 100000));
} }
TextMessage radioMessage(m_ownCallsign.asString(), receivers.join('&'), message); TextMessage radioMessage(m_ownCallsign.asString(), receivers.join('&'), message);
@@ -562,7 +562,7 @@ namespace BlackCore
this->increaseStatisticsValue(QStringLiteral("sendFlightPlan")); this->increaseStatisticsValue(QStringLiteral("sendFlightPlan"));
} }
void CFSDClient::sendPlaneInfoRequest(const BlackMisc::Aviation::CCallsign &receiver) void CFSDClient::sendPlaneInfoRequest(const CCallsign &receiver)
{ {
PlaneInfoRequest planeInfoRequest(m_ownCallsign.asString(), receiver.toQString()); PlaneInfoRequest planeInfoRequest(m_ownCallsign.asString(), receiver.toQString());
sendMessage(planeInfoRequest); sendMessage(planeInfoRequest);
@@ -1010,8 +1010,8 @@ namespace BlackCore
CAltitude cruiseAlt; CAltitude cruiseAlt;
cruiseAlt.parseFromString(cruiseAltString, CPqString::SeparatorBestGuess); cruiseAlt.parseFromString(cruiseAltString, CPqString::SeparatorBestGuess);
const QString depTimePlanned = QString("0000").append(QString::number(fp.m_estimatedDepTime)).right(4); const QString depTimePlanned = QStringLiteral("0000").append(QString::number(fp.m_estimatedDepTime)).right(4);
const QString depTimeActual = QString("0000").append(QString::number(fp.m_actualDepTime)).right(4); const QString depTimeActual = QStringLiteral("0000").append(QString::number(fp.m_actualDepTime)).right(4);
const CCallsign callsign(fp.sender(), CCallsign::Aircraft); const CCallsign callsign(fp.sender(), CCallsign::Aircraft);
const CFlightPlan flightPlan( const CFlightPlan flightPlan(
@@ -1231,22 +1231,22 @@ namespace BlackCore
ServerError serverError = ServerError::fromTokens(tokens); ServerError serverError = ServerError::fromTokens(tokens);
switch (serverError.m_errorNumber) switch (serverError.m_errorNumber)
{ {
case ServerErrorCode::CallsignInUse: CLogMessage(this).error(u"The requested callsign is already taken"); break; case ServerErrorCode::CallsignInUse: CLogMessage(this).error(u"The requested callsign is already taken"); break;
case ServerErrorCode::InvalidCallsign: CLogMessage(this).error(u"The requested callsign is not valid"); break; case ServerErrorCode::InvalidCallsign: CLogMessage(this).error(u"The requested callsign is not valid"); break;
case ServerErrorCode::InvalidCidPassword: CLogMessage(this).error(u"Wrong user ID or password, inactive account"); break; case ServerErrorCode::InvalidCidPassword: CLogMessage(this).error(u"Wrong user ID or password, inactive account"); break;
case ServerErrorCode::InvalidRevision: CLogMessage(this).error(u"This server does not support our protocol version"); break; case ServerErrorCode::InvalidRevision: CLogMessage(this).error(u"This server does not support our protocol version"); break;
case ServerErrorCode::RequestedLevelTooHigh: CLogMessage(this).error(u"You are not authorized to use the requested pilot rating"); break; case ServerErrorCode::RequestedLevelTooHigh: CLogMessage(this).error(u"You are not authorized to use the requested pilot rating"); break;
case ServerErrorCode::ServerFull: CLogMessage(this).error(u"The server is full"); break; case ServerErrorCode::ServerFull: CLogMessage(this).error(u"The server is full"); break;
case ServerErrorCode::CidSuspended: CLogMessage(this).error(u"Your user account is suspended"); break; case ServerErrorCode::CidSuspended: CLogMessage(this).error(u"Your user account is suspended"); break;
case ServerErrorCode::RatingTooLow: CLogMessage(this).error(u"You are not authorized to use the requested rating"); break; case ServerErrorCode::RatingTooLow: CLogMessage(this).error(u"You are not authorized to use the requested rating"); break;
case ServerErrorCode::InvalidClient: CLogMessage(this).error(u"This software is not authorized for use on this network"); break; case ServerErrorCode::InvalidClient: CLogMessage(this).error(u"This software is not authorized for use on this network"); break;
case ServerErrorCode::NoError: CLogMessage(this).info(u"OK"); break; case ServerErrorCode::NoError: CLogMessage(this).info(u"OK"); break;
case ServerErrorCode::SyntaxError: CLogMessage(this).info(u"Malformed packet: Syntax error: %1") << serverError.m_causingParameter; break; case ServerErrorCode::SyntaxError: CLogMessage(this).info(u"Malformed packet: Syntax error: %1") << serverError.m_causingParameter; break;
case ServerErrorCode::InvalidSrcCallsign: CLogMessage(this).info(u"FSD message was using an invalid callsign: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break; case ServerErrorCode::InvalidSrcCallsign: CLogMessage(this).info(u"FSD message was using an invalid callsign: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break;
case ServerErrorCode::NoSuchCallsign: CLogMessage(this).info(u"FSD Server: no such callsign: %1 %2") << serverError.m_causingParameter << serverError.m_description; break; case ServerErrorCode::NoSuchCallsign: CLogMessage(this).info(u"FSD Server: no such callsign: %1 %2") << serverError.m_causingParameter << serverError.m_description; break;
case ServerErrorCode::NoFlightPlan: CLogMessage(this).info(u"FSD Server: no flight plan"); break; case ServerErrorCode::NoFlightPlan: CLogMessage(this).info(u"FSD Server: no flight plan"); break;
case ServerErrorCode::NoWeatherProfile: CLogMessage(this).info(u"FSD Server: requested weather profile does not exist"); break; case ServerErrorCode::NoWeatherProfile: CLogMessage(this).info(u"FSD Server: requested weather profile does not exist"); break;
// we have no idea what these mean // we have no idea what these mean
case ServerErrorCode::AlreadyRegistered: CLogMessage(this).info(u"Server says already registered: %1") << serverError.m_description; break; case ServerErrorCode::AlreadyRegistered: CLogMessage(this).info(u"Server says already registered: %1") << serverError.m_description; break;
@@ -1543,8 +1543,7 @@ namespace BlackCore
if (reLogoff.match(message).hasMatch()) if (reLogoff.match(message).hasMatch())
{ {
emit atisLogoffTimeReplyReceived(sender, message); emit atisLogoffTimeReplyReceived(sender, message);
CInformationMessage atisMessage; CInformationMessage atisMessage(CInformationMessage::ATIS);
atisMessage.setType(CInformationMessage::ATIS);
for (const auto &line : as_const(pendingQuery.m_atisMessage)) for (const auto &line : as_const(pendingQuery.m_atisMessage))
{ {
if (!atisMessage.isEmpty()) atisMessage.appendMessage("\n"); if (!atisMessage.isEmpty()) atisMessage.appendMessage("\n");
@@ -1565,13 +1564,13 @@ namespace BlackCore
if (setting.getFileWriteMode() == CRawFsdMessageSettings::None || setting.getFileDir().isEmpty()) { return; } if (setting.getFileWriteMode() == CRawFsdMessageSettings::None || setting.getFileDir().isEmpty()) { return; }
if (setting.getFileWriteMode() == CRawFsdMessageSettings::Truncate) if (setting.getFileWriteMode() == CRawFsdMessageSettings::Truncate)
{ {
QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log"); const QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log");
m_rawFsdMessageLogFile.setFileName(filePath); m_rawFsdMessageLogFile.setFileName(filePath);
m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly); m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly);
} }
else if (setting.getFileWriteMode() == CRawFsdMessageSettings::Append) else if (setting.getFileWriteMode() == CRawFsdMessageSettings::Append)
{ {
QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log"); const QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log");
m_rawFsdMessageLogFile.setFileName(filePath); m_rawFsdMessageLogFile.setFileName(filePath);
m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly | QIODevice::Append); m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly | QIODevice::Append);
} }
@@ -1581,7 +1580,7 @@ namespace BlackCore
filename += QLatin1String("_"); filename += QLatin1String("_");
filename += QDateTime::currentDateTime().toString(QStringLiteral("yyMMddhhmmss")); filename += QDateTime::currentDateTime().toString(QStringLiteral("yyMMddhhmmss"));
filename += QLatin1String(".log"); filename += QLatin1String(".log");
QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), filename); const QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), filename);
m_rawFsdMessageLogFile.setFileName(filePath); m_rawFsdMessageLogFile.setFileName(filePath);
m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly); m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly);
} }
@@ -1672,8 +1671,8 @@ namespace BlackCore
{ {
while (m_socket.canReadLine()) while (m_socket.canReadLine())
{ {
QByteArray dataEncoded = m_socket.readLine(); const QByteArray dataEncoded = m_socket.readLine();
QString data = m_fsdTextCodec->toUnicode(dataEncoded); const QString data = m_fsdTextCodec->toUnicode(dataEncoded);
parseMessage(data); parseMessage(data);
} }
} }
@@ -1699,13 +1698,12 @@ namespace BlackCore
if (messageType != MessageType::Unknown) if (messageType != MessageType::Unknown)
{ {
// Cutoff the cmd from the beginning // Cutoff the cmd from the beginning
QString payload = line.mid(cmd.size()).trimmed(); const QString payload = line.mid(cmd.size()).trimmed();
// We expected a payload, but there is nothing // We expected a payload, but there is nothing
if (payload.length() == 0) return; if (payload.length() == 0) return;
QStringList tokens = payload.split(':'); const QStringList tokens = payload.split(':');
switch (messageType) switch (messageType)
{ {
case MessageType::AddAtc: /* ignore */ return; case MessageType::AddAtc: /* ignore */ return;
@@ -1746,7 +1744,7 @@ namespace BlackCore
} }
} }
QString prefix = isSent ? "FSD Sent=>" : "FSD Recv=>"; const QString prefix = isSent ? "FSD Sent=>" : "FSD Recv=>";
CRawFsdMessage rawMessage(prefix + fsdMessageFiltered); CRawFsdMessage rawMessage(prefix + fsdMessageFiltered);
rawMessage.setCurrentUtcTime(); rawMessage.setCurrentUtcTime();
if (m_rawFsdMessageLogFile.isOpen()) if (m_rawFsdMessageLogFile.isOpen())
@@ -1813,9 +1811,7 @@ namespace BlackCore
// emit atisVoiceRoomReplyReceived(cs, m_mapAtisMessages[callsign].voiceRoom); // emit atisVoiceRoomReplyReceived(cs, m_mapAtisMessages[callsign].voiceRoom);
emit atisLogoffTimeReplyReceived(cs, m_mapAtisMessages[callsign].zuluLogoff); emit atisLogoffTimeReplyReceived(cs, m_mapAtisMessages[callsign].zuluLogoff);
CInformationMessage atisMessage; CInformationMessage atisMessage(CInformationMessage::ATIS);
atisMessage.setType(CInformationMessage::ATIS);
for (const QString &tm : m_mapAtisMessages[callsign].textLines) for (const QString &tm : m_mapAtisMessages[callsign].textLines)
{ {
const QString fixed = tm.trimmed(); const QString fixed = tm.trimmed();

View File

@@ -32,7 +32,7 @@ namespace BlackGui
explicit CAudioVolumeComponent(QWidget *parent = nullptr); explicit CAudioVolumeComponent(QWidget *parent = nullptr);
//! Destructor //! Destructor
virtual ~CAudioVolumeComponent(); virtual ~CAudioVolumeComponent() override;
private: private:
//! Mute toggleBlackGui::Components::CHotkeyDialog //! Mute toggleBlackGui::Components::CHotkeyDialog