Formatting, comments, Doxygen, minor tweaks

This commit is contained in:
Klaus Basan
2017-10-10 00:13:39 +01:00
committed by Mathew Sutcliffe
parent c5381b01c6
commit 9748b5a442
13 changed files with 287 additions and 287 deletions

View File

@@ -34,7 +34,7 @@ namespace BlackCore
CContextApplication *CContextApplication::registerWithDBus(BlackMisc::CDBusServer *server) CContextApplication *CContextApplication::registerWithDBus(BlackMisc::CDBusServer *server)
{ {
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) { return this; } if (!server || m_mode != CCoreFacadeConfig::LocalInDbusServer) { return this; }
server->addObject(IContextApplication::ObjectPath(), this); server->addObject(IContextApplication::ObjectPath(), this);
return this; return this;
} }
@@ -173,7 +173,7 @@ namespace BlackCore
void CContextApplication::unregisterApplication(const CIdentifier &application) void CContextApplication::unregisterApplication(const CIdentifier &application)
{ {
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << application; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << application; }
int r = this->m_registeredApplications.remove(application); int r = m_registeredApplications.remove(application);
if (r > 0) { emit registrationChanged(); } if (r > 0) { emit registrationChanged(); }
} }

View File

@@ -94,7 +94,7 @@ namespace BlackCore
CContextAudio *CContextAudio::registerWithDBus(CDBusServer *server) CContextAudio *CContextAudio::registerWithDBus(CDBusServer *server)
{ {
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) { return this; } if (!server || m_mode != CCoreFacadeConfig::LocalInDbusServer) { return this; }
server->addObject(IContextAudio::ObjectPath(), this); server->addObject(IContextAudio::ObjectPath(), this);
return this; return this;
} }
@@ -106,14 +106,14 @@ namespace BlackCore
CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return getComVoiceRooms(); return getComVoiceRooms();
} }
CVoiceRoom CContextAudio::getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const CVoiceRoom CContextAudio::getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << withAudioStatus; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << withAudioStatus; }
auto voiceChannel = m_voiceChannelMapping.value(comUnitValue); auto voiceChannel = m_voiceChannelMapping.value(comUnitValue);
@@ -129,7 +129,7 @@ namespace BlackCore
CVoiceRoomList CContextAudio::getComVoiceRooms() const CVoiceRoomList CContextAudio::getComVoiceRooms() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CVoiceRoomList voiceRoomList; CVoiceRoomList voiceRoomList;
@@ -160,7 +160,7 @@ namespace BlackCore
void CContextAudio::leaveAllVoiceRooms() void CContextAudio::leaveAllVoiceRooms()
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;} if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;}
m_voiceChannelMapping.clear(); m_voiceChannelMapping.clear();
m_channel1->leaveVoiceRoom(); m_channel1->leaveVoiceRoom();
@@ -171,7 +171,7 @@ namespace BlackCore
CIdentifier CContextAudio::audioRunsWhere() const CIdentifier CContextAudio::audioRunsWhere() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
static const BlackMisc::CIdentifier i("CContextAudio"); static const BlackMisc::CIdentifier i("CContextAudio");
return i; return i;
@@ -179,34 +179,34 @@ namespace BlackCore
CAudioDeviceInfoList CContextAudio::getAudioDevices() const CAudioDeviceInfoList CContextAudio::getAudioDevices() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CAudioDeviceInfoList devices = this->m_voiceOutputDevice->getOutputDevices(); CAudioDeviceInfoList devices = m_voiceOutputDevice->getOutputDevices();
devices = devices.join(this->m_voiceInputDevice->getInputDevices()); devices = devices.join(m_voiceInputDevice->getInputDevices());
return devices; return devices;
} }
CAudioDeviceInfoList CContextAudio::getCurrentAudioDevices() const CAudioDeviceInfoList CContextAudio::getCurrentAudioDevices() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CAudioDeviceInfoList devices; CAudioDeviceInfoList devices;
devices.push_back(this->m_voiceInputDevice->getCurrentInputDevice()); devices.push_back(m_voiceInputDevice->getCurrentInputDevice());
devices.push_back(this->m_voiceOutputDevice->getCurrentOutputDevice()); devices.push_back(m_voiceOutputDevice->getCurrentOutputDevice());
return devices; return devices;
} }
void CContextAudio::setCurrentAudioDevice(const CAudioDeviceInfo &audioDevice) void CContextAudio::setCurrentAudioDevice(const CAudioDeviceInfo &audioDevice)
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
Q_ASSERT(audioDevice.getType() != CAudioDeviceInfo::Unknown); Q_ASSERT(audioDevice.getType() != CAudioDeviceInfo::Unknown);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << audioDevice; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << audioDevice; }
bool changed = false; bool changed = false;
if (audioDevice.getType() == CAudioDeviceInfo::InputDevice) if (audioDevice.getType() == CAudioDeviceInfo::InputDevice)
{ {
if (this->m_voiceInputDevice->getCurrentInputDevice() != audioDevice) if (m_voiceInputDevice->getCurrentInputDevice() != audioDevice)
{ {
this->m_voiceInputDevice->setInputDevice(audioDevice); m_voiceInputDevice->setInputDevice(audioDevice);
changed = true; changed = true;
} }
if (m_inputDeviceSetting.get() != audioDevice.getName()) if (m_inputDeviceSetting.get() != audioDevice.getName())
@@ -216,9 +216,9 @@ namespace BlackCore
} }
else else
{ {
if (this->m_voiceOutputDevice->getCurrentOutputDevice() != audioDevice) if (m_voiceOutputDevice->getCurrentOutputDevice() != audioDevice)
{ {
this->m_voiceOutputDevice->setOutputDevice(audioDevice); m_voiceOutputDevice->setOutputDevice(audioDevice);
changed = true; changed = true;
} }
if (m_outputDeviceSetting.get() != audioDevice.getName()) if (m_outputDeviceSetting.get() != audioDevice.getName())
@@ -267,8 +267,8 @@ namespace BlackCore
int newVolume; int newVolume;
if (muted) if (muted)
{ {
Q_ASSERT(this->m_voiceOutputDevice); Q_ASSERT(m_voiceOutputDevice);
m_outVolumeBeforeMute = this->m_voiceOutputDevice->getOutputVolume(); m_outVolumeBeforeMute = m_voiceOutputDevice->getOutputVolume();
newVolume = 0; newVolume = 0;
} }
else else
@@ -296,7 +296,7 @@ namespace BlackCore
void CContextAudio::setComVoiceRooms(const CVoiceRoomList &newRooms) void CContextAudio::setComVoiceRooms(const CVoiceRoomList &newRooms)
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
Q_ASSERT(newRooms.size() == 2); Q_ASSERT(newRooms.size() == 2);
Q_ASSERT(getIContextOwnAircraft()); Q_ASSERT(getIContextOwnAircraft());
if (m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; } if (m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; }
@@ -405,7 +405,7 @@ namespace BlackCore
CCallsignSet CContextAudio::getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const CCallsignSet CContextAudio::getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
auto voiceChannel = m_voiceChannelMapping.value(comUnitValue); auto voiceChannel = m_voiceChannelMapping.value(comUnitValue);
@@ -421,7 +421,7 @@ namespace BlackCore
Network::CUserList CContextAudio::getRoomUsers(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const Network::CUserList CContextAudio::getRoomUsers(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
Q_ASSERT(this->getRuntime()); Q_ASSERT(this->getRuntime());
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList(); if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
@@ -431,14 +431,14 @@ namespace BlackCore
void CContextAudio::playSelcalTone(const CSelcal &selcal) const void CContextAudio::playSelcalTone(const CSelcal &selcal) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << selcal; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << selcal; }
m_selcalPlayer->play(90, selcal); m_selcalPlayer->play(90, selcal);
} }
void CContextAudio::playNotification(CNotificationSounds::Notification notification, bool considerSettings) const void CContextAudio::playNotification(CNotificationSounds::Notification notification, bool considerSettings) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; }
bool play = !considerSettings || m_audioSettings.getThreadLocal().getNotificationFlag(notification); bool play = !considerSettings || m_audioSettings.getThreadLocal().getNotificationFlag(notification);
@@ -456,7 +456,7 @@ namespace BlackCore
void CContextAudio::enableAudioLoopback(bool enable) void CContextAudio::enableAudioLoopback(bool enable)
{ {
Q_ASSERT(this->m_audioMixer); Q_ASSERT(m_audioMixer);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (enable) if (enable)
{ {
@@ -470,9 +470,9 @@ namespace BlackCore
bool CContextAudio::isAudioLoopbackEnabled() const bool CContextAudio::isAudioLoopbackEnabled() const
{ {
Q_ASSERT(this->m_audioMixer); Q_ASSERT(m_audioMixer);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_audioMixer->hasMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1); return m_audioMixer->hasMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1);
} }
bool CContextAudio::parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) bool CContextAudio::parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator)
@@ -561,7 +561,7 @@ namespace BlackCore
void CContextAudio::changeDeviceSettings() void CContextAudio::changeDeviceSettings()
{ {
QString inputDeviceName = m_inputDeviceSetting.get(); const QString inputDeviceName = m_inputDeviceSetting.get();
if (!inputDeviceName.isEmpty()) if (!inputDeviceName.isEmpty())
{ {
for (auto device : m_voiceInputDevice->getInputDevices()) for (auto device : m_voiceInputDevice->getInputDevices())
@@ -574,7 +574,7 @@ namespace BlackCore
} }
} }
QString outputDeviceName = m_outputDeviceSetting.get(); const QString outputDeviceName = m_outputDeviceSetting.get();
if (!outputDeviceName.isEmpty()) if (!outputDeviceName.isEmpty())
{ {
for (auto device : m_voiceOutputDevice->getOutputDevices()) for (auto device : m_voiceOutputDevice->getOutputDevices())

View File

@@ -65,36 +65,36 @@ namespace BlackCore
CContextNetwork::registerHelp(); CContextNetwork::registerHelp();
// 1. Init by "network driver" // 1. Init by "network driver"
this->m_network = new CNetworkVatlib(this->getRuntime()->getCContextOwnAircraft(), this); m_network = new CNetworkVatlib(this->getRuntime()->getCContextOwnAircraft(), this);
connect(this->m_network, &INetwork::connectionStatusChanged, this, &CContextNetwork::ps_fsdConnectionStatusChanged); connect(m_network, &INetwork::connectionStatusChanged, this, &CContextNetwork::ps_fsdConnectionStatusChanged);
connect(this->m_network, &INetwork::textMessagesReceived, this, &CContextNetwork::textMessagesReceived); connect(m_network, &INetwork::textMessagesReceived, this, &CContextNetwork::textMessagesReceived);
connect(this->m_network, &INetwork::textMessagesReceived, this, &CContextNetwork::ps_checkForSupervisiorTextMessage); connect(m_network, &INetwork::textMessagesReceived, this, &CContextNetwork::ps_checkForSupervisiorTextMessage);
connect(this->m_network, &INetwork::textMessageSent, this, &CContextNetwork::textMessageSent); connect(m_network, &INetwork::textMessageSent, this, &CContextNetwork::textMessageSent);
// 2. Update timer for data (network data such as frequency) // 2. Update timer for data (network data such as frequency)
this->m_networkDataUpdateTimer = new QTimer(this); m_networkDataUpdateTimer = new QTimer(this);
connect(this->m_networkDataUpdateTimer, &QTimer::timeout, this, &CContextNetwork::requestDataUpdates); connect(m_networkDataUpdateTimer, &QTimer::timeout, this, &CContextNetwork::requestDataUpdates);
this->m_networkDataUpdateTimer->start(30 * 1000); m_networkDataUpdateTimer->start(30 * 1000);
// 3. data reader, start reading when setup is synced with xx delay // 3. data reader, start reading when setup is synced with xx delay
Q_ASSERT_X(sApp->getWebDataServices(), Q_FUNC_INFO, "Missing web data services"); Q_ASSERT_X(sApp->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CContextNetwork::webServiceDataRead); connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CContextNetwork::webServiceDataRead);
// 4. Airspace contents // 4. Airspace contents
Q_ASSERT_X(this->getRuntime()->getCContextOwnAircraft(), Q_FUNC_INFO, "this and own aircraft context must be local"); Q_ASSERT_X(this->getRuntime()->getCContextOwnAircraft(), Q_FUNC_INFO, "this and own aircraft context must be local");
this->m_airspace = new CAirspaceMonitor(this->getRuntime()->getCContextOwnAircraft(), this->m_network, this); m_airspace = new CAirspaceMonitor(this->getRuntime()->getCContextOwnAircraft(), m_network, this);
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationsOnline, this, &CContextNetwork::changedAtcStationsOnline); connect(m_airspace, &CAirspaceMonitor::changedAtcStationsOnline, this, &CContextNetwork::changedAtcStationsOnline);
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationsBooked, this, &CContextNetwork::changedAtcStationsBooked); connect(m_airspace, &CAirspaceMonitor::changedAtcStationsBooked, this, &CContextNetwork::changedAtcStationsBooked);
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationOnlineConnectionStatus, this, &CContextNetwork::changedAtcStationOnlineConnectionStatus); connect(m_airspace, &CAirspaceMonitor::changedAtcStationOnlineConnectionStatus, this, &CContextNetwork::changedAtcStationOnlineConnectionStatus);
connect(this->m_airspace, &CAirspaceMonitor::changedAircraftInRange, this, &CContextNetwork::changedAircraftInRange); connect(m_airspace, &CAirspaceMonitor::changedAircraftInRange, this, &CContextNetwork::changedAircraftInRange);
connect(this->m_airspace, &CAirspaceMonitor::removedAircraft, this, &IContextNetwork::removedAircraft); // DBus connect(m_airspace, &CAirspaceMonitor::removedAircraft, this, &IContextNetwork::removedAircraft); // DBus
connect(this->m_airspace, &CAirspaceMonitor::readyForModelMatching, this, &CContextNetwork::readyForModelMatching); connect(m_airspace, &CAirspaceMonitor::readyForModelMatching, this, &CContextNetwork::readyForModelMatching);
connect(this->m_airspace, &CAirspaceMonitor::addedAircraft, this, &CContextNetwork::addedAircraft); connect(m_airspace, &CAirspaceMonitor::addedAircraft, this, &CContextNetwork::addedAircraft);
} }
CContextNetwork *CContextNetwork::registerWithDBus(BlackMisc::CDBusServer *server) CContextNetwork *CContextNetwork::registerWithDBus(BlackMisc::CDBusServer *server)
{ {
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) return this; if (!server || m_mode != CCoreFacadeConfig::LocalInDbusServer) return this;
server->addObject(IContextNetwork::ObjectPath(), this); server->addObject(IContextNetwork::ObjectPath(), this);
return this; return this;
} }
@@ -106,31 +106,31 @@ namespace BlackCore
CAircraftSituationList CContextNetwork::remoteAircraftSituations(const CCallsign &callsign) const CAircraftSituationList CContextNetwork::remoteAircraftSituations(const CCallsign &callsign) const
{ {
Q_ASSERT(this->m_airspace); Q_ASSERT(m_airspace);
return m_airspace->remoteAircraftSituations(callsign); return m_airspace->remoteAircraftSituations(callsign);
} }
CAircraftPartsList CContextNetwork::remoteAircraftParts(const CCallsign &callsign, qint64 cutoffTimeBefore) const CAircraftPartsList CContextNetwork::remoteAircraftParts(const CCallsign &callsign, qint64 cutoffTimeBefore) const
{ {
Q_ASSERT(this->m_airspace); Q_ASSERT(m_airspace);
return m_airspace->remoteAircraftParts(callsign, cutoffTimeBefore); return m_airspace->remoteAircraftParts(callsign, cutoffTimeBefore);
} }
int CContextNetwork::remoteAircraftSituationsCount(const CCallsign &callsign) const int CContextNetwork::remoteAircraftSituationsCount(const CCallsign &callsign) const
{ {
Q_ASSERT(this->m_airspace); Q_ASSERT(m_airspace);
return m_airspace->remoteAircraftSituationsCount(callsign); return m_airspace->remoteAircraftSituationsCount(callsign);
} }
bool CContextNetwork::isRemoteAircraftSupportingParts(const CCallsign &callsign) const bool CContextNetwork::isRemoteAircraftSupportingParts(const CCallsign &callsign) const
{ {
Q_ASSERT(this->m_airspace); Q_ASSERT(m_airspace);
return m_airspace->isRemoteAircraftSupportingParts(callsign); return m_airspace->isRemoteAircraftSupportingParts(callsign);
} }
CCallsignSet CContextNetwork::remoteAircraftSupportingParts() const CCallsignSet CContextNetwork::remoteAircraftSupportingParts() const
{ {
Q_ASSERT(this->m_airspace); Q_ASSERT(m_airspace);
return m_airspace->remoteAircraftSupportingParts(); return m_airspace->remoteAircraftSupportingParts();
} }
@@ -141,15 +141,15 @@ namespace BlackCore
std::function<void (const CCallsign &)> removedAircraftSlot, std::function<void (const CCallsign &)> removedAircraftSlot,
std::function<void (const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshotSlot) std::function<void (const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshotSlot)
{ {
Q_ASSERT_X(this->m_airspace, Q_FUNC_INFO, "Missing airspace"); Q_ASSERT_X(m_airspace, Q_FUNC_INFO, "Missing airspace");
return this->m_airspace->connectRemoteAircraftProviderSignals(receiver, situationSlot, partsSlot, removedAircraftSlot, aircraftSnapshotSlot); return m_airspace->connectRemoteAircraftProviderSignals(receiver, situationSlot, partsSlot, removedAircraftSlot, aircraftSnapshotSlot);
} }
void CContextNetwork::gracefulShutdown() void CContextNetwork::gracefulShutdown()
{ {
this->disconnect(); // all signals this->disconnect(); // all signals
if (this->isConnected()) { this->disconnectFromNetwork(); } if (this->isConnected()) { this->disconnectFromNetwork(); }
if (this->m_airspace) { this->m_airspace->gracefulShutdown(); } if (m_airspace) { m_airspace->gracefulShutdown(); }
} }
CStatusMessage CContextNetwork::connectToNetwork(const CServer &server, INetwork::LoginMode mode) CStatusMessage CContextNetwork::connectToNetwork(const CServer &server, INetwork::LoginMode mode)
@@ -168,7 +168,7 @@ namespace BlackCore
{ {
return CStatusMessage(CStatusMessage::SeverityError, msg); return CStatusMessage(CStatusMessage::SeverityError, msg);
} }
else if (this->m_network->isConnected()) else if (m_network->isConnected())
{ {
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityError, "Already connected"); return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityError, "Already connected");
} }
@@ -178,10 +178,10 @@ namespace BlackCore
} }
else else
{ {
this->m_currentStatus = INetwork::Connecting; // as semaphore we are going to connect m_currentStatus = INetwork::Connecting; // as semaphore we are going to connect
this->getIContextOwnAircraft()->updateOwnAircraftPilot(server.getUser()); this->getIContextOwnAircraft()->updateOwnAircraftPilot(server.getUser());
const CSimulatedAircraft ownAircraft(this->ownAircraft()); const CSimulatedAircraft ownAircraft(this->ownAircraft());
this->m_network->presetServer(server); m_network->presetServer(server);
// Fall back to observer mode, if no simulator is available or not simulating // Fall back to observer mode, if no simulator is available or not simulating
if (CBuildConfig::isStableBranch() && !this->getIContextSimulator()->isSimulatorSimulating()) if (CBuildConfig::isStableBranch() && !this->getIContextSimulator()->isSimulatorSimulating())
@@ -190,18 +190,18 @@ namespace BlackCore
mode = INetwork::LoginAsObserver; mode = INetwork::LoginAsObserver;
} }
this->m_network->presetLoginMode(mode); m_network->presetLoginMode(mode);
this->m_network->presetCallsign(ownAircraft.getCallsign()); m_network->presetCallsign(ownAircraft.getCallsign());
this->m_network->presetIcaoCodes(ownAircraft); m_network->presetIcaoCodes(ownAircraft);
if (getIContextSimulator()) if (getIContextSimulator())
{ {
this->m_network->presetSimulatorInfo(getIContextSimulator()->getSimulatorPluginInfo()); m_network->presetSimulatorInfo(getIContextSimulator()->getSimulatorPluginInfo());
} }
else else
{ {
this->m_network->presetSimulatorInfo(CSimulatorPluginInfo()); m_network->presetSimulatorInfo(CSimulatorPluginInfo());
} }
this->m_network->initiateConnection(); m_network->initiateConnection();
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection pending " + server.getAddress() + " " + QString::number(server.getPort())); return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection pending " + server.getAddress() + " " + QString::number(server.getPort()));
} }
} }
@@ -209,17 +209,17 @@ namespace BlackCore
CServer CContextNetwork::getConnectedServer() const CServer CContextNetwork::getConnectedServer() const
{ {
return this->isConnected() ? return this->isConnected() ?
this->m_network->getPresetServer() : m_network->getPresetServer() :
CServer(); CServer();
} }
CStatusMessage CContextNetwork::disconnectFromNetwork() CStatusMessage CContextNetwork::disconnectFromNetwork()
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (this->m_network->isConnected() || this->m_network->isPendingConnection()) if (m_network->isConnected() || m_network->isPendingConnection())
{ {
this->m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect
this->m_network->terminateConnection(); m_network->terminateConnection();
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection terminating"); return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection terminating");
} }
else else
@@ -231,16 +231,16 @@ namespace BlackCore
bool CContextNetwork::isConnected() const bool CContextNetwork::isConnected() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_network->isConnected(); return m_network->isConnected();
} }
bool CContextNetwork::isPendingConnection() const bool CContextNetwork::isPendingConnection() const
{ {
// if underlying class says pending, we believe it. But not all states (e.g. disconnecting) are covered // if underlying class says pending, we believe it. But not all states (e.g. disconnecting) are covered
if (this->m_network->isPendingConnection()) return true; if (m_network->isPendingConnection()) return true;
// now check out own extra states, e.g. disconnecting // now check out own extra states, e.g. disconnecting
return INetwork::isPendingStatus(this->m_currentStatus); return INetwork::isPendingStatus(m_currentStatus);
} }
bool CContextNetwork::parseCommandLine(const QString &commandLine, const CIdentifier &originator) bool CContextNetwork::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
@@ -333,26 +333,26 @@ namespace BlackCore
void CContextNetwork::sendTextMessages(const CTextMessageList &textMessages) void CContextNetwork::sendTextMessages(const CTextMessageList &textMessages)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << textMessages; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << textMessages; }
this->m_network->sendTextMessages(textMessages); m_network->sendTextMessages(textMessages);
} }
void CContextNetwork::sendFlightPlan(const CFlightPlan &flightPlan) void CContextNetwork::sendFlightPlan(const CFlightPlan &flightPlan)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << flightPlan; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << flightPlan; }
this->m_network->sendFlightPlan(flightPlan); m_network->sendFlightPlan(flightPlan);
this->m_network->sendFlightPlanQuery(this->ownAircraft().getCallsign()); m_network->sendFlightPlanQuery(this->ownAircraft().getCallsign());
} }
CFlightPlan CContextNetwork::loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const CFlightPlan CContextNetwork::loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->loadFlightPlanFromNetwork(callsign); return m_airspace->loadFlightPlanFromNetwork(callsign);
} }
CUserList CContextNetwork::getUsers() const CUserList CContextNetwork::getUsers() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getUsers(); return m_airspace->getUsers();
} }
CUserList CContextNetwork::getUsersForCallsigns(const CCallsignSet &callsigns) const CUserList CContextNetwork::getUsersForCallsigns(const CCallsignSet &callsigns) const
@@ -360,7 +360,7 @@ namespace BlackCore
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CUserList users; CUserList users;
if (callsigns.isEmpty()) return users; if (callsigns.isEmpty()) return users;
return this->m_airspace->getUsersForCallsigns(callsigns); return m_airspace->getUsersForCallsigns(callsigns);
} }
CUser CContextNetwork::getUserForCallsign(const CCallsign &callsign) const CUser CContextNetwork::getUserForCallsign(const CCallsign &callsign) const
@@ -376,13 +376,13 @@ namespace BlackCore
CClientList CContextNetwork::getOtherClients() const CClientList CContextNetwork::getOtherClients() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getOtherClients(); return m_airspace->getOtherClients();
} }
CClientList CContextNetwork::getOtherClientsForCallsigns(const CCallsignSet &callsigns) const CClientList CContextNetwork::getOtherClientsForCallsigns(const CCallsignSet &callsigns) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getOtherClientsForCallsigns(callsigns); return m_airspace->getOtherClientsForCallsigns(callsigns);
} }
CServerList CContextNetwork::getVatsimFsdServers() const CServerList CContextNetwork::getVatsimFsdServers() const
@@ -402,8 +402,8 @@ namespace BlackCore
void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to) void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << from << to; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << from << to; }
auto fromOld = this->m_currentStatus; // own status cached auto fromOld = m_currentStatus; // own status cached
this->m_currentStatus = to; m_currentStatus = to;
if (fromOld == INetwork::Disconnecting) if (fromOld == INetwork::Disconnecting)
{ {
@@ -475,125 +475,125 @@ namespace BlackCore
CAtcStationList CContextNetwork::getAtcStationsOnline() const CAtcStationList CContextNetwork::getAtcStationsOnline() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getAtcStationsOnline(); return m_airspace->getAtcStationsOnline();
} }
CAtcStationList CContextNetwork::getAtcStationsBooked() const CAtcStationList CContextNetwork::getAtcStationsBooked() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getAtcStationsBooked(); return m_airspace->getAtcStationsBooked();
} }
CSimulatedAircraftList CContextNetwork::getAircraftInRange() const CSimulatedAircraftList CContextNetwork::getAircraftInRange() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getAircraftInRange(); return m_airspace->getAircraftInRange();
} }
CCallsignSet CContextNetwork::getAircraftInRangeCallsigns() const CCallsignSet CContextNetwork::getAircraftInRangeCallsigns() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getAircraftInRangeCallsigns(); return m_airspace->getAircraftInRangeCallsigns();
} }
int CContextNetwork::getAircraftInRangeCount() const int CContextNetwork::getAircraftInRangeCount() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getAircraftInRangeCount(); return m_airspace->getAircraftInRangeCount();
} }
bool CContextNetwork::isAircraftInRange(const CCallsign &callsign) const bool CContextNetwork::isAircraftInRange(const CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->isAircraftInRange(callsign); return m_airspace->isAircraftInRange(callsign);
} }
CSimulatedAircraft CContextNetwork::getAircraftInRangeForCallsign(const CCallsign &callsign) const CSimulatedAircraft CContextNetwork::getAircraftInRangeForCallsign(const CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->getAircraftInRangeForCallsign(callsign); return m_airspace->getAircraftInRangeForCallsign(callsign);
} }
CAircraftModel CContextNetwork::getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const CAircraftModel CContextNetwork::getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->getAircraftInRangeModelForCallsign(callsign); return m_airspace->getAircraftInRangeModelForCallsign(callsign);
} }
CStatusMessageList CContextNetwork::getReverseLookupMessages(const CCallsign &callsign) const CStatusMessageList CContextNetwork::getReverseLookupMessages(const CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->getReverseLookupMessages(callsign); return m_airspace->getReverseLookupMessages(callsign);
} }
bool CContextNetwork::isReverseLookupMessagesEnabled() const bool CContextNetwork::isReverseLookupMessagesEnabled() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->isReverseLookupMessagesEnabled(); return m_airspace->isReverseLookupMessagesEnabled();
} }
void CContextNetwork::enableReverseLookupMessages(bool enabled) void CContextNetwork::enableReverseLookupMessages(bool enabled)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << enabled; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << enabled; }
if (this->m_airspace->isReverseLookupMessagesEnabled() == enabled) { return; } if (m_airspace->isReverseLookupMessagesEnabled() == enabled) { return; }
this->m_airspace->enableReverseLookupMessages(enabled); m_airspace->enableReverseLookupMessages(enabled);
emit CContext::changedLogOrDebugSettings(); emit CContext::changedLogOrDebugSettings();
} }
CStatusMessageList CContextNetwork::getAircraftPartsHistory(const CCallsign &callsign) const CStatusMessageList CContextNetwork::getAircraftPartsHistory(const CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->getAircraftPartsHistory(callsign); return m_airspace->getAircraftPartsHistory(callsign);
} }
CAircraftPartsList CContextNetwork::getRemoteAircraftParts(const CCallsign &callsign, qint64 cutoffTimeValuesBefore) const CAircraftPartsList CContextNetwork::getRemoteAircraftParts(const CCallsign &callsign, qint64 cutoffTimeValuesBefore) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->remoteAircraftParts(callsign, cutoffTimeValuesBefore); return m_airspace->remoteAircraftParts(callsign, cutoffTimeValuesBefore);
} }
bool CContextNetwork::isAircraftPartsHistoryEnabled() const bool CContextNetwork::isAircraftPartsHistoryEnabled() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->isAircraftPartsHistoryEnabled(); return m_airspace->isAircraftPartsHistoryEnabled();
} }
void CContextNetwork::enableAircraftPartsHistory(bool enabled) void CContextNetwork::enableAircraftPartsHistory(bool enabled)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << enabled; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << enabled; }
this->m_airspace->enableAircraftPartsHistory(enabled); m_airspace->enableAircraftPartsHistory(enabled);
emit CContext::changedLogOrDebugSettings(); emit CContext::changedLogOrDebugSettings();
} }
CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->getAtcStationsOnline().findFirstByCallsign(callsign); return m_airspace->getAtcStationsOnline().findFirstByCallsign(callsign);
} }
void CContextNetwork::requestDataUpdates() void CContextNetwork::requestDataUpdates()
{ {
Q_ASSERT(this->m_network); Q_ASSERT(m_network);
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (!this->isConnected()) { return; } if (!this->isConnected()) { return; }
this->requestAtisUpdates(); this->requestAtisUpdates();
this->m_airspace->requestDataUpdates(); m_airspace->requestDataUpdates();
} }
void CContextNetwork::requestAtisUpdates() void CContextNetwork::requestAtisUpdates()
{ {
Q_ASSERT(this->m_network); Q_ASSERT(m_network);
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (!this->isConnected()) { return; } if (!this->isConnected()) { return; }
this->m_airspace->requestAtisUpdates(); m_airspace->requestAtisUpdates();
} }
bool CContextNetwork::updateAircraftEnabled(const CCallsign &callsign, bool enabledForRendering) bool CContextNetwork::updateAircraftEnabled(const CCallsign &callsign, bool enabledForRendering)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << enabledForRendering; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << enabledForRendering; }
bool c = this->m_airspace->updateAircraftEnabled(callsign, enabledForRendering); bool c = m_airspace->updateAircraftEnabled(callsign, enabledForRendering);
if (c) if (c)
{ {
CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign)); CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign));
@@ -606,7 +606,7 @@ namespace BlackCore
bool CContextNetwork::updateAircraftModel(const CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator) bool CContextNetwork::updateAircraftModel(const CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << model; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << model; }
bool c = this->m_airspace->updateAircraftModel(callsign, model, originator); bool c = m_airspace->updateAircraftModel(callsign, model, originator);
if (c) if (c)
{ {
const CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign)); const CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign));
@@ -619,7 +619,7 @@ namespace BlackCore
bool CContextNetwork::updateAircraftNetworkModel(const CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator) bool CContextNetwork::updateAircraftNetworkModel(const CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << model; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << model; }
const bool c = this->m_airspace->updateAircraftNetworkModel(callsign, model, originator); const bool c = m_airspace->updateAircraftNetworkModel(callsign, model, originator);
if (c) if (c)
{ {
const CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign)); const CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign));
@@ -631,7 +631,7 @@ namespace BlackCore
bool CContextNetwork::updateFastPositionEnabled(const CCallsign &callsign, bool enableFastPositonUpdates) bool CContextNetwork::updateFastPositionEnabled(const CCallsign &callsign, bool enableFastPositonUpdates)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << enableFastPositonUpdates; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << enableFastPositonUpdates; }
bool c = this->m_airspace->updateFastPositionEnabled(callsign, enableFastPositonUpdates); bool c = m_airspace->updateFastPositionEnabled(callsign, enableFastPositonUpdates);
if (c) if (c)
{ {
CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign)); CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign));
@@ -644,61 +644,61 @@ namespace BlackCore
void CContextNetwork::requestAtcBookingsUpdate() const void CContextNetwork::requestAtcBookingsUpdate() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
this->m_airspace->requestAtcBookingsUpdate(); m_airspace->requestAtcBookingsUpdate();
} }
bool CContextNetwork::updateAircraftRendered(const CCallsign &callsign, bool rendered) bool CContextNetwork::updateAircraftRendered(const CCallsign &callsign, bool rendered)
{ {
bool c = this->m_airspace->updateAircraftRendered(callsign, rendered); bool c = m_airspace->updateAircraftRendered(callsign, rendered);
return c; return c;
} }
bool CContextNetwork::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation) bool CContextNetwork::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
{ {
return this->m_airspace->updateAircraftGroundElevation(callsign, elevation); return m_airspace->updateAircraftGroundElevation(callsign, elevation);
} }
void CContextNetwork::updateMarkAllAsNotRendered() void CContextNetwork::updateMarkAllAsNotRendered()
{ {
this->m_airspace->updateMarkAllAsNotRendered(); m_airspace->updateMarkAllAsNotRendered();
} }
CAirspaceAircraftSnapshot CContextNetwork::getLatestAirspaceAircraftSnapshot() const CAirspaceAircraftSnapshot CContextNetwork::getLatestAirspaceAircraftSnapshot() const
{ {
return this->m_airspace->getLatestAirspaceAircraftSnapshot(); return m_airspace->getLatestAirspaceAircraftSnapshot();
} }
void CContextNetwork::setFastPositionEnabledCallsigns(CCallsignSet &callsigns) void CContextNetwork::setFastPositionEnabledCallsigns(CCallsignSet &callsigns)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsigns; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsigns; }
Q_ASSERT(this->m_network); Q_ASSERT(m_network);
this->m_network->setInterimPositionReceivers(callsigns); m_network->setInterimPositionReceivers(callsigns);
} }
CCallsignSet CContextNetwork::getFastPositionEnabledCallsigns() const CCallsignSet CContextNetwork::getFastPositionEnabledCallsigns() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
Q_ASSERT(this->m_network); Q_ASSERT(m_network);
return this->m_network->getInterimPositionReceivers(); return m_network->getInterimPositionReceivers();
} }
void CContextNetwork::testRequestAircraftConfig(const CCallsign &callsign) void CContextNetwork::testRequestAircraftConfig(const CCallsign &callsign)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
Q_ASSERT(this->m_network); Q_ASSERT(m_network);
this->m_network->sendAircraftConfigQuery(callsign); m_network->sendAircraftConfigQuery(callsign);
} }
void CContextNetwork::testCreateDummyOnlineAtcStations(int number) void CContextNetwork::testCreateDummyOnlineAtcStations(int number)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << number; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << number; }
this->m_airspace->testCreateDummyOnlineAtcStations(number); m_airspace->testCreateDummyOnlineAtcStations(number);
} }
void CContextNetwork::testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const CAircraftParts &parts, bool incremental) void CContextNetwork::testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const CAircraftParts &parts, bool incremental)
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << parts << incremental; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << parts << incremental; }
this->m_airspace->testAddAircraftParts(callsign, parts, incremental); m_airspace->testAddAircraftParts(callsign, parts, incremental);
} }
void CContextNetwork::testReceivedTextMessages(const CTextMessageList &textMessages) void CContextNetwork::testReceivedTextMessages(const CTextMessageList &textMessages)
@@ -719,8 +719,8 @@ namespace BlackCore
CAtcStationList CContextNetwork::getSelectedAtcStations() const CAtcStationList CContextNetwork::getSelectedAtcStations() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CAtcStation com1Station = this->m_airspace->getAtcStationForComUnit(this->ownAircraft().getCom1System()); CAtcStation com1Station = m_airspace->getAtcStationForComUnit(this->ownAircraft().getCom1System());
CAtcStation com2Station = this->m_airspace->getAtcStationForComUnit(this->ownAircraft().getCom2System()); CAtcStation com2Station = m_airspace->getAtcStationForComUnit(this->ownAircraft().getCom2System());
CAtcStationList selectedStations; CAtcStationList selectedStations;
selectedStations.push_back(com1Station); selectedStations.push_back(com1Station);

