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

KNewStuff

  • knewstuff
  • knewstuff2
  • dxs
dxsengine.cpp
Go to the documentation of this file.
1/*
2 This file is part of KNewStuff2.
3 Copyright (c) 2007 Josef Spillner <spillner@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "dxsengine.h"
20
21#include "dxs.h"
22
23#include <knewstuff2/core/category.h>
24#include <kdebug.h>
25
26using namespace KNS;
27
28DxsEngine::DxsEngine(QObject* parent)
29 : CoreEngine(parent), m_dxspolicy(DxsIfPossible)
30{
31}
32
33DxsEngine::~DxsEngine()
34{
35}
36
37void DxsEngine::setDxsPolicy(Policy policy)
38{
39 m_dxspolicy = policy;
40}
41
42// get the dxs object
43Dxs * DxsEngine::dxsObject(const Provider * provider)
44{
45 return (m_dxsbyprovider.contains(provider) ? m_dxsbyprovider.value(provider) : NULL);
46}
47
48void DxsEngine::loadEntries(Provider *provider)
49{
51 // Ensure that the provider offers DXS at all
52 // Match DXS offerings with the engine's policy
53 if (provider->webService().isValid()) {
54 if (m_dxspolicy == DxsNever) {
55 CoreEngine::loadEntries(provider);
56 return;
57 }
58 } else {
59 if (m_dxspolicy != DxsAlways) {
60 CoreEngine::loadEntries(provider);
61 return;
62 } else {
63 kError() << "DxsEngine: DXS requested but not offered" << endl;
64 return;
65 }
66 }
67
68 // From here on, it's all DXS now
69
70 if (!m_dxsbyprovider.contains(provider)) {
71 Dxs * dxs = new Dxs(this, provider);
72 dxs->setEndpoint(provider->webService());
73 // connect entries signal
74 connect(dxs, SIGNAL(signalEntries(KNS::Entry::List,Feed*)),
75 SLOT(slotEntriesLoadedDXS(KNS::Entry::List,Feed*)));
76 // FIXME: which one of signalFault()/signalError()? Or both?
77 connect(dxs, SIGNAL(signalFault()),
78 SLOT(slotEntriesFailed()));
79 // connect categories signal
80 connect(dxs, SIGNAL(signalCategories(QList<KNS::Category*>)),
81 SLOT(slotCategories(QList<KNS::Category*>)));
82 m_dxsbyprovider.insert(provider, dxs);
83 }
84
85 Dxs * dxs = m_dxsbyprovider.value(provider);
86
87 dxs->call_categories();
88}
89
90void DxsEngine::slotCategories(QList<KNS::Category*> categories)
91{
92 Dxs * dxs = qobject_cast<Dxs*>(sender());
93 Provider * provider = dxs->provider();
94
95 //kDebug() << "slot categories called for provider: " << provider->name().representation();
96
97 for (QList<KNS::Category*>::iterator it = categories.begin(); it != categories.end(); ++it) {
98 Category *category = (*it);
99 QStringList feeds = provider->feeds();
100 for (int i = 0; i < feeds.size(); ++i) {
101 dxs->call_entries(category->id(), feeds.at(i));
102 }
103 }
104}
105
106void DxsEngine::slotEntriesLoadedDXS(KNS::Entry::List list, Feed * feed)
107{
108 Dxs * dxs = qobject_cast<Dxs*>(sender());
109 Provider * provider = dxs->provider();
110
111 mergeEntries(list, feed, provider);
112}
113
114void DxsEngine::slotEntriesFailed()
115{
116 emit signalEntriesFailed();
117}
118
119#include "dxsengine.moc"
category.h
KNS::Category
KNewStuff category.
Definition: category.h:36
KNS::Category::id
QString id() const
Retrieve the unique id of the category.
Definition: category.cpp:45
KNS::CoreEngine
KNewStuff core engine.
Definition: coreengine.h:48
KNS::CoreEngine::signalEntriesFailed
void signalEntriesFailed()
KNS::CoreEngine::mergeEntries
void mergeEntries(Entry::List entries, Feed *feed, const Provider *provider)
Definition: coreengine.cpp:1036
KNS::CoreEngine::loadEntries
void loadEntries(Provider *provider)
Loads all entries of all the feeds from a provider.
Definition: coreengine.cpp:231
KNS::DxsEngine::~DxsEngine
~DxsEngine()
Definition: dxsengine.cpp:33
KNS::DxsEngine::Policy
Policy
Definition: dxsengine.h:46
KNS::DxsEngine::DxsAlways
@ DxsAlways
Definition: dxsengine.h:49
KNS::DxsEngine::DxsNever
@ DxsNever
Definition: dxsengine.h:47
KNS::DxsEngine::DxsEngine
DxsEngine(QObject *parent)
Definition: dxsengine.cpp:28
KNS::DxsEngine::loadEntries
void loadEntries(Provider *provider)
Definition: dxsengine.cpp:48
KNS::DxsEngine::setDxsPolicy
void setDxsPolicy(Policy policy)
Definition: dxsengine.cpp:37
KNS::DxsEngine::dxsObject
Dxs * dxsObject(const Provider *provider)
Definition: dxsengine.cpp:43
KNS::Dxs
KNewStuff DXS proxy.
Definition: dxs.h:49
KNS::Dxs::call_entries
void call_entries(QString category, QString feed)
Definition: dxs.cpp:73
KNS::Dxs::provider
Provider * provider()
Definition: dxs.cpp:47
KNS::Dxs::call_categories
void call_categories()
Definition: dxs.cpp:66
KNS::Dxs::setEndpoint
void setEndpoint(KUrl endpoint)
Definition: dxs.cpp:52
KNS::Feed
KNewStuff feed.
Definition: feed.h:46
KNS::Provider
KNewStuff provider container.
Definition: knewstuff2/core/provider.h:52
KNS::Provider::feeds
QStringList feeds() const
Returns a list of all feeds.
Definition: knewstuff2/core/provider.cpp:119
KNS::Provider::webService
KUrl webService() const
Retrieves the URL to the DXS Web Service.
Definition: knewstuff2/core/provider.cpp:114
QList< Entry * >
QObject
dxs.h
dxsengine.h
kdebug.h
KNS
Definition: knewstuff2/core/author.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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.14.38 API Reference

Skip menu "kdelibs-4.14.38 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