{
// refreshing
m_owner->changeStatus(Delegate::STATUS_IN_PROGRESS);
- SG_LOG(SG_GENERAL, SG_WARN, "downloading " << aUrl);
}
protected:
{
CatalogRef c = new Catalog(aRoot);
c->m_url = aUrl;
- Downloader* dl = new Downloader(c, aUrl);
- aRoot->makeHTTPRequest(dl);
-
+ c->refresh();
return c;
}
CatalogRef c = new Catalog(aRoot);
c->m_installRoot = aPath;
- c->parseProps(props); // will set status
+ c->parseProps(props);
c->parseTimestamp();
+ // parsed XML ok, mark status as valid
+ c->changeStatus(Delegate::STATUS_SUCCESS);
+
return c;
}
void Catalog::refresh()
{
+ if (m_refreshRequest.valid()) {
+ // refresh in progress
+ return;
+ }
+
Downloader* dl = new Downloader(this, url());
+ m_refreshRequest = dl;
// will update status to IN_PROGRESS
m_root->makeHTTPRequest(dl);
}
Dir d(m_installRoot);
d.create(0755);
}
-
- // parsed XML ok, mark status as valid
- changeStatus(Delegate::STATUS_SUCCESS);
}
PackageRef Catalog::getPackageById(const std::string& aId) const
void Catalog::refreshComplete(Delegate::StatusCode aReason)
{
- m_root->catalogRefreshStatus(this, aReason);
changeStatus(aReason);
+ m_refreshRequest.reset();
}
void Catalog::changeStatus(Delegate::StatusCode newStatus)
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/structure/function_list.hxx>
+#include <simgear/io/HTTPRequest.hxx>
#include <simgear/package/Delegate.hxx>
SGPath m_installRoot;
std::string m_url;
Delegate::StatusCode m_status;
+ HTTP::Request_ptr m_refreshRequest;
PackageList m_packages;
time_t m_retrievedTime;
Delegate::StatusCode status, const std::string& bytes)
{
std::string u(request->url());
- SG_LOG(SG_IO, SG_INFO, "downloaded thumbnail:" << u);
if (status == Delegate::STATUS_SUCCESS) {
thumbnailCache[u] = bytes;
fireDataForThumbnail(u, bytes);