KPackage 5.109.0
Public Member Functions | List of all members
KPackage::PackageStructure

This class is used to define the filesystem structure of a package type. More...

#include <KPackage/PackageStructure>

Public Member Functions

 PackageStructure (QObject *parent=nullptr, const QVariantList &args=QVariantList())
 
virtual void initPackage (Package *package)
 Called when a the PackageStructure should initialize a Package with the initial structure.
 
virtual KJob * install (Package *package, const QString &archivePath, const QString &packageRoot)
 Installs a package matching this package structure.
 
virtual void pathChanged (Package *package)
 Called whenever the path changes so that subclasses may take package specific actions.
 
virtual KJob * uninstall (Package *package, const QString &packageRoot)
 Uninstalls a package matching this package structure.
 
virtual KJob * update (Package *package, const QString &archivePath, const QString &packageRoot)
 Updates a package matching this package structure.
 

Detailed Description

This class is used to define the filesystem structure of a package type.

A PackageStructure is implemented as a dynamically loaded plugin, in the reimplementation of initPackage the allowed fines and directories in the package are set into the package, for instance:

package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File"));
package->setDefaultPackageRoot(QStringLiteral("plasma/wallpapers/"));
package->addDirectoryDefinition("images", QStringLiteral("images"), i18n("Images"));
package->addDirectoryDefinition("theme", QStringLiteral("theme"), i18n("Themed Images"));
QStringList mimetypes;
mimetypes << QStringLiteral("image/svg+xml") << QStringLiteral("image/png") << QStringLiteral("image/jpeg");
package->setMimeTypes("images", mimetypes);
Author
Aaron Seigo

Member Function Documentation

◆ initPackage()

virtual void KPackage::PackageStructure::initPackage ( Package package)
virtual

Called when a the PackageStructure should initialize a Package with the initial structure.

This allows setting paths before setPath is called.

Note: one special value is "metadata" which can be set to the location of KPluginMetaData compatible .desktop file within the package. If not defined, it is assumed that this file exists under the top level directory of the package.

Parameters
packagethe Package to set up. The object is empty of all definition when first passed in.

◆ install()

virtual KJob * KPackage::PackageStructure::install ( Package package,
const QString &  archivePath,
const QString &  packageRoot 
)
virtual

Installs a package matching this package structure.

By default installs a native KPackage::Package.

Parameters
packagethe instance of Package that is being used for the install; useful for accessing file paths
archivePathpath to the package archive file
packageRootpath to the directory where the package should be installed to
Returns
KJob* to track the installation status

◆ pathChanged()

virtual void KPackage::PackageStructure::pathChanged ( Package package)
virtual

Called whenever the path changes so that subclasses may take package specific actions.

◆ uninstall()

virtual KJob * KPackage::PackageStructure::uninstall ( Package package,
const QString &  packageRoot 
)
virtual

Uninstalls a package matching this package structure.

Parameters
packagethe instance of Package that is being used for the install; useful for accessing file paths
packageNamethe name of the package to remove
packageRootpath to the directory where the package should be installed to
Returns
KJob* to track the installation status

◆ update()

virtual KJob * KPackage::PackageStructure::update ( Package package,
const QString &  archivePath,
const QString &  packageRoot 
)
virtual

Updates a package matching this package structure.

By default installs a native KPackage::Package. If an older version is already installed, it removes the old one. If the installed one is newer, an error will occur.

Parameters
packagethe instance of Package that is being used for the install; useful for accessing file paths
archivePathpath to the package archive file
packageRootpath to the directory where the package should be installed to
Returns
KJob* to track the installation status
Since
5.17