Allows for short-validity catalogs for development use.
return (diff < 0) ? 0 : diff;
}
+bool Catalog::needsRefresh() const
+{
+ unsigned int maxAge = m_props->getIntValue("max-age-sec", m_root->maxAgeSeconds());
+ return (ageInSeconds() > maxAge);
+}
+
std::string Catalog::getLocalisedString(const SGPropertyNode* aRoot, const char* aName) const
{
if (aRoot->hasChild(m_root->getLocale())) {
Package* getPackageById(const std::string& aId) const;
+ /**
+ * test if the catalog data was retrieved longer ago than the
+ * maximum permitted age for this catalog.
+ */
+ bool needsRefresh() const;
+
unsigned int ageInSeconds() const;
/**
return d->path;
}
-void Root::setMaxAgeSeconds(int seconds)
+void Root::setMaxAgeSeconds(unsigned int seconds)
{
d->maxAgeSeconds = seconds;
}
+
+unsigned int Root::maxAgeSeconds() const
+{
+ return d->maxAgeSeconds;
+}
void Root::setHTTPClient(HTTP::Client* aHTTP)
{
{
CatalogDict::iterator it = d->catalogs.begin();
for (; it != d->catalogs.end(); ++it) {
- if (aForce || (it->second->ageInSeconds() > d->maxAgeSeconds)) {
+ if (aForce || it->second->needsRefresh()) {
it->second->refresh();
}
}
CatalogList catalogs() const;
- void setMaxAgeSeconds(int seconds);
-
+ void setMaxAgeSeconds(unsigned int seconds);
+ unsigned int maxAgeSeconds() const;
+
void setHTTPClient(HTTP::Client* aHTTP);
/**