HaikuDepot: Minor optimization.
- PackageAction now stores/returns a type code indicating the embodied action. Adjust PackageActionView accordingly in its comparison of the old/new package action list.
This commit is contained in:
parent
dd9658f010
commit
a5d9833346
@ -16,9 +16,10 @@ using namespace BPackageKit;
|
||||
// #pragma mark - PackageAction
|
||||
|
||||
|
||||
PackageAction::PackageAction(PackageInfoRef package)
|
||||
PackageAction::PackageAction(int32 type, PackageInfoRef package)
|
||||
:
|
||||
fPackage(package)
|
||||
fPackage(package),
|
||||
fType(type)
|
||||
{
|
||||
// TODO: allow configuring the installation location
|
||||
fPackageManager = new(std::nothrow) PackageManager(
|
||||
|
@ -14,12 +14,22 @@
|
||||
|
||||
class PackageManager;
|
||||
|
||||
enum {
|
||||
PACKAGE_ACTION_INSTALL = 0,
|
||||
PACKAGE_ACTION_UNINSTALL,
|
||||
PACKAGE_ACTION_MAX
|
||||
};
|
||||
|
||||
|
||||
class PackageAction : public BReferenceable {
|
||||
public:
|
||||
PackageAction(PackageInfoRef package);
|
||||
PackageAction(int32 type,
|
||||
PackageInfoRef package);
|
||||
virtual ~PackageAction();
|
||||
|
||||
int32 Type() const
|
||||
{ return fType; }
|
||||
|
||||
virtual const char* Label() const = 0;
|
||||
|
||||
virtual status_t Perform() = 0;
|
||||
@ -32,6 +42,7 @@ protected:
|
||||
|
||||
private:
|
||||
PackageInfoRef fPackage;
|
||||
int32 fType;
|
||||
};
|
||||
|
||||
|
||||
|
@ -547,8 +547,8 @@ public:
|
||||
clearNeeded = true;
|
||||
else {
|
||||
for (int32 i = 0; i < actions.CountItems(); i++) {
|
||||
if (strcasecmp(actions.ItemAtFast(i)->Label(),
|
||||
fPackageActions.ItemAtFast(i)->Label()) != 0) {
|
||||
if (actions.ItemAtFast(i)->Type()
|
||||
!= fPackageActions.ItemAtFast(i)->Type()) {
|
||||
clearNeeded = true;
|
||||
break;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class InstallPackageAction : public PackageAction {
|
||||
public:
|
||||
InstallPackageAction(PackageInfoRef package)
|
||||
:
|
||||
PackageAction(package)
|
||||
PackageAction(PACKAGE_ACTION_INSTALL, package)
|
||||
{
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ class UninstallPackageAction : public PackageAction {
|
||||
public:
|
||||
UninstallPackageAction(PackageInfoRef package)
|
||||
:
|
||||
PackageAction(package)
|
||||
PackageAction(PACKAGE_ACTION_UNINSTALL, package)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user