search/replace old hardcoded types from plasmapkg2

there is a single difference between command line
parameters of plasmapkg2 and kpackagetool5: plasmapkg2
had some hardcoded names like "theme", "plasmoid" etc.
kpackagetool5 requires the servicetype name to be
passed instead. in order to stay compatible convert
those parameter with the proper servicetype name.
it's parsing parameters by hand in order to just
pass anything else without further parsing

BUG:374463
REVIEW:129753
Change-Id: I6adece9b3dd351331d747505c455e0f79cd0ecf7
This commit is contained in:
Marco Martin 2017-01-03 13:23:18 +01:00
parent a0f3d2429d
commit 642db25fb9
2 changed files with 60 additions and 1 deletions

View File

@ -22,6 +22,7 @@
#include <KLocalizedString>
#include <kpackage/package.h>
#include <kpackage/packagestructure.h>
#include "config-plasma.h"
class ThemePackage : public KPackage::PackageStructure
{
@ -34,6 +35,7 @@ public:
// by default the packages have "contents/" as contentsPrefixPaths
// but for the themes we don't want that, so unset it.
package->setContentsPrefixPaths(QStringList());
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/"));
package->addDirectoryDefinition("dialogs", QStringLiteral("dialogs/"), i18n("Images for dialogs"));
package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svg"),

View File

@ -23,13 +23,70 @@
#include <QCoreApplication>
#include <QProcess>
#include <QRegularExpression>
QString typeFromLegacy(const QString &type)
{
if (type == QStringLiteral("plasmoid")) {
return QStringLiteral("Plasma/Applet");
} else if (type == QStringLiteral("package")) {
return QStringLiteral("Plasma/Generic");
} else if (type == QStringLiteral("theme")) {
return QStringLiteral("Plasma/Theme");
} else if (type == QStringLiteral("wallpaper")) {
return QStringLiteral("Plasma/ImageWallpaper");
} else if (type == QStringLiteral("dataengine")) {
return QStringLiteral("Plasma/DataEngine");
} else if (type == QStringLiteral("runner")) {
return QStringLiteral("Plasma/Runner");
} else if (type == QStringLiteral("wallpaperplugin")) {
return QStringLiteral("Plasma/Wallpaper");
} else if (type == QStringLiteral("lookandfeel")) {
return QStringLiteral("Plasma/LookAndFeel");
} else if (type == QStringLiteral("shell")) {
return QStringLiteral("Plasma/Shell");
} else if (type == QStringLiteral("layout-template")) {
return QStringLiteral("Plasma/LayoutTemplate");
} else if (type == QStringLiteral("kwineffect")) {
return QStringLiteral("KWin/Effect");
} else if (type == QStringLiteral("windowswitcher")) {
return QStringLiteral("KWin/WindowSwitcher");
} else if (type == QStringLiteral("kwinscript")) {
return QStringLiteral("KWin/Script");
} else {
return type;
}
}
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QStringList params = app.arguments().mid(1);
//plasmapkg2 had some hardcoded types, kpackagetool5 requires the servicetype passed as the type parameter
//convert between the two
//user passed -t typeName
int typeIndex = params.indexOf(QStringLiteral("-t"));
if (typeIndex > -1 && params.length() > typeIndex + 1) {
params[typeIndex + 1] = typeFromLegacy(params.value(typeIndex + 1));
} else {
//user passed --type typeName
typeIndex = params.indexOf(QStringLiteral("--type"));
if (typeIndex > -1 && params.length() > typeIndex + 1) {
params[typeIndex + 1] = typeFromLegacy(params.value(typeIndex + 1));
} else {
//user passed --type=typeName
typeIndex = params.indexOf(QRegularExpression("--type=.*"));
if (typeIndex > -1) {
params[typeIndex] = QStringLiteral("--type=") + typeFromLegacy(params.value(typeIndex).replace(QStringLiteral("--type="), QString()));
}
}
}
QProcess p;
p.setProcessChannelMode(QProcess::ForwardedChannels);
p.start("kpackagetool5", app.arguments().mid(1));
p.start(QLatin1String("kpackagetool5"), params);
p.waitForFinished();
return p.exitCode();