Formatting

This commit is contained in:
Klaus Basan
2017-09-06 01:18:17 +02:00
committed by Mathew Sutcliffe
parent eab22e86b0
commit a22cd134f8
17 changed files with 68 additions and 106 deletions

View File

@@ -506,26 +506,26 @@ namespace BlackCore
int maxRedirects, int maxRedirects,
std::function<QNetworkReply *(QNetworkAccessManager &, const QNetworkRequest &)> requestOrPostMethod); std::function<QNetworkReply *(QNetworkAccessManager &, const QNetworkRequest &)> requestOrPostMethod);
QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager
BlackMisc::CApplicationInfo::Application m_application = BlackMisc::CApplicationInfo::Unknown; //!< Application if specified BlackMisc::CApplicationInfo::Application m_application = BlackMisc::CApplicationInfo::Unknown; //!< Application if specified
QScopedPointer<CCoreFacade> m_coreFacade; //!< core facade if any QScopedPointer<CCoreFacade> m_coreFacade; //!< core facade if any
QScopedPointer<CSetupReader> m_setupReader; //!< setup reader QScopedPointer<CSetupReader> m_setupReader; //!< setup reader
QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services QScopedPointer<CWebDataServices> m_webDataServices; //!< web data services
QScopedPointer<BlackMisc::CFileLogger> m_fileLogger; //!< file logger QScopedPointer<BlackMisc::CFileLogger> m_fileLogger; //!< file logger
CCookieManager m_cookieManager; //!< single cookie manager for our access manager CCookieManager m_cookieManager; //!< single cookie manager for our access manager
QString m_applicationName; //!< application name QString m_applicationName; //!< application name
QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe QReadWriteLock m_accessManagerLock; //!< lock to make access manager access threadsafe
CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any CCoreFacadeConfig m_coreFacadeConfig; //!< Core facade config if any
CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used
BlackCore::Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? BlackCore::Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching?
std::atomic<bool> m_shutdown { false }; //!< is being shutdown? std::atomic<bool> m_shutdown { false }; //!< is being shutdown?
QTimer m_internetAccessTimer { this }; QTimer m_internetAccessTimer { this };
bool m_useContexts = false; //!< use contexts bool m_useContexts = false; //!< use contexts
bool m_useWebData = false; //!< use web data bool m_useWebData = false; //!< use web data
bool m_signalStartup = true; //!< signal startup automatically bool m_signalStartup = true; //!< signal startup automatically
bool m_devEnv = false; //!< dev. environment bool m_devEnv = false; //!< dev. environment
bool m_unitTest = false; //!< is UNIT test bool m_unitTest = false; //!< is UNIT test
bool m_autoSaveSettings = true; //!< automatically saving all settings bool m_autoSaveSettings = true; //!< automatically saving all settings
bool m_internetAccessible = true; //!< Internet accessible bool m_internetAccessible = true; //!< Internet accessible
// -------------- crashpad ----------------- // -------------- crashpad -----------------

View File

@@ -8,7 +8,6 @@
*/ */
#include "blackcore/data/vatsimsetup.h" #include "blackcore/data/vatsimsetup.h"
#include <QStringList> #include <QStringList>
using namespace BlackMisc; using namespace BlackMisc;
@@ -66,15 +65,12 @@ namespace BlackCore
if (index.isMyself()) { return CVariant::from(*this); } if (index.isMyself()) { return CVariant::from(*this); }
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); } if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexFsdServers: case IndexFsdServers: return CVariant::fromValue(this->m_fsdServers);
return CVariant::fromValue(this->m_fsdServers); case IndexDataFiles: return CVariant::fromValue(this->m_dataFileUrls);
case IndexDataFiles: default: return CValueObject::propertyByIndex(index);
return CVariant::fromValue(this->m_dataFileUrls);
default:
return CValueObject::propertyByIndex(index);
} }
} }
@@ -87,18 +83,12 @@ namespace BlackCore
return; return;
} }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexFsdServers: case IndexFsdServers: this->m_fsdServers = variant.value<CServerList>(); break;
this->m_fsdServers = variant.value<CServerList>(); case IndexDataFiles: this->m_dataFileUrls = variant.value<CUrlList>(); break;
break; default: CValueObject::setPropertyByIndex(index, variant); break;
case IndexDataFiles:
this->m_dataFileUrls = variant.value<CUrlList>();
break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
} }
} }
} // ns } // ns

View File

@@ -89,8 +89,8 @@ namespace BlackCore
QString query = params.toString(); QString query = params.toString();
const QNetworkRequest request(CNetworkUtils::getNetworkRequest(url, CNetworkUtils::PostUrlEncoded)); const QNetworkRequest request(CNetworkUtils::getNetworkRequest(url, CNetworkUtils::PostUrlEncoded));
sApp->postToNetwork(request, query.toUtf8(), { this, &CDatabaseAuthenticationService::parseServerResponse}); sApp->postToNetwork(request, CApplication::NoLogRequestId, query.toUtf8(), { this, &CDatabaseAuthenticationService::parseServerResponse});
QString rm("Sent request to authentication server %1"); static const QString rm("Sent request to authentication server '%1'");
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityInfo, rm.arg(url.toQString()))); msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityInfo, rm.arg(url.toQString())));
return msgs; return msgs;
} }

View File

@@ -601,10 +601,8 @@ namespace BlackCore
Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "needs single entity"); Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "needs single entity");
switch (mode) switch (mode)
{ {
case CDbFlags::Shared: case CDbFlags::Shared: return CDbInfo::entityToSharedName(entity);
return CDbInfo::entityToSharedName(entity); case CDbFlags::SharedInfoOnly: return CDbInfo::sharedInfoFileName();
case CDbFlags::SharedInfoOnly:
return CDbInfo::sharedInfoFileName();
default: default:
case CDbFlags::DbReading: case CDbFlags::DbReading:
return CDbInfo::entityToServiceName(entity); return CDbInfo::entityToServiceName(entity);
@@ -613,7 +611,7 @@ namespace BlackCore
QString CDatabaseReader::dateTimeToDbLatestTs(const QDateTime &ts) QString CDatabaseReader::dateTimeToDbLatestTs(const QDateTime &ts)
{ {
if (!ts.isValid()) return ""; if (!ts.isValid()) { return ""; }
return ts.toUTC().toString(Qt::ISODate); return ts.toUTC().toString(Qt::ISODate);
} }

View File

@@ -262,10 +262,10 @@ namespace BlackCore
void sharedFileHeaderRead(BlackMisc::Network::CEntityFlags::Entity entity, const QString &fileName, bool success); void sharedFileHeaderRead(BlackMisc::Network::CEntityFlags::Entity entity, const QString &fileName, bool success);
protected: protected:
CDatabaseReaderConfigList m_config; //!< DB reder configuration CDatabaseReaderConfigList m_config; //!< DB reder configuration
QString m_statusMessage; //!< Returned status message from watchdog QString m_statusMessage; //!< Returned status message from watchdog
bool m_1stReplyReceived = false; //!< Successful connection? Does not mean data / authorizations are correct bool m_1stReplyReceived = false; //!< Successful connection? Does not mean data / authorizations are correct
mutable QReadWriteLock m_statusLock; //!< Lock mutable QReadWriteLock m_statusLock; //!< Lock
QNetworkReply::NetworkError m_1stReplyStatus = QNetworkReply::UnknownServerError; //!< Successful connection? QNetworkReply::NetworkError m_1stReplyStatus = QNetworkReply::UnknownServerError; //!< Successful connection?
QMap<BlackMisc::Network::CEntityFlags::Entity, HeaderResponse> m_sharedFileResponses; //!< file responses of the shared files QMap<BlackMisc::Network::CEntityFlags::Entity, HeaderResponse> m_sharedFileResponses; //!< file responses of the shared files
BlackMisc::CStatusMessage::StatusSeverity m_severityNoWorkingUrl = BlackMisc::CStatusMessage::SeverityError; //!< severity of message if there is no working URL BlackMisc::CStatusMessage::StatusSeverity m_severityNoWorkingUrl = BlackMisc::CStatusMessage::SeverityError; //!< severity of message if there is no working URL

View File

@@ -61,9 +61,9 @@ namespace BlackCore
private: private:
BlackMisc::Network::CUrl m_modelPublishUrl; BlackMisc::Network::CUrl m_modelPublishUrl;
QNetworkReply *m_pendingReply = nullptr; QNetworkReply *m_pendingReply = nullptr;
qint64 m_replyPendingSince = -1; qint64 m_replyPendingSince = -1;
bool m_shutdown = false; bool m_shutdown = false;
//! Kill the pending reply //! Kill the pending reply
bool killPendingReply(); bool killPendingReply();

View File

@@ -73,10 +73,11 @@ namespace BlackCore
void pauseReader(); void pauseReader();
//! Used in unit test //! Used in unit test
//! \remark needs to be done before started in different thread
void markAsUsedInUnitTest() { m_unitTest = true; } void markAsUsedInUnitTest() { m_unitTest = true; }
protected: protected:
mutable QReadWriteLock m_lock {QReadWriteLock::Recursive}; //!< lock which can be used from the derived classes mutable QReadWriteLock m_lock { QReadWriteLock::Recursive }; //!< lock which can be used from the derived classes
//! Constructor //! Constructor
CThreadedReader(QObject *owner, const QString &name); CThreadedReader(QObject *owner, const QString &name);
@@ -97,7 +98,7 @@ namespace BlackCore
//! This method does the actual work in the derived class //! This method does the actual work in the derived class
virtual void doWorkImpl() {} virtual void doWorkImpl() {}
//! Still enabled etc. //! Still enabled etc.?
bool doWorkCheck() const; bool doWorkCheck() const;
//! Use this to log inconsistent data //! Use this to log inconsistent data

View File

@@ -625,8 +625,10 @@ namespace BlackGui
{ {
if (CBuildConfig::isRunningOnWindowsNtPlatform()) if (CBuildConfig::isRunningOnWindowsNtPlatform())
{ {
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(), QMessageBox::information(nullptr,
QGuiApplication::applicationDisplayName() + ' ' + QCoreApplication::applicationVersion()); QGuiApplication::applicationDisplayName(),
QGuiApplication::applicationDisplayName() + ' ' +
QCoreApplication::applicationVersion());
} }
else else
{ {

View File

@@ -227,6 +227,5 @@ namespace BlackMisc
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE IDatastoreObjectList<BlackMisc::CCountry, BlackMisc::CCountryList, QString>; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE IDatastoreObjectList<BlackMisc::CCountry, BlackMisc::CCountryList, QString>;
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList, int>; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList, int>;
//! \endcond //! \endcond
} // ns } // ns
} // ns } // ns

View File

@@ -82,14 +82,13 @@ namespace BlackMisc
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CLivery, BlackMisc::Aviation::CLiveryList, int>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CLivery, BlackMisc::Aviation::CLiveryList, int>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAircraftIcaoCode, BlackMisc::Aviation::CAircraftIcaoCodeList, int>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAircraftIcaoCode, BlackMisc::Aviation::CAircraftIcaoCodeList, int>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAirlineIcaoCode, BlackMisc::Aviation::CAirlineIcaoCodeList, int>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAirlineIcaoCode, BlackMisc::Aviation::CAirlineIcaoCodeList, int>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList, int>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Db::CDbInfo, BlackMisc::Db::CDbInfoList, int>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Db::CDbInfo, BlackMisc::Db::CDbInfoList, int>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Db::CDistribution, BlackMisc::Db::CDistributionList, int>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Db::CDistribution, BlackMisc::Db::CDistributionList, int>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Simulation::CAircraftModel, BlackMisc::Simulation::CAircraftModelList, int>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Simulation::CAircraftModel, BlackMisc::Simulation::CAircraftModelList, int>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Simulation::CDistributor, BlackMisc::Simulation::CDistributorList, QString>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Simulation::CDistributor, BlackMisc::Simulation::CDistributorList, QString>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::CCountry, BlackMisc::CCountryList, QString>; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::CCountry, BlackMisc::CCountryList, QString>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE IDatastoreObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList, int>;
//! \endcond //! \endcond
} // ns } // ns
} //ns } //ns

View File

@@ -7,23 +7,15 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackmisc/network/clientlist.h" #include "clientlist.h"
#include "blackmisc/metaclassprivate.h"
#include <QString>
#include <tuple>
using namespace BlackMisc::Aviation;
namespace BlackMisc namespace BlackMisc
{ {
namespace Network namespace Network
{ {
CClientList::CClientList() { } CClientList::CClientList() { }
CClientList::CClientList(const CSequence &other) : CSequence<CClient>(other) CClientList::CClientList(const CSequence &other) : CSequence<CClient>(other)
{ } { }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -18,7 +18,6 @@
#include "blackmisc/network/client.h" #include "blackmisc/network/client.h"
#include "blackmisc/sequence.h" #include "blackmisc/sequence.h"
#include "blackmisc/variant.h" #include "blackmisc/variant.h"
#include <QMetaType> #include <QMetaType>
namespace BlackMisc namespace BlackMisc
@@ -39,7 +38,6 @@ namespace BlackMisc
//! Construct from a base class object. //! Construct from a base class object.
CClientList(const CSequence &other); CClientList(const CSequence &other);
}; };
} //namespace } //namespace
} // namespace } // namespace

View File

@@ -58,7 +58,6 @@ namespace BlackMisc
//! From our database JSON format //! From our database JSON format
static CRoleList fromDatabaseJson(const QJsonArray &array); static CRoleList fromDatabaseJson(const QJsonArray &array);
}; };
} //namespace } //namespace
} // namespace } // namespace

