mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 00:45:46 +08:00
Style and log messages
This commit is contained in:
committed by
Mat Sutcliffe
parent
441ca41ee3
commit
5fea046c0b
@@ -24,10 +24,11 @@
|
|||||||
#include <QWriteLocker>
|
#include <QWriteLocker>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Network;
|
|
||||||
using namespace BlackMisc::Simulation;
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
|
using namespace BlackMisc::Geo;
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackCore::Fsd;
|
using namespace BlackCore::Fsd;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
@@ -63,7 +64,7 @@ namespace BlackCore
|
|||||||
// Monitor
|
// Monitor
|
||||||
c = connect(airspaceMonitorParent, &CAirspaceMonitor::addedAircraftSituation, this, &CAirspaceAnalyzer::watchdogTouchAircraftCallsign);
|
c = connect(airspaceMonitorParent, &CAirspaceMonitor::addedAircraftSituation, this, &CAirspaceAnalyzer::watchdogTouchAircraftCallsign);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
Q_UNUSED(c);
|
Q_UNUSED(c)
|
||||||
|
|
||||||
// start in own thread
|
// start in own thread
|
||||||
this->start(QThread::LowestPriority);
|
this->start(QThread::LowestPriority);
|
||||||
@@ -89,7 +90,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CAirspaceAnalyzer::onNetworkPositionUpdate(const CAircraftSituation &situation, const CTransponder &transponder)
|
void CAirspaceAnalyzer::onNetworkPositionUpdate(const CAircraftSituation &situation, const CTransponder &transponder)
|
||||||
{
|
{
|
||||||
Q_UNUSED(transponder);
|
Q_UNUSED(transponder)
|
||||||
this->watchdogTouchAircraftCallsign(situation);
|
this->watchdogTouchAircraftCallsign(situation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,17 +100,17 @@ namespace BlackCore
|
|||||||
m_aircraftCallsignTimestamps[situation.getCallsign()] = QDateTime::currentMSecsSinceEpoch();
|
m_aircraftCallsignTimestamps[situation.getCallsign()] = QDateTime::currentMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirspaceAnalyzer::watchdogTouchAtcCallsign(const CCallsign &callsign, const CFrequency &frequency, const Geo::CCoordinateGeodetic &position, const CLength &range)
|
void CAirspaceAnalyzer::watchdogTouchAtcCallsign(const CCallsign &callsign, const CFrequency &frequency, const CCoordinateGeodetic &position, const CLength &range)
|
||||||
{
|
{
|
||||||
Q_UNUSED(frequency);
|
Q_UNUSED(frequency)
|
||||||
Q_UNUSED(position);
|
Q_UNUSED(position)
|
||||||
Q_UNUSED(range);
|
Q_UNUSED(range)
|
||||||
m_atcCallsignTimestamps[callsign] = QDateTime::currentMSecsSinceEpoch();
|
m_atcCallsignTimestamps[callsign] = QDateTime::currentMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirspaceAnalyzer::onConnectionStatusChanged(CConnectionStatus oldStatus, CConnectionStatus newStatus)
|
void CAirspaceAnalyzer::onConnectionStatusChanged(CConnectionStatus oldStatus, CConnectionStatus newStatus)
|
||||||
{
|
{
|
||||||
Q_UNUSED(oldStatus);
|
Q_UNUSED(oldStatus)
|
||||||
if (newStatus.isDisconnected())
|
if (newStatus.isDisconnected())
|
||||||
{
|
{
|
||||||
this->clear();
|
this->clear();
|
||||||
@@ -164,11 +165,11 @@ namespace BlackCore
|
|||||||
m_doNotRunAgainBefore = -1;
|
m_doNotRunAgainBefore = -1;
|
||||||
|
|
||||||
// checks
|
// checks
|
||||||
const qint64 aircraftTimeoutMs = m_timeoutAircraft.valueInteger(CTimeUnit::ms());
|
const qint64 aircraftTimeoutMs = m_timeoutAircraft.valueInteger(CTimeUnit::ms());
|
||||||
const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms());
|
const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms());
|
||||||
const qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs;
|
const qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs;
|
||||||
const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs;
|
const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs;
|
||||||
const bool enabled = m_enabledWatchdog;
|
const bool enabled = m_enabledWatchdog;
|
||||||
|
|
||||||
const QList<CCallsign> callsignsAircraft = m_aircraftCallsignTimestamps.keys();
|
const QList<CCallsign> callsignsAircraft = m_aircraftCallsignTimestamps.keys();
|
||||||
for (const CCallsign &callsign : callsignsAircraft) // clazy:exclude=container-anti-pattern,range-loop
|
for (const CCallsign &callsign : callsignsAircraft) // clazy:exclude=container-anti-pattern,range-loop
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace BlackCore
|
|||||||
CAirspaceMonitor *airspaceMonitorParent);
|
CAirspaceMonitor *airspaceMonitorParent);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CAirspaceAnalyzer();
|
virtual ~CAirspaceAnalyzer() override;
|
||||||
|
|
||||||
//! Get the latest snapshot
|
//! Get the latest snapshot
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -128,7 +128,7 @@ namespace BlackCore
|
|||||||
CCallsignTimestampSet m_aircraftCallsignTimestamps; //!< for watchdog (pilots)
|
CCallsignTimestampSet m_aircraftCallsignTimestamps; //!< for watchdog (pilots)
|
||||||
CCallsignTimestampSet m_atcCallsignTimestamps; //!< for watchdog (ATC)
|
CCallsignTimestampSet m_atcCallsignTimestamps; //!< for watchdog (ATC)
|
||||||
BlackMisc::PhysicalQuantities::CTime m_timeoutAircraft = { 15, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
BlackMisc::PhysicalQuantities::CTime m_timeoutAircraft = { 15, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
||||||
BlackMisc::PhysicalQuantities::CTime m_timeoutAtc = { 50, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
BlackMisc::PhysicalQuantities::CTime m_timeoutAtc = { 50, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
||||||
qint64 m_lastWatchdogCallMsSinceEpoch; //!< when last called
|
qint64 m_lastWatchdogCallMsSinceEpoch; //!< when last called
|
||||||
qint64 m_doNotRunAgainBefore = -1; //!< do not run again before, also used to detect debugging
|
qint64 m_doNotRunAgainBefore = -1; //!< do not run again before, also used to detect debugging
|
||||||
std::atomic_bool m_enabledWatchdog { true }; //!< watchdog enabled
|
std::atomic_bool m_enabledWatchdog { true }; //!< watchdog enabled
|
||||||
|
|||||||
@@ -729,15 +729,6 @@ namespace BlackCore
|
|||||||
if (changedAtis) { emit this->changedAtisReceived(callsign); }
|
if (changedAtis) { emit this->changedAtisReceived(callsign); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::onAtisVoiceRoomReceived(const CCallsign &callsign, const QString &url)
|
|
||||||
{
|
|
||||||
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
|
||||||
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
|
||||||
Q_UNUSED(url)
|
|
||||||
Q_UNUSED(callsign)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAirspaceMonitor::onAtisLogoffTimeReceived(const CCallsign &callsign, const QString &zuluTime)
|
void CAirspaceMonitor::onAtisLogoffTimeReceived(const CCallsign &callsign, const QString &zuluTime)
|
||||||
{
|
{
|
||||||
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
||||||
|
|||||||
@@ -391,9 +391,6 @@ namespace BlackCore
|
|||||||
void onAircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs);
|
void onAircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs);
|
||||||
void onAircraftInterimUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
void onAircraftInterimUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||||
void onConnectionStatusChanged(BlackMisc::Network::CConnectionStatus oldStatus, BlackMisc::Network::CConnectionStatus newStatus);
|
void onConnectionStatusChanged(BlackMisc::Network::CConnectionStatus oldStatus, BlackMisc::Network::CConnectionStatus newStatus);
|
||||||
|
|
||||||
//! \deprecated
|
|
||||||
void onAtisVoiceRoomReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url);
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "deletepilot.h"
|
#include "deletepilot.h"
|
||||||
|
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
namespace Fsd
|
namespace Fsd
|
||||||
@@ -34,9 +35,10 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (tokens.size() < 1)
|
if (tokens.size() < 1)
|
||||||
{
|
{
|
||||||
BlackMisc::CLogMessage(static_cast<DeletePilot *>(nullptr)).debug(u"Wrong number of arguments.");
|
CLogMessage(static_cast<DeletePilot *>(nullptr)).debug(u"Wrong number of arguments.");
|
||||||
return {};
|
return {};
|
||||||
};
|
}
|
||||||
|
|
||||||
// VATSIM FSD will always supply the CERTIFICATE ID when it rebroadcasts this PDU without regard for whether
|
// VATSIM FSD will always supply the CERTIFICATE ID when it rebroadcasts this PDU without regard for whether
|
||||||
// the client originally specified it. But other FSDs might not.
|
// the client originally specified it. But other FSDs might not.
|
||||||
DeletePilot packet(tokens[0], (tokens.size() >= 2) ? tokens[1] : "");
|
DeletePilot packet(tokens[0], (tokens.size() >= 2) ? tokens[1] : "");
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
#include "directplayutils.h"
|
#include "directplayutils.h"
|
||||||
#include "fs9.h"
|
#include "fs9.h"
|
||||||
#include "lobbyclient.h"
|
#include "lobbyclient.h"
|
||||||
|
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -22,6 +24,8 @@
|
|||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
namespace BlackSimPlugin
|
namespace BlackSimPlugin
|
||||||
{
|
{
|
||||||
namespace Fs9
|
namespace Fs9
|
||||||
@@ -90,20 +94,20 @@ namespace BlackSimPlugin
|
|||||||
bool CLobbyClient::canLobbyConnect()
|
bool CLobbyClient::canLobbyConnect()
|
||||||
{
|
{
|
||||||
if (!m_dpLobbyClient) { return false; }
|
if (!m_dpLobbyClient) { return false; }
|
||||||
GUID appGuid = CFs9Sdk::guid();
|
GUID appGuid = CFs9Sdk::guid();
|
||||||
DWORD dwSize = 0;
|
DWORD dwSize = 0;
|
||||||
DWORD dwItems = 0;
|
DWORD dwItems = 0;
|
||||||
HRESULT hr = m_dpLobbyClient->EnumLocalPrograms(&appGuid, nullptr, &dwSize, &dwItems, 0);
|
const HRESULT hr = m_dpLobbyClient->EnumLocalPrograms(&appGuid, nullptr, &dwSize, &dwItems, 0);
|
||||||
if (hr == DPNERR_BUFFERTOOSMALL)
|
if (hr == DPNERR_BUFFERTOOSMALL)
|
||||||
{
|
{
|
||||||
QScopedArrayPointer<BYTE> memPtr (new BYTE[dwSize]);
|
QScopedArrayPointer<BYTE> memPtr(new BYTE[dwSize]);
|
||||||
DPL_APPLICATION_INFO *appInfo = reinterpret_cast<DPL_APPLICATION_INFO *>(memPtr.data());
|
DPL_APPLICATION_INFO *appInfo = reinterpret_cast<DPL_APPLICATION_INFO *>(memPtr.data());
|
||||||
|
|
||||||
m_dpLobbyClient->EnumLocalPrograms(&appGuid, memPtr.data(), &dwSize, &dwItems, 0);
|
m_dpLobbyClient->EnumLocalPrograms(&appGuid, memPtr.data(), &dwSize, &dwItems, 0);
|
||||||
|
|
||||||
if (dwItems > 0)
|
if (dwItems > 0)
|
||||||
{
|
{
|
||||||
BlackMisc::CLogMessage(this).debug() << "Found lobby application:" << QString::fromWCharArray(appInfo->pwszApplicationName);;
|
CLogMessage(this).debug() << "Found lobby application:" << QString::fromWCharArray(appInfo->pwszApplicationName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -133,23 +137,20 @@ namespace BlackSimPlugin
|
|||||||
dnConnectInfo.guidApplication = pAppGuid;
|
dnConnectInfo.guidApplication = pAppGuid;
|
||||||
|
|
||||||
if (FAILED(hr = allocAndInitConnectSettings(address, &pAppGuid, &dnConnectInfo.pdplConnectionSettings)))
|
if (FAILED(hr = allocAndInitConnectSettings(address, &pAppGuid, &dnConnectInfo.pdplConnectionSettings)))
|
||||||
|
{
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
hr = m_dpLobbyClient->ConnectApplication(&dnConnectInfo,
|
hr = m_dpLobbyClient->ConnectApplication(&dnConnectInfo,
|
||||||
nullptr,
|
nullptr,
|
||||||
&m_applicationHandle,
|
&m_applicationHandle,
|
||||||
INFINITE,
|
INFINITE,
|
||||||
0);
|
0);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr)) { return hr; }
|
||||||
{
|
|
||||||
return hr;
|
CLogMessage(this).info(u"Lobby client '%1' connected!") << address;
|
||||||
}
|
freeConnectSettings(dnConnectInfo.pdplConnectionSettings);
|
||||||
else
|
return S_OK;
|
||||||
{
|
|
||||||
qDebug() << "Connected!";
|
|
||||||
freeConnectSettings(dnConnectInfo.pdplConnectionSettings);
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CLobbyClient::allocAndInitConnectSettings(const QString &address, GUID *pAppGuid, DPL_CONNECTION_SETTINGS **ppdplConnectSettings)
|
HRESULT CLobbyClient::allocAndInitConnectSettings(const QString &address, GUID *pAppGuid, DPL_CONNECTION_SETTINGS **ppdplConnectSettings)
|
||||||
@@ -269,7 +270,7 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
PDPL_MESSAGE_DISCONNECT pDisconnectMsg;
|
PDPL_MESSAGE_DISCONNECT pDisconnectMsg;
|
||||||
pDisconnectMsg = (PDPL_MESSAGE_DISCONNECT)msgBuffer;
|
pDisconnectMsg = (PDPL_MESSAGE_DISCONNECT)msgBuffer;
|
||||||
Q_UNUSED(pDisconnectMsg);
|
Q_UNUSED(pDisconnectMsg)
|
||||||
|
|
||||||
emit disconnected();
|
emit disconnected();
|
||||||
|
|
||||||
@@ -312,10 +313,11 @@ namespace BlackSimPlugin
|
|||||||
case DPLSESSION_HOSTMIGRATEDHERE:
|
case DPLSESSION_HOSTMIGRATEDHERE:
|
||||||
message.append("Host migrated to this client"); break;
|
message.append("Host migrated to this client"); break;
|
||||||
default:
|
default:
|
||||||
message.append(QString("Unknown PDPL_MESSAGE_SESSION_STATUS: %1").arg(pStatusMsg->dwStatus));
|
message.append(QStringLiteral("Unknown PDPL_MESSAGE_SESSION_STATUS: %1").arg(pStatusMsg->dwStatus));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
qDebug() << message;
|
|
||||||
|
CLogMessage(this).info(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user