2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
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.
19 typedef Repository
* PluginFactory(IVariantLoader
*);
21 Repository
* Variants::load(const KService::Ptr
& plugin
) {
23 QString symbol
= plugin
->library() + "_initrepo";
24 KLibrary
pluginLib(plugin
->library());
26 // resolve initrepo function
27 void* initrepo_
= pluginLib
.resolveSymbol(qPrintable(symbol
));
29 kWarning() << "Error loading plugin" << plugin
->library();
30 kWarning() << pluginLib
.errorString();
33 PluginFactory
* initrepo
= reinterpret_cast<PluginFactory
*>(initrepo_
);
35 return (*initrepo
)(this);
38 Variants::Variants() { }
40 Variants
& Variants::self() {
45 Variant
* Variants::create(const KService::Ptr
& plugin
) {
46 Repository
* repo
= load(plugin
);
48 return new Variant(plugin
->name(), repo
,
49 plugin
->property("X-Tagua-Proxy").toString());
54 Variant
* Variants::create(const QString
& name
) {
55 KService::Ptr service
= get(name
);
56 return service
? create(service
) : 0;
59 KService::Ptr
Variants::get(const QString
& name
) {
60 KService::List services
=
61 KServiceTypeTrader::self()->query("Tagua/Variant",
62 "Name =~ '" + name
+ "'");
64 return KService::Ptr();
69 KService::List
Variants::all() const {
70 return KServiceTypeTrader::self()->query(
71 "Tagua/Variant", "[X-Tagua-Hidden] == false");
74 Repository
* Variants::getRepository(const QString
& variant
) {
75 KService::Ptr service
= get(variant
);
76 if (!service
) return 0;