Merge branch 'sebas/kplugins'
This includes the ctor for dataengines, plus some more work on this topic. REVIEW:111691
This commit is contained in:
commit
0368d7423c
@ -30,6 +30,8 @@ find_package(Qt5X11Extras REQUIRED NO_MODULE)
|
||||
|
||||
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
|
||||
|
||||
#add_definitions(-Wno-deprecated)
|
||||
|
||||
if(KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED)
|
||||
set(KDE_NO_DEPRECATED TRUE)
|
||||
set(CMAKE_AUTOMOC_MOC_OPTIONS "-DKDE_NO_DEPRECATED")
|
||||
@ -194,7 +196,5 @@ install(FILES
|
||||
add_subdirectory(src)
|
||||
add_subdirectory( desktoptheme )
|
||||
|
||||
# install(EXPORT plasmaTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
# FILE plasmaTargets.cmake COMPONENT Devel)
|
||||
install(EXPORT PlasmaTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE PlasmaTargets.cmake NAMESPACE KF5:: COMPONENT Devel)
|
||||
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
@ -136,10 +136,10 @@ void SortFilterModel::setSortOrder(const Qt::SortOrder order)
|
||||
sort(0, order);
|
||||
}
|
||||
|
||||
QVariantHash SortFilterModel::get(int row) const
|
||||
QVariantMap SortFilterModel::get(int row) const
|
||||
{
|
||||
QModelIndex idx = index(row, 0);
|
||||
QVariantHash hash;
|
||||
QVariantMap hash;
|
||||
|
||||
QHash<int, QByteArray>::const_iterator i;
|
||||
for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) {
|
||||
@ -199,7 +199,7 @@ void DataModel::dataUpdated(const QString &sourceName, const Plasma::DataEngine:
|
||||
QVariantList list;
|
||||
|
||||
if (!m_dataSource->data().isEmpty()) {
|
||||
QVariantHash::const_iterator i = m_dataSource->data().constBegin();
|
||||
QVariantMap::const_iterator i = m_dataSource->data().constBegin();
|
||||
|
||||
while (i != m_dataSource->data().constEnd()) {
|
||||
if (!m_sourceFilter.isEmpty() && m_sourceFilterRE.isValid() && !m_sourceFilterRE.exactMatch(i.key())) {
|
||||
@ -252,8 +252,8 @@ void DataModel::setDataSource(QObject *object)
|
||||
|
||||
m_dataSource = source;
|
||||
|
||||
const QHash<QString, QVariant> data = source->data();
|
||||
QHash<QString, QVariant>::const_iterator i = data.constBegin();
|
||||
const QMap<QString, QVariant> data = source->data();
|
||||
QMap<QString, QVariant>::const_iterator i = data.constBegin();
|
||||
while (i != data.constEnd()) {
|
||||
dataUpdated(i.key(), i.value().value<Plasma::DataEngine::Data>());
|
||||
++i;
|
||||
@ -343,10 +343,10 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list)
|
||||
m_items[sourceName] = list.toVector();
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
if (list.first().canConvert<QVariantHash>()) {
|
||||
if (list.first().canConvert<QVariantMap>()) {
|
||||
foreach (const QVariant &item, list) {
|
||||
const QVariantHash &vh = item.value<QVariantHash>();
|
||||
QHashIterator<QString, QVariant> it(vh);
|
||||
const QVariantMap &vh = item.value<QVariantMap>();
|
||||
QMapIterator<QString, QVariant> it(vh);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
const QString &roleName = it.key();
|
||||
@ -395,7 +395,7 @@ void DataModel::removeSource(const QString &sourceName)
|
||||
if (m_keyRoleFilter.isEmpty()) {
|
||||
//source name in the map, linear scan
|
||||
for (int i = 0; i < m_items.value(QString()).count(); ++i) {
|
||||
if (m_items.value(QString())[i].value<QVariantHash>().value("DataEngineSource") == sourceName) {
|
||||
if (m_items.value(QString())[i].value<QVariantMap>().value("DataEngineSource") == sourceName) {
|
||||
beginResetModel();
|
||||
m_items[QString()].remove(i);
|
||||
endResetModel();
|
||||
@ -436,11 +436,8 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
//is it the reserved role: DataEngineSource ?
|
||||
//also, if each source is an item DataEngineSource is a role between all the others, otherwise we know it from the role variable
|
||||
//finally, sub items are some times QVariantHash some times QVariantMaps
|
||||
if (!m_keyRoleFilter.isEmpty() && m_roleNames.value(role) == "DataEngineSource") {
|
||||
return source;
|
||||
} else if (m_items.value(source).value(actualRow).canConvert<QVariantHash>()) {
|
||||
return m_items.value(source).value(actualRow).value<QVariantHash>().value(m_roleNames.value(role));
|
||||
} else {
|
||||
return m_items.value(source).value(actualRow).value<QVariantMap>().value(m_roleNames.value(role));
|
||||
}
|
||||
@ -491,17 +488,17 @@ int DataModel::columnCount(const QModelIndex &parent) const
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariantHash DataModel::get(int row) const
|
||||
QVariantMap DataModel::get(int row) const
|
||||
{
|
||||
QModelIndex idx = index(row, 0);
|
||||
QVariantHash hash;
|
||||
QVariantMap map;
|
||||
|
||||
QHash<int, QByteArray>::const_iterator i;
|
||||
for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) {
|
||||
hash[i.value()] = data(idx, i.key());
|
||||
map[i.value()] = data(idx, i.key());
|
||||
}
|
||||
|
||||
return hash;
|
||||
return map;
|
||||
}
|
||||
|
||||
int DataModel::roleNameToId(const QString &name)
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
*
|
||||
* @arg int i the row we want
|
||||
*/
|
||||
Q_INVOKABLE QVariantHash get(int i) const;
|
||||
Q_INVOKABLE QVariantMap get(int i) const;
|
||||
|
||||
Q_INVOKABLE int mapRowToSource(int i) const;
|
||||
|
||||
@ -184,7 +184,7 @@ public:
|
||||
*
|
||||
* @arg int i the row we want
|
||||
*/
|
||||
Q_INVOKABLE QVariantHash get(int i) const;
|
||||
Q_INVOKABLE QVariantMap get(int i) const;
|
||||
|
||||
protected:
|
||||
void setItems(const QString &sourceName, const QVariantList &list);
|
||||
|
@ -141,7 +141,6 @@ void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine
|
||||
//it can arrive also data we don't explicitly connected a source
|
||||
if (m_connectedSources.contains(sourceName)) {
|
||||
m_data.insert(sourceName.toLatin1(), data);
|
||||
|
||||
emit dataChanged();
|
||||
emit newData(sourceName, data);
|
||||
} else if (m_dataEngine) {
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
};
|
||||
Q_DECLARE_FLAGS(Changes, Change)
|
||||
|
||||
typedef QHash<QString, QVariant> Data;
|
||||
typedef QMap<QString, QVariant> Data;
|
||||
|
||||
DataSource(QObject* parent=0);
|
||||
|
||||
@ -89,10 +89,10 @@ public:
|
||||
|
||||
/**
|
||||
* All the data fetched by this dataengine.
|
||||
* This is an hash of hashes. At the first level, there are the source names, at the secons, they keys set by the DataEngine
|
||||
* This is a map of maps. At the first level, there are the source names, at the secons, they keys set by the DataEngine
|
||||
*/
|
||||
Q_PROPERTY(QVariantHash data READ data NOTIFY dataChanged);
|
||||
QVariantHash data() const {return m_data;}
|
||||
Q_PROPERTY(QVariantMap data READ data NOTIFY dataChanged);
|
||||
QVariantMap data() const {return m_data;}
|
||||
|
||||
/**
|
||||
* @returns a Plasma::Service given a source name
|
||||
@ -131,7 +131,7 @@ private:
|
||||
QString m_id;
|
||||
int m_interval;
|
||||
QString m_engine;
|
||||
QVariantHash m_data;
|
||||
QVariantMap m_data;
|
||||
Plasma::DataEngine* m_dataEngine;
|
||||
Plasma::DataEngineConsumer* m_dataEngineConsumer;
|
||||
QStringList m_connectedSources;
|
||||
|
@ -62,6 +62,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-plasma.h.cmake ${CMAKE_CURRENT
|
||||
include_directories(${KDEPIMLIBS_INCLUDE_DIRS} ${GPGME_INCLUDES})
|
||||
|
||||
add_subdirectory(autotests)
|
||||
add_subdirectory(tests)
|
||||
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1209)
|
||||
|
||||
########### next target ###############
|
||||
|
@ -70,6 +70,7 @@ Applet::Applet(const KPluginInfo &info, QObject *parent, uint appletId)
|
||||
: QObject(parent),
|
||||
d(new AppletPrivate(KService::Ptr(), &info, appletId, this))
|
||||
{
|
||||
qDebug() << " From KPluginInfo, valid? " << info.isValid();
|
||||
// WARNING: do not access config() OR globalConfig() in this method!
|
||||
// that requires a scene, which is not available at this point
|
||||
d->init();
|
||||
|
@ -63,7 +63,7 @@ void PackageStructureTest::copyPerformance()
|
||||
const QString bar = foo.filePath("mainscript");
|
||||
}
|
||||
|
||||
QVERIFY(t.elapsed() < 200);
|
||||
QVERIFY(t.elapsed() < 400);
|
||||
}
|
||||
|
||||
void PackageStructureTest::emptyContentsPrefix()
|
||||
|
@ -56,12 +56,22 @@ DataEngine::DataEngine(const KPluginInfo &plugin, QObject *parent)
|
||||
d->setupScriptSupport();
|
||||
d->script->init();
|
||||
} else {
|
||||
// qDebug() << "called";
|
||||
// default implementation does nothing. this is for engines that have to
|
||||
// start things in motion external to themselves before they can work
|
||||
}
|
||||
}
|
||||
|
||||
DataEngine::DataEngine(QObject* parent, const QVariantList &args)
|
||||
: Plasma::DataEngine(KPluginInfo(args), parent)
|
||||
{
|
||||
if (d->script) {
|
||||
d->setupScriptSupport();
|
||||
d->script->init();
|
||||
}
|
||||
qDebug() << "PWC dataengine: " << d->dataEngineDescription.isValid() << d->dataEngineDescription.name();
|
||||
qDebug() << "PWC args: " << args;
|
||||
}
|
||||
|
||||
DataEngine::~DataEngine()
|
||||
{
|
||||
//qDebug() << objectName() << ": bye bye birdy! ";
|
||||
@ -382,8 +392,8 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
|
||||
{
|
||||
updateTimestamp.start();
|
||||
|
||||
if (info.isValid()) {
|
||||
e->setObjectName(info.name());
|
||||
if (dataEngineDescription.isValid()) {
|
||||
e->setObjectName(dataEngineDescription.name());
|
||||
} else {
|
||||
e->setObjectName("NullEngine");
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ class PLASMA_EXPORT DataEngine : public QObject
|
||||
**/
|
||||
explicit DataEngine(const KPluginInfo &plugin, QObject *parent = 0);
|
||||
|
||||
explicit DataEngine(QObject *parent = 0, const QVariantList &args = QVariantList());
|
||||
|
||||
~DataEngine();
|
||||
|
||||
/**
|
||||
@ -430,6 +432,11 @@ K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
||||
K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
|
||||
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
||||
|
||||
#define K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(libname, classname, jsonFile) \
|
||||
K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) \
|
||||
K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
|
||||
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
||||
|
||||
Q_DECLARE_METATYPE(Plasma::DataEngine*)
|
||||
|
||||
#endif // multiple inclusion guard
|
||||
|
1
src/plasma/tests/CMakeLists.txt
Normal file
1
src/plasma/tests/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(kplugins)
|
13
src/plasma/tests/kplugins/CMakeLists.txt
Normal file
13
src/plasma/tests/kplugins/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
project("plugintest")
|
||||
|
||||
add_executable(plugintest
|
||||
main.cpp
|
||||
plugintest.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(plugintest kdeqt5staging plasma)
|
||||
|
||||
message("INSTALL_TARGETS_DEFAULT_ARGS ${INSTALL_TARGETS_DEFAULT_ARGS}")
|
||||
|
||||
#install(TARGETS plugintest ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
43
src/plasma/tests/kplugins/main.cpp
Normal file
43
src/plasma/tests/kplugins/main.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
|
||||
* Copyright 2013 Sebastian Kügler <sebas@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <qcommandlineparser.h>
|
||||
#include <qcommandlineoption.h>
|
||||
|
||||
#include "plugintest.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCommandLineParser *parser = new QCommandLineParser;
|
||||
Plasma::PluginTest app(argc, argv, parser);
|
||||
|
||||
const QString description = i18n("Plugin test app");
|
||||
const char version[] = "2.0";
|
||||
|
||||
app.setApplicationVersion(version);
|
||||
parser->addVersionOption();
|
||||
parser->addHelpOption(description);
|
||||
|
||||
parser->addOption(QCommandLineOption(QStringList() << "s" << "show", i18nc("Do not translate <name>", "Show plugins"), "name"));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
295
src/plasma/tests/kplugins/plugintest.cpp
Normal file
295
src/plasma/tests/kplugins/plugintest.cpp
Normal file
@ -0,0 +1,295 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2013 Sebastian Kügler <sebas@kde.org> *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public License *
|
||||
* along with this library; see the file COPYING.LIB. If not, write to *
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
||||
* Boston, MA 02110-1301, USA. *
|
||||
*******************************************************************************/
|
||||
|
||||
#include "plugintest.h"
|
||||
|
||||
#include <kpluginfactory.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kservice.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kshell.h>
|
||||
#include <KSycoca>
|
||||
#include <klocalizedstring.h>
|
||||
|
||||
#include <plasma/applet.h>
|
||||
#include <plasma/packagestructure.h>
|
||||
#include <plasma/package.h>
|
||||
#include <plasma/pluginloader.h>
|
||||
#include <plasma/dataengine.h>
|
||||
#include <KGlobal>
|
||||
#include <klocale.h>
|
||||
#include <kjob.h>
|
||||
|
||||
#include <qcommandlineparser.h>
|
||||
#include <QDir>
|
||||
#include <QDBusInterface>
|
||||
#include <QFileInfo>
|
||||
#include <QMap>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class PluginTestPrivate {
|
||||
public:
|
||||
QString pluginName;
|
||||
QCommandLineParser *parser;
|
||||
};
|
||||
|
||||
PluginTest::PluginTest(int& argc, char** argv, QCommandLineParser *parser) :
|
||||
QApplication(argc, argv)
|
||||
{
|
||||
d = new PluginTestPrivate;
|
||||
d->parser = parser;
|
||||
QTimer::singleShot(0, this, SLOT(runMain()));
|
||||
}
|
||||
|
||||
PluginTest::~PluginTest()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void PluginTest::runMain()
|
||||
{
|
||||
qDebug() << "plugin test runs: ";
|
||||
//loadDataEngine();
|
||||
// qDebug() << " - - - -- - - - - ------------------------------------\n";
|
||||
// qDebug() << " libs are in: " << QCoreApplication::libraryPaths();
|
||||
// //loadKQPlugin();
|
||||
qDebug() << "::: loadKPlugin() == " << loadKPlugin();
|
||||
// qDebug() << " - - - -- - - - - ------------------------------------\n";
|
||||
// qDebug() << "::: loadKService() == " << loadKService();
|
||||
//
|
||||
qDebug() << " - - - -- - - - - ------------------------------------\n";
|
||||
qDebug() << "::: loadKFromPlasma() == " << loadFromPlasma();
|
||||
exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
bool PluginTest::loadKPlugin()
|
||||
{
|
||||
bool ok = false;
|
||||
qDebug() << "Load KPlugin";
|
||||
QString pluginPath = "/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/";
|
||||
QCoreApplication::addLibraryPath(pluginPath);
|
||||
//QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/libkqpluginfactory.so", this);
|
||||
QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/plugins/kf5/kplugins/libplasma_engine_time.so", this);
|
||||
KPluginFactory *factory = qobject_cast<KPluginFactory*>(loader.instance());
|
||||
//QObject *factory = loader.instance();
|
||||
if (factory) {
|
||||
qDebug() << "loaded successfully and cast";
|
||||
qDebug() << "metadata: " << loader.metaData();
|
||||
//QObject *o = factory->createPlugin("time");
|
||||
//qDebug() << " objec name:" << o->objectName();
|
||||
//Plasma::DataEngine *time_engine = qobject_cast<Plasma::DataEngine*>(factory->create(this, QVariantList()));
|
||||
Plasma::DataEngine *time_engine = 0;
|
||||
// Plasma::DataEngine *time_engine = factory->create(this, QVariantList());
|
||||
time_engine = factory->create<Plasma::DataEngine>(this, QVariantList());
|
||||
|
||||
if (time_engine) {
|
||||
qDebug() << "Successfully loaded timeengine";
|
||||
time_engine->connectSource("Europe/Amsterdam", this);
|
||||
qDebug() << "SOURCE: " << time_engine->sources();
|
||||
ok = true;
|
||||
} else {
|
||||
qDebug() << "Timeengine failed to load. :(";
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
qDebug() << "loading failed somehow";
|
||||
}
|
||||
//KQPluginFactory* factory = new KQPluginFactory(KPluginInfo(), this);
|
||||
return ok;
|
||||
|
||||
}
|
||||
|
||||
bool PluginTest::loadFromKService(const QString &name)
|
||||
{
|
||||
DataEngine *engine = 0;
|
||||
|
||||
// load the engine, add it to the engines
|
||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine",
|
||||
constraint);
|
||||
QString error;
|
||||
|
||||
if (offers.isEmpty()) {
|
||||
qDebug() << "offers are empty for " << name << " with constraint " << constraint;
|
||||
} else {
|
||||
QVariantList allArgs;
|
||||
allArgs << offers.first()->storageId();
|
||||
QString api = offers.first()->property("X-Plasma-API").toString();
|
||||
if (api.isEmpty()) {
|
||||
if (offers.first()) {
|
||||
KPluginLoader plugin(*offers.first());
|
||||
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
|
||||
engine = offers.first()->createInstance<Plasma::DataEngine>(0, allArgs, &error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
engine = new DataEngine(KPluginInfo(offers.first()), 0);
|
||||
}
|
||||
}
|
||||
|
||||
return engine != 0;
|
||||
}
|
||||
|
||||
|
||||
bool PluginTest::loadFromPlasma()
|
||||
{
|
||||
bool ok = false;
|
||||
const QStringList allEngines = Plasma::PluginLoader::self()->listAllEngines();
|
||||
qDebug() << "All engines: " << allEngines;
|
||||
foreach (const QString &e, allEngines) {
|
||||
Plasma::DataEngine *engine = Plasma::PluginLoader::self()->loadDataEngine(e);
|
||||
if (engine) {
|
||||
engine->connectSource("Europe/Amsterdam", this);
|
||||
engine->connectSource("Battery", this);
|
||||
engine->connectAllSources(this);
|
||||
qDebug() << "SOURCE: " << engine->sources();
|
||||
ok = true;
|
||||
}
|
||||
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
void PluginTest::loadKQPlugin()
|
||||
{
|
||||
qDebug() << "Load KQPlugin";
|
||||
#if 0
|
||||
QString pluginPath = "/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/";
|
||||
QCoreApplication::addLibraryPath(pluginPath);
|
||||
//QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/libkqpluginfactory.so", this);
|
||||
QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/plugins/kf5/kplugins/libplasma_engine_time.so", this);
|
||||
KPluginFactory *factory = qobject_cast<KPluginFactory*>(loader.instance());
|
||||
//QObject *factory = loader.instance();
|
||||
if (factory) {
|
||||
qDebug() << "loaded successfully and cast";
|
||||
qDebug() << "metadata: " << loader.metaData();
|
||||
//QObject *o = factory->createPlugin("time");
|
||||
//qDebug() << " objec name:" << o->objectName();
|
||||
//Plasma::DataEngine *time_engine = qobject_cast<Plasma::DataEngine*>(factory->create(this, QVariantList()));
|
||||
//Plasma::DataEngine *time_engine = factory->create(this, QVariantList());
|
||||
Plasma::DataEngine *time_engine = factory->createInstance<Plasma::DataEngine>(0, this, QVariantList());
|
||||
|
||||
if (time_engine) {
|
||||
qDebug() << "Successfully loaded timeengine";
|
||||
time_engine->connectSource("Europe/Amsterdam", this);
|
||||
qDebug() << "SOURCE: " << time_engine->sources();
|
||||
} else {
|
||||
qDebug() << "Timeengine failed to load. :(";
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
qDebug() << "loading failed somehow";
|
||||
}
|
||||
//KQPluginFactory* factory = new KQPluginFactory(KPluginInfo(), this);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PluginTest::loadKService(const QString &name)
|
||||
{
|
||||
// DataEngine *engine = d->isDefaultLoader ? 0 : internalLoadDataEngine(name);
|
||||
// if (engine) {
|
||||
// return engine;
|
||||
// }
|
||||
qDebug() << "Load KService";
|
||||
DataEngine *engine = 0;
|
||||
// load the engine, add it to the engines
|
||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
|
||||
constraint = QString();
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine",
|
||||
constraint);
|
||||
QString error;
|
||||
|
||||
if (offers.isEmpty()) {
|
||||
qDebug() << "offers are empty for " << name << " with constraint " << constraint;
|
||||
} else {
|
||||
qDebug() << "Found a bunch of stuff";
|
||||
|
||||
QVariantList allArgs;
|
||||
allArgs << offers.first()->storageId();
|
||||
QString api = offers.first()->property("X-Plasma-API").toString();
|
||||
if (api.isEmpty()) {
|
||||
if (offers.first()) {
|
||||
KPluginLoader plugin(*offers.first());
|
||||
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
|
||||
//KPluginInfo::List infos = KPluginInfo::fromServices(offers.first());
|
||||
//qDebug() << " plugininfo:" << info.name();
|
||||
engine = offers.first()->createInstance<Plasma::DataEngine>(0, allArgs, &error);
|
||||
qDebug() << "DE";
|
||||
if (engine) {
|
||||
engine->connectSource("Europe/Amsterdam", this);
|
||||
qDebug() << "SOURCE: " << engine->sources();
|
||||
//qDebug() << "DataEngine ID: " << engine->pluginInfo().name();
|
||||
} else {
|
||||
qDebug() << "Engine invalid";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Plugin version incompatible" << plugin.pluginVersion();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
engine = new DataEngine(KPluginInfo(offers.first()), 0);
|
||||
qDebug() << "DataEngine ID (from KPluginINfo): " << engine << engine->pluginInfo().icon() << engine->pluginInfo().name();
|
||||
}
|
||||
QStringList result;
|
||||
foreach (const KService::Ptr &service, offers) {
|
||||
const QString _plugin = service->property("X-KDE-PluginInfo-Name", QVariant::String).toString();
|
||||
qDebug() << "Found plugin: " << _plugin;
|
||||
if (!result.contains(_plugin)) {
|
||||
result << _plugin;
|
||||
//engine = PluginLoader::self()->loadDataEngine(_plugin);
|
||||
//engine = PluginLoader::self()->loadDataEngine(name);
|
||||
//qDebug() << "SOURCE: " << engine->sources();
|
||||
|
||||
//engine->setPluginInfo(service->pluginInfo());
|
||||
//qDebug() << engine->pluginInfo().name();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!engine) {
|
||||
qDebug() << "Couldn't load engine \"" << name << "\". Error given: " << error;
|
||||
}
|
||||
|
||||
return engine != 0;
|
||||
}
|
||||
|
||||
void PluginTest::dataUpdated(QString s, Plasma::DataEngine::Data d)
|
||||
{
|
||||
// qDebug() << "new data for source: " << s << d;
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include "moc_plugintest.cpp"
|
||||
|
60
src/plasma/tests/kplugins/plugintest.h
Normal file
60
src/plasma/tests/kplugins/plugintest.h
Normal file
@ -0,0 +1,60 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2012 Sebastian Kügler <sebas@kde.org> *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public License *
|
||||
* along with this library; see the file COPYING.LIB. If not, write to *
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
||||
* Boston, MA 02110-1301, USA. *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PLUGINTEST_H
|
||||
#define PLUGINTEST_H
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
|
||||
class QCommandLineParser;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class PluginTestPrivate;
|
||||
|
||||
class PluginTest : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PluginTest(int& argc, char** argv, QCommandLineParser *parser);
|
||||
virtual ~PluginTest();
|
||||
|
||||
void showPackageInfo(const QString &pluginName);
|
||||
|
||||
public Q_SLOTS:
|
||||
void runMain();
|
||||
bool loadKPlugin();
|
||||
bool loadFromKService(const QString &name = "time");
|
||||
bool loadFromPlasma();
|
||||
void loadKQPlugin();
|
||||
bool loadKService(const QString &name = QString());
|
||||
void dataUpdated(QString s, Plasma::DataEngine::Data d);
|
||||
|
||||
private:
|
||||
PluginTestPrivate* d;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -191,7 +191,7 @@ bool ScriptEnv::importBuiltinExtension(const QString &extension, QScriptValue &o
|
||||
|
||||
bool ScriptEnv::importExtensions(const KPluginInfo &info, QScriptValue &obj, Authorization &auth)
|
||||
{
|
||||
QStringList requiredExtensions = info.service()->property("X-Plasma-RequiredExtensions", QVariant::StringList).toStringList();
|
||||
QStringList requiredExtensions = info.property("X-Plasma-RequiredExtensions", QVariant::StringList).toStringList();
|
||||
if (!requiredExtensions.isEmpty()) {
|
||||
// qDebug() << "required extensions are" << requiredExtensions;
|
||||
}
|
||||
@ -219,7 +219,7 @@ bool ScriptEnv::importExtensions(const KPluginInfo &info, QScriptValue &obj, Aut
|
||||
}
|
||||
}
|
||||
|
||||
QStringList optionalExtensions = info.service()->property("X-Plasma-OptionalExtensions", QVariant::StringList).toStringList();
|
||||
QStringList optionalExtensions = info.property("X-Plasma-OptionalExtensions", QVariant::StringList).toStringList();
|
||||
if (!optionalExtensions.isEmpty()) {
|
||||
// qDebug() << "optional extensions are" << optionalExtensions;
|
||||
}
|
||||
|
@ -69,4 +69,5 @@ private:
|
||||
friend class AppletInterface;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <k4aboutdata.h>
|
||||
|
||||
// KIO
|
||||
#include <kemailsettings.h> // no camelcase include
|
||||
//#include <kemailsettings.h> // no camelcase include
|
||||
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/Containment>
|
||||
@ -382,10 +382,11 @@ QScriptValue ScriptEngine::defaultApplication(QScriptContext *context, QScriptEn
|
||||
// specific implementation system. there is much room for improvement here. see
|
||||
// kdebase-runtime/kcontrol/componentchooser/ for all the gory details ;)
|
||||
if (application.compare("mailer", Qt::CaseInsensitive) == 0) {
|
||||
KEMailSettings settings;
|
||||
// KEMailSettings settings;
|
||||
|
||||
// in KToolInvocation, the default is kmail; but let's be friendlier :)
|
||||
QString command = settings.getSetting(KEMailSettings::ClientProgram);
|
||||
// QString command = settings.getSetting(KEMailSettings::ClientProgram);
|
||||
QString command;
|
||||
if (command.isEmpty()) {
|
||||
if (KService::Ptr kontact = KService::serviceByStorageId("kontact")) {
|
||||
return storageId ? kontact->storageId() : onlyExec(kontact->exec());
|
||||
@ -395,7 +396,8 @@ QScriptValue ScriptEngine::defaultApplication(QScriptContext *context, QScriptEn
|
||||
}
|
||||
|
||||
if (!command.isEmpty()) {
|
||||
if (settings.getSetting(KEMailSettings::ClientTerminal) == "true") {
|
||||
//if (settings.getSetting(KEMailSettings::ClientTerminal) == "true") {
|
||||
if (false) {
|
||||
KConfigGroup confGroup(KGlobal::config(), "General");
|
||||
const QString preferredTerminal = confGroup.readPathEntry("TerminalApplication", QString::fromLatin1("konsole"));
|
||||
command = preferredTerminal + QString::fromLatin1(" -e ") + command;
|
||||
|
@ -126,7 +126,7 @@ void PlasmaAppletItem::setRunning(int count)
|
||||
bool PlasmaAppletItem::matches(const QString &pattern) const
|
||||
{
|
||||
if (m_info.service()) {
|
||||
const QStringList keywords = m_info.service()->keywords();
|
||||
const QStringList keywords = m_info.property("Keywords").toStringList();
|
||||
foreach (const QString &keyword, keywords) {
|
||||
if (keyword.startsWith(pattern, Qt::CaseInsensitive)) {
|
||||
return true;
|
||||
|
10
tools/port-kdebug.sh
Normal file
10
tools/port-kdebug.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# kDebug() becomes qDebug() in cpp files
|
||||
|
||||
for FS in `find $PWD -type f -name '*.cpp'`; do
|
||||
perl -p -i -e 's/kDebug\(\)/qDebug()/g' $FS
|
||||
done
|
||||
|
||||
#exit;
|
||||
|
@ -61,6 +61,10 @@ for FS in `find $PWD -type f -name 'CMakeLists.txt'`; do
|
||||
perl -p -i -e 's/IMPORTS_INSTALL_DIR/QML_INSTALL_DIR/g' $FS
|
||||
done
|
||||
|
||||
for FS in `find $PWD -type f -name '*.h'`; do
|
||||
perl -p -i -e 's/slots/Q_SLOTS/g' $FS
|
||||
done
|
||||
|
||||
#exit;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user