Add support for defaultPackageRoot and servicePrefix to package handling.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=865083
This commit is contained in:
parent
02ba0e68a1
commit
fdfdb97adb
18
package.cpp
18
package.cpp
@ -219,7 +219,8 @@ QStringList Package::listInstalled(const QString& packageRoot) // static
|
||||
}
|
||||
|
||||
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 @@ bool Package::installPackage(const QString& package,
|
||||
|
||||
//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::installPackage(const QString& package,
|
||||
}
|
||||
|
||||
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 @@ bool Package::uninstallPackage(const QString& pluginName,
|
||||
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;
|
||||
|
@ -53,7 +53,7 @@ class PLASMA_EXPORT Package
|
||||
|
||||
/**
|
||||
* Construct a Package object.
|
||||
*
|
||||
*
|
||||
* @arg packagePath full path to the package directory
|
||||
* @arg structure the package structure describing this package
|
||||
*/
|
||||
@ -131,7 +131,8 @@ class PLASMA_EXPORT Package
|
||||
* @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 @@ class PLASMA_EXPORT Package
|
||||
* @return true on successful uninstallation, false otherwise
|
||||
**/
|
||||
static bool uninstallPackage(const QString &package,
|
||||
const QString &packageRoot);
|
||||
const QString &packageRoot,
|
||||
const QString &servicePrefix);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -66,6 +66,8 @@ public:
|
||||
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 @@ PackageStructure::PackageStructure(QObject *parent, const QString &type)
|
||||
{
|
||||
d->type = type;
|
||||
d->contentsPrefix = "contents/";
|
||||
d->packageRoot = "plasma/plasmoids/";
|
||||
d->servicePrefix = "plasma-applet-";
|
||||
}
|
||||
|
||||
PackageStructure::~PackageStructure()
|
||||
@ -327,7 +331,7 @@ void PackageStructure::read(const KConfigBase *config)
|
||||
{
|
||||
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,12 +390,32 @@ void PackageStructure::setContentsPrefix(const QString &prefix)
|
||||
|
||||
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
|
||||
|
@ -185,7 +185,7 @@ public:
|
||||
* 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 @@ public:
|
||||
*/
|
||||
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
|
||||
@ -253,6 +268,11 @@ protected:
|
||||
*/
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user