6#include <QJsonDocument>
18using namespace swift::misc::network;
19using namespace swift::misc::db;
40 return m_infoObjects.size();
48 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Using this for CInfoDataReader makes no sense");
55 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Using this for CInfoDataReader makes no sense");
62 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Using this for CInfoDataReader makes no sense");
71 Q_ASSERT_X(sApp, Q_FUNC_INFO,
"Need sApp");
75 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Using this for CInfoDataReader makes no sense");
81 return sApp->getWebDataServices()->getCacheTimestamp(entity);
89 Q_ASSERT_X(sApp, Q_FUNC_INFO,
"Need sApp");
93 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Using this for CInfoDataReader makes no sense");
99 return sApp->getWebDataServices()->getCacheCount(entity);
104 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Using this for CInfoDataReader makes no sense");
111 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Using this for CInfoDataReader makes no sense");
154 void CInfoDataReader::parseInfoObjectsData(
QNetworkReply *nwReplyPtr)
164 const CDatabaseReader::JsonDatastoreResponse res =
166 if (res.hasErrorMessage())
175 const int n = infoObjects.
size();
179 const QString urlStr = nwReply->url().toString();
185 m_infoObjects = infoObjects;
191 CUrl CInfoDataReader::getDbInfoObjectsUrl()
const
196 CUrl CInfoDataReader::getSharedInfoObjectsUrl()
const
211 qFatal(
"Wrong mode");
216 const QDateTime &newerThan)
221 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Not implemented for CInfoDataReader");
230 default: qFatal(
"Wrong mode");
240 Q_UNUSED(overrideNewer)
241 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Not supported");
251 Q_UNUSED(overrideNewer)
252 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Not supported");
swift::misc::network::CUrlLogList getUrlLogList() const
Get the URL log list.
QNetworkReply * getFromNetworkAndLog(const swift::misc::network::CUrl &url, const swift::misc::CSlot< void(QNetworkReply *)> &callback)
Get request from network, and log with m_urlReadLog.
bool doWorkCheck() const
Still enabled etc.?
Value object encapsulating a list of reader configs.
void emitAndLogDataRead(swift::misc::network::CEntityFlags::Entity entity, int number, const JsonDatastoreResponse &res)
Emit signal and log when data have been read.
void logNoWorkingUrl(swift::misc::network::CEntityFlags::Entity entity)
Log if no working URL exists, using m_noWorkingUrlSeverity.
CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name)
Constructor.
swift::misc::network::CUrl getBaseUrl(swift::misc::db::CDbFlags::DataRetrievalModeFlag mode) const
Base URL for mode (either a shared or DB URL).
void dataRead(swift::misc::network::CEntityFlags::Entity entities, swift::misc::network::CEntityFlags::ReadState state, int number, const QUrl &url)
Combined read signal.
CDatabaseReader::JsonDatastoreResponse setStatusAndTransformReplyIntoDatastoreResponse(QNetworkReply *nwReply)
Check if terminated or error, otherwise split into array of objects.
int getInfoObjectCount() const
Get info list size (either shared or from DB).
swift::misc::db::CDbInfoList getInfoObjects() const
Get info list (either shared or from DB).
void synchronizeCaches(swift::misc::network::CEntityFlags::Entity entities)
Admit caches for given entities.
void readInfoData()
Allow to call directly, special for info objects reader.
int getCacheCount(swift::misc::network::CEntityFlags::Entity entity) const
Cache`s number of entities.
swift::misc::CStatusMessageList readFromJsonFiles(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)
Data read from local data.
swift::misc::network::CUrl getInfoObjectsUrl() const
URL depending on mode, i.e. shared/DB.
void invalidateCaches(swift::misc::network::CEntityFlags::Entity entities)
Invalidate the caches for given entities.
bool hasChangedUrl(swift::misc::network::CEntityFlags::Entity entity, swift::misc::network::CUrl &oldUrlInfo, swift::misc::network::CUrl &newUrlInfo) const
Changed URL, means the cache values have been read from elsewhere.
void admitCaches(swift::misc::network::CEntityFlags::Entity entities)
Admit caches for given entities.
CInfoDataReader(QObject *owner, const CDatabaseReaderConfigList &config, swift::misc::db::CDbFlags::DataRetrievalModeFlag mode)
Constructor.
swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheTimestampNewerThan(const QDateTime &threshold) const
Entities already having data in cache (based on timestamp assumption).
swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheCount() const
Entities already having data in cache.
QDateTime getCacheTimestamp(swift::misc::network::CEntityFlags::Entity entity) const
Get cache timestamp.
swift::misc::network::CUrl getDbServiceBaseUrl() const
Get the service URL, individual for each reader.
bool areAllInfoObjectsRead() const
All data read?
bool readFromJsonFilesInBackground(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)
Data read from local data.
swift::misc::network::CEntityFlags::Entity getSupportedEntities() const
Supported entities by this reader.
const QObject * owner() const
Owner of the worker.
Class for emitting a log message.
static void preformatted(const CStatusMessage &statusMessage)
Sends a verbatim, preformatted message to the log.
Derived & error(const char16_t(&format)[N])
Set the severity to error, providing a format string.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
size_type size() const
Returns number of elements in the sequence.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
DataRetrievalModeFlag
Which data to read, requires corresponding readers.
@ DbReading
directly from DB
static const QString & sharedInfoFileName()
Get shared info file name.
Value object encapsulating a list of info objects.
static CDbInfoList fromDatabaseJson(const QJsonArray &array)
From our database JSON format.
static bool isSingleEntity(CEntityFlags::Entity flag)
Representing single entity?
EntityFlag
Which data to read, requires corresponding readers.
@ DbInfoObjectEntity
info about DB data (kind of metadata)
@ SharedInfoObjectEntity
info about shared DB data (metadata)
@ ReadStarted
reading has been started
@ ReadFailed
reading failed
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
bool isEmpty() const
Empty.
CUrl withAppendedPath(const QString &path) const
Append path.
Value object encapsulating a list of voice rooms.
bool hasPending() const
Any pending calls.
QString getSummary() const
Summary.
Core data traits (aka cached values) and classes.
Classes interacting with the swift database (aka "datastore").
Free functions in swift::misc.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.