PackagesInfo Class

(KDUpdater::PackagesInfo)

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

Header: #include <PackagesInfo>
Inherits: QObject

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()
  • 31 public functions inherited from QObject

Public Slots

void refresh()
  • 1 public slot inherited from QObject

Signals

void reset()

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

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:

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:

ConstantValueDescription
KDUpdater::PackagesInfo::NoError0No error occurred.
KDUpdater::PackagesInfo::NotYetReadError1The installation information was not parsed yet from the XML file.
KDUpdater::PackagesInfo::CouldNotReadPackageFileError2The specified installation information file could not be read (does not exist or is not readable).
KDUpdater::PackagesInfo::InvalidXmlError3The installation information file contains invalid XML.
KDUpdater::PackagesInfo::InvalidContentError4The 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.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.