virtual void installProgress(InstallRef aInstall, unsigned int aBytes, unsigned int aTotal) = 0;
virtual void finishInstall(InstallRef aInstall, StatusCode aReason) = 0;
+ /**
+ * Notification when catalogs/packages are added or removed
+ */
+ virtual void availablePackagesChanged() {}
+
virtual void dataForThumbnail(const std::string& aThumbnailUrl,
- size_t lenth, const uint8_t* bytes)
- {}
+ size_t lenth, const uint8_t* bytes) {}
};
} // of namespace pkg
(*it)->catalogRefreshed(catalog, status);
}
}
-
-
+
+ void firePackagesChanged()
+ {
+ DelegateVec::const_iterator it;
+ for (it = delegates.begin(); it != delegates.end(); ++it) {
+ (*it)->availablePackagesChanged();
+ }
+ }
+
void thumbnailDownloadComplete(HTTP::Request_ptr request,
Delegate::StatusCode status, const std::string& bytes)
{
if (aReason == Delegate::STATUS_IN_PROGRESS) {
d->refreshing.insert(aCat);
-
- if (catIt == d->catalogs.end()) {
- // first fresh, add to our storage now
- d->catalogs.insert(catIt, CatalogDict::value_type(aCat->id(), aCat));
- }
} else {
d->refreshing.erase(aCat);
}
-
+
if ((aReason != Delegate::STATUS_REFRESHED) && (aReason != Delegate::STATUS_IN_PROGRESS)) {
// if the failure is permanent, delete the catalog from our
// list (don't touch it on disk)
}
}
}
-
+
+ if ((aReason == Delegate::STATUS_REFRESHED) && (catIt == d->catalogs.end())) {
+ assert(!aCat->id().empty());
+ d->catalogs.insert(catIt, CatalogDict::value_type(aCat->id(), aCat));
+ }
+
if (d->refreshing.empty()) {
d->fireRefreshStatus(CatalogRef(), Delegate::STATUS_REFRESHED);
+ d->firePackagesChanged();
}
}
SG_LOG(SG_GENERAL, SG_WARN, "removeCatalogById: unknown ID:" << aId);
return false;
}
-
+
CatalogRef cat = catIt->second;
-
+
// drop the reference
d->catalogs.erase(catIt);
-
+
bool ok = cat->uninstall();
if (!ok) {
SG_LOG(SG_GENERAL, SG_WARN, "removeCatalogById: catalog :" << aId
<< "failed to uninstall");
}
-
+
+ // notify that a catalog is being removed
+ d->firePackagesChanged();
+
return ok;
}
-
+
void Root::requestThumbnailData(const std::string& aUrl)
{
MemThumbnailCache::iterator it = d->thumbnailCache.find(aUrl);