View File

@@ -234,48 +234,32 @@ namespace BlackMisc
return q; return q;
} }
CVariant CUrl::propertyByIndex(const BlackMisc::CPropertyIndex &index) const CVariant CUrl::propertyByIndex(const CPropertyIndex &index) const
{ {
if (index.isMyself()) { return CVariant::from(*this); } if (index.isMyself()) { return CVariant::from(*this); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexHost: case IndexHost: return CVariant::fromValue(this->m_host);
return CVariant::fromValue(this->m_host); case IndexPort: return CVariant::fromValue(this->m_port);
case IndexPort: case IndexScheme: return CVariant::fromValue(this->m_scheme);
return CVariant::fromValue(this->m_port); case IndexPath: return CVariant::fromValue(this->m_path);
case IndexScheme: default: return CValueObject::propertyByIndex(index);
return CVariant::fromValue(this->m_scheme);
case IndexPath:
return CVariant::fromValue(this->m_path);
default:
return CValueObject::propertyByIndex(index);
} }
} }
void CUrl::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) void CUrl::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
{ {
if (index.isMyself()) { (*this) = variant.to<CUrl>(); return; } if (index.isMyself()) { (*this) = variant.to<CUrl>(); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexHost: case IndexHost: this->setHost(variant.value<QString>()); break;
this->setHost(variant.value<QString>()); case IndexPort: this->setPort(variant.value<qint32>()); break;
break; case IndexPath: this->setPath(variant.value<QString>()); break;
case IndexPort: case IndexScheme: this->setScheme(variant.value<QString>()); break;
this->setPort(variant.value<qint32>()); default: CValueObject::setPropertyByIndex(index, variant); break;
break;
case IndexPath:
this->setPath(variant.value<QString>());
break;
case IndexScheme:
this->setScheme(variant.value<QString>());
break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
} }
} }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -9,8 +9,8 @@
//! \file //! \file
#ifndef BLACKMISC_NETWORK_NETWORKLOCATION_H #ifndef BLACKMISC_NETWORK_URL_H
#define BLACKMISC_NETWORK_NETWORKLOCATION_H #define BLACKMISC_NETWORK_URL_H
#include "blackmisc/blackmiscexport.h" #include "blackmisc/blackmiscexport.h"
#include "blackmisc/metaclass.h" #include "blackmisc/metaclass.h"

