fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / kio / kio / kfilewriteplugin.cpp
blob3cc4ec1aaccbab03ef258a38458fbdd3cd2819d9
1 /* This file is part of the KDE libraries
3 Copyright (c) 2007 Jos van den Oever <jos@vandenoever.info>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library 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 GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
20 #include "kfilemetainfo_p.h"
21 #include "kglobal.h"
22 #include "kservicetypetrader.h"
23 #include <QHash>
24 #include <QDebug>
26 KFileWritePlugin::KFileWritePlugin(QObject* parent, const QStringList&)
27 :QObject(parent), d(0)
31 KFileWritePlugin::~KFileWritePlugin() {
34 K_GLOBAL_STATIC(KFileWriterProvider, staticKFileWriterProvider)
36 KFileWriterProvider*
37 KFileWriterProvider::self() {
38 return staticKFileWriterProvider;
41 KFileWriterProvider::~KFileWriterProvider() {
42 qDeleteAll(plugins);
43 plugins.clear();
46 KFileWritePlugin*
47 KFileWriterProvider::loadPlugin(const QString& key) {
48 //kDebug() << "loading writer for key " << key;
49 const QString constraint = QString::fromLatin1("'%1' in MetaDataKeys")
50 .arg(key);
51 KService::List offers = KServiceTypeTrader::self()->query(
52 "KFileWrite", constraint);
53 if (offers.isEmpty()) {
54 return 0;
56 return offers.first()->createInstance<KFileWritePlugin>();
59 #include "kfilewriteplugin.moc"