LocalPackageHub Class | Qt Installer Framework Manual

Qt Installer Framework Manual | LocalPackageHub

# LocalPackageHub Class

(KDUpdater::LocalPackageHub)

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

Header: | #include <LocalPackageHub>

- List of all members, including inherited members

## Public Types

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

## Public Functions

| LocalPackageHub()
| ~LocalPackageHub()
void | addPackage(const QString &name, const QString &version, const QString &title, const QString &description, const QStringList &dependencies, const QStringList &autoDependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, bool checkable)
QString | applicationName() const
QString | applicationVersion() const
void | clearPackageInfos()
Error | error() const
QString | errorString() const
QString | fileName() const
bool | isValid() const
LocalPackage | packageInfo(const QString &pkgName) const
int | packageInfoCount() const
QList<LocalPackage> | packageInfos() const
QStringList | packageNames() const
void | refresh()
bool | removePackage(const QString &name)
void | setApplicationName(const QString &name)
void | setApplicationVersion(const QString &version)
void | setFileName(const QString &fileName)
void | writeToDisk()

## Detailed Description

The LocalPackageHub 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.

## Member Type Documentation

### enum LocalPackageHub::Error

Error codes related to retrieving information about installed packages:

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

## Member Function Documentation

### LocalPackageHub::LocalPackageHub()

Constructs a local package hub. To fully setup the class you have to call setFileName().

See also setFileName.

### LocalPackageHub::~LocalPackageHub()

Destructor

### void LocalPackageHub::addPackage(const QString &name, const QString &version, const QString &title, const QString &description, const QStringList &dependencies, const QStringList &autoDependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, bool checkable)

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

### QString LocalPackageHub::applicationName() const

Returns the application name.

See also setApplicationName().

### QString LocalPackageHub::applicationVersion() const

Returns the application version.

See also setApplicationVersion().

### void LocalPackageHub::clearPackageInfos()

Clears the installed package list.

### Error LocalPackageHub::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 LocalPackageHub::errorString() const

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

### QString LocalPackageHub::fileName() const

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

See also setFileName().

### bool LocalPackageHub::isValid() const

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

### LocalPackage LocalPackageHub::packageInfo(const QString &pkgName) const

Returns the package info structure whose name is pkgName. If no such package was found, this function returns a default-constructed value.

### int LocalPackageHub::packageInfoCount() const

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

### QList<LocalPackage> LocalPackageHub::packageInfos() const

Returns all package info structures.

### QStringList LocalPackageHub::packageNames() const

Returns a list of all local installed packages.

### void LocalPackageHub::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 LocalPackageHub::removePackage(const QString &name)

Removes the package specified by name. Returns `false` if the package is not found.

### void LocalPackageHub::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 LocalPackageHub::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 LocalPackageHub::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().

### void LocalPackageHub::writeToDisk()

Writes the installation information file to disk.