mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 14:15:35 +08:00
refs #316 Changed blackcore to use CLogMessage to emit messages.
Also changed functions which always returned CStatusMessageList containing a single CStatusMessage, to return CStatusMessage instead for simplicity.
This commit is contained in:
@@ -66,6 +66,9 @@ namespace BlackCore
|
|||||||
ActionStops
|
ActionStops
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.context.application"; }
|
||||||
|
|
||||||
//! Service name
|
//! Service name
|
||||||
static const QString &InterfaceName()
|
static const QString &InterfaceName()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "context_runtime.h"
|
#include "context_runtime.h"
|
||||||
#include "input_manager.h"
|
#include "input_manager.h"
|
||||||
#include "blackmisc/settingutilities.h"
|
#include "blackmisc/settingutilities.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QtMsgHandler>
|
#include <QtMsgHandler>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextApplication::notifyAboutComponentChange(uint component, uint action)
|
void CContextApplication::notifyAboutComponentChange(uint component, uint action)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { QString::number(component), QString::number(action) });
|
CLogMessage().debug(this) << Q_FUNC_INFO << QString::number(component) << QString::number(action);
|
||||||
this->componentChanged(component, action);
|
this->componentChanged(component, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
bool CContextApplication::writeToFile(const QString &fileName, const QString &content)
|
bool CContextApplication::writeToFile(const QString &fileName, const QString &content)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { fileName, content.left(25) });
|
CLogMessage().debug(this) << Q_FUNC_INFO << fileName << content.left(25);
|
||||||
if (fileName.isEmpty()) return false;
|
if (fileName.isEmpty()) return false;
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
@@ -76,7 +77,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
QString CContextApplication::readFromFile(const QString &fileName)
|
QString CContextApplication::readFromFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, fileName);
|
CLogMessage().debug(this) << Q_FUNC_INFO << fileName;
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
QString content;
|
QString content;
|
||||||
if (fileName.isEmpty()) return content;
|
if (fileName.isEmpty()) return content;
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ namespace BlackCore
|
|||||||
IContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
IContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.context.audio"; }
|
||||||
|
|
||||||
//! \brief Interface name
|
//! \brief Interface name
|
||||||
static const QString &InterfaceName()
|
static const QString &InterfaceName()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "blackmisc/notificationsounds.h"
|
#include "blackmisc/notificationsounds.h"
|
||||||
#include "blackmisc/voiceroomlist.h"
|
#include "blackmisc/voiceroomlist.h"
|
||||||
#include "blackmisc/hotkeyfunction.h"
|
#include "blackmisc/hotkeyfunction.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ namespace BlackCore
|
|||||||
CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const
|
CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return getComVoiceRooms();
|
return getComVoiceRooms();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ namespace BlackCore
|
|||||||
CVoiceRoom CContextAudio::getCom1VoiceRoom(bool withAudioStatus) const
|
CVoiceRoom CContextAudio::getCom1VoiceRoom(bool withAudioStatus) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, withAudioStatus);
|
CLogMessage().debug(this) << Q_FUNC_INFO << withAudioStatus;
|
||||||
// We always have the audio status due to shared status
|
// We always have the audio status due to shared status
|
||||||
return m_channelCom1->getVoiceRoom();
|
return m_channelCom1->getVoiceRoom();
|
||||||
}
|
}
|
||||||
@@ -97,7 +98,7 @@ namespace BlackCore
|
|||||||
CVoiceRoom CContextAudio::getCom2VoiceRoom(bool withAudioStatus) const
|
CVoiceRoom CContextAudio::getCom2VoiceRoom(bool withAudioStatus) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, withAudioStatus);
|
CLogMessage().debug(this) << Q_FUNC_INFO << withAudioStatus;
|
||||||
// We always have the audio status due to shared status
|
// We always have the audio status due to shared status
|
||||||
return m_channelCom2->getVoiceRoom();
|
return m_channelCom2->getVoiceRoom();
|
||||||
}
|
}
|
||||||
@@ -108,7 +109,7 @@ namespace BlackCore
|
|||||||
CVoiceRoomList CContextAudio::getComVoiceRooms() const
|
CVoiceRoomList CContextAudio::getComVoiceRooms() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
CVoiceRoomList voiceRoomList;
|
CVoiceRoomList voiceRoomList;
|
||||||
voiceRoomList.push_back(m_channelCom1->getVoiceRoom());
|
voiceRoomList.push_back(m_channelCom1->getVoiceRoom());
|
||||||
voiceRoomList.push_back(m_channelCom2->getVoiceRoom());
|
voiceRoomList.push_back(m_channelCom2->getVoiceRoom());
|
||||||
@@ -121,7 +122,7 @@ namespace BlackCore
|
|||||||
void CContextAudio::leaveAllVoiceRooms()
|
void CContextAudio::leaveAllVoiceRooms()
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
m_channelCom1->leaveVoiceRoom();
|
m_channelCom1->leaveVoiceRoom();
|
||||||
m_channelCom2->leaveVoiceRoom();
|
m_channelCom2->leaveVoiceRoom();
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ namespace BlackCore
|
|||||||
CAudioDeviceList CContextAudio::getAudioDevices() const
|
CAudioDeviceList CContextAudio::getAudioDevices() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->m_voice->audioDevices();
|
return this->m_voice->audioDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +143,7 @@ namespace BlackCore
|
|||||||
CAudioDeviceList CContextAudio::getCurrentAudioDevices() const
|
CAudioDeviceList CContextAudio::getCurrentAudioDevices() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
CAudioDeviceList devices;
|
CAudioDeviceList devices;
|
||||||
devices.push_back(this->m_voice->getCurrentInputDevice());
|
devices.push_back(this->m_voice->getCurrentInputDevice());
|
||||||
devices.push_back(this->m_voice->getCurrentOutputDevice());
|
devices.push_back(this->m_voice->getCurrentOutputDevice());
|
||||||
@@ -156,7 +157,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
Q_ASSERT(audioDevice.getType() != CAudioDevice::Unknown);
|
Q_ASSERT(audioDevice.getType() != CAudioDevice::Unknown);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, audioDevice.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << audioDevice;
|
||||||
if (audioDevice.getType() == CAudioDevice::InputDevice)
|
if (audioDevice.getType() == CAudioDevice::InputDevice)
|
||||||
{
|
{
|
||||||
this->m_voice->setInputDevice(audioDevice);
|
this->m_voice->setInputDevice(audioDevice);
|
||||||
@@ -173,7 +174,7 @@ namespace BlackCore
|
|||||||
void CContextAudio::setVolumes(const CComSystem &com1, const CComSystem &com2)
|
void CContextAudio::setVolumes(const CComSystem &com1, const CComSystem &com2)
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { com1.toQString(), com2.toQString() });
|
CLogMessage().debug(this) << Q_FUNC_INFO << com1 << com2;
|
||||||
|
|
||||||
// volumes
|
// volumes
|
||||||
qint32 vol1 = com1.getVolumeOutput();
|
qint32 vol1 = com1.getVolumeOutput();
|
||||||
@@ -192,7 +193,7 @@ namespace BlackCore
|
|||||||
bool CContextAudio::isMuted() const
|
bool CContextAudio::isMuted() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return m_channelCom1->isMuted() && m_channelCom2->isMuted();
|
return m_channelCom1->isMuted() && m_channelCom2->isMuted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
Q_ASSERT(newRooms.size() == 2);
|
Q_ASSERT(newRooms.size() == 2);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, newRooms.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << newRooms;
|
||||||
|
|
||||||
CVoiceRoomList currentRooms = getComVoiceRooms();
|
CVoiceRoomList currentRooms = getComVoiceRooms();
|
||||||
CVoiceRoom currentRoom1 = currentRooms[0];
|
CVoiceRoom currentRoom1 = currentRooms[0];
|
||||||
@@ -244,7 +245,7 @@ namespace BlackCore
|
|||||||
CCallsignList CContextAudio::getCom1RoomCallsigns() const
|
CCallsignList CContextAudio::getCom1RoomCallsigns() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return m_channelCom1->getVoiceRoomCallsigns();
|
return m_channelCom1->getVoiceRoomCallsigns();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +255,7 @@ namespace BlackCore
|
|||||||
CCallsignList CContextAudio::getCom2RoomCallsigns() const
|
CCallsignList CContextAudio::getCom2RoomCallsigns() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return m_channelCom2->getVoiceRoomCallsigns();
|
return m_channelCom2->getVoiceRoomCallsigns();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +267,7 @@ namespace BlackCore
|
|||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
Q_ASSERT(this->getRuntime());
|
Q_ASSERT(this->getRuntime());
|
||||||
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
|
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->getIContextNetwork()->getUsersForCallsigns(this->getCom1RoomCallsigns());
|
return this->getIContextNetwork()->getUsersForCallsigns(this->getCom1RoomCallsigns());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +279,7 @@ namespace BlackCore
|
|||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
Q_ASSERT(this->getRuntime());
|
Q_ASSERT(this->getRuntime());
|
||||||
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
|
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->getIContextNetwork()->getUsersForCallsigns(this->getCom2RoomCallsigns());
|
return this->getIContextNetwork()->getUsersForCallsigns(this->getCom2RoomCallsigns());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +289,7 @@ namespace BlackCore
|
|||||||
void CContextAudio::playSelcalTone(const CSelcal &selcal) const
|
void CContextAudio::playSelcalTone(const CSelcal &selcal) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, selcal.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << selcal;
|
||||||
CAudioDevice outputDevice = m_voice->getCurrentOutputDevice();
|
CAudioDevice outputDevice = m_voice->getCurrentOutputDevice();
|
||||||
BlackSound::CSoundGenerator::playSelcal(90, selcal, outputDevice);
|
BlackSound::CSoundGenerator::playSelcal(90, selcal, outputDevice);
|
||||||
}
|
}
|
||||||
@@ -299,7 +300,7 @@ namespace BlackCore
|
|||||||
void CContextAudio::playNotification(uint notification, bool considerSettings) const
|
void CContextAudio::playNotification(uint notification, bool considerSettings) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, QString::number(notification));
|
CLogMessage().debug(this) << Q_FUNC_INFO << notification;
|
||||||
|
|
||||||
auto notificationSound = static_cast<BlackSound::CNotificationSounds::Notification>(notification);
|
auto notificationSound = static_cast<BlackSound::CNotificationSounds::Notification>(notification);
|
||||||
if (considerSettings)
|
if (considerSettings)
|
||||||
@@ -326,7 +327,7 @@ namespace BlackCore
|
|||||||
void CContextAudio::runMicrophoneTest()
|
void CContextAudio::runMicrophoneTest()
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
this->m_voice->runMicrophoneTest();
|
this->m_voice->runMicrophoneTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +337,7 @@ namespace BlackCore
|
|||||||
void CContextAudio::runSquelchTest()
|
void CContextAudio::runSquelchTest()
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
this->m_voice->runSquelchTest();
|
this->m_voice->runSquelchTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +347,7 @@ namespace BlackCore
|
|||||||
QString CContextAudio::getMicrophoneTestResult() const
|
QString CContextAudio::getMicrophoneTestResult() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->m_voice->micTestResultAsString();
|
return this->m_voice->micTestResultAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +357,7 @@ namespace BlackCore
|
|||||||
double CContextAudio::getSquelchValue() const
|
double CContextAudio::getSquelchValue() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return static_cast<double>(this->m_voice->inputSquelch());
|
return static_cast<double>(this->m_voice->inputSquelch());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +367,7 @@ namespace BlackCore
|
|||||||
void CContextAudio::enableAudioLoopback(bool enable)
|
void CContextAudio::enableAudioLoopback(bool enable)
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_voice);
|
Q_ASSERT(this->m_voice);
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
m_voice->enableAudioLoopback(enable);
|
m_voice->enableAudioLoopback(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ namespace BlackCore
|
|||||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.context.network"; }
|
||||||
|
|
||||||
//! DBus interface name
|
//! DBus interface name
|
||||||
static const QString &InterfaceName()
|
static const QString &InterfaceName()
|
||||||
{
|
{
|
||||||
@@ -144,13 +147,13 @@ namespace BlackCore
|
|||||||
* \return messages gererated during connecting
|
* \return messages gererated during connecting
|
||||||
* \see INetwork::LoginMode
|
* \see INetwork::LoginMode
|
||||||
*/
|
*/
|
||||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint loginMode) = 0;
|
virtual BlackMisc::CStatusMessage connectToNetwork(uint loginMode) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Disconnect from network
|
* Disconnect from network
|
||||||
* \return messages generated during disconnecting
|
* \return messages generated during disconnecting
|
||||||
*/
|
*/
|
||||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork() = 0;
|
virtual BlackMisc::CStatusMessage disconnectFromNetwork() = 0;
|
||||||
|
|
||||||
//! Network connected?
|
//! Network connected?
|
||||||
virtual bool isConnected() const = 0;
|
virtual bool isConnected() const = 0;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/networkutils.h"
|
#include "blackmisc/networkutils.h"
|
||||||
#include "blackmisc/avatcstationlist.h"
|
#include "blackmisc/avatcstationlist.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
#include <QtXml/QDomElement>
|
#include <QtXml/QDomElement>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@@ -104,32 +105,31 @@ namespace BlackCore
|
|||||||
/*
|
/*
|
||||||
* Connect to network
|
* Connect to network
|
||||||
*/
|
*/
|
||||||
CStatusMessageList CContextNetwork::connectToNetwork(uint loginMode)
|
CStatusMessage CContextNetwork::connectToNetwork(uint loginMode)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
CStatusMessageList msgs;
|
|
||||||
QString msg;
|
|
||||||
CServer currentServer = this->getIContextSettings()->getNetworkSettings().getCurrentTrafficNetworkServer();
|
CServer currentServer = this->getIContextSettings()->getNetworkSettings().getCurrentTrafficNetworkServer();
|
||||||
|
|
||||||
|
QString msg;
|
||||||
if (!currentServer.getUser().isValid())
|
if (!currentServer.getUser().isValid())
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "Invalid user credentials"));
|
return CLogMessage().error(this, "Invalid user credentials");
|
||||||
}
|
}
|
||||||
else if (!this->ownAircraft().getIcaoInfo().hasAircraftAndAirlineDesignator())
|
else if (!this->ownAircraft().getIcaoInfo().hasAircraftAndAirlineDesignator())
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "Invalid ICAO data for own aircraft"));
|
return CLogMessage().error(this, "Invalid ICAO data for own aircraft");
|
||||||
}
|
}
|
||||||
else if (!CNetworkUtils::canConnect(currentServer, msg, 2000))
|
else if (!CNetworkUtils::canConnect(currentServer, msg, 2000))
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, msg));
|
return CLogMessage().error(this, msg);
|
||||||
}
|
}
|
||||||
else if (this->m_network->isConnected())
|
else if (this->m_network->isConnected())
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "Already connected"));
|
return CLogMessage().error(this, "Already connected");
|
||||||
}
|
}
|
||||||
else if (this->isPendingConnection())
|
else if (this->isPendingConnection())
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "Pending connection, please wait"));
|
return CLogMessage().error(this, "Pending connection, please wait");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -143,36 +143,31 @@ namespace BlackCore
|
|||||||
this->m_network->presetIcaoCodes(ownAircraft.getIcaoInfo());
|
this->m_network->presetIcaoCodes(ownAircraft.getIcaoInfo());
|
||||||
this->m_network->setOwnAircraft(ownAircraft);
|
this->m_network->setOwnAircraft(ownAircraft);
|
||||||
this->m_network->initiateConnection();
|
this->m_network->initiateConnection();
|
||||||
msg = "Connection pending ";
|
return CLogMessage().info(this, "Connection pending %1 %2") << currentServer.getAddress() << currentServer.getPort();
|
||||||
msg.append(" ").append(currentServer.getAddress()).append(" ").append(QString::number(currentServer.getPort()));
|
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, msg));
|
|
||||||
}
|
}
|
||||||
return msgs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disconnect from network
|
* Disconnect from network
|
||||||
*/
|
*/
|
||||||
CStatusMessageList CContextNetwork::disconnectFromNetwork()
|
CStatusMessage CContextNetwork::disconnectFromNetwork()
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
CStatusMessageList msgs;
|
|
||||||
if (this->m_network->isConnected())
|
if (this->m_network->isConnected())
|
||||||
{
|
{
|
||||||
this->m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect
|
this->m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect
|
||||||
this->m_network->terminateConnection();
|
this->m_network->terminateConnection();
|
||||||
this->m_airspace->clear();
|
this->m_airspace->clear();
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, "Connection terminating"));
|
return CLogMessage().info(this, "Connection terminating");
|
||||||
}
|
}
|
||||||
else if (this->isPendingConnection())
|
else if (this->isPendingConnection())
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "Pending connection, please wait"));
|
return CLogMessage().warning(this, "Pending connection, please wait");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "Already disconnected"));
|
return CLogMessage().warning(this, "Already disconnected");
|
||||||
}
|
}
|
||||||
return msgs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -180,7 +175,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
bool CContextNetwork::isConnected() const
|
bool CContextNetwork::isConnected() const
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->m_network->isConnected();
|
return this->m_network->isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +193,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::sendTextMessages(const CTextMessageList &textMessages)
|
void CContextNetwork::sendTextMessages(const CTextMessageList &textMessages)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, textMessages.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << textMessages;
|
||||||
this->m_network->sendTextMessages(textMessages);
|
this->m_network->sendTextMessages(textMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,14 +202,14 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::sendFlightPlan(const CFlightPlan &flightPlan)
|
void CContextNetwork::sendFlightPlan(const CFlightPlan &flightPlan)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, flightPlan.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << flightPlan;
|
||||||
this->m_network->sendFlightPlan(flightPlan);
|
this->m_network->sendFlightPlan(flightPlan);
|
||||||
this->m_network->sendFlightPlanQuery(this->ownAircraft().getCallsign());
|
this->m_network->sendFlightPlanQuery(this->ownAircraft().getCallsign());
|
||||||
}
|
}
|
||||||
|
|
||||||
CFlightPlan CContextNetwork::loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const
|
CFlightPlan CContextNetwork::loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->m_airspace->loadFlightPlanFromNetwork(callsign);
|
return this->m_airspace->loadFlightPlanFromNetwork(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,8 +264,8 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message)
|
void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { QString::number(from), QString::number(to) });
|
CLogMessage().debug(this) << Q_FUNC_INFO << from << to;
|
||||||
INetwork::ConnectionStatus fromOld = this->m_currentStatus;
|
auto fromOld = this->m_currentStatus;
|
||||||
this->m_currentStatus = to;
|
this->m_currentStatus = to;
|
||||||
|
|
||||||
if (fromOld == INetwork::Disconnecting)
|
if (fromOld == INetwork::Disconnecting)
|
||||||
@@ -280,26 +275,20 @@ namespace BlackCore
|
|||||||
from = INetwork::Disconnecting;
|
from = INetwork::Disconnecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessageList msgs;
|
|
||||||
// send 1st position
|
// send 1st position
|
||||||
if (to == INetwork::Connected)
|
if (to == INetwork::Connected)
|
||||||
{
|
{
|
||||||
QString m("Connected, own aircraft ");
|
CLogMessage().info(this, "Connected, own aircraft %1") << this->ownAircraft().toQString();
|
||||||
m.append(this->ownAircraft().toQString(true));
|
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, m));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// send as message
|
// send as message
|
||||||
QString m("Connection status changed from %1 to %2");
|
if (to == INetwork::DisconnectedError)
|
||||||
m = m.arg(INetwork::connectionStatusToString(from), INetwork::connectionStatusToString(to));
|
|
||||||
if (!message.isEmpty()) m.append(" ").append(message);
|
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork,
|
|
||||||
to == INetwork::DisconnectedError ? CStatusMessage::SeverityError : CStatusMessage::SeverityInfo, m));
|
|
||||||
// FIXME (MS) conditional increases the number of scenarios which must be considered and continuously tested
|
|
||||||
// This is more a guard than a real conditional, e.g. when system shuts down
|
|
||||||
if (this->getIContextApplication())
|
|
||||||
{
|
{
|
||||||
this->getIContextApplication()->sendStatusMessages(msgs);
|
CLogMessage().error(this, "Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLogMessage().info(this, "Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send as own signal
|
// send as own signal
|
||||||
@@ -311,11 +300,8 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::ps_dataFileRead()
|
void CContextNetwork::ps_dataFileRead()
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (this->getIContextApplication())
|
CLogMessage().info(this, "Read VATSIM data file");
|
||||||
{
|
|
||||||
this->getIContextApplication()->sendStatusMessage(CStatusMessage::getInfoMessage("Read VATSIM data file", CStatusMessage::TypeTrafficNetwork));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -323,7 +309,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::ps_fsdTextMessageReceived(const CTextMessageList &messages)
|
void CContextNetwork::ps_fsdTextMessageReceived(const CTextMessageList &messages)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, messages.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << messages;
|
||||||
this->textMessagesReceived(messages); // relay
|
this->textMessagesReceived(messages); // relay
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,8 +341,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::ps_receivedBookings(const CAtcStationList &)
|
void CContextNetwork::ps_receivedBookings(const CAtcStationList &)
|
||||||
{
|
{
|
||||||
// TODO (MS) no test for if (this->getIContextApplication()) here?
|
CLogMessage().info(this, "Read bookings from network");
|
||||||
this->getIContextApplication()->sendStatusMessage(CStatusMessage::getInfoMessage("Read bookings from network", CStatusMessage::TypeTrafficNetwork));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -395,7 +380,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
BlackMisc::Aviation::CInformationMessage CContextNetwork::getMetar(const BlackMisc::Aviation::CAirportIcao &airportIcaoCode)
|
BlackMisc::Aviation::CInformationMessage CContextNetwork::getMetar(const BlackMisc::Aviation::CAirportIcao &airportIcaoCode)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, airportIcaoCode.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << airportIcaoCode;
|
||||||
return m_airspace->getMetar(airportIcaoCode);
|
return m_airspace->getMetar(airportIcaoCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "blackmisc/setnetwork.h"
|
#include "blackmisc/setnetwork.h"
|
||||||
#include "blackmisc/nwclientlist.h"
|
#include "blackmisc/nwclientlist.h"
|
||||||
#include "blackmisc/digestsignal.h"
|
#include "blackmisc/digestsignal.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
@@ -55,29 +56,29 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
||||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override
|
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
BlackMisc::CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->m_airspace->getAtcStationsOnline();
|
return this->m_airspace->getAtcStationsOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::getAtcStationsBooked()
|
//! \copydoc IContextNetwork::getAtcStationsBooked()
|
||||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override
|
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
BlackMisc::CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->m_airspace->getAtcStationsBooked();
|
return this->m_airspace->getAtcStationsBooked();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::getAircraftsInRange()
|
//! \copydoc IContextNetwork::getAircraftsInRange()
|
||||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
|
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
BlackMisc::CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
return this->m_airspace->getAircraftInRange();
|
return this->m_airspace->getAircraftInRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::connectToNetwork()
|
//! \copydoc IContextNetwork::connectToNetwork()
|
||||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint mode) override;
|
virtual BlackMisc::CStatusMessage connectToNetwork(uint mode) override;
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
||||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork() override;
|
virtual BlackMisc::CStatusMessage disconnectFromNetwork() override;
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::isConnected()
|
//! \copydoc IContextNetwork::isConnected()
|
||||||
virtual bool isConnected() const override;
|
virtual bool isConnected() const override;
|
||||||
|
|||||||
@@ -131,14 +131,14 @@ namespace BlackCore
|
|||||||
this->m_dBusInterface->callDBus(QLatin1Literal("testCreateDummyOnlineAtcStations"), number);
|
this->m_dBusInterface->callDBus(QLatin1Literal("testCreateDummyOnlineAtcStations"), number);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::CStatusMessageList CContextNetworkProxy::connectToNetwork(uint loginMode)
|
BlackMisc::CStatusMessage CContextNetworkProxy::connectToNetwork(uint loginMode)
|
||||||
{
|
{
|
||||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("connectToNetwork"), loginMode);
|
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1Literal("connectToNetwork"), loginMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::CStatusMessageList CContextNetworkProxy::disconnectFromNetwork()
|
BlackMisc::CStatusMessage CContextNetworkProxy::disconnectFromNetwork()
|
||||||
{
|
{
|
||||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("disconnectFromNetwork"));
|
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1Literal("disconnectFromNetwork"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContextNetworkProxy::isConnected() const
|
bool CContextNetworkProxy::isConnected() const
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ namespace BlackCore
|
|||||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override;
|
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override;
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::connectToNetwork()
|
//! \copydoc IContextNetwork::connectToNetwork()
|
||||||
virtual BlackMisc::CStatusMessageList connectToNetwork(uint mode) override;
|
virtual BlackMisc::CStatusMessage connectToNetwork(uint mode) override;
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
||||||
virtual BlackMisc::CStatusMessageList disconnectFromNetwork() override;
|
virtual BlackMisc::CStatusMessage disconnectFromNetwork() override;
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::isConnected()
|
//! \copydoc IContextNetwork::isConnected()
|
||||||
virtual bool isConnected() const override;
|
virtual bool isConnected() const override;
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ namespace BlackCore
|
|||||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME)
|
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.context.ownaircraft"; }
|
||||||
|
|
||||||
//! DBus interface name
|
//! DBus interface name
|
||||||
static const QString &InterfaceName()
|
static const QString &InterfaceName()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "context_audio.h"
|
#include "context_audio.h"
|
||||||
#include "context_runtime.h"
|
#include "context_runtime.h"
|
||||||
#include "context_settings.h"
|
#include "context_settings.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
@@ -70,7 +71,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextOwnAircraft::resolveVoiceRooms()
|
void CContextOwnAircraft::resolveVoiceRooms()
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (this->m_voiceRoom1UrlOverride.isEmpty() && this->m_voiceRoom2UrlOverride.isEmpty() && !this->m_automaticVoiceRoomResolution) return;
|
if (this->m_voiceRoom1UrlOverride.isEmpty() && this->m_voiceRoom2UrlOverride.isEmpty() && !this->m_automaticVoiceRoomResolution) return;
|
||||||
if (!this->getIContextNetwork()) return; // no chance to resolve rooms
|
if (!this->getIContextNetwork()) return; // no chance to resolve rooms
|
||||||
if (!this->getIContextAudio()) return; // no place to set rooms
|
if (!this->getIContextAudio()) return; // no place to set rooms
|
||||||
@@ -93,7 +94,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextOwnAircraft::updateOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft, const QString &originator)
|
void CContextOwnAircraft::updateOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft, const QString &originator)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { ownAircraft().toQString(), originator });
|
CLogMessage().debug(this) << Q_FUNC_INFO << ownAircraft() << originator;
|
||||||
|
|
||||||
// trigger the correct signals
|
// trigger the correct signals
|
||||||
bool changedCockpit = this->updateOwnCockpit(aircraft.getCom1System(), aircraft.getCom2System(), aircraft.getTransponder(), originator);
|
bool changedCockpit = this->updateOwnCockpit(aircraft.getCom1System(), aircraft.getCom2System(), aircraft.getTransponder(), originator);
|
||||||
@@ -120,7 +121,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
bool CContextOwnAircraft::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const QString &originator)
|
bool CContextOwnAircraft::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const QString &originator)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { position.toQString(), altitude.toQString(), originator });
|
CLogMessage().debug(this) << Q_FUNC_INFO << position << altitude << originator;
|
||||||
bool changed = (this->m_ownAircraft.getPosition() != position);
|
bool changed = (this->m_ownAircraft.getPosition() != position);
|
||||||
if (changed) this->m_ownAircraft.setPosition(position);
|
if (changed) this->m_ownAircraft.setPosition(position);
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
bool CContextOwnAircraft::updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation, const QString &originator)
|
bool CContextOwnAircraft::updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation, const QString &originator)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, situation.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << situation;
|
||||||
bool changed = this->m_ownAircraft.getSituation() != situation;
|
bool changed = this->m_ownAircraft.getSituation() != situation;
|
||||||
if (!changed) return changed;
|
if (!changed) return changed;
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
bool CContextOwnAircraft::updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const QString &originator)
|
bool CContextOwnAircraft::updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const QString &originator)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { com1.toQString(), com2.toQString(), transponder.toQString() });
|
CLogMessage().debug(this) << Q_FUNC_INFO << com1 << com2 << transponder;
|
||||||
bool changed = this->m_ownAircraft.hasChangedCockpitData(com1, com2, transponder);
|
bool changed = this->m_ownAircraft.hasChangedCockpitData(com1, com2, transponder);
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
@@ -183,7 +184,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CContextOwnAircraft::setAudioOutputVolumes(int outputVolumeCom1, int outputVolumeCom2)
|
void CContextOwnAircraft::setAudioOutputVolumes(int outputVolumeCom1, int outputVolumeCom2)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { QString::number(outputVolumeCom1), QString::number(outputVolumeCom2) });
|
CLogMessage().debug(this) << Q_FUNC_INFO << outputVolumeCom1 << outputVolumeCom2;
|
||||||
|
|
||||||
CComSystem com1 = this->m_ownAircraft.getCom1System();
|
CComSystem com1 = this->m_ownAircraft.getCom1System();
|
||||||
com1.setVolumeOutput(outputVolumeCom1);
|
com1.setVolumeOutput(outputVolumeCom1);
|
||||||
@@ -213,7 +214,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextOwnAircraft::setAudioVoiceRoomOverrideUrls(const QString &voiceRoom1Url, const QString &voiceRoom2Url)
|
void CContextOwnAircraft::setAudioVoiceRoomOverrideUrls(const QString &voiceRoom1Url, const QString &voiceRoom2Url)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { voiceRoom1Url, voiceRoom2Url });
|
CLogMessage().debug(this) << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url;
|
||||||
|
|
||||||
this->m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed();
|
this->m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed();
|
||||||
this->m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed();
|
this->m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed();
|
||||||
@@ -225,7 +226,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable)
|
void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable)
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, enable);
|
CLogMessage().debug(this) << Q_FUNC_INFO << enable;
|
||||||
this->m_automaticVoiceRoomResolution = enable;
|
this->m_automaticVoiceRoomResolution = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +235,7 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
CAircraft CContextOwnAircraft::getOwnAircraft() const
|
CAircraft CContextOwnAircraft::getOwnAircraft() const
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, this->m_ownAircraft.toQString());
|
CLogMessage().debug(this) << Q_FUNC_INFO << this->m_ownAircraft;
|
||||||
return this->m_ownAircraft;
|
return this->m_ownAircraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "blackmisc/statusmessagelist.h"
|
#include "blackmisc/statusmessagelist.h"
|
||||||
#include "blackmisc/avaircraft.h"
|
#include "blackmisc/avaircraft.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackcore/context_runtime.h"
|
#include "blackcore/context_runtime.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -442,8 +443,7 @@ namespace BlackCore
|
|||||||
connect(this->m_contextSettings, &IContextSettings::changedSettings, this->m_contextSimulator, &IContextSimulator::settingsChanged);
|
connect(this->m_contextSettings, &IContextSettings::changedSettings, this->m_contextSimulator, &IContextSimulator::settingsChanged);
|
||||||
if (!this->m_contextSimulator->loadSimulatorPluginFromSettings())
|
if (!this->m_contextSimulator->loadSimulatorPluginFromSettings())
|
||||||
{
|
{
|
||||||
qWarning() << "No simulator plugin loaded";
|
CLogMessage().warning(this, "No simulator plugin loaded");
|
||||||
this->sendStatusMessage(CStatusMessage::getWarningMessage("No simulator plugin loaded", CStatusMessage::TypeSimulator));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace BlackCore
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.runtime"; }
|
||||||
//! Tags to identify the context when logging a slot
|
//! Tags to identify the context when logging a slot
|
||||||
enum LogContext
|
enum LogContext
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ namespace BlackCore
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.context.settings"; }
|
||||||
|
|
||||||
//! Service name
|
//! Service name
|
||||||
static const QString &InterfaceName()
|
static const QString &InterfaceName()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/settingutilities.h"
|
#include "blackmisc/settingutilities.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
@@ -32,8 +33,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (!CSettingUtilities::initSettingsDirectory())
|
if (!CSettingUtilities::initSettingsDirectory())
|
||||||
{
|
{
|
||||||
return CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError,
|
return CLogMessage().error(this, "Cannot init directory: %1") << this->getSettingsDirectory();
|
||||||
QString("Cannot init directory: %1").arg(this->getSettingsDirectory()));
|
|
||||||
}
|
}
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QFile jsonFile(this->getSettingsFileName());
|
QFile jsonFile(this->getSettingsFileName());
|
||||||
@@ -94,13 +94,11 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
return CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityInfo,
|
return CLogMessage().info(this, "Read settings: %1") << this->getSettingsFileName();
|
||||||
QString("Read settings: %1").arg(this->getSettingsFileName()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError,
|
return CLogMessage().error(this, "Problem reading settings: %1") << this->getSettingsFileName();
|
||||||
QString("Problem reading settings: %1").arg(this->getSettingsFileName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,8 +109,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (!CSettingUtilities::initSettingsDirectory())
|
if (!CSettingUtilities::initSettingsDirectory())
|
||||||
{
|
{
|
||||||
return CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError,
|
return CLogMessage().error(this, "Cannot init directory: %1") << this->getSettingsDirectory();
|
||||||
QString("Cannot init directory: %1").arg(this->getSettingsDirectory()));
|
|
||||||
}
|
}
|
||||||
QFile jsonFile(this->getSettingsFileName());
|
QFile jsonFile(this->getSettingsFileName());
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
@@ -124,13 +121,11 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
return CStatusMessage(CStatusMessage::TypeSettings, CStatusMessage::SeverityInfo,
|
return CLogMessage().info(this, "Written settings: %1") << this->getSettingsFileName();
|
||||||
QString("Written settings: %1").arg(this->getSettingsFileName()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return CStatusMessage(CStatusMessage::TypeSettings, CStatusMessage::SeverityError,
|
return CLogMessage().error(this, "Problem writing settings: %1") << this->getSettingsFileName();
|
||||||
QString("Problem writing settings: %1").arg(this->getSettingsFileName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,9 +142,7 @@ namespace BlackCore
|
|||||||
if (write)
|
if (write)
|
||||||
return this->write();
|
return this->write();
|
||||||
else
|
else
|
||||||
return CStatusMessage(CStatusMessage::TypeSettings, CStatusMessage::SeverityInfo,
|
return CLogMessage().info(this, "Reset settings data, not written");
|
||||||
QString("Reset settings data, not written"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CContextSettings::getSettingsAsJsonString() const
|
QString CContextSettings::getSettingsAsJsonString() const
|
||||||
@@ -244,7 +237,7 @@ namespace BlackCore
|
|||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (path.startsWith(IContextSettings::PathNetworkSettings()))
|
if (path.startsWith(IContextSettings::PathNetworkSettings()))
|
||||||
{
|
{
|
||||||
msgs = this->m_settingsNetwork.value(nextLevelPath, command, value, changed);
|
msgs.push_back(this->m_settingsNetwork.value(nextLevelPath, command, value, changed));
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
msgs.push_back(this->write());
|
msgs.push_back(this->write());
|
||||||
@@ -253,7 +246,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else if (path.startsWith(IContextSettings::PathAudioSettings()))
|
else if (path.startsWith(IContextSettings::PathAudioSettings()))
|
||||||
{
|
{
|
||||||
msgs = this->m_settingsAudio.value(nextLevelPath, command, value, changed);
|
msgs.push_back(this->m_settingsAudio.value(nextLevelPath, command, value, changed));
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
msgs.push_back(this->write());
|
msgs.push_back(this->write());
|
||||||
@@ -262,7 +255,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else if (path.startsWith(IContextSettings::PathSimulatorSettings()))
|
else if (path.startsWith(IContextSettings::PathSimulatorSettings()))
|
||||||
{
|
{
|
||||||
msgs = this->m_settingsSimulator.value(nextLevelPath, command, value, changed);
|
msgs.push_back(this->m_settingsSimulator.value(nextLevelPath, command, value, changed));
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
msgs.push_back(this->write());
|
msgs.push_back(this->write());
|
||||||
@@ -271,8 +264,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// wrong path
|
msgs.push_back(CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path);
|
||||||
msgs = CSettingUtilities::wrongPathMessages(path);
|
|
||||||
}
|
}
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ namespace BlackCore
|
|||||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME)
|
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.context.simulator"; }
|
||||||
|
|
||||||
//! Service name
|
//! Service name
|
||||||
static const QString &InterfaceName()
|
static const QString &InterfaceName()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "context_application.h"
|
#include "context_application.h"
|
||||||
#include "context_network_impl.h"
|
#include "context_network_impl.h"
|
||||||
#include "context_runtime.h"
|
#include "context_runtime.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
|
|
||||||
@@ -52,42 +53,42 @@ namespace BlackCore
|
|||||||
|
|
||||||
bool CContextSimulator::isConnected() const
|
bool CContextSimulator::isConnected() const
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (!m_simulator) return false;
|
if (!m_simulator) return false;
|
||||||
return m_simulator->isConnected();
|
return m_simulator->isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContextSimulator::canConnect()
|
bool CContextSimulator::canConnect()
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (!m_simulator) return false;
|
if (!m_simulator) return false;
|
||||||
return m_simulator->canConnect();
|
return m_simulator->canConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContextSimulator::connectTo()
|
bool CContextSimulator::connectTo()
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (!m_simulator) return false;
|
if (!m_simulator) return false;
|
||||||
return m_simulator->connectTo();
|
return m_simulator->connectTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextSimulator::asyncConnectTo()
|
void CContextSimulator::asyncConnectTo()
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (!m_simulator || m_canConnectResult.isRunning()) return; // already checking
|
if (!m_simulator || m_canConnectResult.isRunning()) return; // already checking
|
||||||
m_simulator->asyncConnectTo();
|
m_simulator->asyncConnectTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContextSimulator::disconnectFrom()
|
bool CContextSimulator::disconnectFrom()
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (!m_simulator) return false;
|
if (!m_simulator) return false;
|
||||||
return m_simulator->disconnectFrom();
|
return m_simulator->disconnectFrom();
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackSim::CSimulatorInfo CContextSimulator::getSimulatorInfo() const
|
BlackSim::CSimulatorInfo CContextSimulator::getSimulatorInfo() const
|
||||||
{
|
{
|
||||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO);
|
CLogMessage().debug(this) << Q_FUNC_INFO;
|
||||||
if (!m_simulator) return BlackSim::CSimulatorInfo::UnspecifiedSim();
|
if (!m_simulator) return BlackSim::CSimulatorInfo::UnspecifiedSim();
|
||||||
return m_simulator->getSimulatorInfo();
|
return m_simulator->getSimulatorInfo();
|
||||||
}
|
}
|
||||||
@@ -137,7 +138,7 @@ namespace BlackCore
|
|||||||
// warning if we do not have any plugins
|
// warning if we do not have any plugins
|
||||||
if (m_simulatorFactories.isEmpty())
|
if (m_simulatorFactories.isEmpty())
|
||||||
{
|
{
|
||||||
this->getRuntime()->sendStatusMessage(CStatusMessage::getErrorMessage("No simulator plugins", CStatusMessage::TypeSimulator));
|
CLogMessage().error(this, "No simulator plugins");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,9 +150,7 @@ namespace BlackCore
|
|||||||
// no plugin found
|
// no plugin found
|
||||||
if (iterator == m_simulatorFactories.end())
|
if (iterator == m_simulatorFactories.end())
|
||||||
{
|
{
|
||||||
QString m = QString("Plugin not found: '%1'").arg(simulatorInfo.toQString(true));
|
CLogMessage().error(this, "Plugin not found: '%1'") << simulatorInfo.toQString(true);
|
||||||
this->getRuntime()->sendStatusMessage(CStatusMessage::getErrorMessage(m, CStatusMessage::TypeSimulator));
|
|
||||||
qCritical() << m;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,8 +192,7 @@ namespace BlackCore
|
|||||||
asyncConnectTo();
|
asyncConnectTo();
|
||||||
|
|
||||||
// info about what is going on
|
// info about what is going on
|
||||||
QString m = QString("Simulator plugin loaded: '%1'").arg(this->m_simulator->getSimulatorInfo().toQString(true));
|
CLogMessage().info(this, "Simulator plugin loaded: '%1'") << this->m_simulator->getSimulatorInfo().toQString(true);
|
||||||
this->getRuntime()->sendStatusMessage(CStatusMessage::getInfoMessage(m, CStatusMessage::TypeSimulator));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,13 +347,11 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (this->loadSimulatorPlugin(plugin))
|
if (this->loadSimulatorPlugin(plugin))
|
||||||
{
|
{
|
||||||
QString m = QString("Plugin loaded: '%1'").arg(plugin.toQString(true));
|
CLogMessage().info(this, "Plugin loaded: '%1'") << plugin.toQString(true);
|
||||||
this->getRuntime()->sendStatusMessage(CStatusMessage::getInfoMessage(m, CStatusMessage::TypeSimulator));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString m = QString("Cannot load driver: '%1'").arg(plugin.toQString(true));
|
CLogMessage().error(this, "Cannot load driver: '%1'") << plugin.toQString(true);
|
||||||
this->getRuntime()->sendStatusMessage(CStatusMessage::getErrorMessage(m, CStatusMessage::TypeSimulator));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,9 +373,7 @@ namespace BlackCore
|
|||||||
m_pluginsDir = QDir(path);
|
m_pluginsDir = QDir(path);
|
||||||
if (!m_pluginsDir.exists())
|
if (!m_pluginsDir.exists())
|
||||||
{
|
{
|
||||||
QString m = QString("No plugin directory: %1").arg(m_pluginsDir.currentPath());
|
CLogMessage().error(this, "No plugin directory: %1") << m_pluginsDir.currentPath();
|
||||||
qWarning() << m;
|
|
||||||
this->getRuntime()->sendStatusMessage(CStatusMessage::getErrorMessage(m, CStatusMessage::TypeSimulator));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,9 +397,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString m = loader.errorString();
|
CLogMessage().error(this, loader.errorString());
|
||||||
this->getRuntime()->sendStatusMessage(CStatusMessage::getErrorMessage(m, CStatusMessage::TypeSimulator));
|
|
||||||
qDebug() << m;
|
|
||||||
qDebug() << "Also check if required dll/libs of plugin exists";
|
qDebug() << "Also check if required dll/libs of plugin exists";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
virtual ~INetwork() {}
|
virtual ~INetwork() {}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Log message category.
|
||||||
|
*/
|
||||||
|
static QString getMessageCategory() { return "swift.trafficNetwork"; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Flags for capabilities bitfield.
|
* Flags for capabilities bitfield.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "network_vatlib.h"
|
#include "network_vatlib.h"
|
||||||
#include "blackmisc/project.h"
|
#include "blackmisc/project.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -1083,42 +1084,34 @@ namespace BlackCore
|
|||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetworkVatlib::onErrorReceived(Cvatlib_Network *, Cvatlib_Network::error type, const char *msgData, const char *data, void *cbvar)
|
void CNetworkVatlib::onErrorReceived(Cvatlib_Network *, Cvatlib_Network::error type, const char *msg, const char *data, void *cbvar)
|
||||||
{
|
{
|
||||||
QString msg;
|
auto *self = cbvar_cast(cbvar);
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case Cvatlib_Network::error_CallsignTaken: msg = "The requested callsign is already taken"; goto terminate;
|
case Cvatlib_Network::error_CallsignTaken: CLogMessage().error(self, "The requested callsign is already taken"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_CallsignInvalid: msg = "The requested callsign is not valid"; goto terminate;
|
case Cvatlib_Network::error_CallsignInvalid: CLogMessage().error(self, "The requested callsign is not valid"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_CIDPasswdInvalid: msg = "Wrong user ID or password"; goto terminate;
|
case Cvatlib_Network::error_CIDPasswdInvalid: CLogMessage().error(self, "Wrong user ID or password"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_ProtoVersion: msg = "This server does not support our protocol version"; goto terminate;
|
case Cvatlib_Network::error_ProtoVersion: CLogMessage().error(self, "This server does not support our protocol version"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_LevelTooHigh: msg = "You are not authorized to use the requested pilot rating"; goto terminate;
|
case Cvatlib_Network::error_LevelTooHigh: CLogMessage().error(self, "You are not authorized to use the requested pilot rating"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_ServerFull: msg = "The server is full"; goto terminate;
|
case Cvatlib_Network::error_ServerFull: CLogMessage().error(self, "The server is full"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_CIDSuspended: msg = "Your user account is suspended"; goto terminate;
|
case Cvatlib_Network::error_CIDSuspended: CLogMessage().error(self, "Your user account is suspended"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_InvalidPosition: msg = "You are not authorized to use the requested pilot rating"; goto terminate;
|
case Cvatlib_Network::error_InvalidPosition: CLogMessage().error(self, "You are not authorized to use the requested pilot rating"); emit self->terminate(); break;
|
||||||
case Cvatlib_Network::error_SoftwareNotAuthorized: msg = "This client software has not been authorized for use on this network"; goto terminate;
|
case Cvatlib_Network::error_SoftwareNotAuthorized: CLogMessage().error(self, "This software is not authorized for use on this network"); emit self->terminate(); break;
|
||||||
|
|
||||||
case Cvatlib_Network::error_Ok: msg = "OK"; break;
|
case Cvatlib_Network::error_Ok: CLogMessage().info(self, "OK"); break;
|
||||||
case Cvatlib_Network::error_Syntax: msg = "Malformed packet: Syntax error: "; msg.append(cbvar_cast(cbvar)->fromFSD(data)); break;
|
case Cvatlib_Network::error_Syntax: CLogMessage().info(self, "Malformed packet: Syntax error: %1") << self->fromFSD(data); break;
|
||||||
case Cvatlib_Network::error_SourceInvalid: msg = "Server: source invalid "; msg.append(cbvar_cast(cbvar)->fromFSD(data)); break;
|
case Cvatlib_Network::error_SourceInvalid: CLogMessage().info(self, "Server: source invalid %1") << self->fromFSD(data); break;
|
||||||
case Cvatlib_Network::error_CallsignNotExists: msg = "Shim lib: "; msg.append(cbvar_cast(cbvar)->fromFSD(msgData)).append(" (").append(cbvar_cast(cbvar)->fromFSD(data)).append(")"); break;
|
case Cvatlib_Network::error_CallsignNotExists: CLogMessage().info(self, "Shim lib: %1 (%2)") << self->fromFSD(msg) << self->fromFSD(data); break;
|
||||||
case Cvatlib_Network::error_NoFP: msg = "Server: no flight plan"; break;
|
case Cvatlib_Network::error_NoFP: CLogMessage().info(self, "Server: no flight plan"); break;
|
||||||
case Cvatlib_Network::error_NoWeather: msg = "Server: requested weather profile does not exist"; break;
|
case Cvatlib_Network::error_NoWeather: CLogMessage().info(self, "Server: requested weather profile does not exist"); break;
|
||||||
|
|
||||||
// we have no idea what these mean
|
// we have no idea what these mean
|
||||||
case Cvatlib_Network::error_Registered:
|
case Cvatlib_Network::error_Registered:
|
||||||
case Cvatlib_Network::error_InvalidControl: msg = "Server: "; msg.append(cbvar_cast(cbvar)->fromFSD(msgData)); break;
|
case Cvatlib_Network::error_InvalidControl: CLogMessage().info(self, "Server: ") << self->fromFSD(msg); break;
|
||||||
|
|
||||||
default: qFatal("VATSIM shim library: %s (error %d)", qPrintable(msg), type); goto terminate;
|
default: qFatal("VATSIM shim library: %s (error %d)", msg, type); emit self->terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
emit cbvar_cast(cbvar)->statusMessage(BlackMisc::CStatusMessage(BlackMisc::CStatusMessage::TypeTrafficNetwork, BlackMisc::CStatusMessage::SeverityInfo, msg));
|
|
||||||
return;
|
|
||||||
|
|
||||||
terminate:
|
|
||||||
emit cbvar_cast(cbvar)->statusMessage(BlackMisc::CStatusMessage(BlackMisc::CStatusMessage::TypeTrafficNetwork, BlackMisc::CStatusMessage::SeverityError, msg));
|
|
||||||
emit cbvar_cast(cbvar)->terminate(); // private, will be handled during the next pass of the Qt event loop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetworkVatlib::onWindDataReceived(Cvatlib_Network *, Cvatlib_Network::WindLayer /** layers **/[4], void * /** cbvar **/)
|
void CNetworkVatlib::onWindDataReceived(Cvatlib_Network *, Cvatlib_Network::WindLayer /** layers **/[4], void * /** cbvar **/)
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace BlackCore
|
|||||||
Q_ENUMS(Status)
|
Q_ENUMS(Status)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.simulator"; }
|
||||||
|
|
||||||
//! ISimulator connection
|
//! ISimulator connection
|
||||||
enum Status
|
enum Status
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ namespace BlackCore
|
|||||||
IVoice(QObject *parent = nullptr);
|
IVoice(QObject *parent = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.voice"; }
|
||||||
|
|
||||||
//! Virtual destructor.
|
//! Virtual destructor.
|
||||||
virtual ~IVoice() {}
|
virtual ~IVoice() {}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace BlackCore
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Log message category
|
||||||
|
static QString getMessageCategory() { return "swift.voice.channel"; }
|
||||||
|
|
||||||
//! Com status
|
//! Com status
|
||||||
enum ConnectionStatus
|
enum ConnectionStatus
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "voice_channel_vatlib.h"
|
#include "voice_channel_vatlib.h"
|
||||||
#include "voice_channel_vatlib_p.h"
|
#include "voice_channel_vatlib_p.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
@@ -139,27 +140,22 @@ namespace BlackCore
|
|||||||
catch (const NetworkNotConnectedException &e)
|
catch (const NetworkNotConnectedException &e)
|
||||||
{
|
{
|
||||||
// this could be caused by a race condition during normal operation, so not an error
|
// this could be caused by a race condition during normal operation, so not an error
|
||||||
msg.append("NetworkNotConnectedException").append(" ").append(e.what());
|
CLogMessage().debug(q) << "NetworkNotConnectedException" << e.what() << "in" << caller;
|
||||||
emit q->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
|
||||||
qDebug() << "NetworkNotConnectedException caught in " << caller << "\n" << e.what();
|
|
||||||
}
|
}
|
||||||
catch (const VatlibException &e)
|
catch (const VatlibException &e)
|
||||||
{
|
{
|
||||||
msg.append("VatlibException").append(" ").append(e.what());
|
CLogMessage().error(q, "VatlibException %1 in %2") << e.what() << caller;
|
||||||
emit q->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
Q_ASSERT(false);
|
||||||
qFatal("VatlibException caught in %s\n%s", caller, e.what());
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
msg.append("std::exception").append(" ").append(e.what());
|
CLogMessage().error(q, "std::exception %1 in %2") << e.what() << caller;
|
||||||
emit q->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
Q_ASSERT(false);
|
||||||
qFatal("std::exception caught in %s\n%s", caller, e.what());
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
msg.append("unknown exception");
|
CLogMessage().error(q, "Unknown exception in %1") << caller;
|
||||||
emit q->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
Q_ASSERT(false);
|
||||||
qFatal("Unknown exception caught in %s", caller);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "voice_vatlib.h"
|
#include "voice_vatlib.h"
|
||||||
#include "voice_channel_vatlib.h"
|
#include "voice_channel_vatlib.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -429,27 +430,22 @@ namespace BlackCore
|
|||||||
catch (const NetworkNotConnectedException &e)
|
catch (const NetworkNotConnectedException &e)
|
||||||
{
|
{
|
||||||
// this could be caused by a race condition during normal operation, so not an error
|
// this could be caused by a race condition during normal operation, so not an error
|
||||||
msg.append("NetworkNotConnectedException").append(" ").append(e.what());
|
CLogMessage().debug(this) << "NetworkNotConnectedException" << e.what() << "in" << caller;
|
||||||
emit this->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
|
||||||
qDebug() << "NetworkNotConnectedException caught in " << caller << "\n" << e.what();
|
|
||||||
}
|
}
|
||||||
catch (const VatlibException &e)
|
catch (const VatlibException &e)
|
||||||
{
|
{
|
||||||
msg.append("VatlibException").append(" ").append(e.what());
|
CLogMessage().error(this, "VatlibException %1 in %2") << e.what() << caller;
|
||||||
emit this->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
Q_ASSERT(false);
|
||||||
qFatal("VatlibException caught in %s\n%s", caller, e.what());
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
msg.append("std::exception").append(" ").append(e.what());
|
CLogMessage().error(this, "std::exception %1 in %2") << e.what() << caller;
|
||||||
emit this->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
Q_ASSERT(false);
|
||||||
qFatal("std::exception caught in %s\n%s", caller, e.what());
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
msg.append("unknown exception");
|
CLogMessage().error(this, "Unknown exception in %1") << caller;
|
||||||
emit this->statusMessage(CStatusMessage::getErrorMessage(msg, CStatusMessage::TypeAudio));
|
Q_ASSERT(false);
|
||||||
qFatal("Unknown exception caught in %s", caller);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user