View File

@@ -205,10 +205,10 @@ namespace BlackCore
CAirspaceMonitor *airspace() const { return m_airspace; } CAirspaceMonitor *airspace() const { return m_airspace; }
private: private:
CAirspaceMonitor *m_airspace = nullptr; CAirspaceMonitor *m_airspace = nullptr;
INetwork *m_network = nullptr; INetwork *m_network = nullptr;
INetwork::ConnectionStatus m_currentStatus = INetwork::Disconnected; //!< used to detect pending connections INetwork::ConnectionStatus m_currentStatus = INetwork::Disconnected; //!< used to detect pending connections
QTimer *m_networkDataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates() QTimer *m_networkDataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
// Digest signals, only sending after some time // Digest signals, only sending after some time
BlackMisc::CDigestSignal m_dsAtcStationsBookedChanged { this, &IContextNetwork::changedAtcStationsBooked, &IContextNetwork::changedAtcStationsBookedDigest, 750, 2 }; BlackMisc::CDigestSignal m_dsAtcStationsBookedChanged { this, &IContextNetwork::changedAtcStationsBooked, &IContextNetwork::changedAtcStationsBookedDigest, 750, 2 };

View File

@@ -73,40 +73,40 @@ namespace BlackCore
CContextOwnAircraft *CContextOwnAircraft::registerWithDBus(CDBusServer *server) CContextOwnAircraft *CContextOwnAircraft::registerWithDBus(CDBusServer *server)
{ {
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) return this; if (!server || m_mode != CCoreFacadeConfig::LocalInDbusServer) return this;
server->addObject(IContextOwnAircraft::ObjectPath(), this); server->addObject(IContextOwnAircraft::ObjectPath(), this);
return this; return this;
} }
CSimulatedAircraft CContextOwnAircraft::getOwnAircraft() const CSimulatedAircraft CContextOwnAircraft::getOwnAircraft() const
{ {
if (this->m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
QReadLocker l(&m_lockAircraft); QReadLocker l(&m_lockAircraft);
return this->m_ownAircraft; return m_ownAircraft;
} }
CCoordinateGeodetic CContextOwnAircraft::getOwnAircraftPosition() const CCoordinateGeodetic CContextOwnAircraft::getOwnAircraftPosition() const
{ {
QReadLocker l(&m_lockAircraft); QReadLocker l(&m_lockAircraft);
return this->m_ownAircraft.getPosition(); return m_ownAircraft.getPosition();
} }
CAircraftSituation CContextOwnAircraft::getOwnAircraftSituation() const CAircraftSituation CContextOwnAircraft::getOwnAircraftSituation() const
{ {
QReadLocker l(&m_lockAircraft); QReadLocker l(&m_lockAircraft);
return this->m_ownAircraft.getSituation(); return m_ownAircraft.getSituation();
} }
CAircraftParts CContextOwnAircraft::getOwnAircraftParts() const CAircraftParts CContextOwnAircraft::getOwnAircraftParts() const
{ {
QReadLocker l(&m_lockAircraft); QReadLocker l(&m_lockAircraft);
return this->m_ownAircraft.getParts(); return m_ownAircraft.getParts();
} }
CAircraftModel CContextOwnAircraft::getOwnAircraftModel() const CAircraftModel CContextOwnAircraft::getOwnAircraftModel() const
{ {
QReadLocker l(&m_lockAircraft); QReadLocker l(&m_lockAircraft);
return this->m_ownAircraft.getModel(); return m_ownAircraft.getModel();
} }
CLength CContextOwnAircraft::getDistanceToOwnAircraft(const ICoordinateGeodetic &position) const CLength CContextOwnAircraft::getDistanceToOwnAircraft(const ICoordinateGeodetic &position) const
@@ -121,13 +121,13 @@ namespace BlackCore
{ {
// use copy to minimize lock time // use copy to minimize lock time
QReadLocker rl(&m_lockAircraft); QReadLocker rl(&m_lockAircraft);
ownAircraft = this->m_ownAircraft; ownAircraft = m_ownAircraft;
} }
ownAircraft.initComSystems(); ownAircraft.initComSystems();
ownAircraft.initTransponder(); ownAircraft.initTransponder();
ownAircraft.setSituation(getDefaultSituation()); ownAircraft.setSituation(getDefaultSituation());
ownAircraft.setPilot(this->m_currentNetworkServer.get().getUser()); ownAircraft.setPilot(m_currentNetworkServer.get().getUser());
// If we already have a model from somehwere, keep it, otherwise init default // If we already have a model from somehwere, keep it, otherwise init default
ownAircraft.setModel(this->reverseLookupModel(ownAircraft.getModel())); ownAircraft.setModel(this->reverseLookupModel(ownAircraft.getModel()));
@@ -163,16 +163,16 @@ namespace BlackCore
if (!this->getIContextNetwork() || !this->getIContextAudio() || !this->getIContextApplication()) { return; } // no chance to resolve rooms if (!this->getIContextNetwork() || !this->getIContextAudio() || !this->getIContextApplication()) { return; } // no chance to resolve rooms
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (this->m_voiceRoom1UrlOverride.isEmpty() && this->m_voiceRoom2UrlOverride.isEmpty() && !this->m_automaticVoiceRoomResolution) { return; } if (m_voiceRoom1UrlOverride.isEmpty() && m_voiceRoom2UrlOverride.isEmpty() && !m_automaticVoiceRoomResolution) { return; }
if (!this->m_automaticVoiceRoomResolution) { return; } // not responsible if (!m_automaticVoiceRoomResolution) { return; } // not responsible
// requires correct frequencies set // requires correct frequencies set
// but local network uses exactly this object here, so if frequencies are set here, // but local network uses exactly this object here, so if frequencies are set here,
// they are for network context as well // they are for network context as well
CVoiceRoomList rooms = this->getIContextNetwork()->getSelectedVoiceRooms(); CVoiceRoomList rooms = this->getIContextNetwork()->getSelectedVoiceRooms();
if (!this->m_voiceRoom1UrlOverride.isEmpty()) rooms[0] = CVoiceRoom(this->m_voiceRoom1UrlOverride); if (!m_voiceRoom1UrlOverride.isEmpty()) rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride);
if (!this->m_voiceRoom2UrlOverride.isEmpty()) rooms[1] = CVoiceRoom(this->m_voiceRoom2UrlOverride); if (!m_voiceRoom2UrlOverride.isEmpty()) rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride);
// set the rooms // set the rooms
emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms); emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms);
@@ -189,9 +189,9 @@ namespace BlackCore
{ {
CAircraftModel updateModel(this->reverseLookupModel(model)); CAircraftModel updateModel(this->reverseLookupModel(model));
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
const bool changed = (this->m_ownAircraft.getModel() != updateModel); const bool changed = (m_ownAircraft.getModel() != updateModel);
if (!changed) { return false; } if (!changed) { return false; }
this->m_ownAircraft.setModel(updateModel); m_ownAircraft.setModel(updateModel);
return true; return true;
} }
@@ -199,46 +199,46 @@ namespace BlackCore
{ {
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
// there is intentionally no equal check // there is intentionally no equal check
this->m_ownAircraft.setSituation(situation); m_ownAircraft.setSituation(situation);
return true; return true;
} }
bool CContextOwnAircraft::updateOwnParts(const CAircraftParts &parts) bool CContextOwnAircraft::updateOwnParts(const CAircraftParts &parts)
{ {
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
bool changed = (this->m_ownAircraft.getParts() != parts); bool changed = (m_ownAircraft.getParts() != parts);
if (!changed) { return false; } if (!changed) { return false; }
this->m_ownAircraft.setParts(parts); m_ownAircraft.setParts(parts);
return true; return true;
} }
bool CContextOwnAircraft::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) bool CContextOwnAircraft::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude)
{ {
if (this->m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << position << altitude; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << position << altitude; }
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
bool changed = (this->m_ownAircraft.getPosition() != position); bool changed = (m_ownAircraft.getPosition() != position);
if (changed) { this->m_ownAircraft.setPosition(position); } if (changed) { m_ownAircraft.setPosition(position); }
if (this->m_ownAircraft.getAltitude() != altitude) if (m_ownAircraft.getAltitude() != altitude)
{ {
changed = true; changed = true;
this->m_ownAircraft.setAltitude(altitude); m_ownAircraft.setAltitude(altitude);
} }
return changed; return changed;
} }
bool CContextOwnAircraft::updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const CIdentifier &originator) bool CContextOwnAircraft::updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const CIdentifier &originator)
{ {
if (this->m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder; }
bool changed; bool changed;
{ {
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
changed = this->m_ownAircraft.hasChangedCockpitData(com1, com2, transponder); changed = m_ownAircraft.hasChangedCockpitData(com1, com2, transponder);
if (changed) { this->m_ownAircraft.setCockpit(com1, com2, transponder); } if (changed) { m_ownAircraft.setCockpit(com1, com2, transponder); }
} }
if (changed) if (changed)
{ {
emit this->changedAircraftCockpit(this->m_ownAircraft, originator); emit this->changedAircraftCockpit(m_ownAircraft, originator);
this->resolveVoiceRooms(); this->resolveVoiceRooms();
} }
return changed; return changed;
@@ -252,9 +252,9 @@ namespace BlackCore
CTransponder xpdr; CTransponder xpdr;
{ {
QReadLocker l(&m_lockAircraft); QReadLocker l(&m_lockAircraft);
com1 = this->m_ownAircraft.getCom1System(); com1 = m_ownAircraft.getCom1System();
com2 = this->m_ownAircraft.getCom2System(); com2 = m_ownAircraft.getCom2System();
xpdr = this->m_ownAircraft.getTransponder(); xpdr = m_ownAircraft.getTransponder();
} }
if (unit == CComSystem::Com1) if (unit == CComSystem::Com1)
{ {
@@ -271,8 +271,8 @@ namespace BlackCore
{ {
{ {
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
if (this->m_ownAircraft.getPilot() == pilot) { return false; } if (m_ownAircraft.getPilot() == pilot) { return false; }
this->m_ownAircraft.setPilot(pilot); m_ownAircraft.setPilot(pilot);
} }
emit this->changedPilot(pilot); emit this->changedPilot(pilot);
return true; return true;
@@ -282,8 +282,8 @@ namespace BlackCore
{ {
{ {
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
if (this->m_ownAircraft.getCallsign() == callsign) { return false; } if (m_ownAircraft.getCallsign() == callsign) { return false; }
this->m_ownAircraft.setCallsign(callsign); m_ownAircraft.setCallsign(callsign);
} }
emit this->changedCallsign(callsign); emit this->changedCallsign(callsign);
return true; return true;
@@ -293,7 +293,7 @@ namespace BlackCore
{ {
{ {
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
if (!this->m_ownAircraft.setIcaoCodes(aircraftIcaoCode, airlineIcaoCode)) { return false; } if (!m_ownAircraft.setIcaoCodes(aircraftIcaoCode, airlineIcaoCode)) { return false; }
} }
emit this->changedAircraftIcaoCodes(aircraftIcaoCode, airlineIcaoCode); emit this->changedAircraftIcaoCodes(aircraftIcaoCode, airlineIcaoCode);
return true; return true;
@@ -303,8 +303,8 @@ namespace BlackCore
{ {
{ {
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
if (this->m_ownAircraft.getSelcal() == selcal) { return false; } if (m_ownAircraft.getSelcal() == selcal) { return false; }
this->m_ownAircraft.setSelcal(selcal); m_ownAircraft.setSelcal(selcal);
} }
emit this->changedSelcal(selcal, originator); emit this->changedSelcal(selcal, originator);
return true; return true;
@@ -338,16 +338,16 @@ namespace BlackCore
void CContextOwnAircraft::setAudioVoiceRoomOverrideUrls(const QString &voiceRoom1Url, const QString &voiceRoom2Url) void CContextOwnAircraft::setAudioVoiceRoomOverrideUrls(const QString &voiceRoom1Url, const QString &voiceRoom2Url)
{ {
if (this->m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; }
this->m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed(); m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed();
this->m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed(); m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed();
this->resolveVoiceRooms(); this->resolveVoiceRooms();
} }
void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable) void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable)
{ {
if (this->m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enable; } if (m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enable; }
this->m_automaticVoiceRoomResolution = enable; m_automaticVoiceRoomResolution = enable;
} }
bool CContextOwnAircraft::parseCommandLine(const QString &commandLine, const CIdentifier &originator) bool CContextOwnAircraft::parseCommandLine(const QString &commandLine, const CIdentifier &originator)

View File

@@ -79,10 +79,10 @@ namespace BlackCore
if (config.requiresDBusConnection()) if (config.requiresDBusConnection())
{ {
this->initDBusConnection(dbusAddress); this->initDBusConnection(dbusAddress);
if (!this->m_dbusConnection.isConnected()) if (!m_dbusConnection.isConnected())
{ {
QString notConnected("DBus connection failed: "); QString notConnected("DBus connection failed: ");
const QString e = this->m_dbusConnection.lastError().message(); const QString e = m_dbusConnection.lastError().message();
if (!e.isEmpty()) { notConnected.append(e); } if (!e.isEmpty()) { notConnected.append(e); }
Q_ASSERT_X(false, "CRuntime::init", notConnected.toUtf8().constData()); Q_ASSERT_X(false, "CRuntime::init", notConnected.toUtf8().constData());
CLogMessage(this).error(notConnected); CLogMessage(this).error(notConnected);
@@ -91,27 +91,27 @@ namespace BlackCore
times.insert("DBus", time.restart()); times.insert("DBus", time.restart());
// contexts // contexts
this->m_contextApplication = IContextApplication::create(this, config.getModeApplication(), this->m_dbusServer, this->m_dbusConnection); m_contextApplication = IContextApplication::create(this, config.getModeApplication(), m_dbusServer, m_dbusConnection);
times.insert("Application", time.restart()); times.insert("Application", time.restart());
this->m_contextAudio = IContextAudio::create(this, config.getModeAudio(), this->m_dbusServer, this->m_dbusConnection); m_contextAudio = IContextAudio::create(this, config.getModeAudio(), m_dbusServer, m_dbusConnection);
times.insert("Audio", time.restart()); times.insert("Audio", time.restart());
this->m_contextOwnAircraft = IContextOwnAircraft::create(this, config.getModeOwnAircraft(), this->m_dbusServer, this->m_dbusConnection); m_contextOwnAircraft = IContextOwnAircraft::create(this, config.getModeOwnAircraft(), m_dbusServer, m_dbusConnection);
times.insert("Own aircraft", time.restart()); times.insert("Own aircraft", time.restart());
this->m_contextNetwork = IContextNetwork::create(this, config.getModeNetwork(), this->m_dbusServer, this->m_dbusConnection); m_contextNetwork = IContextNetwork::create(this, config.getModeNetwork(), m_dbusServer, m_dbusConnection);
times.insert("Network", time.restart()); times.insert("Network", time.restart());
this->m_contextSimulator = IContextSimulator::create(this, config.getModeSimulator(), this->m_dbusServer, this->m_dbusConnection); m_contextSimulator = IContextSimulator::create(this, config.getModeSimulator(), m_dbusServer, m_dbusConnection);
times.insert("Simulator", time.restart()); times.insert("Simulator", time.restart());
// checks -------------- // checks --------------
// 1. own aircraft and simulator should reside in same location // 1. own aircraft and simulator should reside in same location
Q_ASSERT(!this->m_contextSimulator || (this->m_contextOwnAircraft->isUsingImplementingObject() == this->m_contextSimulator->isUsingImplementingObject())); Q_ASSERT(!m_contextSimulator || (m_contextOwnAircraft->isUsingImplementingObject() == m_contextSimulator->isUsingImplementingObject()));
// 2. own aircraft and network should reside in same location // 2. own aircraft and network should reside in same location
Q_ASSERT(!this->m_contextNetwork || (this->m_contextOwnAircraft->isUsingImplementingObject() == this->m_contextNetwork->isUsingImplementingObject())); Q_ASSERT(!m_contextNetwork || (m_contextOwnAircraft->isUsingImplementingObject() == m_contextNetwork->isUsingImplementingObject()));
// post inits, wiring things among context (e.g. signal slots) // post inits, wiring things among context (e.g. signal slots)
time.restart(); time.restart();
@@ -125,8 +125,8 @@ namespace BlackCore
bool CCoreFacade::hasRemoteApplicationContext() const bool CCoreFacade::hasRemoteApplicationContext() const
{ {
Q_ASSERT(this->m_contextApplication); Q_ASSERT(m_contextApplication);
return !this->m_contextApplication->isUsingImplementingObject(); return !m_contextApplication->isUsingImplementingObject();
} }
void CCoreFacade::registerMetadata() void CCoreFacade::registerMetadata()
@@ -148,9 +148,9 @@ namespace BlackCore
void CCoreFacade::initDBusServer(const QString &dBusAddress) void CCoreFacade::initDBusServer(const QString &dBusAddress)
{ {
if (this->m_dbusServer) { return; } if (m_dbusServer) { return; }
Q_ASSERT(!dBusAddress.isEmpty()); Q_ASSERT(!dBusAddress.isEmpty());
this->m_dbusServer = new CDBusServer(dBusAddress, this); m_dbusServer = new CDBusServer(dBusAddress, this);
CLogMessage(this).info("DBus server on address: %1") << dBusAddress; CLogMessage(this).info("DBus server on address: %1") << dBusAddress;
} }
@@ -164,35 +164,35 @@ namespace BlackCore
times.insert("Post setup, connects first", time.restart()); times.insert("Post setup, connects first", time.restart());
// local simulator? // local simulator?
if (this->m_contextSimulator && this->m_contextSimulator->isUsingImplementingObject()) if (m_contextSimulator && m_contextSimulator->isUsingImplementingObject())
{ {
// only connect if network runs locally, no round trips // only connect if network runs locally, no round trips
// remark: from a design perspective it would be nice if those could be avoided (seperation of concerns) // remark: from a design perspective it would be nice if those could be avoided (seperation of concerns)
// those connects here reprent cross context dependencies // those connects here reprent cross context dependencies
if (this->m_contextNetwork && this->m_contextNetwork->isUsingImplementingObject()) if (m_contextNetwork && m_contextNetwork->isUsingImplementingObject())
{ {
Q_ASSERT_X(this->getCContextNetwork(), Q_FUNC_INFO, "No local network object"); Q_ASSERT_X(this->getCContextNetwork(), Q_FUNC_INFO, "No local network object");
Q_ASSERT_X(this->getCContextNetwork()->airspace(), Q_FUNC_INFO, "No airspace object"); Q_ASSERT_X(this->getCContextNetwork()->airspace(), Q_FUNC_INFO, "No airspace object");
c = connect(this->m_contextNetwork, &IContextNetwork::textMessagesReceived, c = connect(m_contextNetwork, &IContextNetwork::textMessagesReceived,
this->getCContextSimulator(), &CContextSimulator::ps_textMessagesReceived); this->getCContextSimulator(), &CContextSimulator::ps_textMessagesReceived);
Q_ASSERT(c); Q_ASSERT(c);
// use readyForModelMatching instead of CAirspaceMonitor::addedAircraft, as it contains client information // use readyForModelMatching instead of CAirspaceMonitor::addedAircraft, as it contains client information
// ready for model matching is sent delayed when all information are available // ready for model matching is sent delayed when all information are available
c = connect(this->m_contextNetwork, &IContextNetwork::readyForModelMatching, c = connect(m_contextNetwork, &IContextNetwork::readyForModelMatching,
this->getCContextSimulator(), &CContextSimulator::ps_addedRemoteAircraft); this->getCContextSimulator(), &CContextSimulator::ps_addedRemoteAircraft);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(this->m_contextNetwork, &IContextNetwork::removedAircraft, c = connect(m_contextNetwork, &IContextNetwork::removedAircraft,
this->getCContextSimulator(), &CContextSimulator::ps_removedRemoteAircraft); this->getCContextSimulator(), &CContextSimulator::ps_removedRemoteAircraft);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(this->m_contextNetwork, &IContextNetwork::changedRemoteAircraftModel, c = connect(m_contextNetwork, &IContextNetwork::changedRemoteAircraftModel,
this->getCContextSimulator(), &CContextSimulator::ps_changedRemoteAircraftModel); this->getCContextSimulator(), &CContextSimulator::ps_changedRemoteAircraftModel);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(this->m_contextNetwork, &IContextNetwork::changedRemoteAircraftEnabled, c = connect(m_contextNetwork, &IContextNetwork::changedRemoteAircraftEnabled,
this->getCContextSimulator(), &CContextSimulator::ps_changedRemoteAircraftEnabled); this->getCContextSimulator(), &CContextSimulator::ps_changedRemoteAircraftEnabled);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(this->m_contextNetwork, &IContextNetwork::connectionStatusChanged, c = connect(m_contextNetwork, &IContextNetwork::connectionStatusChanged,
this->getCContextSimulator(), &CContextSimulator::ps_networkConnectionStatusChanged); this->getCContextSimulator(), &CContextSimulator::ps_networkConnectionStatusChanged);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(this->getCContextNetwork()->airspace(), &CAirspaceMonitor::requestedNewAircraft, c = connect(this->getCContextNetwork()->airspace(), &CAirspaceMonitor::requestedNewAircraft,
@@ -204,12 +204,12 @@ namespace BlackCore
} }
// only if own aircraft runs locally // only if own aircraft runs locally
if (this->m_contextOwnAircraft && this->m_contextOwnAircraft->isUsingImplementingObject()) if (m_contextOwnAircraft && m_contextOwnAircraft->isUsingImplementingObject())
{ {
c = connect(this->m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit, c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit,
this->getCContextSimulator(), &CContextSimulator::ps_updateSimulatorCockpitFromContext); this->getCContextSimulator(), &CContextSimulator::ps_updateSimulatorCockpitFromContext);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(this->m_contextOwnAircraft, &IContextOwnAircraft::changedSelcal, c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedSelcal,
this->getCContextSimulator(), &CContextSimulator::ps_updateSimulatorSelcalFromContext); this->getCContextSimulator(), &CContextSimulator::ps_updateSimulatorSelcalFromContext);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(this->getCContextSimulator(), &CContextSimulator::ownAircraftModelChanged, c = connect(this->getCContextSimulator(), &CContextSimulator::ownAircraftModelChanged,
@@ -223,23 +223,23 @@ namespace BlackCore
// only where network and(!) own aircraft run locally // only where network and(!) own aircraft run locally
// -> in the core or an all local implementation // -> in the core or an all local implementation
if (this->m_contextNetwork && this->m_contextOwnAircraft && this->m_contextNetwork->isUsingImplementingObject() && this->m_contextOwnAircraft->isUsingImplementingObject()) if (m_contextNetwork && m_contextOwnAircraft && m_contextNetwork->isUsingImplementingObject() && m_contextOwnAircraft->isUsingImplementingObject())
{ {
c = this->connect(this->m_contextNetwork, &IContextNetwork::changedAtcStationOnlineConnectionStatus, c = this->connect(m_contextNetwork, &IContextNetwork::changedAtcStationOnlineConnectionStatus,
this->getCContextOwnAircraft(), &CContextOwnAircraft::ps_changedAtcStationOnlineConnectionStatus); this->getCContextOwnAircraft(), &CContextOwnAircraft::ps_changedAtcStationOnlineConnectionStatus);
Q_ASSERT(c); Q_ASSERT(c);
times.insert("Post setup, connects network", time.restart()); times.insert("Post setup, connects network", time.restart());
} }
// fake signals to work around setting values in audio context for local audio with remote core // fake signals to work around setting values in audio context for local audio with remote core
if (this->m_contextAudio && this->m_contextAudio->isUsingImplementingObject()) if (m_contextAudio && m_contextAudio->isUsingImplementingObject())
{ {
Q_ASSERT(this->m_contextApplication); Q_ASSERT(m_contextApplication);
Q_ASSERT(this->m_contextOwnAircraft); Q_ASSERT(m_contextOwnAircraft);
c = this->connect(this->m_contextApplication, &IContextApplication::fakedSetComVoiceRoom, c = this->connect(m_contextApplication, &IContextApplication::fakedSetComVoiceRoom,
this->getCContextAudio(), &CContextAudio::setComVoiceRooms); this->getCContextAudio(), &CContextAudio::setComVoiceRooms);
Q_ASSERT(c); Q_ASSERT(c);
c = this->connect(this->m_contextOwnAircraft, &IContextOwnAircraft::changedCallsign, this->getCContextAudio(), &IContextAudio::setOwnCallsignForRooms); c = this->connect(m_contextOwnAircraft, &IContextOwnAircraft::changedCallsign, this->getCContextAudio(), &IContextAudio::setOwnCallsignForRooms);
Q_ASSERT(c); Q_ASSERT(c);
times.insert("Post setup, connects audio", time.restart()); times.insert("Post setup, connects audio", time.restart());
} }
@@ -247,15 +247,15 @@ namespace BlackCore
void CCoreFacade::gracefulShutdown() void CCoreFacade::gracefulShutdown()
{ {
if (!this->m_initalized) { return; } if (!m_initalized) { return; }
if (m_shuttingDown) { return; } if (m_shuttingDown) { return; }
this->m_shuttingDown = true; m_shuttingDown = true;
// disable all signals towards runtime // disable all signals towards runtime
disconnect(this); disconnect(this);
// unregister all from DBus // unregister all from DBus
if (this->m_dbusServer) { this->m_dbusServer->removeAllObjects(); } if (m_dbusServer) { m_dbusServer->removeAllObjects(); }
// handle contexts // handle contexts
if (this->getIContextSimulator()) if (this->getIContextSimulator())
@@ -268,7 +268,7 @@ namespace BlackCore
} }
this->getIContextSimulator()->deleteLater(); this->getIContextSimulator()->deleteLater();
QDBusConnection defaultConnection("default"); QDBusConnection defaultConnection("default");
this->m_contextSimulator = IContextSimulator::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection); m_contextSimulator = IContextSimulator::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
} }
// log off from network, if connected // log off from network, if connected
@@ -276,14 +276,14 @@ namespace BlackCore
{ {
disconnect(this->getIContextNetwork()); disconnect(this->getIContextNetwork());
this->getIContextNetwork()->disconnectFromNetwork(); this->getIContextNetwork()->disconnectFromNetwork();
if (this->m_contextNetwork->isUsingImplementingObject()) if (m_contextNetwork->isUsingImplementingObject())
{ {
this->getCContextNetwork()->gracefulShutdown(); // for threads this->getCContextNetwork()->gracefulShutdown(); // for threads
} }
this->getIContextNetwork()->deleteLater(); this->getIContextNetwork()->deleteLater();
// replace by dummy object avoiding nullptr issues during shutdown phase // replace by dummy object avoiding nullptr issues during shutdown phase
QDBusConnection defaultConnection("default"); QDBusConnection defaultConnection("default");
this->m_contextNetwork = IContextNetwork::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection); m_contextNetwork = IContextNetwork::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
} }
if (this->getIContextAudio()) if (this->getIContextAudio())
@@ -292,7 +292,7 @@ namespace BlackCore
this->getIContextAudio()->deleteLater(); this->getIContextAudio()->deleteLater();
// replace by dummy object avoiding nullptr issues during shutdown phase // replace by dummy object avoiding nullptr issues during shutdown phase
QDBusConnection defaultConnection("default"); QDBusConnection defaultConnection("default");
this->m_contextAudio = IContextAudio::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection); m_contextAudio = IContextAudio::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
} }
if (this->getIContextOwnAircraft()) if (this->getIContextOwnAircraft())
@@ -300,7 +300,7 @@ namespace BlackCore
disconnect(this->getIContextOwnAircraft()); disconnect(this->getIContextOwnAircraft());
this->getIContextOwnAircraft()->deleteLater(); this->getIContextOwnAircraft()->deleteLater();
QDBusConnection defaultConnection("default"); QDBusConnection defaultConnection("default");
this->m_contextOwnAircraft = IContextOwnAircraft::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection); m_contextOwnAircraft = IContextOwnAircraft::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
} }
if (this->getIContextApplication()) if (this->getIContextApplication())
@@ -308,134 +308,134 @@ namespace BlackCore
disconnect(this->getIContextApplication()); disconnect(this->getIContextApplication());
this->getIContextApplication()->deleteLater(); this->getIContextApplication()->deleteLater();
QDBusConnection defaultConnection("default"); QDBusConnection defaultConnection("default");
this->m_contextApplication = IContextApplication::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection); m_contextApplication = IContextApplication::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
} }
} }
void CCoreFacade::initDBusConnection(const QString &address) void CCoreFacade::initDBusConnection(const QString &address)
{ {
if (this->m_initDBusConnection) { return; } if (m_initDBusConnection) { return; }
if (address.isEmpty() || address == CDBusServer::sessionBusAddress()) if (address.isEmpty() || address == CDBusServer::sessionBusAddress())
{ {
this->m_dbusConnection = QDBusConnection::sessionBus(); m_dbusConnection = QDBusConnection::sessionBus();
} }
else if (address == CDBusServer::systemBusAddress()) else if (address == CDBusServer::systemBusAddress())
{ {
this->m_dbusConnection = QDBusConnection::sessionBus(); m_dbusConnection = QDBusConnection::sessionBus();
} }
else else
{ {
this->m_dbusConnection = QDBusConnection::connectToPeer(address, "BlackBoxRuntime"); m_dbusConnection = QDBusConnection::connectToPeer(address, "BlackBoxRuntime");
} }
} }
const IContextApplication *CCoreFacade::getIContextApplication() const const IContextApplication *CCoreFacade::getIContextApplication() const
{ {
return this->m_contextApplication; return m_contextApplication;
} }
IContextApplication *CCoreFacade::getIContextApplication() IContextApplication *CCoreFacade::getIContextApplication()
{ {
return this->m_contextApplication; return m_contextApplication;
} }
IContextAudio *CCoreFacade::getIContextAudio() IContextAudio *CCoreFacade::getIContextAudio()
{ {
return this->m_contextAudio; return m_contextAudio;
} }
const IContextAudio *CCoreFacade::getIContextAudio() const const IContextAudio *CCoreFacade::getIContextAudio() const
{ {
return this->m_contextAudio; return m_contextAudio;
} }
IContextNetwork *CCoreFacade::getIContextNetwork() IContextNetwork *CCoreFacade::getIContextNetwork()
{ {
return this->m_contextNetwork; return m_contextNetwork;
} }
const IContextNetwork *CCoreFacade::getIContextNetwork() const const IContextNetwork *CCoreFacade::getIContextNetwork() const
{ {
return this->m_contextNetwork; return m_contextNetwork;
} }
IContextOwnAircraft *CCoreFacade::getIContextOwnAircraft() IContextOwnAircraft *CCoreFacade::getIContextOwnAircraft()
{ {
return this->m_contextOwnAircraft; return m_contextOwnAircraft;
} }
const IContextOwnAircraft *CCoreFacade::getIContextOwnAircraft() const const IContextOwnAircraft *CCoreFacade::getIContextOwnAircraft() const
{ {
return this->m_contextOwnAircraft; return m_contextOwnAircraft;
} }
const IContextSimulator *CCoreFacade::getIContextSimulator() const const IContextSimulator *CCoreFacade::getIContextSimulator() const
{ {
return this->m_contextSimulator; return m_contextSimulator;
} }
IContextSimulator *CCoreFacade::getIContextSimulator() IContextSimulator *CCoreFacade::getIContextSimulator()
{ {
return this->m_contextSimulator; return m_contextSimulator;
} }
CContextAudio *CCoreFacade::getCContextAudio() CContextAudio *CCoreFacade::getCContextAudio()
{ {
Q_ASSERT_X(this->m_contextAudio && this->m_contextAudio->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextAudio && m_contextAudio->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextAudio *>(this->m_contextAudio); return static_cast<CContextAudio *>(m_contextAudio);
} }
const CContextAudio *CCoreFacade::getCContextAudio() const const CContextAudio *CCoreFacade::getCContextAudio() const
{ {
Q_ASSERT_X(this->m_contextAudio && this->m_contextAudio->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextAudio && m_contextAudio->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextAudio *>(this->m_contextAudio); return static_cast<CContextAudio *>(m_contextAudio);
} }
CContextApplication *CCoreFacade::getCContextApplication() CContextApplication *CCoreFacade::getCContextApplication()
{ {
Q_ASSERT_X(this->m_contextApplication && this->m_contextApplication->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextApplication && m_contextApplication->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextApplication *>(this->m_contextApplication); return static_cast<CContextApplication *>(m_contextApplication);
} }
const CContextApplication *CCoreFacade::getCContextApplication() const const CContextApplication *CCoreFacade::getCContextApplication() const
{ {
Q_ASSERT_X(this->m_contextApplication && this->m_contextApplication->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextApplication && m_contextApplication->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextApplication *>(this->m_contextApplication); return static_cast<CContextApplication *>(m_contextApplication);
} }
CContextNetwork *CCoreFacade::getCContextNetwork() CContextNetwork *CCoreFacade::getCContextNetwork()
{ {
Q_ASSERT_X(this->m_contextNetwork && this->m_contextNetwork->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextNetwork && m_contextNetwork->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextNetwork *>(this->m_contextNetwork); return static_cast<CContextNetwork *>(m_contextNetwork);
} }
const CContextNetwork *CCoreFacade::getCContextNetwork() const const CContextNetwork *CCoreFacade::getCContextNetwork() const
{ {
Q_ASSERT_X(this->m_contextNetwork && this->m_contextNetwork->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextNetwork && m_contextNetwork->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextNetwork *>(this->m_contextNetwork); return static_cast<CContextNetwork *>(m_contextNetwork);
} }
CContextOwnAircraft *CCoreFacade::getCContextOwnAircraft() CContextOwnAircraft *CCoreFacade::getCContextOwnAircraft()
{ {
Q_ASSERT_X(this->m_contextOwnAircraft && this->m_contextOwnAircraft->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextOwnAircraft && m_contextOwnAircraft->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextOwnAircraft *>(this->m_contextOwnAircraft); return static_cast<CContextOwnAircraft *>(m_contextOwnAircraft);
} }
const CContextOwnAircraft *CCoreFacade::getCContextOwnAircraft() const const CContextOwnAircraft *CCoreFacade::getCContextOwnAircraft() const
{ {
Q_ASSERT_X(this->m_contextOwnAircraft && this->m_contextOwnAircraft->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextOwnAircraft && m_contextOwnAircraft->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextOwnAircraft *>(this->m_contextOwnAircraft); return static_cast<CContextOwnAircraft *>(m_contextOwnAircraft);
} }
CContextSimulator *CCoreFacade::getCContextSimulator() CContextSimulator *CCoreFacade::getCContextSimulator()
{ {
Q_ASSERT_X(this->m_contextSimulator && this->m_contextSimulator->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextSimulator && m_contextSimulator->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextSimulator *>(this->m_contextSimulator); return static_cast<CContextSimulator *>(m_contextSimulator);
} }
const CContextSimulator *CCoreFacade::getCContextSimulator() const const CContextSimulator *CCoreFacade::getCContextSimulator() const
{ {
Q_ASSERT_X(this->m_contextSimulator && this->m_contextSimulator->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); Q_ASSERT_X(m_contextSimulator && m_contextSimulator->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
return static_cast<CContextSimulator *>(this->m_contextSimulator); return static_cast<CContextSimulator *>(m_contextSimulator);
} }
} // namespace } // namespace

View File

@@ -86,22 +86,22 @@ namespace BlackCore
//! DBus address? //! DBus address?
bool hasDBusAddress() const { return !this->m_dbusAddress.isEmpty(); } bool hasDBusAddress() const { return !this->m_dbusAddress.isEmpty(); }
//! predefined for Core //! Predefined for Core
static CCoreFacadeConfig forCoreAllLocalInDBus(const QString &dbusBootstrapAddress = ""); static CCoreFacadeConfig forCoreAllLocalInDBus(const QString &dbusBootstrapAddress = "");
//! predefined for Core //! Predefined for Core
static CCoreFacadeConfig forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress = ""); static CCoreFacadeConfig forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress = "");
//! predefined, completely local (e.g. for unit tests) //! Predefined, completely local (e.g. for unit tests)
static CCoreFacadeConfig local(const QString &dbusBootstrapAddress = ""); static CCoreFacadeConfig local(const QString &dbusBootstrapAddress = "");
//! predefined, completely remote (e.g. for GUI with core) //! Predefined, completely remote (e.g. for GUI with core)
static CCoreFacadeConfig remote(const QString &dbusBootstrapAddress = ""); static CCoreFacadeConfig remote(const QString &dbusBootstrapAddress = "");
//! predefined, remote with local audio (e.g. Aduio in GUI) //! Predefined, remote with local audio (e.g. Aduio in GUI)
static CCoreFacadeConfig remoteLocalAudio(const QString &dbusBootstrapAddress = ""); static CCoreFacadeConfig remoteLocalAudio(const QString &dbusBootstrapAddress = "");
//! predefined all empty config (normlly used when the real config can only be determined later) //! Predefined, all empty configs (normally used when the real config can only be determined later)
static CCoreFacadeConfig allEmpty(); static CCoreFacadeConfig allEmpty();
}; };
} }

View File

@@ -104,8 +104,8 @@ namespace BlackCore
{ {
const CUrlList urls(this->m_onlineHelpUrls); const CUrlList urls(this->m_onlineHelpUrls);
// we display in the standard browser, so the user will realize if the URL // we display in the standard browser,
// does not work // so the user will realize if the URL does not work
CUrl url = (urls.size() < 2) ? urls.frontOrDefault() : urls.getRandomUrl(); CUrl url = (urls.size() < 2) ? urls.frontOrDefault() : urls.getRandomUrl();
if (url.isEmpty()) { return url; } if (url.isEmpty()) { return url; }

View File

@@ -47,9 +47,9 @@ CSwiftCore::CSwiftCore(QWidget *parent) :
setSystemTrayMode(MinimizeToTray | QuitOnClose); setSystemTrayMode(MinimizeToTray | QuitOnClose);
setSystemTrayToolTip(name); setSystemTrayToolTip(name);
this->m_mwaLogComponent = ui->comp_InfoArea->getLogComponent(); m_mwaLogComponent = ui->comp_InfoArea->getLogComponent();
this->m_mwaOverlayFrame = nullptr; m_mwaOverlayFrame = nullptr;
this->m_mwaStatusBar = nullptr; m_mwaStatusBar = nullptr;
initLogDisplay(); initLogDisplay();
initSlots(); initSlots();
@@ -149,7 +149,7 @@ void CSwiftCore::initSlots()
void CSwiftCore::initLogDisplay() void CSwiftCore::initLogDisplay()
{ {
this->m_mwaLogComponent->showDetails(false); m_mwaLogComponent->showDetails(false);
CLogHandler::instance()->install(true); CLogHandler::instance()->install(true);
CLogHandler::instance()->enableConsoleOutput(false); // default disable CLogHandler::instance()->enableConsoleOutput(false); // default disable
auto logHandler = CLogHandler::instance()->handlerForPattern( auto logHandler = CLogHandler::instance()->handlerForPattern(

View File

@@ -147,12 +147,12 @@ private:
//! Audio device lists //! Audio device lists
void setAudioDeviceLists(); void setAudioDeviceLists();
//! Context availability, used by watchdog //! Context and DBus availability, used by watchdog
void setContextAvailability(); void setContextAvailability();
//! Position of own plane for testing //! Position of own plane for testing
//! \param wgsLatitude WGS latitude //! \param wgsLatitude WGS latitude
//! \param wgsLongitude WGS longitude //! \param wgsLongitude WGS longitude
//! \param altitude //! \param altitude
void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude); void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude);

View File

@@ -39,9 +39,9 @@ bool SwiftGuiStd::ps_reloadOwnAircraft()
// check for changed aircraft // check for changed aircraft
bool changed = false; bool changed = false;
CSimulatedAircraft loadedAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft(); CSimulatedAircraft loadedAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
if (loadedAircraft != this->m_ownAircraft) if (loadedAircraft != m_ownAircraft)
{ {
this->m_ownAircraft = loadedAircraft; m_ownAircraft = loadedAircraft;
changed = true; changed = true;
} }
return changed; return changed;
@@ -54,7 +54,7 @@ void SwiftGuiStd::setTestPosition(const QString &wgsLatitude, const QString &wgs
CLongitude::fromWgs84(wgsLongitude), CLongitude::fromWgs84(wgsLongitude),
CAltitude(0, CLengthUnit::m())); CAltitude(0, CLengthUnit::m()));
this->m_ownAircraft.setPosition(coordinate); m_ownAircraft.setPosition(coordinate);
this->m_ownAircraft.setAltitude(altitude); m_ownAircraft.setAltitude(altitude);
sGui->getIContextOwnAircraft()->updateOwnPosition(coordinate, altitude); sGui->getIContextOwnAircraft()->updateOwnPosition(coordinate, altitude);
} }

View File

@@ -22,7 +22,7 @@ using namespace BlackCore;
CSwiftGuiStdApplication::CSwiftGuiStdApplication() : CSwiftGuiStdApplication::CSwiftGuiStdApplication() :
CGuiApplication(CApplicationInfo::swiftPilotClientGui(), CApplicationInfo::PilotClientGui, CIcons::swift1024()) CGuiApplication(CApplicationInfo::swiftPilotClientGui(), CApplicationInfo::PilotClientGui, CIcons::swift1024())
{ {
this->addParserOption(this->m_cmdFacadeMode); this->addParserOption(m_cmdFacadeMode);
this->addWindowModeOption(); this->addWindowModeOption();
this->addDBusAddressOption(); this->addDBusAddressOption();
this->addVatlibOptions(); this->addVatlibOptions();
@@ -33,9 +33,9 @@ CStatusMessageList CSwiftGuiStdApplication::startHookIn()
Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed cmd line arguments"); Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed cmd line arguments");
CoreModes::CoreMode coreMode = CoreModes::CoreInGuiProcess; CoreModes::CoreMode coreMode = CoreModes::CoreInGuiProcess;
const QString dBusAddress(this->getCmdDBusAddressValue()); const QString dBusAddress(this->getCmdDBusAddressValue());
if (this->isParserOptionSet(this->m_cmdFacadeMode)) if (this->isParserOptionSet(m_cmdFacadeMode))
{ {
const QString v(this->getParserValue(this->m_cmdFacadeMode)); const QString v(this->getParserValue(m_cmdFacadeMode));
coreMode = CoreModes::stringToCoreMode(v); coreMode = CoreModes::stringToCoreMode(v);
} }

View File

@@ -62,12 +62,12 @@ void SwiftGuiStd::init()
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui"); Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "Missing web services"); Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "Missing web services");
if (this->m_init) { return; } if (m_init) { return; }
this->setVisible(false); // hide all, so no flashing windows during init this->setVisible(false); // hide all, so no flashing windows during init
this->m_mwaStatusBar = &this->m_statusBar; m_mwaStatusBar = &m_statusBar;
this->m_mwaOverlayFrame = ui->fr_CentralFrameInside; m_mwaOverlayFrame = ui->fr_CentralFrameInside;
this->m_mwaLogComponent = ui->comp_MainInfoArea->getLogComponent(); m_mwaLogComponent = ui->comp_MainInfoArea->getLogComponent();
sGui->initMainApplicationWindow(this); sGui->initMainApplicationWindow(this);
@@ -98,24 +98,24 @@ void SwiftGuiStd::init()
} }
// timers // timers
if (this->m_timerContextWatchdog == nullptr) if (m_timerContextWatchdog == nullptr)
{ {
this->m_timerContextWatchdog = new QTimer(this); m_timerContextWatchdog = new QTimer(this);
this->m_timerContextWatchdog->setObjectName(this->objectName().append(":m_timerContextWatchdog")); m_timerContextWatchdog->setObjectName(this->objectName().append(":m_timerContextWatchdog"));
} }
// info bar and status bar // info bar and status bar
this->m_statusBar.initStatusBar(ui->sb_MainStatusBar); m_statusBar.initStatusBar(ui->sb_MainStatusBar);
ui->dw_InfoBarStatus->allowStatusBar(false); ui->dw_InfoBarStatus->allowStatusBar(false);
ui->dw_InfoBarStatus->setPreferredSizeWhenFloating(ui->dw_InfoBarStatus->size()); // set floating size ui->dw_InfoBarStatus->setPreferredSizeWhenFloating(ui->dw_InfoBarStatus->size()); // set floating size
// navigator // navigator
this->m_navigator->addAction(this->getToggleWindowVisibilityAction(this->m_navigator.data())); m_navigator->addAction(this->getToggleWindowVisibilityAction(m_navigator.data()));
this->m_navigator->addActions(ui->comp_MainInfoArea->getInfoAreaToggleFloatingActions(this->m_navigator.data())); m_navigator->addActions(ui->comp_MainInfoArea->getInfoAreaToggleFloatingActions(m_navigator.data()));
this->m_navigator->addAction(this->getWindowNormalAction(this->m_navigator.data())); m_navigator->addAction(this->getWindowNormalAction(m_navigator.data()));
this->m_navigator->addAction(this->getWindowMinimizeAction(this->m_navigator.data())); m_navigator->addAction(this->getWindowMinimizeAction(m_navigator.data()));
this->m_navigator->addAction(this->getToggleStayOnTopAction(this->m_navigator.data())); m_navigator->addAction(this->getToggleStayOnTopAction(m_navigator.data()));
this->m_navigator->buildNavigator(1); m_navigator->buildNavigator(1);
// wire GUI signals // wire GUI signals
this->initGuiSignals(); this->initGuiSignals();
@@ -126,10 +126,10 @@ void SwiftGuiStd::init()
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::ps_onConnectionStatusChanged); connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::ps_onConnectionStatusChanged);
connect(sGui->getIContextNetwork(), &IContextNetwork::textMessagesReceived, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageReceived); connect(sGui->getIContextNetwork(), &IContextNetwork::textMessagesReceived, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageReceived);
connect(sGui->getIContextNetwork(), &IContextNetwork::textMessageSent, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageSent); connect(sGui->getIContextNetwork(), &IContextNetwork::textMessageSent, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageSent);
connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &SwiftGuiStd::ps_handleTimerBasedUpdates); connect(m_timerContextWatchdog, &QTimer::timeout, this, &SwiftGuiStd::ps_handleTimerBasedUpdates);
// start timers, update timers will be started when network is connected // start timers, update timers will be started when network is connected
this->m_timerContextWatchdog->start(2500); m_timerContextWatchdog->start(2500);
// init availability // init availability
this->setContextAvailability(); this->setContextAvailability();
@@ -153,7 +153,7 @@ void SwiftGuiStd::init()
this->setVisible(true); this->setVisible(true);
emit sGui->startUpCompleted(true); emit sGui->startUpCompleted(true);
this->m_init = true; m_init = true;
QTimer::singleShot(2500, this, &SwiftGuiStd::ps_verifyDataAvailability); QTimer::singleShot(2500, this, &SwiftGuiStd::ps_verifyDataAvailability);
if (!sGui->isNetworkAccessible()) if (!sGui->isNetworkAccessible())
@@ -205,8 +205,8 @@ void SwiftGuiStd::initGuiSignals()
connect(ui->menu_WindowFont, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(ui->menu_WindowFont, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
connect(ui->menu_WindowMinimize, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(ui->menu_WindowMinimize, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
connect(ui->menu_WindowToggleOnTop, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(ui->menu_WindowToggleOnTop, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
connect(ui->menu_WindowToggleNavigator, &QAction::triggered, this->m_navigator.data(), &CNavigatorDialog::toggleNavigator); connect(ui->menu_WindowToggleNavigator, &QAction::triggered, m_navigator.data(), &CNavigatorDialog::toggleNavigator);
connect(this->m_navigator.data(), &CNavigatorDialog::navigatorClosed, this, &SwiftGuiStd::ps_navigatorClosed); connect(m_navigator.data(), &CNavigatorDialog::navigatorClosed, this, &SwiftGuiStd::ps_navigatorClosed);
connect(ui->menu_InternalsPage, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(ui->menu_InternalsPage, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
connect(ui->menu_MovingMap, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(ui->menu_MovingMap, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
@@ -241,7 +241,7 @@ void SwiftGuiStd::initGuiSignals()
void SwiftGuiStd::initialDataReads() void SwiftGuiStd::initialDataReads()
{ {
this->setContextAvailability(); this->setContextAvailability();
if (!this->m_coreAvailable) if (!m_coreAvailable)
{ {
CLogMessage(this).error("No initial data read as network context is not available"); CLogMessage(this).error("No initial data read as network context is not available");
return; return;
@@ -253,7 +253,7 @@ void SwiftGuiStd::initialDataReads()
void SwiftGuiStd::stopAllTimers(bool disconnectSignalSlots) void SwiftGuiStd::stopAllTimers(bool disconnectSignalSlots)
{ {
this->m_timerContextWatchdog->stop(); m_timerContextWatchdog->stop();
if (!disconnectSignalSlots) { return; } if (!disconnectSignalSlots) { return; }
this->disconnect(this->m_timerContextWatchdog); this->disconnect(m_timerContextWatchdog);
} }