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,
|
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
|
//TODO: report *what* failed if something does fail
|
||||||
QDir root(packageRoot);
|
QDir root(packageRoot);
|
||||||
@ -332,11 +333,7 @@ bool Package::installPackage(const QString& package,
|
|||||||
|
|
||||||
//TODO: reduce code duplication with registerPackage below
|
//TODO: reduce code duplication with registerPackage below
|
||||||
|
|
||||||
QString serviceName;
|
QString serviceName = servicePrefix + meta.pluginName();
|
||||||
if (KGlobal::hasMainComponent()) {
|
|
||||||
serviceName = KGlobal::mainComponent().componentName();
|
|
||||||
}
|
|
||||||
serviceName.append("_plasma_applet_" + meta.pluginName());
|
|
||||||
|
|
||||||
QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop");
|
QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop");
|
||||||
KIO::FileCopyJob *job = KIO::file_copy(metaPath, service, -1, KIO::HideProgressInfo);
|
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,
|
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.
|
// We need to remove the package directory and its metadata file.
|
||||||
QString targetName = pluginName;
|
QString targetName = pluginName;
|
||||||
@ -367,11 +365,7 @@ bool Package::uninstallPackage(const QString& pluginName,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString serviceName;
|
QString serviceName = servicePrefix + pluginName;
|
||||||
if (KGlobal::hasMainComponent()) {
|
|
||||||
serviceName = KGlobal::mainComponent().componentName();
|
|
||||||
}
|
|
||||||
serviceName.append("_plasma_applet_" + pluginName);
|
|
||||||
|
|
||||||
QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop");
|
QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop");
|
||||||
kDebug() << "Removing service file " << service;
|
kDebug() << "Removing service file " << service;
|
||||||
|
@ -53,7 +53,7 @@ class PLASMA_EXPORT Package
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a Package object.
|
* Construct a Package object.
|
||||||
*
|
*
|
||||||
* @arg packagePath full path to the package directory
|
* @arg packagePath full path to the package directory
|
||||||
* @arg structure the package structure describing this package
|
* @arg structure the package structure describing this package
|
||||||
*/
|
*/
|
||||||
@ -131,7 +131,8 @@ class PLASMA_EXPORT Package
|
|||||||
* @return true on successful installation, false otherwise
|
* @return true on successful installation, false otherwise
|
||||||
**/
|
**/
|
||||||
static bool installPackage(const QString &package,
|
static bool installPackage(const QString &package,
|
||||||
const QString &packageRoot);
|
const QString &packageRoot,
|
||||||
|
const QString &servicePrefix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninstalls a package.
|
* Uninstalls a package.
|
||||||
@ -142,7 +143,8 @@ class PLASMA_EXPORT Package
|
|||||||
* @return true on successful uninstallation, false otherwise
|
* @return true on successful uninstallation, false otherwise
|
||||||
**/
|
**/
|
||||||
static bool uninstallPackage(const QString &package,
|
static bool uninstallPackage(const QString &package,
|
||||||
const QString &packageRoot);
|
const QString &packageRoot,
|
||||||
|
const QString &servicePrefix);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,6 +66,8 @@ public:
|
|||||||
QString type;
|
QString type;
|
||||||
QString path;
|
QString path;
|
||||||
QString contentsPrefix;
|
QString contentsPrefix;
|
||||||
|
QString packageRoot;
|
||||||
|
QString servicePrefix;
|
||||||
QMap<QByteArray, ContentStructure> contents;
|
QMap<QByteArray, ContentStructure> contents;
|
||||||
QStringList mimetypes;
|
QStringList mimetypes;
|
||||||
static QHash<QString, PackageStructure::Ptr> structures;
|
static QHash<QString, PackageStructure::Ptr> structures;
|
||||||
@ -79,6 +81,8 @@ PackageStructure::PackageStructure(QObject *parent, const QString &type)
|
|||||||
{
|
{
|
||||||
d->type = type;
|
d->type = type;
|
||||||
d->contentsPrefix = "contents/";
|
d->contentsPrefix = "contents/";
|
||||||
|
d->packageRoot = "plasma/plasmoids/";
|
||||||
|
d->servicePrefix = "plasma-applet-";
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageStructure::~PackageStructure()
|
PackageStructure::~PackageStructure()
|
||||||
@ -327,7 +331,7 @@ void PackageStructure::read(const KConfigBase *config)
|
|||||||
{
|
{
|
||||||
d->contents.clear();
|
d->contents.clear();
|
||||||
d->mimetypes.clear();
|
d->mimetypes.clear();
|
||||||
d->type = config->group("").readEntry("Type", QString());
|
d->type = config->group("").readEntry("Type", QString());
|
||||||
|
|
||||||
QStringList groups = config->groupList();
|
QStringList groups = config->groupList();
|
||||||
foreach (const QString &group, groups) {
|
foreach (const QString &group, groups) {
|
||||||
@ -386,12 +390,32 @@ void PackageStructure::setContentsPrefix(const QString &prefix)
|
|||||||
|
|
||||||
bool PackageStructure::installPackage(const QString &package, const QString &packageRoot)
|
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)
|
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
|
} // Plasma namespace
|
||||||
|
@ -185,7 +185,7 @@ public:
|
|||||||
* Define mimetypes for a given part of the structure
|
* Define mimetypes for a given part of the structure
|
||||||
* The path must already have been added using addDirectoryDefinition
|
* The path must already have been added using addDirectoryDefinition
|
||||||
* or addFileDefinition.
|
* or addFileDefinition.
|
||||||
*
|
*
|
||||||
* @param path the path of the entry within the package
|
* @param path the path of the entry within the package
|
||||||
* @param mimetypes a list of mimetypes
|
* @param mimetypes a list of mimetypes
|
||||||
**/
|
**/
|
||||||
@ -242,6 +242,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
QString contentsPrefix() const;
|
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:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Sets the prefix that all the contents in this package should
|
* Sets the prefix that all the contents in this package should
|
||||||
@ -253,6 +268,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void setContentsPrefix(const QString &prefix);
|
void setContentsPrefix(const QString &prefix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets preferred package root.
|
||||||
|
*/
|
||||||
|
void setDefaultPackageRoot(const QString &packageRoot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called whenever the path changes so that subclasses may take
|
* Called whenever the path changes so that subclasses may take
|
||||||
* package specific actions.
|
* package specific actions.
|
||||||
|
Loading…
Reference in New Issue
Block a user