diff --git a/scriptengines/javascript/javascriptdataengine.cpp b/scriptengines/javascript/javascriptdataengine.cpp index 300527bac..f89c69d5c 100644 --- a/scriptengines/javascript/javascriptdataengine.cpp +++ b/scriptengines/javascript/javascriptdataengine.cpp @@ -52,11 +52,10 @@ bool JavaScriptDataEngine::init() qRegisterMetaType("Plasma::DataEngine::Data"); qRegisterMetaType("DataEngine::Data"); qScriptRegisterMapMetaType(m_qscriptEngine); - /** -TODO: Service bindings -m_qscriptEngine->setDefaultPrototype(qMetaTypeId(), m_qscriptEngine->newQObject(new DummyService())); -m_qscriptEngine->setDefaultPrototype(qMetaTypeId(), m_qscriptEngine->newQObject(new ServiceJob(QString(), QString(), QMap()))); - */ + m_qscriptEngine->setDefaultPrototype(qMetaTypeId(), m_qscriptEngine->newQObject(new DummyService(), QScriptEngine::ScriptOwnership)); + m_qscriptEngine->setDefaultPrototype(qMetaTypeId(), + m_qscriptEngine->newQObject(new ServiceJob(QString(), QString(), QMap()), + QScriptEngine::ScriptOwnership )); Authorization auth; if (!m_qscriptEngine->importExtensions(description(), iface, auth)) { @@ -254,17 +253,18 @@ bool JavaScriptDataEngine::updateSourceEvent(const QString &source) return false; } -/* Plasma::Service *JavaScriptDataEngine::serviceForSource(const QString &source) { - QScriptValue rv = callFunction("updateSourceEvent"); - if (rv.isValid() && rv.isVariant()) { - return rv.toVariant().value(); + QScriptValueList args; + args << source; + QScriptValue rv = callFunction("updateSourceEvent", args); + if (rv.isValid() && rv.isQObject()) { + return qobject_cast(rv.toQObject()); } return 0; } -*/ + K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(javascriptdataengine, JavaScriptDataEngine) #include diff --git a/scriptengines/javascript/javascriptdataengine.h b/scriptengines/javascript/javascriptdataengine.h index 18341c823..44ef60167 100644 --- a/scriptengines/javascript/javascriptdataengine.h +++ b/scriptengines/javascript/javascriptdataengine.h @@ -41,7 +41,7 @@ public: QStringList sources() const; bool sourceRequestEvent(const QString &name); bool updateSourceEvent(const QString &source); - //TODO: Plasma::Service *serviceForSource(const QString &source); + Plasma::Service *serviceForSource(const QString &source); int maxSourceCount() const; void jsSetMaxSourceCount(int count);