7#ifndef KPACKAGE_PACKAGE_H
8#define KPACKAGE_PACKAGE_H
10#include <QCryptographicHash>
15#include <KPluginMetaData>
17#include <kpackage/package_export.h>
64class PackageStructure;
74 RootCreationError = KJob::UserDefinedError + 1,
150 QString
filePath(
const QByteArray &key,
const QString &filename = QString())
const;
165 QUrl
fileUrl(
const QByteArray &key,
const QString &filename = QString())
const;
176#if KPACKAGE_ENABLE_DEPRECATED_SINCE(5, 106)
181 KPACKAGE_DEPRECATED_VERSION(5, 106,
"deprecated for lack of usage")
182 QString name(const QByteArray &key) const;
226#if KPACKAGE_ENABLE_DEPRECATED_SINCE(5, 21)
232 KPACKAGE_DEPRECATED_VERSION(5, 21,
"Use Package::cryptographicHash(QCryptographicHash::Algorithm)")
233 QString contentsHash() const;
266 void addFileDefinition(
const QByteArray &key,
const QString &path,
const QString &name = QString());
302 void setMimeTypes(
const QByteArray &key,
const QStringList &mimeTypes);
373 KJob *
install(
const QString &sourcePackage,
const QString &packageRoot = QString());
387 KJob *
update(
const QString &sourcePackage,
const QString &packageRoot = QString());
394 KJob *
uninstall(
const QString &packageName,
const QString &packageRoot);
397 QExplicitlySharedDataPointer<PackagePrivate> d;
398 friend class PackagePrivate;
This class is used to define the filesystem structure of a package type.
Definition packagestructure.h:42
object representing an installed package
Definition package.h:67
void setContentsPrefixPaths(const QStringList &prefixPaths)
Sets the prefixes that all the contents in this package should appear under.
QByteArray cryptographicHash(QCryptographicHash::Algorithm algorithm) const
Package & operator=(const Package &rhs)
Assignment operator.
void addDirectoryDefinition(const QByteArray &key, const QString &path, const QString &name=QString())
Adds a directory to the structure of the package.
void setRequired(const QByteArray &key, bool required)
Sets whether or not a given part of the structure is required or not.
bool hasValidStructure() const
void setMimeTypes(const QByteArray &key, const QStringList &mimeTypes)
Define mimeTypes for a given part of the structure The path must already have been added using addDir...
void setPath(const QString &path)
Sets the path to the root of this package.
QUrl fileUrl(const QByteArray &key, const QString &filename=QString()) const
Get the url to a given file based on the key and an optional filename, is the file:// or qrc:// forma...
Package(PackageStructure *structure=nullptr)
Default constructor.
QString defaultPackageRoot() const
void addFileDefinition(const QByteArray &key, const QString &path, const QString &name=QString())
Adds a file to the structure of the package.
JobError
Error codes for the install/update/remove jobs.
Definition package.h:73
@ PackageMoveError
Failure to move a package from the system temporary folder to its final destination.
Definition package.h:85
@ UnsupportedArchiveFormatError
The archive format of the package is not supported.
Definition package.h:76
@ PackageAlreadyInstalledError
The package is already installed and a normal install (not update) was performed.
Definition package.h:84
@ PluginNameInvalidError
The plugin name contains characters different from letters, digits, dots and underscores.
Definition package.h:80
@ OldVersionRemovalError
Failed to remove the old version of the package during an upgrade.
Definition package.h:82
@ UpdatePackageTypeMismatchError
A package with this plugin name was already installed, but has a different type in the metadata....
Definition package.h:81
@ NewerVersionAlreadyInstalledError
We tried to update, but the same version or a newer one is already installed.
Definition package.h:83
@ MetadataFileMissingError
The package doesn't have a metadata.desktop file.
Definition package.h:78
@ PackageFileNotFoundError
The package file does not exist.
Definition package.h:75
@ PackageCopyError
Failure to copy a package folder from somewhere in the filesystem to its final destination.
Definition package.h:86
@ PackageOpenError
Can't open the package file for reading.
Definition package.h:77
@ PackageUninstallError
Failure to uninstall a package.
Definition package.h:87
@ PluginNameMissingError
The metadata.desktop file doesn't specify a plugin name.
Definition package.h:79
KJob * install(const QString &sourcePackage, const QString &packageRoot=QString())
Installs a package matching this package structure.
QStringList entryList(const QByteArray &key) const
Get the list of files of a given type.
KJob * update(const QString &sourcePackage, const QString &packageRoot=QString())
Updates a package matching this package structure.
QList< QByteArray > requiredDirectories() const
bool isRequired(const QByteArray &key) const
const QString path() const
void setMetadata(const KPluginMetaData &data)
Sets the metadata for the KPackage.
void setDefaultPackageRoot(const QString &packageRoot)
Sets preferred package root.
QString filePath(const QByteArray &key, const QString &filename=QString()) const
Get the path to a given file based on the key and an optional filename.
void setAllowExternalPaths(bool allow)
Sets whether or not external paths/symlinks can be followed by a package.
KPluginMetaData metadata() const
KPackage::Package fallbackPackage() const
void removeDefinition(const QByteArray &key)
Removes a definition from the structure of the package.
KJob * uninstall(const QString &packageName, const QString &packageRoot)
Uninstalls a package matching this package structure.
QStringList contentsPrefixPaths() const
bool allowExternalPaths() const
QList< QByteArray > files() const
Package(const Package &other)
Copy constructor.
void setFallbackPackage(const KPackage::Package &package)
Sets the fallback package root path If a file won't be found in this package, it will search it in th...
QList< QByteArray > directories() const
QList< QByteArray > requiredFiles() const
QStringList mimeTypes(const QByteArray &key) const
void setDefaultMimeTypes(const QStringList &mimeTypes)
Defines the default mimeTypes for any definitions that do not have associated mimeTypes.