File indexing completed on 2023-10-01 04:11:44
0001 /* 0002 SPDX-FileCopyrightText: 2011 Aaron Seigo <aseigo@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef PLASMA_PACKAGESTRUCTURE_H 0008 #define PLASMA_PACKAGESTRUCTURE_H 0009 0010 #include <QStringList> 0011 0012 #include <plasma/package.h> 0013 #include <plasma/plasma.h> 0014 #include <plasma/plasma_export.h> 0015 0016 #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) 0017 0018 namespace Plasma 0019 { 0020 class PackageStructurePrivate; 0021 0022 class PLASMA_EXPORT PackageStructure : public QObject 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 PLASMA_DEPRECATED_VERSION(5, 6, "Use KPackage API") 0028 explicit PackageStructure(QObject *parent = nullptr, const QVariantList &args = QVariantList()); 0029 0030 ~PackageStructure() override; 0031 0032 /** 0033 * Called when a the PackageStructure should initialize a Package with the initial 0034 * structure. This allows setting paths before setPath is called. 0035 * 0036 * Note: one special value is "metadata" which can be set to the location of KPluginInfo 0037 * compatible .desktop file within the package. If not defined, it is assumed that this file 0038 * exists under the top level directory of the package. 0039 * 0040 * @param package the Package to set up. The object is empty of all definition when 0041 * first passed in. 0042 */ 0043 virtual void initPackage(Package *package); 0044 0045 /** 0046 * Called whenever the path changes so that subclasses may take 0047 * package specific actions. 0048 */ 0049 virtual void pathChanged(Package *package); 0050 0051 /** 0052 * Installs a package matching this package structure. By default installs a 0053 * native Plasma::Package. 0054 * 0055 * @param package the instance of Package that is being used for the install; useful for 0056 * accessing file paths 0057 * @param archivePath path to the package archive file 0058 * @param packageRoot path to the directory where the package should be 0059 * installed to 0060 * @return KJob* to track the installation status 0061 **/ 0062 virtual KJob *install(Package *package, const QString &archivePath, const QString &packageRoot); 0063 0064 /** 0065 * Uninstalls a package matching this package structure. 0066 * 0067 * @param package the instance of Package that is being used for the install; useful for 0068 * accessing file paths 0069 * @param packageName the name of the package to remove 0070 * @param packageRoot path to the directory where the package should be installed to 0071 * @return KJob* to track the installation status 0072 */ 0073 virtual KJob *uninstall(Package *package, const QString &packageRoot); 0074 0075 private: 0076 PackageStructurePrivate *d; 0077 friend class Package; 0078 friend class PluginLoader; 0079 friend class PackageStructurePrivate; 0080 0081 Q_PRIVATE_SLOT(d, void installPathChanged(const QString &path)) 0082 }; 0083 0084 } // Plasma namespace 0085 0086 /** 0087 * Register a Package class when it is contained in a loadable module 0088 */ 0089 /* clang-format off */ 0090 #define K_EXPORT_PLASMA_PACKAGE(libname, classname) \ 0091 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) 0092 0093 #define K_EXPORT_PLASMA_PACKAGE_WITH_JSON(classname, jsonFile) \ 0094 K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) 0095 /* clang-format on */ 0096 0097 #endif // PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) 0098 0099 #endif