• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KNewStuff

dxsengine.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of KNewStuff2.
00003     Copyright (c) 2007 Josef Spillner <spillner@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "dxsengine.h"
00022 
00023 #include "dxs.h"
00024 
00025 #include <knewstuff2/core/category.h>
00026 #include <kdebug.h>
00027 
00028 using namespace KNS;
00029 
00030 DxsEngine::DxsEngine(QObject* parent)
00031         : CoreEngine(parent), m_dxspolicy(DxsIfPossible)
00032 {
00033 }
00034 
00035 DxsEngine::~DxsEngine()
00036 {
00037 }
00038 
00039 void DxsEngine::setDxsPolicy(Policy policy)
00040 {
00041     m_dxspolicy = policy;
00042 }
00043 
00044 // get the dxs object
00045 Dxs * DxsEngine::dxsObject(const Provider * provider)
00046 {
00047     return (m_dxsbyprovider.contains(provider) ? m_dxsbyprovider.value(provider) : NULL);
00048 }
00049 
00050 void DxsEngine::loadEntries(Provider *provider)
00051 {
00053     // Ensure that the provider offers DXS at all
00054     // Match DXS offerings with the engine's policy
00055     if (provider->webService().isValid()) {
00056         if (m_dxspolicy == DxsNever) {
00057             CoreEngine::loadEntries(provider);
00058             return;
00059         }
00060     } else {
00061         if (m_dxspolicy != DxsAlways) {
00062             CoreEngine::loadEntries(provider);
00063             return;
00064         } else {
00065             kError() << "DxsEngine: DXS requested but not offered" << endl;
00066             return;
00067         }
00068     }
00069 
00070     // From here on, it's all DXS now
00071 
00072     if (!m_dxsbyprovider.contains(provider)) {
00073         Dxs * dxs = new Dxs(this, provider);
00074         dxs->setEndpoint(provider->webService());
00075         // connect entries signal
00076         connect(dxs, SIGNAL(signalEntries(KNS::Entry::List, Feed*)),
00077                 SLOT(slotEntriesLoadedDXS(KNS::Entry::List, Feed*)));
00078         // FIXME: which one of signalFault()/signalError()? Or both?
00079         connect(dxs, SIGNAL(signalFault()),
00080                 SLOT(slotEntriesFailed()));
00081         // connect categories signal
00082         connect(dxs, SIGNAL(signalCategories(QList<KNS::Category*>)),
00083                 SLOT(slotCategories(QList<KNS::Category*>)));
00084         m_dxsbyprovider.insert(provider, dxs);
00085     }
00086 
00087     Dxs * dxs = m_dxsbyprovider.value(provider);
00088 
00089     dxs->call_categories();
00090 }
00091 
00092 void DxsEngine::slotCategories(QList<KNS::Category*> categories)
00093 {
00094     Dxs * dxs = qobject_cast<Dxs*>(sender());
00095     Provider * provider = dxs->provider();
00096 
00097     //kDebug() << "slot categories called for provider: " << provider->name().representation();
00098 
00099     for (QList<KNS::Category*>::iterator it = categories.begin(); it != categories.end(); ++it) {
00100         Category *category = (*it);
00101         QStringList feeds = provider->feeds();
00102         for (int i = 0; i < feeds.size(); ++i) {
00103             dxs->call_entries(category->id(), feeds.at(i));
00104         }
00105     }
00106 }
00107 
00108 void DxsEngine::slotEntriesLoadedDXS(KNS::Entry::List list, Feed * feed)
00109 {
00110     Dxs * dxs = qobject_cast<Dxs*>(sender());
00111     Provider * provider = dxs->provider();
00112 
00113     mergeEntries(list, feed, provider);
00114 }
00115 
00116 void DxsEngine::slotEntriesFailed()
00117 {
00118     emit signalEntriesFailed();
00119 }
00120 
00121 #include "dxsengine.moc"

KNewStuff

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal