pluginloader: Change behavior of X-KDE-ParentApp

Summary:
X-KDE-ParentApp is the key in desktop file to display that given service
or application is part of the another application or extension of other
application. In KDE4 this key was used to mark applets to be used in the
specific application like plasma-desktop, kdevelop, amarok etc.

In KF5 world, none of this applications have applet loading mechanism
apart from plasma*, and there are likely only Plasma applet, containment
or dataengines.

Previous API, when no/empty parentApp was passed would filter out every
application which had something as parentApp. This was to ensure only
compatible plugins are loaded in Plasma. This resulted in applets
getting excluded if they suggested that org.kde.plasmashell is their
parent application. Refine this API to,

- If no/empty parentApp is provided, provide all applets
- If parentApp is provided, filter by applet

This behavior is more filter like instead of other way around.

CHANGELOG: Applet, DataEngine and containment listing methods in
Plasma::PluginLoader no longer filters the plugins with X-KDE-ParentApp
provided when empty string is passed.

Test Plan:
tested that plasma loads properly, plasmaengineexplorer lists
all engines and plasmawindowed works fine. Neverthless requires more testing

Reviewers: mart, apol

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D22049
This commit is contained in:
Bhushan Shah 2019-06-23 20:25:28 +05:30
parent 9f04ae48e2
commit 7ae271987c
2 changed files with 18 additions and 49 deletions

View File

@ -58,7 +58,6 @@ public:
}
static QSet<QString> knownCategories();
static QString parentAppConstraint(const QString &parentApp = QString());
static QSet<QString> s_customCategories;
QHash<QString, QPointer<PackageStructure> > structures;
@ -119,21 +118,6 @@ QSet<QString> PluginLoaderPrivate::knownCategories()
return categories;
}
QString PluginLoaderPrivate::parentAppConstraint(const QString &parentApp)
{
if (parentApp.isEmpty()) {
QCoreApplication *app = QCoreApplication::instance();
if (!app) {
return QString();
}
return QStringLiteral("((not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '') or [X-KDE-ParentApp] == '%1')")
.arg(app->applicationName());
}
return QStringLiteral("[X-KDE-ParentApp] == '%1'").arg(parentApp);
}
PluginLoader::PluginLoader()
: d(new PluginLoaderPrivate)
{
@ -535,7 +519,7 @@ QList<KPluginMetaData> PluginLoader::listAppletMetaData(const QString &category,
filter = [excluded, parentApp](const KPluginMetaData &md) -> bool
{
const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
return (pa.isEmpty() || pa == parentApp) && !excluded.contains(md.category());
return (parentApp.isEmpty() || pa == parentApp) && !excluded.contains(md.category());
};
} else { //specific category (this could be an excluded one - is that bad?)
@ -543,9 +527,9 @@ QList<KPluginMetaData> PluginLoader::listAppletMetaData(const QString &category,
{
const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
if (category == QLatin1String("Miscellaneous")) {
return (pa.isEmpty() || pa == parentApp) && (md.category() == category || md.category().isEmpty());
return (parentApp.isEmpty() || pa == parentApp) && (md.category() == category || md.category().isEmpty());
} else {
return (pa.isEmpty() || pa == parentApp) && md.category() == category;
return (parentApp.isEmpty() || pa == parentApp) && md.category() == category;
}
};
}
@ -600,7 +584,7 @@ QList<KPluginMetaData> PluginLoader::listAppletMetaDataForUrl(const QUrl &url)
auto filter = [&parentApp](const KPluginMetaData &md) -> bool
{
const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
return (pa.isEmpty() || pa == parentApp) && !KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns")).isEmpty();
return (parentApp.isEmpty() || pa == parentApp) && !KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns")).isEmpty();
};
const QList<KPluginMetaData> allApplets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter);
@ -634,7 +618,7 @@ QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool vi
auto filter = [&parentApp, &excluded, visibleOnly](const KPluginMetaData &md) -> bool
{
const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
return (pa.isEmpty() || pa == parentApp)
return (parentApp.isEmpty() || pa == parentApp)
&& (excluded.isEmpty() || excluded.contains(md.value(QStringLiteral("X-KDE-PluginInfo-Category"))))
&& (!visibleOnly || !md.isHidden());
};
@ -695,8 +679,7 @@ KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type,
if (!md.serviceTypes().contains(QStringLiteral("Plasma/Containment"))) {
return false;
}
const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
if (!pa.isEmpty() && pa != parentApp) {
if (!parentApp.isEmpty() && md.value(QStringLiteral("X-KDE-ParentApp")) != parentApp) {
return false;
}
@ -749,9 +732,7 @@ KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
}
QString constraint;
if (parentApp.isEmpty()) {
constraint = QStringLiteral("not exist [X-KDE-ParentApp]");
} else {
if (!parentApp.isEmpty()) {
constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\'');
}
@ -768,9 +749,7 @@ KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parent
}
QString constraint;
if (parentApp.isEmpty()) {
constraint = QStringLiteral("not exist [X-KDE-ParentApp]");
} else {
if (!parentApp.isEmpty()) {
constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\'');
}

View File

@ -82,8 +82,7 @@ public:
* @param parentApp the application to filter dataengines on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only dataengines not specifically
* registered to an application.
* list of all dataengines.
*/
static QStringList listAllEngines(const QString &parentApp = QString());
@ -93,8 +92,7 @@ public:
* @param parentApp the application to filter dataengines on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only dataengines not specifically
* registered to an application.
* list of all dataengines.
* @return list of dataengines
**/
static KPluginInfo::List listEngineInfo(const QString &parentApp = QString());
@ -110,8 +108,7 @@ public:
* @param parentApp the application to filter dataengines on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only dataengines not specifically
* registered to an application.
* list of all dataengines in specified categories.
* @return list of dataengines
* @since 4.3
**/
@ -169,8 +166,7 @@ public:
* @param parentApp the application to filter applets on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only applets not specifically
* registered to an application.
* list of all applets in specified category.
* @return list of applets
*
* @deprecated use listAppletMetaData. Doesn't support metadata.json packages.
@ -190,8 +186,7 @@ public:
* @param parentApp the application to filter applets on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only applets not specifically
* registered to an application.
* list of all applets in specified categories.
* @return list of applets
*
* @since 5.28
@ -236,8 +231,7 @@ public:
* @param parentApp the application to filter applets on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only applets not specifically
* registered to an application.
* list of all Applets.
* @return list of categories
* @param visibleOnly true if it should only return applets that are marked as visible
*/
@ -277,8 +271,7 @@ public:
* @param parentApp the application to filter containments on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only containments not specifically
* registered to an application.
* list of all containments.
* @return list of containments
**/
static KPluginInfo::List listContainments(const QString &category = QString(),
@ -299,8 +292,7 @@ public:
* @param parentApp the application to filter containments on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only containments not specifically
* registered to an application.
* list of all containments, matching categories/type.
* @return list of containments
**/
static KPluginInfo::List listContainmentsOfType(const QString &type,
@ -325,8 +317,7 @@ public:
* @param parentApp the application to filter dataengines on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only dataengines not specifically
* registered to an application.
* list of all dataengines
* @return list of dataengines
**/
KPluginInfo::List listDataEngineInfo(const QString &parentApp = QString());
@ -337,8 +328,7 @@ public:
* @param parentApp the application to filter ContainmentActions on. Uses the
* X-KDE-ParentApp entry (if any) in the plugin info.
* The default value of QString() will result in a
* list containing only ContainmentActions not specifically
* registered to an application.
* list of all ContainmentActions.
* @return list of ContainmentActions
**/
KPluginInfo::List listContainmentActionsInfo(const QString &parentApp);