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

KNewStuff

  • sources
  • kde-4.12
  • kdelibs
  • 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 
26 using namespace KNS;
27 
28 DxsEngine::DxsEngine(QObject* parent)
29  : CoreEngine(parent), m_dxspolicy(DxsIfPossible)
30 {
31 }
32 
33 DxsEngine::~DxsEngine()
34 {
35 }
36 
37 void DxsEngine::setDxsPolicy(Policy policy)
38 {
39  m_dxspolicy = policy;
40 }
41 
42 // get the dxs object
43 Dxs * DxsEngine::dxsObject(const Provider * provider)
44 {
45  return (m_dxsbyprovider.contains(provider) ? m_dxsbyprovider.value(provider) : NULL);
46 }
47 
48 void 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 
90 void 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 
106 void 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 
114 void DxsEngine::slotEntriesFailed()
115 {
116  emit signalEntriesFailed();
117 }
118 
119 #include "dxsengine.moc"
dxsengine.h
KNS::Dxs::call_entries
void call_entries(QString category, QString feed)
Definition: dxs.cpp:73
kdebug.h
category.h
KNS::DxsEngine::setDxsPolicy
void setDxsPolicy(Policy policy)
Definition: dxsengine.cpp:37
KNS::CoreEngine::loadEntries
void loadEntries(Provider *provider)
Loads all entries of all the feeds from a provider.
Definition: coreengine.cpp:231
KNS::Dxs
KNewStuff DXS proxy.
Definition: dxs.h:48
kError
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KNS::DxsEngine::~DxsEngine
~DxsEngine()
Definition: dxsengine.cpp:33
QObject
KNS::Dxs::provider
Provider * provider()
Definition: dxs.cpp:47
KNS::DxsEngine::dxsObject
Dxs * dxsObject(const Provider *provider)
Definition: dxsengine.cpp:43
KNS::CoreEngine
KNewStuff core engine.
Definition: coreengine.h:47
KNS::DxsEngine::DxsAlways
Definition: dxsengine.h:49
KNS::DxsEngine::DxsEngine
DxsEngine(QObject *parent)
Definition: dxsengine.cpp:28
KNS::Category
KNewStuff category.
Definition: category.h:35
QStringList
KNS::DxsEngine::Policy
Policy
Definition: dxsengine.h:46
KNS::Dxs::call_categories
void call_categories()
Definition: dxs.cpp:66
KNS::Category::id
QString id() const
Retrieve the unique id of the category.
Definition: category.cpp:45
KNS::CoreEngine::signalEntriesFailed
void signalEntriesFailed()
KNS::DxsEngine::DxsNever
Definition: dxsengine.h:47
KNS::DxsEngine::loadEntries
void loadEntries(Provider *provider)
Definition: dxsengine.cpp:48
KNS::Provider::webService
KUrl webService() const
Retrieves the URL to the DXS Web Service.
Definition: knewstuff2/core/provider.cpp:114
dxs.h
KNS::Dxs::setEndpoint
void setEndpoint(KUrl endpoint)
Definition: dxs.cpp:52
KNS::Feed
KNewStuff feed.
Definition: feed.h:45
KNS::Provider
KNewStuff provider container.
Definition: knewstuff2/core/provider.h:51
QList< Entry * >
KNS::CoreEngine::mergeEntries
void mergeEntries(Entry::List entries, Feed *feed, const Provider *provider)
Definition: coreengine.cpp:1036
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:48 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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