Add support for removing packages
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=846532
This commit is contained in:
parent
76d6071e46
commit
c8f517206a
37
package.cpp
37
package.cpp
@ -28,6 +28,7 @@
|
||||
#include <KComponentData>
|
||||
#include <KDesktopFile>
|
||||
#include <KIO/CopyJob>
|
||||
#include <KIO/DeleteJob>
|
||||
#include <KIO/FileCopyJob>
|
||||
#include <KIO/Job>
|
||||
#include <KPluginInfo>
|
||||
@ -332,6 +333,42 @@ bool Package::installPackage(const QString& package,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Package::uninstallPackage(const QString& pluginName,
|
||||
const QString& packageRoot) // static
|
||||
{
|
||||
// We need to remove the package directory and its metadata file.
|
||||
QString targetName = pluginName;
|
||||
targetName = packageRoot + '/' + targetName;
|
||||
|
||||
if (!QFile::exists(targetName)) {
|
||||
kWarning() << targetName << "does not exist";
|
||||
return false;
|
||||
}
|
||||
|
||||
QString serviceName;
|
||||
if (KGlobal::hasMainComponent()) {
|
||||
serviceName = KGlobal::mainComponent().componentName();
|
||||
}
|
||||
serviceName.append("_plasma_applet_" + pluginName);
|
||||
|
||||
QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop");
|
||||
kDebug() << "Removing service file " << service;
|
||||
bool ok = QFile::remove( service );
|
||||
|
||||
if ( !ok ) {
|
||||
kWarning() << "Unable to remove " << service;
|
||||
return ok;
|
||||
}
|
||||
|
||||
KIO::DeleteJob *job = KIO::del( KUrl(targetName) );
|
||||
if (!job->exec()) {
|
||||
kWarning() << "Could not delete package from:" << targetName << " : " << job->errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Package::registerPackage(const PackageMetadata &data, const QString &iconPath)
|
||||
{
|
||||
QString serviceName("plasma-applet-" + data.pluginName());
|
||||
|
12
package.h
12
package.h
@ -131,6 +131,18 @@ class PLASMA_EXPORT Package
|
||||
static bool installPackage(const QString &package,
|
||||
const QString &packageRoot);
|
||||
|
||||
/**
|
||||
* Uninstalls a package.
|
||||
*
|
||||
* @param package path to the Plasmagik package
|
||||
* @param packageRoot path to the directory where the package should be
|
||||
* installed to
|
||||
* @return true on successful uninstallation, false otherwise
|
||||
**/
|
||||
static bool uninstallPackage(const QString &package,
|
||||
const QString &packageRoot);
|
||||
|
||||
|
||||
/**
|
||||
* Registers a package described by the given desktop file
|
||||
*
|
||||
|
@ -391,8 +391,7 @@ bool PackageStructure::installPackage(const QString &package, const QString &pac
|
||||
|
||||
bool PackageStructure::uninstallPackage(const QString &packageName, const QString &packageRoot)
|
||||
{
|
||||
//TODO: implement
|
||||
return false;
|
||||
return Package::uninstallPackage(packageName, packageRoot);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
Loading…
Reference in New Issue
Block a user