Allow loading KPluginMetaData from a .desktop file

Review Request #121122 - Created Nov. 14, 2014 and submitted

Sebastian Kügler
kdeframeworks, plasma
arichardson, dfaure, mart

This set of patches moves the code to decode and json-serialize from desktoptojson into its own class, used by the KPluginMetaData(QString file) constructor.

These functions are not exported, desktoptojson directly includes this class. I've done it this way to avoid littering the API, yet removing as much duplicated code from desktoptojson as possible. These functions have gone into their own class, and made static, since they don't carry state, anyway.

The purpose of this patch is to allow the package indexer in kpackage (the split-out framework containing Plasma::Package) to create a correct, KPlugin-compatible cache file from package metadata. This patch allows us to just feed a .desktop file into KPluginMetaData and get back correct deserialized KPluginMetaData objects. It allows us to cut out the KService dependency in KPackage.

In particular, this is split up into the following patches (you can find it in git kcoreaddons[sebas/kpluginmetadata] as well):

Remove now-duplicated code in desktoptojson

Use escapeValue, deserializeList and convertToJson from

Move the bits to parse .desktop files into its own class

This encapsulates the desktop file parseing logic into its own class.
It's fairly self-contained, all static code. This also makes it easier
to share this code with the desktoptojson binary.

Allow to read KPluginMetaData from .desktop files

Move the logic to create a KPluginMetaData object from desktoptojson
into KPluginMetaData.

This allows to load metadata from a .desktop file, making it possible to
load desktop files without going through KPluginInfo (and thus
KService). This is useful for conversion to json data, which will be
used to index packages in the KPackage framework for faster lookups,
similar to the index proof-of-concept for KPluginTrader.

Add an autotest for loading KPluginMetaData from a .desktop file

Added an autotest which compares a KPluginMetaData object created from a desktop file. Also used this code from kpackage.


  • 0
  • 4
  • 0
  • 4
Description From Last Updated
Sebastian Kügler
Kai Uwe Broulik
Martin Flöser
Alex Richardson
Marco Martin
Sebastian Kügler
Review request changed

Status: Closed (submitted)