make PackageStructure plugins use the json method as with DataEngines
This commit is contained in:
parent
aa99a4f15c
commit
cd87344d80
@ -27,6 +27,7 @@
|
||||
#include <plasma/plasma.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
#include <plasma/package.h>
|
||||
#include <plasma/version.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -98,5 +99,9 @@ private:
|
||||
#define K_EXPORT_PLASMA_PACKAGE(libname, classname) \
|
||||
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
||||
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
||||
#endif
|
||||
|
||||
#define K_EXPORT_PLASMA_PACKAGE_WITH_JSON(classname, jsonFile) \
|
||||
K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) \
|
||||
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
||||
|
||||
#endif
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
PluginLoaderPrivate()
|
||||
: isDefaultLoader(false),
|
||||
dataEnginePluginDir("plasma/dataengine"),
|
||||
packageStructurePluginDir("plasma/packagestructure"),
|
||||
packageRE("[^a-zA-Z0-9\\-_]")
|
||||
{
|
||||
}
|
||||
@ -64,6 +65,7 @@ public:
|
||||
QHash<QString, QWeakPointer<PackageStructure> > structures;
|
||||
bool isDefaultLoader;
|
||||
QString dataEnginePluginDir;
|
||||
QString packageStructurePluginDir;
|
||||
QRegExp packageRE;
|
||||
};
|
||||
|
||||
@ -443,23 +445,16 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s
|
||||
}
|
||||
|
||||
// first we check for plugins in sycoca
|
||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint);
|
||||
|
||||
QVariantList args;
|
||||
QString error;
|
||||
foreach (const KService::Ptr &offer, offers) {
|
||||
structure = qobject_cast<PackageStructure *>(offer->createInstance<PackageStructure>(0, args, &error));
|
||||
|
||||
if (structure) {
|
||||
d->structures.insert(hashkey, structure);
|
||||
return Package(structure);
|
||||
}
|
||||
const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat);
|
||||
structure = KPluginTrader::createInstanceFromQuery<Plasma::PackageStructure>(d->packageStructurePluginDir, "Plasma/PackageStructure", constraint, 0);
|
||||
if (structure) {
|
||||
d->structures.insert(hashkey, structure);
|
||||
return Package(structure);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// qDebug() << "Couldn't load Package for" << packageFormat << "! reason given: " << error;
|
||||
#endif
|
||||
}
|
||||
|
||||
return Package();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user