24 #include <kservicetypetrader.h>
30 #include "private/componentinstaller_p.h"
36 #include "private/packages_p.h"
69 QString constraintTemplate =
"'%1' in [X-Plasma-ComponentTypes]";
76 if (!constraint.isEmpty()) {
77 constraint.append(
" or ");
80 constraint.append(constraintTemplate.arg(
"Applet"));
84 if (!constraint.isEmpty()) {
85 constraint.append(
" or ");
88 constraint.append(constraintTemplate.arg(
"DataEngine"));
92 if (!constraint.isEmpty()) {
93 constraint.append(
" or ");
96 constraint.append(constraintTemplate.arg(
"Runner"));
100 if (!constraint.isEmpty()) {
101 constraint.append(
" or ");
104 constraint.append(constraintTemplate.arg(
"Wallpaper"));
107 KService::List offers = KServiceTypeTrader::self()->query(
"Plasma/ScriptEngine", constraint);
111 QStringList languages;
112 foreach (
const KService::Ptr &service, offers) {
113 QString language = service->property(
"X-Plasma-API").toString();
114 if (!languages.contains(language)) {
115 languages.append(language);
124 if (language.isEmpty()) {
125 return KService::List();
128 QRegExp re(
"[^a-zA-Z0-9\\-_]");
129 if (re.indexIn(language) != -1) {
130 kDebug() <<
"invalid language attempted:" << language;
131 return KService::List();
137 component =
"Applet";
140 component =
"DataEngine";
143 component =
"Runner";
146 component =
"Wallpaper";
149 return KService::List();
153 QString constraint = QString(
"[X-Plasma-API] == '%1' and "
154 "'%2' in [X-Plasma-ComponentTypes]").arg(language, component);
155 KService::List offers = KServiceTypeTrader::self()->query(
"Plasma/ScriptEngine", constraint);
158 if (offers.isEmpty()) {
159 kDebug() <<
"No offers for \"" << language <<
"\"";
173 foreach (
const KService::Ptr &service, offers) {
196 kDebug() <<
"Couldn't load script engine for language " << language
197 <<
"! error reported: " << error;
201 ComponentInstaller::self()->installMissingComponent(
"scriptengine", language);
278 if (offers.isEmpty()) {
282 KService::Ptr offer = offers.first();
283 QString packageFormat = offer->property(
"X-Plasma-PackageFormat").toString();
285 if (packageFormat.isEmpty()) {
295 #include <scriptengine.moc>