* Add Plasma/PluginApplet as another type of plasmoid service
svn path=/trunk/KDE/kdebase/runtime/; revision=1002598
This commit is contained in:
parent
830751924f
commit
b2045f2adc
@ -53,19 +53,21 @@ void runKbuildsycoca()
|
|||||||
dbus.call(QDBus::NoBlock, "recreate");
|
dbus.call(QDBus::NoBlock, "recreate");
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList packages(const QString& type)
|
QStringList packages(const QStringList& types)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
foreach (const QString& type, types) {
|
||||||
KService::List services = KServiceTypeTrader::self()->query("Plasma/" + type);
|
KService::List services = KServiceTypeTrader::self()->query("Plasma/" + type);
|
||||||
foreach(const KService::Ptr &service, services) {
|
foreach(const KService::Ptr &service, services) {
|
||||||
result << service->property("X-KDE-PluginInfo-Name", QVariant::String).toString();
|
result << service->property("X-KDE-PluginInfo-Name", QVariant::String).toString();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void listPackages(const QString& type)
|
void listPackages(const QStringList& types)
|
||||||
{
|
{
|
||||||
QStringList list = packages(type);
|
QStringList list = packages(types);
|
||||||
list.sort();
|
list.sort();
|
||||||
foreach(const QString& package, list) {
|
foreach(const QString& package, list) {
|
||||||
output(package);
|
output(package);
|
||||||
@ -114,13 +116,14 @@ int main(int argc, char **argv)
|
|||||||
const QString type = args->getOption("type").toLower();
|
const QString type = args->getOption("type").toLower();
|
||||||
QString packageRoot = type;
|
QString packageRoot = type;
|
||||||
QString servicePrefix;
|
QString servicePrefix;
|
||||||
QString pluginType;
|
QStringList pluginTypes;
|
||||||
Plasma::PackageStructure *installer = 0;
|
Plasma::PackageStructure *installer = 0;
|
||||||
|
|
||||||
if (type == i18nc("package type", "plasmoid") || type == "plasmoid") {
|
if (type == i18nc("package type", "plasmoid") || type == "plasmoid") {
|
||||||
packageRoot = "plasma/plasmoids/";
|
packageRoot = "plasma/plasmoids/";
|
||||||
servicePrefix = "plasma-applet-";
|
servicePrefix = "plasma-applet-";
|
||||||
pluginType = "Applet";
|
pluginTypes << "Applet";
|
||||||
|
pluginTypes << "PopupApplet";
|
||||||
} else if (type == i18nc("package type", "theme") || type == "theme") {
|
} else if (type == i18nc("package type", "theme") || type == "theme") {
|
||||||
packageRoot = "desktoptheme/";
|
packageRoot = "desktoptheme/";
|
||||||
} else if (type == i18nc("package type", "wallpaper") || type == "wallpaper") {
|
} else if (type == i18nc("package type", "wallpaper") || type == "wallpaper") {
|
||||||
@ -128,11 +131,11 @@ int main(int argc, char **argv)
|
|||||||
} else if (type == i18nc("package type", "dataengine") || type == "dataengine") {
|
} else if (type == i18nc("package type", "dataengine") || type == "dataengine") {
|
||||||
packageRoot = "plasma/dataengines/";
|
packageRoot = "plasma/dataengines/";
|
||||||
servicePrefix = "plasma-dataengine-";
|
servicePrefix = "plasma-dataengine-";
|
||||||
pluginType = "DataEngine";
|
pluginTypes << "DataEngine";
|
||||||
} else if (type == i18nc("package type", "runner") || type == "runner") {
|
} else if (type == i18nc("package type", "runner") || type == "runner") {
|
||||||
packageRoot = "plasma/runners/";
|
packageRoot = "plasma/runners/";
|
||||||
servicePrefix = "plasma-runner-";
|
servicePrefix = "plasma-runner-";
|
||||||
pluginType = "Runner";
|
pluginTypes << "Runner";
|
||||||
} else {
|
} else {
|
||||||
QString constraint = QString("'%1' == [X-KDE-PluginInfo-Name]").arg(packageRoot);
|
QString constraint = QString("'%1' == [X-KDE-PluginInfo-Name]").arg(packageRoot);
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint);
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint);
|
||||||
@ -151,11 +154,11 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
packageRoot = installer->defaultPackageRoot();
|
packageRoot = installer->defaultPackageRoot();
|
||||||
pluginType = installer->type();
|
pluginTypes << installer->type();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->isSet("list")) {
|
if (args->isSet("list")) {
|
||||||
listPackages(pluginType);
|
listPackages(pluginTypes);
|
||||||
} else {
|
} else {
|
||||||
// install, remove or upgrade
|
// install, remove or upgrade
|
||||||
if (!installer) {
|
if (!installer) {
|
||||||
@ -201,7 +204,7 @@ int main(int argc, char **argv)
|
|||||||
pluginName = metadata.pluginName();
|
pluginName = metadata.pluginName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList installed = packages(pluginType);
|
QStringList installed = packages(pluginTypes);
|
||||||
if (installed.contains(pluginName)) {
|
if (installed.contains(pluginName)) {
|
||||||
if (installer->uninstallPackage(pluginName, packageRoot)) {
|
if (installer->uninstallPackage(pluginName, packageRoot)) {
|
||||||
output(i18n("Successfully removed %1", pluginName));
|
output(i18n("Successfully removed %1", pluginName));
|
||||||
|
Loading…
Reference in New Issue
Block a user