Ref T203, renamings and improved messages in setup reader

This commit is contained in:
Klaus Basan
2017-12-11 04:13:34 +01:00
parent 4c0c28a4a4
commit 7cf5dcdd8a
3 changed files with 18 additions and 18 deletions

View File

@@ -446,7 +446,7 @@ namespace BlackCore
} }
if (m_setupReader->hasCmdLineBootstrapUrl()) if (m_setupReader->hasCmdLineBootstrapUrl())
{ {
msgs.push_back(CStatusMessage(this).info("Check cmd line argument '%1'") << m_setupReader->getCmdLineBootstrapUrl()); msgs.push_back(CStatusMessage(this).info("Bootstrap URL cmd line argument '%1'") << m_setupReader->getCmdLineBootstrapUrl());
} }
return msgs; return msgs;
} }
@@ -1420,7 +1420,7 @@ namespace BlackCore
QString CApplication::getLastSuccesfulDistributionUrl() const QString CApplication::getLastSuccesfulDistributionUrl() const
{ {
if (!this->hasSetupReader()) { return ""; } if (!this->hasSetupReader()) { return ""; }
return m_setupReader->getLastSuccessfulDistributionUrl(); return m_setupReader->getLastSuccessfulUpdateInfoUrl();
} }
CStatusMessageList CApplication::synchronizeSetup(int timeoutMs) CStatusMessageList CApplication::synchronizeSetup(int timeoutMs)

View File

@@ -241,7 +241,7 @@ namespace BlackCore
return msgs; return msgs;
} }
const CStatusMessage m(this, CStatusMessage::SeverityInfo, "Start reading URL: " + url.toQString()); const CStatusMessage m(this, CStatusMessage::SeverityInfo, "Start reading URL: " + url.toQString());
sApp->getFromNetwork(url.toNetworkRequest(), { this, &CSetupReader::parseSetupFile }); sApp->getFromNetwork(url.toNetworkRequest(), { this, &CSetupReader::parseBootstrapFile });
this->setLastSetupReadErrorMessages(m); // clear errors this->setLastSetupReadErrorMessages(m); // clear errors
return m; return m;
} }
@@ -310,7 +310,7 @@ namespace BlackCore
} }
} }
void CSetupReader::parseSetupFile(QNetworkReply *nwReplyPtr) void CSetupReader::parseBootstrapFile(QNetworkReply *nwReplyPtr)
{ {
// wrap pointer, make sure any exit cleans up reply // wrap pointer, make sure any exit cleans up reply
// required to use delete later as object is created in a different thread // required to use delete later as object is created in a different thread
@@ -426,7 +426,7 @@ namespace BlackCore
nwReplyPtr->close(); nwReplyPtr->close();
if (updateInfoJsonString.isEmpty()) if (updateInfoJsonString.isEmpty())
{ {
CLogMessage(this).info("No distribution file content"); CLogMessage(this).info("No update info file content");
// try next URL // try next URL
} }
else else
@@ -451,7 +451,7 @@ namespace BlackCore
else else
{ {
{ {
QWriteLocker l(&m_lockDistribution); QWriteLocker l(&m_lockUpdateInfo);
m_lastSuccessfulUpdateInfoUrl = urlString; m_lastSuccessfulUpdateInfoUrl = urlString;
} }
CLogMessage(this).info("Update info loaded from '%1") << urlString; CLogMessage(this).info("Update info loaded from '%1") << urlString;
@@ -465,7 +465,7 @@ namespace BlackCore
{ {
// we downloaded an unparsable JSON file. // we downloaded an unparsable JSON file.
// as we control those files something is wrong // as we control those files something is wrong
const QString errorMsg = QString("Distribution file loaded from '%1' cannot be parsed").arg(urlString); const QString errorMsg = QString("Update info file loaded from '%1' cannot be parsed").arg(urlString);
const CStatusMessage msg = ex.toStatusMessage(this, errorMsg); const CStatusMessage msg = ex.toStatusMessage(this, errorMsg);
CLogMessage::preformatted(msg); CLogMessage::preformatted(msg);
@@ -569,14 +569,14 @@ namespace BlackCore
return !updateInfo.isEmpty(); return !updateInfo.isEmpty();
} }
QDateTime CSetupReader::getDistributionCacheTimestamp() const QDateTime CSetupReader::getUpdateInfoCacheTimestamp() const
{ {
return m_updateInfo.getTimestamp(); return m_updateInfo.getTimestamp();
} }
QString CSetupReader::getLastSuccessfulDistributionUrl() const QString CSetupReader::getLastSuccessfulUpdateInfoUrl() const
{ {
QReadLocker l(&m_lockDistribution); QReadLocker l(&m_lockUpdateInfo);
return m_lastSuccessfulUpdateInfoUrl; return m_lastSuccessfulUpdateInfoUrl;
} }

View File

@@ -33,10 +33,10 @@ namespace BlackMisc { class CLogCategoryList; }
namespace BlackCoreTest { class CTestConnectivity; } namespace BlackCoreTest { class CTestConnectivity; }
namespace BlackCore namespace BlackCore
{ {
//! Read the central URLs / locations of our data / setup. //! Read the central URLs / locations of our data, setup and versions.
//! //!
//! \details This class should be only used in BlackCore::CApplication. It will also trigger reading //! \details This class should be only used in BlackCore::CApplication.
//! update information. //! It will also trigger reading update information.
//! //!
//! \note This class is no(!) BlackCore::CThreadedReader as it will be loaded once during startup //! \note This class is no(!) BlackCore::CThreadedReader as it will be loaded once during startup
//! and reading setup data is fast. The read file is also called "bootstrap" file as it tells //! and reading setup data is fast. The read file is also called "bootstrap" file as it tells
@@ -99,13 +99,13 @@ namespace BlackCore
//! \threadsafe //! \threadsafe
bool hasCachedUpdateInfo() const; bool hasCachedUpdateInfo() const;
//! Distribution cache timestamp //! Update info cache timestamp
//! \threadsafe //! \threadsafe
QDateTime getDistributionCacheTimestamp() const; QDateTime getUpdateInfoCacheTimestamp() const;
//! Last distribution URL successfully read //! Last update info URL successfully read
//! \threadsafe //! \threadsafe
QString getLastSuccessfulDistributionUrl() const; QString getLastSuccessfulUpdateInfoUrl() const;
//! Last setup parsing error messages (if any) //! Last setup parsing error messages (if any)
BlackMisc::CStatusMessageList getLastSetupReadErrorMessages() const; BlackMisc::CStatusMessageList getLastSetupReadErrorMessages() const;
@@ -201,7 +201,7 @@ namespace BlackCore
//! \threadsafe //! \threadsafe
BlackMisc::CStatusMessageList manageSetupAvailability(bool webRead, bool localRead = false); BlackMisc::CStatusMessageList manageSetupAvailability(bool webRead, bool localRead = false);
//! Emit the available signal //! Emit the availability signal
//! \threadsafe //! \threadsafe
void manageUpdateInfoAvailability(bool webRead); void manageUpdateInfoAvailability(bool webRead);