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 Install;
class Catalog; class Catalog;
class Package;
typedef SGSharedPtr<Catalog> CatalogRef; typedef SGSharedPtr<Catalog> CatalogRef;
typedef SGSharedPtr<Install> InstallRef; typedef SGSharedPtr<Install> InstallRef;
typedef SGSharedPtr<Package> PackageRef;
/** /**
* package delegate is the mechanism to discover progress / completion / * 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 installProgress(InstallRef aInstall, unsigned int aBytes, unsigned int aTotal) = 0;
virtual void finishInstall(InstallRef aInstall, StatusCode aReason) = 0; virtual void finishInstall(InstallRef aInstall, StatusCode aReason) = 0;
virtual void finishUninstall(PackageRef aPackage) {}
/** /**
* Notification when catalogs/packages are added or removed * 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; DelegateVec delegates;
SGPath path; SGPath path;
@ -652,6 +658,7 @@ void Root::unregisterInstall(InstallRef ins)
} }
d->m_installs.erase(ins->package()); d->m_installs.erase(ins->package());
d->fireFinishUninstall(ins->package());
} }
} // of namespace pkg } // of namespace pkg