chalk

kis_filter_registry.cpp
1/*
2 * Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
3 * Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#include <tqstring.h>
20#include <tqptrlist.h>
21
22#include <tdeaction.h>
23#include <kdebug.h>
24#include <tdelocale.h>
25#include <tdeparts/plugin.h>
26#include <kservice.h>
27#include <ktrader.h>
28#include <tdeparts/componentfactory.h>
29#include "kis_debug_areas.h"
30#include <math.h>
31#include "kis_types.h"
32#include "kis_filter_registry.h"
33#include "kis_paint_device.h"
34#include "kis_filter.h"
35
36KisFilterRegistry *KisFilterRegistry::m_singleton = 0;
37
38KisFilterRegistry::KisFilterRegistry()
39{
40 Q_ASSERT(KisFilterRegistry::m_singleton == 0);
41 KisFilterRegistry::m_singleton = this;
42
43 TDETrader::OfferList offers = TDETrader::self()->query(TQString::fromLatin1("Chalk/Filter"),
44 TQString::fromLatin1("(Type == 'Service') and "
45 "([X-Chalk-Version] == 2)"));
46
47 TDETrader::OfferList::ConstIterator iter;
48
49 for(iter = offers.begin(); iter != offers.end(); ++iter)
50 {
51 KService::Ptr service = *iter;
52 int errCode = 0;
53 KParts::Plugin* plugin =
54 KParts::ComponentFactory::createInstanceFromService<KParts::Plugin> ( service, this, 0, TQStringList(), &errCode);
55 if ( plugin )
56 kdDebug(DBG_AREA_PLUGINS) << "found plugin " << service->property("Name").toString() << "\n";
57 else {
58 kdDebug(41006) << "found plugin " << service->property("Name").toString() << ", " << errCode << "\n";
59 if( errCode == KParts::ComponentFactory::ErrNoLibrary)
60 {
61 kdWarning(41006) << " Error loading plugin was : ErrNoLibrary " << KLibLoader::self()->lastErrorMessage() << endl;
62 }
63 }
64
65 }
66
67}
68
69KisFilterRegistry::~KisFilterRegistry()
70{
71}
72
73KisFilterRegistry* KisFilterRegistry::instance()
74{
75 if(KisFilterRegistry::m_singleton == 0)
76 {
77 KisFilterRegistry::m_singleton = new KisFilterRegistry();
78 }
79 return KisFilterRegistry::m_singleton;
80}
81
82#include "kis_filter_registry.moc"