Experiment with loading the KPluginInfo from the plugin's metadata

This commit is contained in:
Sebastian Kügler 2013-07-03 05:13:25 +02:00
parent a9c022f5b9
commit 5d41347527
3 changed files with 43 additions and 10 deletions

View File

@ -48,9 +48,9 @@
namespace Plasma namespace Plasma
{ {
DataEngine::DataEngine(const KPluginInfo &plugin, QObject *parent) DataEngine::DataEngine(const KPluginInfo &plugin, QObject *parent, const QVariantList &args)
: QObject(parent), : QObject(parent),
d(new DataEnginePrivate(this, plugin)) d(new DataEnginePrivate(this, plugin, args))
{ {
if (d->script) { if (d->script) {
d->setupScriptSupport(); d->setupScriptSupport();
@ -63,9 +63,9 @@ DataEngine::DataEngine(const KPluginInfo &plugin, QObject *parent)
} }
DataEngine::DataEngine(QObject* parent, const QVariantList &args) DataEngine::DataEngine(QObject* parent, const QVariantList &args)
: Plasma::DataEngine(KPluginInfo(), parent) : Plasma::DataEngine(KPluginInfo(), parent, args)
{ {
qDebug() << "wrong constructor for timeengine :(";
} }
DataEngine::~DataEngine() DataEngine::~DataEngine()
@ -375,7 +375,7 @@ void DataEngine::setStorageEnabled(const QString &source, bool store)
} }
// Private class implementations // Private class implementations
DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info) DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info, const QVariantList &args)
: q(e), : q(e),
dataEngineDescription(info), dataEngineDescription(info),
refCount(-1), // first ref refCount(-1), // first ref
@ -388,10 +388,43 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
{ {
updateTimestamp.start(); updateTimestamp.start();
if (info.isValid()) { if (!info.isValid()) {
e->setObjectName(info.name()); qDebug() << "######################################################";
qDebug() << "\n\n arg constructor for timeengine :(" << args.count() << args;
qDebug() << "\n######################################################";
KConfig _c("/tmp/pluginconfig.desktop", KConfig::SimpleConfig);
KConfigGroup c = _c.group("Desktop Entry");
foreach (const QVariant &v, args) {
qDebug() << "------------------";
qDebug() << " V: " << v;
if (v.canConvert<QVariantMap>()) {
QVariantMap m = v.toMap();
//c.setName(QLatin1String("Desktop Entry"));
foreach (const QString &k, m.keys()) {
qDebug() << " info " << k;// << m[k];
if (k == QLatin1String("MetaData") && m[k].canConvert<QVariantMap>()) {
qDebug() << "found the metadata object" << k;
QVariantMap meta = m[k].toMap();
foreach (const QString &l, meta.keys()) {
qDebug() << " " << l << " = " << meta[l];
c.writeEntry("eins", "foobar");
}
}
}
}
}
c.sync();
dataEngineDescription = KPluginInfo("/tmp/pluginconfig.desktop");
//dataEngineDescription.load(c);
}
if (dataEngineDescription.isValid()) {
e->setObjectName(dataEngineDescription.name());
qDebug() << "Plugininfo is valid! :-)";
} else { } else {
e->setObjectName("NullEngine"); e->setObjectName("NullEngine");
qDebug() << "Plugininfo is INVALID! :-)";
} }
if (dataEngineDescription.isValid()) { if (dataEngineDescription.isValid()) {

View File

@ -71,9 +71,9 @@ class PLASMA_EXPORT DataEngine : public QObject
* @param parent The parent object. * @param parent The parent object.
* @param plugin plugin info that describes the engine * @param plugin plugin info that describes the engine
**/ **/
explicit DataEngine(const KPluginInfo &plugin, QObject *parent = 0); explicit DataEngine(const KPluginInfo &plugin, QObject *parent = 0, const QVariantList &args = QVariantList());
explicit DataEngine(QObject* parent = 0, const QVariantList& args = QVariantList()); explicit DataEngine(QObject *parent = 0, const QVariantList &args = QVariantList());
~DataEngine(); ~DataEngine();

View File

@ -34,7 +34,7 @@ class Service;
class DataEnginePrivate class DataEnginePrivate
{ {
public: public:
DataEnginePrivate(DataEngine *e, const KPluginInfo &info); DataEnginePrivate(DataEngine *e, const KPluginInfo &info, const QVariantList &args = QVariantList());
~DataEnginePrivate(); ~DataEnginePrivate();
DataContainer *source(const QString &sourceName, bool createWhenMissing = true); DataContainer *source(const QString &sourceName, bool createWhenMissing = true);
void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval, void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval,