Packages: notify delegate of uninstalls.

This commit is contained in:
James Turner 2016-11-06 21:58:01 +01:00
parent 2dcff4bb8e
commit 5cd250e452
2 changed files with 11 additions and 0 deletions

View File

@ -29,9 +29,11 @@ namespace pkg
class Install;
class Catalog;
class Package;
typedef SGSharedPtr<Catalog> CatalogRef;
typedef SGSharedPtr<Install> InstallRef;
typedef SGSharedPtr<Package> PackageRef;
/**
* package delegate is the mechanism to discover progress / completion /
@ -68,6 +70,8 @@ public:
virtual void installProgress(InstallRef aInstall, unsigned int aBytes, unsigned int aTotal) = 0;
virtual void finishInstall(InstallRef aInstall, StatusCode aReason) = 0;
virtual void finishUninstall(PackageRef aPackage) {}
/**
* Notification when catalogs/packages are added or removed
*/

View File

@ -153,6 +153,12 @@ public:
}
}
void fireFinishUninstall(PackageRef pkg)
{
std::for_each(delegates.begin(), delegates.end(),
[pkg](Delegate* d) {d->finishUninstall(pkg);});
}
DelegateVec delegates;
SGPath path;
@ -652,6 +658,7 @@ void Root::unregisterInstall(InstallRef ins)
}
d->m_installs.erase(ins->package());
d->fireFinishUninstall(ins->package());
}
} // of namespace pkg