PackagesInfo Class | Qt Installer Framework Manual

Qt Installer Framework Manual | PackagesInfo

# PackagesInfo Class

(KDUpdater::PackagesInfo)

The PackagesInfo class provides access to information about packages installed on the application side. More...

Header: | #include <PackagesInfo>

- List of all members, including inherited members

## Public Types

enum | Error { NoError, NotYetReadError, CouldNotReadPackageFileError, InvalidXmlError, InvalidContentError }

## Public Functions

QString | applicationName() const
QString | applicationVersion() const
void | clearPackageInfoList()
Error | error() const
QString | errorString() const
QString | fileName() const
int | findPackageInfo(const QString &pkgName) const
bool | installPackage(const QString &name, const QString &version, const QString &title = QString(), const QString &description = QString(), const QStringList &dependencies = QStringList(), bool forcedInstallation = false, bool virtualComp = false, quint64 uncompressedSize = 0, const QString &inheritVersionFrom = QString())
bool | isValid() const
PackageInfo | packageInfo(int index) const
int | packageInfoCount() const
QVector<KDUpdater::PackageInfo> | packageInfos() const
bool | removePackage(const QString &name)
void | setApplicationName(const QString &name)
void | setApplicationVersion(const QString &version)
void | setFileName(const QString &fileName)
bool | updatePackage(const QString &name, const QString &version, const QDate &date)
void | writeToDisk()

## Public Slots

void | refresh()

## Signals

void | reset()

## Detailed Description

The PackagesInfo class provides access to information about packages installed on the application side.

This class parses the installation information XML file specified via the setFileName() method and provides access to the information defined within the file through an API. You can:

- Get the application name via the applicationName() method.
- Get the application version via the applicationVersion() method.
- Get information about the number of packages installed and their meta-data via the packageInfoCount() and packageInfo() methods.

Instances of this class cannot be created. Each instance of KDUpdater::Application has one instance of this class associated with it. You can fetch a pointer to an instance of this class for an application via the KDUpdater::Application::packagesInfo() method.

## Member Type Documentation

### enum PackagesInfo::Error

Error codes related to retrieving information about installed packages:

Constant | Value | Description
--- | --- | ---
`KDUpdater::PackagesInfo::NoError` | `0` | No error occurred.
`KDUpdater::PackagesInfo::NotYetReadError` | `1` | The installation information was not parsed yet from the XML file.
`KDUpdater::PackagesInfo::CouldNotReadPackageFileError` | `2` | The specified installation information file could not be read (does not exist or is not readable).
`KDUpdater::PackagesInfo::InvalidXmlError` | `3` | The installation information file contains invalid XML.
`KDUpdater::PackagesInfo::InvalidContentError` | `4` | The installation information file contains valid XML, but does not match the expected format for package descriptions.

## Member Function Documentation

### QString PackagesInfo::applicationName() const

Returns the application name.

See also setApplicationName().

### QString PackagesInfo::applicationVersion() const

Returns the application version.

See also setApplicationVersion().

### void PackagesInfo::clearPackageInfoList()

Clears the installed package list.

### Error PackagesInfo::error() const

Returns the error that was found during the processing of the installation information XML file. If no error was found, returns NoError.

### QString PackagesInfo::errorString() const

Returns a human-readable description of the last error that occurred.

### QString PackagesInfo::fileName() const

Returns the name of the installation information XML file that this class refers to.

See also setFileName().

### int PackagesInfo::findPackageInfo(const QString &pkgName) const

Returns the index of the package whose name is pkgName. If no such package was found, this function returns -1.

### bool PackagesInfo::installPackage(const QString &name, const QString &version, const QString &title = QString(), const QString &description = QString(), const QStringList &dependencies = QStringList(), bool forcedInstallation = false, bool virtualComp = false, quint64 uncompressedSize = 0, const QString &inheritVersionFrom = QString())

Marks the package specified by name as installed. Sets the values of version, title, description, dependencies, forcedInstallation, virtualComp, uncompressedSize, and inheritVersionFrom for the package.

Returns `true` if the installation information was modified.

### bool PackagesInfo::isValid() const

Returns `true` if PackagesInfo is valid; otherwise returns `false`. You can use the errorString() method to receive a descriptive error message.

### PackageInfo PackagesInfo::packageInfo(int index) const

Returns the package info structure at index. If an invalid index is passed, the function returns a default-constructed value.

### int PackagesInfo::packageInfoCount() const

Returns the number of KDUpdater::PackageInfo objects contained in this class.

### QVector<KDUpdater::PackageInfo> PackagesInfo::packageInfos() const

Returns all package info structures.

### `[slot]` void PackagesInfo::refresh()

Re-reads the installation information XML file and updates itself. Changes to applicationName() and applicationVersion() are lost after this function returns. The function emits a reset() signal after completion.

### bool PackagesInfo::removePackage(const QString &name)

Removes the package specified by name.

Returns `false` if the package is not found.

### `[signal]` void PackagesInfo::reset()

This signal is emitted whenever the contents of this class are refreshed, usually from within the refresh() slot.

### void PackagesInfo::setApplicationName(const QString &name)

Sets the application name to name. By default, this is the name specified in the `<ApplicationName>` element of the installation information XML file.

See also applicationName().

### void PackagesInfo::setApplicationVersion(const QString &version)

Sets the application version to version. By default, this is the version specified in the `<ApplicationVersion>` element of the installation information XML file.

See also applicationVersion().

### void PackagesInfo::setFileName(const QString &fileName)

Sets the complete file name of the installation information XML file to fileName. The function also issues a call to refresh() to reload installation information from the XML file.

See also fileName() and KDUpdater::Application::setPackagesXMLFileName().

### bool PackagesInfo::updatePackage(const QString &name, const QString &version, const QDate &date)

Updates the package specified by name and sets its version to version and the last update date to date.

Returns `false` if the package is not found.

### void PackagesInfo::writeToDisk()

Writes the installation information file to disk.