Allow package deinstallation from package file

Uninstall previously only took plugin names. This is unfortunate, since
it made uninstallation from a package file impossible, leaving it to the
user to figure out the plugin name before a package can be uninstalled.

So let's read the plugin name from the zip prior to uninstalling.
This commit is contained in:
Sebastian Kügler 2014-02-02 02:33:47 +01:00
parent 9e491920e5
commit 1fedbb587c
2 changed files with 33 additions and 12 deletions

View File

@ -36,7 +36,7 @@ int main(int argc, char **argv)
parser.addVersionOption();
parser.addHelpOption();
parser.setApplicationDescription(description);
parser.addOption(QCommandLineOption(QStringList() << "h" << "hash", i18nc("Do not translate <path>", "Generate a SHA1 hash for the package at <path>"), "path"));
parser.addOption(QCommandLineOption(QStringList() << "hash", i18nc("Do not translate <path>", "Generate a SHA1 hash for the package at <path>"), "path"));
parser.addOption(QCommandLineOption(QStringList() << "g" << "global", i18n("For install or remove, operates on packages installed for all users.")));
parser.addOption(QCommandLineOption(QStringList() << "t" << "type",
i18nc("theme, wallpaper, etc. are keywords, but they may be translated, as both versions "

View File

@ -206,7 +206,7 @@ void PlasmaPkg::runMain()
d->pluginTypes << "Plasma/Wallpaper";
d->packageRoot = "plasma/wallpapers/";
d->servicePrefix = "plasma-wallpaper-";
qDebug() << "service type and root set " << d->servicePrefix << d->packageRoot << d->pluginTypes;
//qDebug() << "service type and root set " << d->servicePrefix << d->packageRoot << d->pluginTypes;
} else if (type.compare(i18nc("package type", "dataengine"), Qt::CaseInsensitive) == 0 ||
type.compare("dataengine", Qt::CaseInsensitive) == 0) {
d->packageRoot = "plasma/dataengines/";
@ -222,7 +222,7 @@ void PlasmaPkg::runMain()
d->packageRoot = "plasma/wallpapers/";
d->servicePrefix = "plasma-wallpaper-";
d->pluginTypes << "Plasma/Wallpaper";
qDebug() << "2service type and root set " << d->servicePrefix << d->packageRoot << d->pluginTypes;
//qDebug() << "2service type and root set " << d->servicePrefix << d->packageRoot << d->pluginTypes;
} else if (type.compare(i18nc("package type", "lookandfeel"), Qt::CaseInsensitive) == 0 ||
type.compare("lookandfeel", Qt::CaseInsensitive) == 0) {
d->packageRoot = "plasma/look-and-feel/";
@ -338,7 +338,21 @@ void PlasmaPkg::runMain()
}
}
QStringList installed = d->packages(d->pluginTypes);
if (installed.contains(pluginName)) {
const QString file = QDir::currentPath() + '/' + pluginName;
if (QFile::exists(d->packageFile)) {
const QString file = QDir::currentPath() + '/' + d->package;
//Plasma::Package *p = d->installer;
d->installer->setPath(d->packageFile);
if (d->installer->isValid()) {
if (d->installer->metadata().isValid()) {
pluginName = d->installer->metadata().property("X-KDE-PluginInfo-Name").toString();
}
}
}
// Uninstalling ...
if (installed.contains(pluginName)) { // Assume it's a plugin name
d->installer->setPath(pluginName);
KJob *uninstallJob = d->installer->uninstall(pluginName, d->packageRoot);
connect(uninstallJob, SIGNAL(result(KJob*)), SLOT(packageUninstalled(KJob*)));
@ -380,7 +394,7 @@ void PlasmaPkgPrivate::runKbuildsycoca()
QStringList PlasmaPkgPrivate::packages(const QStringList& types)
{
QStringList result;
qDebug() << "listing " << types;
//qDebug() << "listing " << types;
foreach (const QString& type, types) {
if (type.compare("Plasma/Generic", Qt::CaseInsensitive) == 0) {
@ -401,13 +415,13 @@ QStringList PlasmaPkgPrivate::packages(const QStringList& types)
if (type.compare("Plasma/Theme", Qt::CaseInsensitive) == 0) {
const QStringList &packs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "desktoptheme/", QStandardPaths::LocateDirectory);
foreach (const QString &ppath, packs) {
qDebug() << "THeme path: " << ppath;
//qDebug() << "THeme path: " << ppath;
const QDir cd(ppath);
const QStringList &entries = cd.entryList(QDir::Dirs);
foreach (const QString pack, entries) {
if ((pack != "." && pack != "..") &&
(QFile::exists(ppath+'/'+pack+"/metadata.desktop"))) {
qDebug() << "Theme exists" << pack;
//qDebug() << "Theme exists" << pack;
result << pack;
}
}
@ -434,13 +448,20 @@ QStringList PlasmaPkgPrivate::packages(const QStringList& types)
void PlasmaPkg::showPackageInfo(const QString& pluginName)
{
// qDebug() << "showPackageInfo" << pluginName;
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Applet");
//qDebug() << "showPackageInfo" << pluginName;
QString type = QStringLiteral("Plasma/Applet");
if (!d->pluginTypes.contains(type) && d->pluginTypes.count() > 0) {
type = d->pluginTypes.at(0);
}
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(type);
//QString p = findPackageRoot("org.kde.microblog-qml", "plasma/plasmoids/");
pkg.setDefaultPackageRoot(d->packageRoot);
pkg.setPath(pluginName);
if (QFile::exists(d->packageFile)) {
pkg.setPath(d->packageFile);
} else {
pkg.setPath(pluginName);
}
KPluginInfo i = pkg.metadata();
if (!i.isValid()) {
@ -577,7 +598,7 @@ void PlasmaPkgPrivate::listTypes()
//QString path = structure->defaultPackageRoot();
//QString path = defaultPackageRoot;
plugins.insert(name, QStringList() << plugin);
qDebug() << "KService stuff:" << name << plugin << comment;
//qDebug() << "KService stuff:" << name << plugin << comment;
}
renderTypeTable(plugins);