1 | /* This file is part of the KDE project |
2 | Copyright (C) 2009, 2012 Dag Andersen <danders@get2net.dk> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
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 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | |
21 | #include "kptschedulerpluginloader.h" |
22 | |
23 | #include "kptschedulerplugin.h" |
24 | #include "kptdebug.h" |
25 | |
26 | #include <kservicetypetrader.h> |
27 | #include <kdebug.h> |
28 | |
29 | |
30 | namespace KPlato |
31 | { |
32 | |
33 | SchedulerPluginLoader::SchedulerPluginLoader(QObject * parent) |
34 | : QObject(parent) |
35 | { |
36 | } |
37 | |
38 | SchedulerPluginLoader::~SchedulerPluginLoader() |
39 | { |
40 | } |
41 | |
42 | void SchedulerPluginLoader::loadAllPlugins() |
43 | { |
44 | kDebug(planDbg()) << "Load all plugins" ; |
45 | KService::List offers = KServiceTypeTrader::self()->query("Plan/SchedulerPlugin" ); |
46 | |
47 | KService::List::const_iterator iter; |
48 | for(iter = offers.constBegin(); iter < offers.constEnd(); ++iter) |
49 | { |
50 | QString error; |
51 | KService::Ptr service = *iter; |
52 | |
53 | KPluginFactory *factory = KPluginLoader(service->library()).factory(); |
54 | |
55 | if (!factory) |
56 | { |
57 | kError() << "KPluginFactory could not load the plugin:" << service->library(); |
58 | continue; |
59 | } |
60 | |
61 | SchedulerPlugin *plugin = factory->create<SchedulerPlugin>(this); |
62 | |
63 | if (plugin) { |
64 | kDebug(planDbg()) << "Load plugin:" << service->name()<<", " <<service->comment(); |
65 | plugin->setName( service->name() ); |
66 | plugin->setComment( service->comment() ); |
67 | emit pluginLoaded( service->library(), plugin); |
68 | } else { |
69 | kDebug(planDbg()) << error; |
70 | } |
71 | } |
72 | } |
73 | |
74 | } //namespace KPlato |
75 | |