From be999113720ec0f21ccee5d1d1c985212837de02 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 20 Oct 2019 23:08:52 +0200 Subject: [PATCH] Style, minor adjustments --- .../afv/audio/soundcardsampleprovider.cpp | 2 +- src/blackcore/afv/audio/soundcardsampleprovider.h | 2 +- src/blackcore/afv/clients/afvclient.cpp | 14 ++++++++++++-- src/blackcore/afv/clients/afvclient.h | 7 ++++--- src/blackcore/context/contextownaircraftimpl.h | 10 +++++----- src/blackcore/db/networkwatchdog.cpp | 2 +- src/blackcore/fsd/addpilot.cpp | 6 ++++-- src/blackcore/fsd/addpilot.h | 6 +++--- src/blackcore/fsd/fsdclient.cpp | 8 ++++---- src/blackcore/fsd/fsdclient.h | 9 +++------ 10 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/blackcore/afv/audio/soundcardsampleprovider.cpp b/src/blackcore/afv/audio/soundcardsampleprovider.cpp index 142ff24f7..1b400a200 100644 --- a/src/blackcore/afv/audio/soundcardsampleprovider.cpp +++ b/src/blackcore/afv/audio/soundcardsampleprovider.cpp @@ -169,7 +169,7 @@ namespace BlackCore } } - QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID) + QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID) const { return m_receiverInputs.at(transceiverID)->getReceivingCallsignsString(); } diff --git a/src/blackcore/afv/audio/soundcardsampleprovider.h b/src/blackcore/afv/audio/soundcardsampleprovider.h index 63dbe1390..f798e5e9c 100644 --- a/src/blackcore/afv/audio/soundcardsampleprovider.h +++ b/src/blackcore/afv/audio/soundcardsampleprovider.h @@ -52,7 +52,7 @@ namespace BlackCore void updateRadioTransceivers(const QVector &radioTransceivers); //! Receiving callsign as single string - QString getReceivingCallsigns(quint16 transceiverID); + QString getReceivingCallsigns(quint16 transceiverID) const; signals: //! Changed callsigns diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index 04a822e3c..5f09a5a5d 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -747,20 +747,30 @@ namespace BlackCore emit outputVolumePeakVU(args.PeakVU); } - QString CAfvClient::getReceivingCallsignsCom1() + QString CAfvClient::getReceivingCallsignsCom1() const { QMutexLocker lock(&m_mutex); if (!m_soundcardSampleProvider) return {}; return m_soundcardSampleProvider->getReceivingCallsigns(0); } - QString CAfvClient::getReceivingCallsignsCom2() + QString CAfvClient::getReceivingCallsignsCom2() const { QMutexLocker lock(&m_mutex); if (!m_soundcardSampleProvider) return {}; return m_soundcardSampleProvider->getReceivingCallsigns(1); } + QStringList CAfvClient::getReceivingCallsignsCom1Com2() const + { + QStringList coms; + QMutexLocker lock(&m_mutex); + if (!m_soundcardSampleProvider) { return {{ QString(), QString()}}; } + coms << m_soundcardSampleProvider->getReceivingCallsigns(0); + coms << m_soundcardSampleProvider->getReceivingCallsigns(1); + return coms; + } + bool CAfvClient::updateVoiceServerUrl(const QString &url) { QMutexLocker lock(&m_mutexConnection); diff --git a/src/blackcore/afv/clients/afvclient.h b/src/blackcore/afv/clients/afvclient.h index a96fbef48..3d2ffbc49 100644 --- a/src/blackcore/afv/clients/afvclient.h +++ b/src/blackcore/afv/clients/afvclient.h @@ -224,7 +224,7 @@ namespace BlackCore //! Recently used device //! \threadsafe //! @{ - const BlackMisc::Audio::CAudioDeviceInfo &getInputDevice() const; + const BlackMisc::Audio::CAudioDeviceInfo &getInputDevice() const; const BlackMisc::Audio::CAudioDeviceInfo &getOutputDevice() const; bool usesSameDevices(const BlackMisc::Audio::CAudioDeviceInfo &inputDevice, const BlackMisc::Audio::CAudioDeviceInfo &outputDevice); //! @} @@ -232,8 +232,9 @@ namespace BlackCore //! Callsigns currently received //! \threadsafe //! @{ - QString getReceivingCallsignsCom1(); - QString getReceivingCallsignsCom2(); + QString getReceivingCallsignsCom1() const; + QString getReceivingCallsignsCom2() const; + QStringList getReceivingCallsignsCom1Com2() const; //! @} //! Update the voice server URL diff --git a/src/blackcore/context/contextownaircraftimpl.h b/src/blackcore/context/contextownaircraftimpl.h index 684e2dd44..5df240fde 100644 --- a/src/blackcore/context/contextownaircraftimpl.h +++ b/src/blackcore/context/contextownaircraftimpl.h @@ -11,11 +11,11 @@ #ifndef BLACKCORE_CONTEXT_CONTEXTOWNAIRCRAFT_IMPL_H #define BLACKCORE_CONTEXT_CONTEXTOWNAIRCRAFT_IMPL_H -#include "blackcore/blackcoreexport.h" #include "blackcore/context/contextownaircraft.h" #include "blackcore/corefacadeconfig.h" #include "blackcore/vatsim/vatsimsettings.h" #include "blackcore/actionbind.h" +#include "blackcore/blackcoreexport.h" #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/simulation/ownaircraftprovider.h" #include "blackmisc/simulation/simulatedaircraft.h" @@ -211,16 +211,16 @@ namespace BlackCore CContextOwnAircraft *registerWithDBus(BlackMisc::CDBusServer *server); private: - BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< my aircraft - mutable QReadWriteLock m_lockAircraft; //!< lock aircraft + BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< my aircraft + mutable QReadWriteLock m_lockAircraft; //!< lock aircraft CActionBind m_actionToggleXpdr { BlackMisc::Input::toggleXPDRStateHotkeyAction(), BlackMisc::Input::toggleXPDRStateHotkeyIcon(), this, &CContextOwnAircraft::actionToggleTransponder }; CActionBind m_actionIdent { BlackMisc::Input::toggleXPDRIdentHotkeyAction(), BlackMisc::Input::toggleXPDRIdentHotkeyIcon(), this, &CContextOwnAircraft::actionIdent }; static constexpr qint64 MinHistoryDeltaMs = 1000; static constexpr int MaxHistoryElements = 20; - QTimer m_historyTimer; //!< history timer - std::atomic_bool m_history { true }; //!< enable history + QTimer m_historyTimer; //!< history timer + std::atomic_bool m_history { true }; //!< enable history BlackMisc::Aviation::CAircraftSituationList m_situationHistory; //!< history, latest situation first BlackMisc::CSetting m_currentNetworkServer { this }; diff --git a/src/blackcore/db/networkwatchdog.cpp b/src/blackcore/db/networkwatchdog.cpp index 6acb53f4a..7d552a949 100644 --- a/src/blackcore/db/networkwatchdog.cpp +++ b/src/blackcore/db/networkwatchdog.cpp @@ -24,7 +24,7 @@ namespace BlackCore { const CLogCategoryList &CNetworkWatchdog::getLogCategories() { - static const BlackMisc::CLogCategoryList cats = CContinuousWorker::getLogCategories().with( + static const CLogCategoryList cats = CContinuousWorker::getLogCategories().with( { CLogCategory::swiftDbWebservice(), CLogCategory::webservice(), CLogCategory::network() }); diff --git a/src/blackcore/fsd/addpilot.cpp b/src/blackcore/fsd/addpilot.cpp index 9e85f5a2b..d57b4dca3 100644 --- a/src/blackcore/fsd/addpilot.cpp +++ b/src/blackcore/fsd/addpilot.cpp @@ -11,6 +11,8 @@ #include "blackmisc/logmessage.h" +using namespace BlackMisc; + namespace BlackCore { namespace Fsd @@ -40,9 +42,9 @@ namespace BlackCore { if (tokens.size() < 6) { - BlackMisc::CLogMessage(static_cast(nullptr)).warning(u"Wrong number of arguments."); + CLogMessage(static_cast(nullptr)).warning(u"Wrong number of arguments."); return {}; - }; + } PilotRating rating = static_cast(tokens[4].toInt()); int protocolRevision = tokens[5].toInt(); diff --git a/src/blackcore/fsd/addpilot.h b/src/blackcore/fsd/addpilot.h index 928d17b58..8e3765863 100644 --- a/src/blackcore/fsd/addpilot.h +++ b/src/blackcore/fsd/addpilot.h @@ -29,10 +29,10 @@ namespace BlackCore AddPilot(const QString &callsign, const QString &cid, const QString &password, PilotRating rating, int protocolRevision, SimType simType, const QString &realName); //! Get user cid - QString cid() const { return m_cid; } + const QString &cid() const { return m_cid; } //! Get user password - QString password() const { return m_password; } + const QString &password() const { return m_password; } //! Get pilot rating PilotRating rating() const { return m_rating; } @@ -44,7 +44,7 @@ namespace BlackCore SimType simType() const { return m_simType; } //! Get real name - QString realName() const { return m_realName; } + const QString &realName() const { return m_realName; } //! Message converted to tokens QStringList toTokens() const; diff --git a/src/blackcore/fsd/fsdclient.cpp b/src/blackcore/fsd/fsdclient.cpp index 4a2dddc4d..07c1bedb7 100644 --- a/src/blackcore/fsd/fsdclient.cpp +++ b/src/blackcore/fsd/fsdclient.cpp @@ -1246,10 +1246,10 @@ namespace BlackCore case ServerErrorCode::NoWeatherProfile: CLogMessage(this).info(u"FSD Server: requested weather profile does not exist"); break; // 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::InvalidCtrl: CLogMessage(this).info(u"Server invalid control: %1") << serverError.m_description; break; - case ServerErrorCode::Unknown: CLogMessage(this).info(u"Server sent unknown error code: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break; - case ServerErrorCode::AuthTimeout: CLogMessage(this).info(u"Client did not authenticate in time"); break; + case ServerErrorCode::AlreadyRegistered: CLogMessage(this).info(u"Server says already registered: %1") << serverError.m_description; break; + case ServerErrorCode::InvalidCtrl: CLogMessage(this).info(u"Server invalid control: %1") << serverError.m_description; break; + case ServerErrorCode::Unknown: CLogMessage(this).info(u"Server sent unknown error code: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break; + case ServerErrorCode::AuthTimeout: CLogMessage(this).info(u"Client did not authenticate in time"); break; } if (serverError.isFatalError()) { disconnectFromServer(); } } diff --git a/src/blackcore/fsd/fsdclient.h b/src/blackcore/fsd/fsdclient.h index 77a329735..f969e945b 100644 --- a/src/blackcore/fsd/fsdclient.h +++ b/src/blackcore/fsd/fsdclient.h @@ -208,9 +208,6 @@ namespace BlackCore //! We received a reply to one of our ATIS queries. void atisReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &atis); - //! We received a reply to one of our ATIS queries, containing the controller's voice room URL. - // void atisVoiceRoomReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url); - //! We received a reply to one of our ATIS queries, containing the controller's planned logoff time. void atisLogoffTimeReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &zuluTime); @@ -349,8 +346,8 @@ namespace BlackCore // Client data QString m_clientName; QString m_hostApplication; - int m_versionMajor = 0; - int m_versionMinor = 0; + int m_versionMajor = 0; + int m_versionMinor = 0; int m_protocolRevision = 0; ServerType m_serverType = ServerType::LegacyFsd; Capabilities m_capabilities = Capabilities::None; @@ -413,7 +410,7 @@ namespace BlackCore QTimer m_positionUpdateTimer; //!< sending positions QTimer m_interimPositionUpdateTimer; //!< sending interim positions - qint64 m_additionalOffsetTime = 0; //!< additional offset time + qint64 m_additionalOffsetTime = 0; //!< additional offset time bool m_statistics = false; QMap m_callStatistics;