mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #316 Changed blackmisc and blacksim 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:
@@ -1,4 +1,5 @@
|
||||
#include "setaudio.h"
|
||||
#include "logmessage.h"
|
||||
using namespace BlackSound;
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -160,11 +161,10 @@ namespace BlackMisc
|
||||
/*
|
||||
* Value
|
||||
*/
|
||||
BlackMisc::CStatusMessageList CSettingsAudio::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
|
||||
BlackMisc::CStatusMessage CSettingsAudio::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
|
||||
{
|
||||
// TODO: This needs to be refactored to a smarter way to delegate commands
|
||||
changedFlag = false;
|
||||
CStatusMessageList msgs;
|
||||
if (path == CSettingsAudio::ValueNotificationFlag())
|
||||
{
|
||||
if (command == CSettingUtilities::CmdSetTrue() || command == CSettingUtilities::CmdSetFalse())
|
||||
@@ -173,10 +173,10 @@ namespace BlackMisc
|
||||
char value = (command == CSettingUtilities::CmdSetTrue()) ? '1' : '0' ;
|
||||
this->initNotificationFlags();
|
||||
this->m_notificationFlags.replace(index, 1, value);
|
||||
return msgs;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
return CSettingUtilities::wrongPathMessages(path);
|
||||
return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace BlackMisc
|
||||
bool operator !=(const CSettingsAudio &other) const;
|
||||
|
||||
//! \copydoc BlackCore::IContextSettings
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag);
|
||||
virtual BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag);
|
||||
|
||||
//! \copydoc CValueObject::getValueHash
|
||||
virtual uint getValueHash() const override;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
@@ -156,11 +157,10 @@ namespace BlackMisc
|
||||
/*
|
||||
* Value
|
||||
*/
|
||||
BlackMisc::CStatusMessageList CSettingsNetwork::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
|
||||
BlackMisc::CStatusMessage CSettingsNetwork::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
|
||||
{
|
||||
// TODO: This needs to be refactored to a smarter way to delegate commands
|
||||
changedFlag = false;
|
||||
CStatusMessageList msgs;
|
||||
if (path == CSettingsNetwork::ValueTrafficServers())
|
||||
{
|
||||
const CServer server = value.value<CServer>();
|
||||
@@ -183,8 +183,7 @@ namespace BlackMisc
|
||||
changedFlag = this->m_trafficNetworkServers.contains(&CServer::getName, server.getName());
|
||||
this->m_trafficNetworkServers.removeIf(&CServer::getName, server.getName());
|
||||
}
|
||||
msgs.push_back(CStatusMessage::getInfoMessage("Set current server", CStatusMessage::TypeSettings));
|
||||
return msgs;
|
||||
return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "Set current server");
|
||||
}
|
||||
else if (path == CSettingsNetwork::ValueBookingServiceUrl())
|
||||
{
|
||||
@@ -192,12 +191,11 @@ namespace BlackMisc
|
||||
{
|
||||
QString v = value.toString();
|
||||
changedFlag = (v != this->m_bookingServiceUrl);
|
||||
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "booking URL"));
|
||||
this->m_bookingServiceUrl = v;
|
||||
return msgs;
|
||||
return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "booking URL%1 changed") << (changedFlag ? "" : " not");
|
||||
}
|
||||
}
|
||||
return CSettingUtilities::wrongPathMessages(path);
|
||||
return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace BlackMisc
|
||||
bool operator !=(const CSettingsNetwork &other) const;
|
||||
|
||||
//! \copydoc BlackCore::IContextSettings
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag);
|
||||
virtual BlackMisc::CStatusMessage value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag);
|
||||
|
||||
//! \copydoc CValueObject::getValueHash
|
||||
virtual uint getValueHash() const override;
|
||||
|
||||
@@ -26,6 +26,15 @@ namespace BlackMisc
|
||||
|
||||
public:
|
||||
|
||||
//! Log message category for anything related to settings
|
||||
static QString getMessageCategory() { return "swift.settings"; }
|
||||
|
||||
//! Log message category for settings validation messages
|
||||
static QString validationMessageCategory() { return "swift.settings.validation"; }
|
||||
|
||||
//! Log message category for settings update messages
|
||||
static QString updateMessageCategory() { return "swift.settings.update"; }
|
||||
|
||||
//! Command validate
|
||||
static const QString &CmdValidate()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "setsimulator.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
@@ -149,22 +150,20 @@ namespace BlackSim
|
||||
/*
|
||||
* Value
|
||||
*/
|
||||
BlackMisc::CStatusMessageList CSettingsSimulator::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
|
||||
BlackMisc::CStatusMessage CSettingsSimulator::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
|
||||
{
|
||||
// TODO: This needs to be refactored to a smarter way to delegate commands
|
||||
changedFlag = false;
|
||||
CStatusMessageList msgs;
|
||||
if (path == CSettingsSimulator::ValueSelectedDriver())
|
||||
{
|
||||
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
|
||||
{
|
||||
CSimulatorInfo v = value.value<CSimulatorInfo>();
|
||||
changedFlag = (v != this->m_selectedPlugin);
|
||||
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "selected driver"));
|
||||
this->m_selectedPlugin = v;
|
||||
return msgs;
|
||||
return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "selected driver%1 changed") << (changedFlag ? "" : " not");
|
||||
}
|
||||
return CSettingUtilities::wrongCommandMessages(command);
|
||||
return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong command: %1") << command;
|
||||
}
|
||||
else if (path == CSettingsSimulator::ValueSyncTime())
|
||||
{
|
||||
@@ -172,11 +171,10 @@ namespace BlackSim
|
||||
{
|
||||
bool v = value.value<bool>();
|
||||
changedFlag = (v != this->m_timeSync);
|
||||
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "time synchronization"));
|
||||
this->m_timeSync = v;
|
||||
return msgs;
|
||||
return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "time synchronization%1 changed") << (changedFlag ? "" : " not");
|
||||
}
|
||||
return CSettingUtilities::wrongCommandMessages(command);
|
||||
return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong command: %1") << command;
|
||||
}
|
||||
else if (path == CSettingsSimulator::ValueSyncTimeOffset())
|
||||
{
|
||||
@@ -184,15 +182,14 @@ namespace BlackSim
|
||||
{
|
||||
CTime v = value.value<CTime>();
|
||||
changedFlag = (v != this->m_timeSyncOffset);
|
||||
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "time synchronization offset"));
|
||||
this->m_timeSyncOffset = v;
|
||||
return msgs;
|
||||
return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "time synchronization offset%1 changed") << (changedFlag ? "" : " not");
|
||||
}
|
||||
return CSettingUtilities::wrongCommandMessages(command);
|
||||
return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong command: %1") << command;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CSettingUtilities::wrongPathMessages(path);
|
||||
return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace BlackSim
|
||||
void initDefaultValues();
|
||||
|
||||
//! \copydoc BlackCore::IContextSettings
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag);
|
||||
virtual BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag);
|
||||
|
||||
//! \copydoc CValueObject::getValueHash
|
||||
virtual uint getValueHash() const override;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "blacksim/simulatorinfo.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/avairportlist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QtConcurrent>
|
||||
@@ -550,8 +551,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
|
||||
m_syncDeferredCounter = 5; // allow some time to sync
|
||||
QString msg = QString("Synchronized time to UTC: %1").arg(myTime.toString());
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage(msg, CStatusMessage::TypeSimulator));
|
||||
CLogMessage().info(this, "Synchronized time to UTC: %1") << myTime.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "blacksim/simulatorinfo.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/avairportlist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -37,7 +38,7 @@ namespace BlackSimPlugin
|
||||
.arg(event->szApplicationName)
|
||||
.arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor)
|
||||
.arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
|
||||
simulatorFsx->displayStatusMessage(CStatusMessage::getInfoMessage(CProject::systemNameAndVersion()));
|
||||
CLogMessage().info(CSimulatorFsx::getMessageCategory(), CProject::systemNameAndVersion());
|
||||
break;
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_EXCEPTION:
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "simulator_xplane.h"
|
||||
#include "xbus_service_proxy.h"
|
||||
#include "xbus_traffic_proxy.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QTimer>
|
||||
|
||||
@@ -254,7 +255,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
emit displayStatusMessage(CStatusMessage::getWarningMessage("X-Plane already provides real time synchronization", CStatusMessage::TypeSimulator));
|
||||
CLogMessage().warning(this, "X-Plane already provides real time synchronization");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user