Logo Search packages:      
Sourcecode: qapt version File versions  Download package

int QApt::Package::state (  )  const

Member function that returns the state of a package, using the PackageState enum to define states.

Returns:
The PackageState flags of the package as an int

Definition at line 528 of file package.cpp.

References Held, InstallBroken, Installed, InstallPolicyBroken, IsAuto, IsGarbage, IsImportant, NewInstall, NotDownloadable, NotInstalled, NowBroken, NowPolicyBroken, ResidualConfig, ToDowngrade, ToInstall, ToKeep, ToPurge, ToReInstall, ToRemove, ToUpgrade, and Upgradeable.

Referenced by QApt::Backend::commitChanges(), isInstalled(), QApt::Backend::markedPackages(), Package(), QApt::Backend::packageCount(), QApt::Backend::restoreCacheState(), setInstall(), QApt::Backend::upgradeablePackages(), and wouldBreak().

{
    int packageState = 0;

    pkgDepCache::StateCache &stateCache = (*d->depCache)[*d->packageIter];
    pkgCache::VerIterator ver = d->packageIter->CurrentVer();

    if (stateCache.Install()) {
        packageState |= ToInstall;
    }

    if (stateCache.iFlags & pkgDepCache::ReInstall) {
        packageState |= ToReInstall;
    } else if (stateCache.NewInstall()) { // Order matters here.
        packageState |= NewInstall;
    } else if (stateCache.Upgrade()) {
        packageState |= ToUpgrade;
    } else if (stateCache.Downgrade()) {
        packageState |= ToDowngrade;
    } else if (stateCache.Delete()) {
        packageState |= ToRemove;
        if (stateCache.iFlags & pkgDepCache::Purge) {
            packageState |= ToPurge;
        }
    } else if (stateCache.Keep()) {
        packageState |= ToKeep;
    }

    if (!ver.end()) {
        packageState |= Installed;

        if (stateCache.CandidateVer != NULL && stateCache.Upgradable()) {
            packageState |= Upgradeable;
            if (stateCache.Keep()) {
                packageState |= Held;
            }
      }

        if (stateCache.Downgrade()) {
            packageState |= ToDowngrade;
        }
    } else {
        packageState |= NotInstalled;
    }
    if (stateCache.NowBroken()) {
        packageState |= NowBroken;
    }

    if (stateCache.InstBroken()) {
        packageState |= InstallBroken;
    }

    if ((*d->packageIter)->Flags & (pkgCache::Flag::Important |
                              pkgCache::Flag::Essential)) {
        packageState |= IsImportant;
    }

    if ((*d->packageIter)->CurrentState == pkgCache::State::ConfigFiles) {
        packageState |= ResidualConfig;
    }

    if (stateCache.CandidateVer == 0) {
        packageState |= NotDownloadable;
    } else if (!stateCache.CandidateVerIter(*d->depCache).Downloadable()) {
        packageState |= NotDownloadable;
    }

    if (stateCache.Flags & pkgCache::Flag::Auto) {
        packageState |= IsAuto;
    }

    if (stateCache.Garbage) {
        packageState |= IsGarbage;
    }

    if (stateCache.NowPolicyBroken()) {
        packageState |= NowPolicyBroken;
    }

    if (stateCache.InstPolicyBroken()) {
        packageState |= InstallPolicyBroken;
    }

   return packageState | d->state;
}


Generated by  Doxygen 1.6.0   Back to index