Allow updating a Catalog URL explicitly.

Needed for fallback Catalog URL support.
This commit is contained in:
James Turner 2016-05-25 21:46:16 +01:00
parent 43ebde9914
commit 8211f1c482
2 changed files with 16 additions and 2 deletions

View File

@ -144,7 +144,7 @@ protected:
" to \n\t" << url); " to \n\t" << url);
// update the URL and kick off a new request // update the URL and kick off a new request
m_owner->m_url = url; m_owner->setUrl(url);
Downloader* dl = new Downloader(m_owner, url); Downloader* dl = new Downloader(m_owner, url);
m_owner->root()->makeHTTPRequest(dl); m_owner->root()->makeHTTPRequest(dl);
} else { } else {
@ -437,6 +437,14 @@ std::string Catalog::url() const
return m_url; return m_url;
} }
void Catalog::setUrl(const std::string &url)
{
m_url = url;
if (m_status == Delegate::FAIL_NOT_FOUND) {
m_status = Delegate::FAIL_UNKNOWN;
}
}
std::string Catalog::name() const std::string Catalog::name() const
{ {
return getLocalisedString(m_props, "name"); return getLocalisedString(m_props, "name");
@ -505,8 +513,8 @@ std::string Catalog::getLocalisedString(const SGPropertyNode* aRoot, const char*
void Catalog::refreshComplete(Delegate::StatusCode aReason) void Catalog::refreshComplete(Delegate::StatusCode aReason)
{ {
changeStatus(aReason);
m_refreshRequest.reset(); m_refreshRequest.reset();
changeStatus(aReason);
} }
void Catalog::changeStatus(Delegate::StatusCode newStatus) void Catalog::changeStatus(Delegate::StatusCode newStatus)

View File

@ -106,6 +106,12 @@ public:
std::string url() const; std::string url() const;
/**
* update the URL of a package. Does not trigger a refresh, but resets
* error state if the previous URL was not found.
*/
void setUrl(const std::string& url);
std::string name() const; std::string name() const;
std::string description() const; std::string description() const;