2
Copyright (C) 2010 Kai Dombrowe <just89@gmx.de>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
#include "pluginmanager_p.h"
23
#include <QtCore/QDir>
24
#include <QtCore/QPluginLoader>
30
PluginManager::PluginManager(QObject *parent)
39
QList<Joschy::PluginInfo> PluginManager::availableProvider() const
42
QList<Joschy::PluginInfo> list;
43
foreach (const PluginInfo &info, m_pluginList) {
44
if (info.type() == Joschy::PluginInfo::ProviderType) {
53
QList<Joschy::PluginInfo> PluginManager::availableNetworkLayer() const
56
QList<Joschy::PluginInfo> list;
57
foreach (const PluginInfo &info, m_pluginList) {
58
if (info.type() == Joschy::PluginInfo::NetworkLayerType) {
67
void PluginManager::unloadPlugin(Joschy::Plugin *plugin)
70
if (m_loadedPlugins.contains(plugin)) {
71
m_loadedPlugins.removeAll(plugin);
78
void PluginManager::updatePluginList()
83
JOSCHY_DEBUG() << "load plugin list...";
84
const QStringList filters = QStringList() << "*.plugin";
85
foreach (const QString &pluginDir, Joschy::PluginInfo::pluginDirs()) {
86
JOSCHY_DEBUG() << "PluginDir:" << pluginDir;
88
foreach (const QString &file, dir.entryList(filters, QDir::Files)) {
89
m_pluginList.append(PluginInfo(dir.absoluteFilePath(file)));
92
JOSCHY_DEBUG() << "Done: " << m_pluginList.size();
97
Joschy::Plugin *PluginManager::loadPluginInternal(const Joschy::PluginInfo &info)
100
JOSCHY_DEBUG() << "load:" << info.library();
101
QPluginLoader loader(info.library());
102
QObject *instance = loader.instance();
104
JOSCHY_DEBUG() << "success";
105
Joschy::Plugin *plugin = qobject_cast<Joschy::Plugin*>(instance);
106
m_loadedPlugins.append(plugin);
107
plugin->setPluginManager(this);
110
JOSCHY_DEBUG() << "error:" << loader.errorString();
117
} // namespace Joschy
120
#include "pluginmanager_p.moc"