hi, This patch enables custom packages to use default install function by adding defaultPackageRoot and servicePrefix to package handling.
Petri
Index: libs/plasma/package.h =================================================================== --- libs/plasma/package.h (revision 865053) +++ libs/plasma/package.h (working copy) @@ -53,7 +53,7 @@ /** * Construct a Package object. - * + * * @arg packagePath full path to the package directory * @arg structure the package structure describing this package */ @@ -131,7 +131,8 @@ * @return true on successful installation, false otherwise **/ static bool installPackage(const QString &package, - const QString &packageRoot); + const QString &packageRoot, + const QString &servicePrefix); /** * Uninstalls a package. @@ -142,7 +143,8 @@ * @return true on successful uninstallation, false otherwise **/ static bool uninstallPackage(const QString &package, - const QString &packageRoot); + const QString &packageRoot, + const QString &servicePrefix); /** Index: libs/plasma/package.cpp =================================================================== --- libs/plasma/package.cpp (revision 865053) +++ libs/plasma/package.cpp (working copy) @@ -219,7 +219,8 @@ } bool Package::installPackage(const QString& package, - const QString& packageRoot) // static + const QString& packageRoot, + const QString& servicePrefix) // static { //TODO: report *what* failed if something does fail QDir root(packageRoot); @@ -332,11 +333,7 @@ //TODO: reduce code duplication with registerPackage below - QString serviceName; - if (KGlobal::hasMainComponent()) { - serviceName = KGlobal::mainComponent().componentName(); - } - serviceName.append("_plasma_applet_" + meta.pluginName()); + QString serviceName = servicePrefix + meta.pluginName(); QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop"); KIO::FileCopyJob *job = KIO::file_copy(metaPath, service, -1, KIO::HideProgressInfo); @@ -356,7 +353,8 @@ } bool Package::uninstallPackage(const QString& pluginName, - const QString& packageRoot) // static + const QString& packageRoot, + const QString& servicePrefix) // static { // We need to remove the package directory and its metadata file. QString targetName = pluginName; @@ -367,11 +365,7 @@ return false; } - QString serviceName; - if (KGlobal::hasMainComponent()) { - serviceName = KGlobal::mainComponent().componentName(); - } - serviceName.append("_plasma_applet_" + pluginName); + QString serviceName = servicePrefix + pluginName; QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop"); kDebug() << "Removing service file " << service; Index: libs/plasma/packagestructure.cpp =================================================================== --- libs/plasma/packagestructure.cpp (revision 865053) +++ libs/plasma/packagestructure.cpp (working copy) @@ -66,6 +66,8 @@ QString type; QString path; QString contentsPrefix; + QString packageRoot; + QString servicePrefix; QMap<QByteArray, ContentStructure> contents; QStringList mimetypes; static QHash<QString, PackageStructure::Ptr> structures; @@ -79,6 +81,8 @@ { d->type = type; d->contentsPrefix = "contents/"; + d->packageRoot = "plasma/plasmoids/"; + d->servicePrefix = "plasma-applet-"; } PackageStructure::~PackageStructure() @@ -327,7 +331,7 @@ { d->contents.clear(); d->mimetypes.clear(); - d->type = config->group("").readEntry("Type", QString()); + d->type = config->group("").readEntry("Type", QString()); QStringList groups = config->groupList(); foreach (const QString &group, groups) { @@ -386,14 +390,34 @@ bool PackageStructure::installPackage(const QString &package, const QString &packageRoot) { - return Package::installPackage(package, packageRoot); + return Package::installPackage(package, packageRoot, d->servicePrefix); } bool PackageStructure::uninstallPackage(const QString &packageName, const QString &packageRoot) { - return Package::uninstallPackage(packageName, packageRoot); + return Package::uninstallPackage(packageName, packageRoot, d->servicePrefix); } +QString PackageStructure::defaultPackageRoot() const +{ + return d->packageRoot; +} + +QString PackageStructure::servicePrefix() const +{ + return d->servicePrefix; +} + +void PackageStructure::setDefaultPackageRoot(const QString &packageRoot) +{ + d->packageRoot = packageRoot; +} + +void PackageStructure::setServicePrefix(const QString &servicePrefix) +{ + d->servicePrefix = servicePrefix; +} + } // Plasma namespace #include "packagestructure.moc" Index: libs/plasma/packagestructure.h =================================================================== --- libs/plasma/packagestructure.h (revision 865053) +++ libs/plasma/packagestructure.h (working copy) @@ -185,7 +185,7 @@ * Define mimetypes for a given part of the structure * The path must already have been added using addDirectoryDefinition * or addFileDefinition. - * + * * @param path the path of the entry within the package * @param mimetypes a list of mimetypes **/ @@ -242,6 +242,21 @@ */ QString contentsPrefix() const; + /** + * @return preferred package root. This defaults to plasma/plasmoids/ + */ + QString defaultPackageRoot() const; + + /** + * @return service prefix used in desktop files. This defaults to plasma-applet- + */ + QString servicePrefix() const; + + /** + * Sets service prefix. + */ + void setServicePrefix(const QString &servicePrefix); + protected: /** * Sets the prefix that all the contents in this package should @@ -254,6 +269,11 @@ void setContentsPrefix(const QString &prefix); /** + * Sets preferred package root. + */ + void setDefaultPackageRoot(const QString &packageRoot); + + /** * Called whenever the path changes so that subclasses may take * package specific actions. */ Index: plasma/tools/plasmapkg/main.cpp =================================================================== --- plasma/tools/plasmapkg/main.cpp (revision 865053) +++ plasma/tools/plasmapkg/main.cpp (working copy) @@ -96,17 +96,17 @@ Plasma::PackageStructure *installer = new Plasma::PackageStructure(); if (type == i18n("plasmoid") || type == "plasmoid") { packageRoot = "plasma/plasmoids/"; - servicePrefix = "plasma-applet-"; + installer->setServicePrefix("plasma-applet-"); } else if (type == i18n("theme") || type == "theme") { packageRoot = "desktoptheme/"; } else if (type == i18n("wallpaper") || type == "wallpaper") { packageRoot = "wallpapers/"; } else if (type == i18n("dataengine") || type == "dataengine") { packageRoot = "plasma/dataengines/"; - servicePrefix = "plasma-dataengine-"; + installer->setServicePrefix("plasma-dataengine-"); } else if (type == i18n("runner") || type == "runner") { packageRoot = "plasma/runners/"; - servicePrefix = "plasma-abstractrunner-"; + installer->setServicePrefix("plasma-runner-"); } else { // support for non-native widget packages delete installer; @@ -128,8 +128,7 @@ type, error)); return 1; } - - packageRoot = "plasma/plasmoids"; + packageRoot = installer->defaultPackageRoot(); } if (args->isSet("packageroot")) {
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel