mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Added with() and withValidation() methods in CLogCategoryList.
This commit is contained in:
@@ -179,7 +179,7 @@ namespace BlackCore
|
|||||||
Q_ASSERT(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 = m_voiceOutputDevice->getOutputDevices();
|
CAudioDeviceInfoList devices = m_voiceOutputDevice->getOutputDevices();
|
||||||
devices = devices.join(m_voiceInputDevice->getInputDevices());
|
devices.push_back(m_voiceInputDevice->getInputDevices());
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace BlackCore
|
|||||||
CStatusMessageList CDatabaseAuthenticationService::login(const QString &username, const QString &password)
|
CStatusMessageList CDatabaseAuthenticationService::login(const QString &username, const QString &password)
|
||||||
{
|
{
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
static const CLogCategoryList cats(getLogCategories().join({ CLogCategory::validation() }));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
|
|
||||||
if (!sApp || m_shutdown) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Shutdown in progress")); return msgs; }
|
if (!sApp || m_shutdown) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Shutdown in progress")); return msgs; }
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ namespace BlackCore
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
const QJsonObject jsonObj(Json::jsonObjectFromString(json));
|
const QJsonObject jsonObj(Json::jsonObjectFromString(json));
|
||||||
CAuthenticatedUser user = CAuthenticatedUser::fromDatabaseJson(jsonObj.contains("user") ? jsonObj["user"].toObject() : jsonObj);
|
CAuthenticatedUser user = CAuthenticatedUser::fromDatabaseJson(jsonObj.contains("user") ? jsonObj["user"].toObject() : jsonObj);
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
|
|||||||
@@ -708,10 +708,10 @@ namespace BlackCore
|
|||||||
|
|
||||||
const CLogCategoryList &CDatabaseReader::getLogCategories()
|
const CLogCategoryList &CDatabaseReader::getLogCategories()
|
||||||
{
|
{
|
||||||
static const BlackMisc::CLogCategoryList cats
|
static const CLogCategoryList cats = CThreadedReader::getLogCategories().with(
|
||||||
(
|
{
|
||||||
CThreadedReader::getLogCategories().join({ CLogCategory::swiftDbWebservice(), CLogCategory::webservice() })
|
CLogCategory::swiftDbWebservice(), CLogCategory::webservice()
|
||||||
);
|
});
|
||||||
return cats;
|
return cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
const CLogCategoryList &CNetworkWatchdog::getLogCategories()
|
const CLogCategoryList &CNetworkWatchdog::getLogCategories()
|
||||||
{
|
{
|
||||||
static const BlackMisc::CLogCategoryList cats
|
static const BlackMisc::CLogCategoryList cats = CContinuousWorker::getLogCategories().with(
|
||||||
(
|
{
|
||||||
CContinuousWorker::getLogCategories().join({ CLogCategory::swiftDbWebservice(), CLogCategory::webservice(), CLogCategory::network() })
|
CLogCategory::swiftDbWebservice(), CLogCategory::webservice(), CLogCategory::network()
|
||||||
);
|
});
|
||||||
return cats;
|
return cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
const CLogCategoryList &CDbStashComponent::validationCategories() const
|
const CLogCategoryList &CDbStashComponent::validationCategories() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
return cats;
|
return cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CVoiceSetup::validate() const
|
CStatusMessageList CVoiceSetup::validate() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
if (this->getVatsimUdpVoicePort() < 1 || this->getVatsimUdpVoicePort() > 65535) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Invalid voice port")); }
|
if (this->getVatsimUdpVoicePort() < 1 || this->getVatsimUdpVoicePort() > 65535) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Invalid voice port")); }
|
||||||
msgs.addCategories(cats);
|
msgs.addCategories(cats);
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CAirlineIcaoCode::validate() const
|
CStatusMessageList CAirlineIcaoCode::validate() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation() }));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
if (!hasValidDesignator()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Airline: missing designator")); }
|
if (!hasValidDesignator()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Airline: missing designator")); }
|
||||||
if (!hasValidCountry()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Airline: missing country")); }
|
if (!hasValidCountry()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Airline: missing country")); }
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CLivery::validate() const
|
CStatusMessageList CLivery::validate() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation() }));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msg;
|
CStatusMessageList msg;
|
||||||
if (!hasCombinedCode()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Livery: missing livery code")); }
|
if (!hasCombinedCode()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Livery: missing livery code")); }
|
||||||
if (!hasColorFuselage()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, u"Livery: no fuselage color")); }
|
if (!hasColorFuselage()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, u"Livery: no fuselage color")); }
|
||||||
|
|||||||
@@ -68,6 +68,15 @@ namespace BlackMisc
|
|||||||
template <typename T, typename = std::enable_if_t<std::is_class<T>::value>>
|
template <typename T, typename = std::enable_if_t<std::is_class<T>::value>>
|
||||||
CLogCategoryList(const T *pointer) : CLogCategoryList(fromClass<T>()) { Q_UNUSED(pointer); }
|
CLogCategoryList(const T *pointer) : CLogCategoryList(fromClass<T>()) { Q_UNUSED(pointer); }
|
||||||
|
|
||||||
|
//! Return a copy with another category appended.
|
||||||
|
CLogCategoryList with(const CLogCategory &other) const { auto copy = *this; copy.push_back(other); return copy; }
|
||||||
|
|
||||||
|
//! Return a copy with some other categories appended.
|
||||||
|
CLogCategoryList with(const CLogCategoryList &other) const { auto copy = *this; copy.push_back(other); return copy; }
|
||||||
|
|
||||||
|
//! Return a copy with validation category appended.
|
||||||
|
CLogCategoryList withValidation() const { return with(CLogCategory::validation()); }
|
||||||
|
|
||||||
//! Convert each of the categories to a QString and return the result as a QStringList.
|
//! Convert each of the categories to a QString and return the result as a QStringList.
|
||||||
QStringList toQStringList() const;
|
QStringList toQStringList() const;
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CAuthenticatedUser::validate() const
|
CStatusMessageList CAuthenticatedUser::validate() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
// callsign optional
|
// callsign optional
|
||||||
if (!this->hasValidDbKey()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, u"Invalid id"));}
|
if (!this->hasValidDbKey()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, u"Invalid id"));}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CFsdSetup::validate() const
|
CStatusMessageList CFsdSetup::validate() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
if (this->getTextCodec().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"No codec")); }
|
if (this->getTextCodec().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"No codec")); }
|
||||||
if (!textCodecNames(true, true).contains(this->getTextCodec())) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Unrecognized codec name")); }
|
if (!textCodecNames(true, true).contains(this->getTextCodec())) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Unrecognized codec name")); }
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CServer::validate() const
|
CStatusMessageList CServer::validate() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
if (this->getName().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing name")); }
|
if (this->getName().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing name")); }
|
||||||
if (this->getAddress().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing address")); }
|
if (this->getAddress().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Missing address")); }
|
||||||
|
|||||||
@@ -781,7 +781,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CAircraftModel::validate(bool withNestedObjects) const
|
CStatusMessageList CAircraftModel::validate(bool withNestedObjects) const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation() }));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
if (!hasModelString()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Model: missing model string (aka key)")); }
|
if (!hasModelString()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Model: missing model string (aka key)")); }
|
||||||
if (!hasValidSimulator()) {msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Model: no simulator set")); }
|
if (!hasValidSimulator()) {msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Model: no simulator set")); }
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessageList CDistributor::validate() const
|
CStatusMessageList CDistributor::validate() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation() }));
|
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
if (!hasValidDbKey()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Distributor: missing id")); }
|
if (!hasValidDbKey()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Distributor: missing id")); }
|
||||||
if (!hasDescription()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Distributor: missing description")); }
|
if (!hasDescription()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Distributor: missing description")); }
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ namespace BlackMisc
|
|||||||
newMsgs.append(msg.getMessage());
|
newMsgs.append(msg.getMessage());
|
||||||
CStatusMessage::StatusSeverity ms = msg.getSeverity();
|
CStatusMessage::StatusSeverity ms = msg.getSeverity();
|
||||||
if (s < ms) { s = ms; }
|
if (s < ms) { s = ms; }
|
||||||
cats = cats.join(msg.getCategories());
|
cats.push_back(msg.getCategories());
|
||||||
}
|
}
|
||||||
const CStatusMessage newMsg(cats, s, newMsgs.join(", "));
|
const CStatusMessage newMsg(cats, s, newMsgs.join(", "));
|
||||||
return newMsg;
|
return newMsg;
|
||||||
|
|||||||
Reference in New Issue
Block a user