• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.8.3 API Reference
  • KDE Home
  • Contact Us
 

KNewStuff

providerloader.cpp
Go to the documentation of this file.
00001 /*
00002     This file is part of KNewStuff2.
00003     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
00004     Copyright (c) 2003 - 2007 Josef Spillner <spillner@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public
00017     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 #include "providerloader.h"
00021 
00022 #include "providerhandler.h"
00023 
00024 #include <QtCore/QByteArray>
00025 
00026 #include <kconfig.h>
00027 #include <kdebug.h>
00028 #include <kio/job.h>
00029 #include <klocale.h>
00030 
00031 using namespace KNS;
00032 
00033 ProviderLoader::ProviderLoader(QObject* parent)
00034         : QObject(parent)
00035 {
00036 }
00037 
00038 void ProviderLoader::load(const QString &providersurl)
00039 {
00040     //kDebug(550) << "ProviderLoader::load()";
00041 
00042     m_providers.clear();
00043     m_jobdata.clear();
00044 
00045     //kDebug(550) << "ProviderLoader::load(): providersUrl: " << providersurl;
00046 
00047     KIO::TransferJob *job = KIO::get(KUrl(providersurl), KIO::NoReload, KIO::HideProgressInfo);
00048     connect(job, SIGNAL(result(KJob*)),
00049             SLOT(slotJobResult(KJob*)));
00050     connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
00051             SLOT(slotJobData(KIO::Job*,QByteArray)));
00052 }
00053 
00054 void ProviderLoader::slotJobData(KIO::Job *, const QByteArray &data)
00055 {
00056     //kDebug(550) << "ProviderLoader::slotJobData()";
00057 
00058     m_jobdata.append(data);
00059 }
00060 
00061 void ProviderLoader::slotJobResult(KJob *job)
00062 {
00063     if (job->error()) {
00064         emit signalProvidersFailed();
00065         return;
00066     }
00067 
00068     //kDebug(550) << "--PROVIDERS-START--";
00069     //kDebug(550) << QString::fromUtf8(m_jobdata);
00070     //kDebug(550) << "--PROVIDERS-END--";
00071 
00072     QDomDocument doc;
00073     if (!doc.setContent(m_jobdata)) {
00074         emit signalProvidersFailed();
00075         return;
00076     }
00077 
00078     QDomElement providers = doc.documentElement();
00079 
00080     if (providers.tagName() != "ghnsproviders" &&
00081             providers.tagName() != "knewstuffproviders") {
00082         kWarning(550) << "No document in providers.xml.";
00083         emit signalProvidersFailed();
00084         return;
00085     }
00086 
00087     QDomNode n;
00088     for (n = providers.firstChild(); !n.isNull(); n = n.nextSibling()) {
00089         QDomElement p = n.toElement();
00090 
00091         if (p.tagName() == "provider") {
00092             ProviderHandler handler(p);
00093             m_providers.append(handler.providerptr());
00094         }
00095     }
00096 
00097     emit signalProvidersLoaded(m_providers);
00098 }
00099 
00100 #include "providerloader.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 20:57:20 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KNewStuff

Skip menu "KNewStuff"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.8.3 API Reference

Skip menu "kdelibs-4.8.3 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal