diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kolf/pluginloader.cpp | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kolf/pluginloader.cpp')
-rw-r--r-- | kolf/pluginloader.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/kolf/pluginloader.cpp b/kolf/pluginloader.cpp new file mode 100644 index 00000000..23d1a494 --- /dev/null +++ b/kolf/pluginloader.cpp @@ -0,0 +1,65 @@ +#include <qstring.h> +#include <qvaluelist.h> +#include <qstringlist.h> +#include <qfile.h> +#include <qobject.h> + +#include <kdebug.h> +#include <kglobal.h> +#include <kstandarddirs.h> +#include <ksimpleconfig.h> +#include <klibloader.h> + +#include "pluginloader.h" + +ObjectList *PluginLoader::loadAll() +{ + ObjectList *ret = new ObjectList; + + QStringList libs; + QStringList files = KGlobal::dirs()->findAllResources("appdata", "*.plugin", false, true); + + for (QStringList::Iterator it = files.begin(); it != files.end(); ++it) + { + KSimpleConfig cfg(*it); + QString filename(cfg.readEntry("Filename", "")); + + libs.append(filename); + } + + for (QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) + { + Object *newObject = load(*it); + if (newObject) + ret->append(newObject); + } + + return ret; +} + +Object *PluginLoader::load(const QString &filename) +{ + KLibFactory *factory = KLibLoader::self()->factory(filename.latin1()); + + if (!factory) + { + kdWarning() << "no factory for " << filename << "!" << endl; + return 0; + } + + QObject *newObject = factory->create(0, "objectInstance", "Object"); + + if (!newObject) + { + kdWarning() << "no newObject for " << filename << "!" << endl; + return 0; + } + + Object *ret = dynamic_cast<Object *>(newObject); + + if (!ret) + kdWarning() << "no ret for " << filename << "!" << endl; + + return ret; +} + |