View File

@@ -9,8 +9,8 @@
//! \file //! \file
#ifndef BLACKMISC_NETWORK_NETWORKLOCATIONLIST_H #ifndef BLACKMISC_NETWORK_URLLIST_H
#define BLACKMISC_NETWORK_NETWORKLOCATIONLIST_H #define BLACKMISC_NETWORK_URLLIST_H
#include "blackmisc/blackmiscexport.h" #include "blackmisc/blackmiscexport.h"
#include "blackmisc/collection.h" #include "blackmisc/collection.h"
@@ -26,7 +26,7 @@ namespace BlackMisc
{ {
namespace Network namespace Network
{ {
//! Value object encapsulating a list of servers. //! Value object encapsulating a list of URLs.
class BLACKMISC_EXPORT CUrlList : class BLACKMISC_EXPORT CUrlList :
public CSequence<CUrl>, public CSequence<CUrl>,
public BlackMisc::Mixin::MetaType<CUrlList> public BlackMisc::Mixin::MetaType<CUrlList>

View File

@@ -174,7 +174,7 @@ namespace BlackMisc
bool ITimestampBased::canHandleIndex(const CPropertyIndex &index) bool ITimestampBased::canHandleIndex(const CPropertyIndex &index)
{ {
if (index.isEmpty()) { return false; } if (index.isEmpty()) { return false; }
int i = index.frontCasted<int>(); const int i = index.frontCasted<int>();
return (i >= static_cast<int>(IndexUtcTimestamp)) && (i <= static_cast<int>(IndexMSecsSinceEpoch)); return (i >= static_cast<int>(IndexUtcTimestamp)) && (i <= static_cast<int>(IndexMSecsSinceEpoch));
} }
@@ -182,7 +182,7 @@ namespace BlackMisc
{ {
if (!index.isEmpty()) if (!index.isEmpty())
{ {
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexUtcTimestamp: case IndexUtcTimestamp:
@@ -212,7 +212,7 @@ namespace BlackMisc
{ {
if (!index.isEmpty()) if (!index.isEmpty())
{ {
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexUtcTimestamp: case IndexUtcTimestamp: