KPluginLoader: Use filename when searching for plugin by id
Open, Needs TriagePublic

Description

If one wants to query a plugin by id the JSON metadata has to be loaded for each plugin and the containing pluginId has to be compared. Using the filename one can do this far quicker.

This would also make it obsolete to set the pluginId in the JSON metadata in the long run.

Suggested plan of action:
Identify & adjust places where the filename is not the same as the pluginId. With the install namespaces and kcoreaddons_add_plugin CMake utility this should not resolve in any conflicting file names.
Use the file name in KPluginMetaData as the pluginId if it is not explicitly set in the JSON metadata.

Search for the plugin based on the filename in KPluginLoader::findPluginsById. If we find any load the KPluginMetaData and make sure the the pluginId matches. If we haven't found anything do the search as we currently do. The last two code paths can be considered compatibility logic.

Alternatively one could create a method KPluginLoader::findPluginById which will return just a single plugin. The id should be unique inside of its namespace and we don't want to have any duplicates from different install prefixes. That would be my preferred way of implementing, it also allows apps to use the more performant approach without any of the old compatibility logic being involved.

alex created this task.May 23 2021, 8:45 AM
alex moved this task from Backlog to In Progress on the KF6 board.May 29 2021, 3:16 PM

Alternatively one could create a method KPluginLoader::findPluginById which will return just a single plugin.

This was agreed on in the KF6 weekly discussion.

Is there anything left to do here?

alex added a comment.Feb 21 2023, 6:08 AM

Yep, but only some minor things.

alex moved this task from In Progress to Done on the KF6 board.Mar 4 2023, 10:19 AM