6#include <QCoreApplication>
11#include <QWriteLocker>
20using namespace swift::misc::network;
21using namespace swift::core::vatsim;
41 return m_updateTimestamp;
47 m_updateTimestamp = updateTimestamp;
61 oldHash = m_contentHash;
63 size_t newHash =
qHash(startPosition < 0 ? content : content.
mid(startPosition));
64 if (oldHash == newHash)
70 m_contentHash = newHash;
88 "Needs to run in own thread");
106 if (!m_unitTest && (!sApp || sApp->isShuttingDown()))
117 if (!outdatedPendingUrls.
isEmpty())
121 m_urlReadLog.removeOlderThanNowMinusOffset(OutdatedPendingCallMs);
std::atomic_llong m_networkReplyCurrent
current bytes
QDateTime getUpdateTimestamp() const
Thread safe, get update timestamp.
QPair< qint64, qint64 > getNetworkReplyBytes() const
Max./current bytes.
void setUpdateTimestamp(const QDateTime &updateTimestamp=QDateTime::currentDateTimeUtc())
Thread safe, set update timestamp.
static const QStringList & getLogCategories()
Log categories.
virtual void networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url)
Network request progress.
static void logInconsistentData(const swift::misc::CStatusMessage &msg, const char *funcInfo=nullptr)
Use this to log inconsistent data.
swift::misc::network::CUrlLogList getReadLog() const
Get the read log.
void setMarkedAsFailed(bool failed)
Set marker for read failed.
std::atomic_int m_networkReplyProgress
Progress percentage 0...100.
bool isMarkedAsFailed() const
Is marked as read failed.
void threadAssertCheck() const
Make sure everything runs correctly in own thread.
void logNetworkReplyReceived(QNetworkReply *reply)
Network reply received, mark in m_urlReadLog.
QReadWriteLock m_lock
lock which can be used from the derived classes
bool didContentChange(const QString &content, int startPosition=-1)
Stores new content hash and returns if content changed (based on hash value.
swift::misc::network::CUrlLogList getUrlLogList() const
Get the URL log list.
CThreadedReader(const CThreadedReader &)=delete
Copy constructor.
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.?
qint64 lastModifiedMsSinceEpoch(QNetworkReply *nwReply) const
When was reply last modified, -1 if N/A.
std::atomic_llong m_networkReplyMax
max bytes
bool isEnabled() const
Enabled (running)?
const QObject * owner() const
Owner of the worker.
CContinuousWorker(QObject *owner, const QString &name)
Constructor.
static const QString & worker()
Background task.
static const QString & dataInconsistency()
Data inconsistency.
Class for emitting a log message.
static void preformatted(const CStatusMessage &statusMessage)
Sends a verbatim, preformatted message to the log.
bool isEmpty() const
Message empty.
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
bool isEmpty() const
Synonym for empty.
Callable wrapper for a member function with function signature F.
Streamable status message, e.g.
QString getMessage() const
Message.
void addCategory(const CLogCategory &category)
Add category, avoids duplicates.
static bool isInThisThread(const QObject *toBeTested)
Is the current thread the object's thread?
bool isAbandoned() const
For the task to check whether it can finish early.
QString toQString(bool i18n=false) const
Cast as QString.
static qint64 lastModifiedMsSinceEpoch(const QNetworkReply *nwReply)
Last modified from reply.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
Value object encapsulating a list of voice rooms.
CUrlLogList findOutdatedPending(int outdatedOffsetMs) const
Find outdated pending log entries.
int addPendingUrl(const CUrl &url, int maxNumber=10)
Add a pending URL.
Backend services of the swift project, like dealing with the network or the simulators.
Free functions in swift::misc.
size_t qHash(const std::string &key, uint seed)
std::string qHash
const char * constData() const const
QCoreApplication * instance()
QNetworkReply::NetworkError error() const const
QThread * thread() const const
QString mid(qsizetype position, qsizetype n) &&
QByteArray toLatin1() const const
QThread * currentThread()
#define SWIFT_AUDIT_X(COND, WHERE, WHAT)
A weaker kind of verify.