• 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
  • knewstuff3
  • core
knewstuff3/core/engine.h
Go to the documentation of this file.
1 /*
2  knewstuff3/engine.h.
3  Copyright (c) 2007 Josef Spillner <spillner@kde.org>
4  Copyright (C) 2007-2010 Frederik Gladhorn <gladhorn@kde.org>
5  Copyright (c) 2009 Jeremy Whiting <jpwhiting@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef KNEWSTUFF3_ENGINE_H
22 #define KNEWSTUFF3_ENGINE_H
23 
24 #include <QtCore/QObject>
25 #include <QtCore/QString>
26 #include <QtCore/QMap>
27 
28 #include "provider.h"
29 #include "entryinternal.h"
30 
31 class QTimer;
32 class KJob;
33 
34 namespace Attica {
35  class ProviderManager;
36  class Provider;
37 }
38 
39 namespace KNS3
40 {
41 class Cache;
42 class Installation;
43 
52 class Engine : public QObject
53 {
54  Q_OBJECT
55 public:
59  Engine(QObject* parent = 0);
60 
65  ~Engine();
66 
75  bool init(const QString &configfile);
76 
89  void install(KNS3::EntryInternal entry, int linkId = 1);
90 
97  void uninstall(KNS3::EntryInternal entry);
98 
99  void loadPreview(const KNS3::EntryInternal& entry, EntryInternal::PreviewType type);
100  void loadDetails(const KNS3::EntryInternal& entry);
101 
102  void setSortMode(Provider::SortMode mode);
103 
107  void setCategoriesFilter(const QStringList& categories);
108  void setSearchTerm(const QString& searchString);
109  void reloadEntries();
110  void requestMoreData();
111  void requestData(int page, int pageSize);
112 
113  void checkForUpdates();
114 
118  void contactAuthor(const EntryInternal& entry);
119 
120  bool userCanVote(const EntryInternal& entry);
121  void vote(const EntryInternal& entry, uint rating);
122  bool userCanBecomeFan(const EntryInternal& entry);
123  void becomeFan(const EntryInternal& entry);
124 
125  QStringList categories() const;
126  QStringList categoriesFilter() const;
127 
128 Q_SIGNALS:
132  void signalMessage(const QString& message);
133 
134  void signalProvidersLoaded();
135  void signalEntriesLoaded(const KNS3::EntryInternal::List& entries);
136  void signalUpdateableEntriesLoaded(const KNS3::EntryInternal::List& entries);
137  void signalEntryChanged(const KNS3::EntryInternal& entry);
138  void signalEntryDetailsLoaded(const KNS3::EntryInternal& entry);
139 
140  // a new search result is there, clear the list of items
141  void signalResetView();
142 
143  void signalEntryPreviewLoaded(const KNS3::EntryInternal&, KNS3::EntryInternal::PreviewType);
144  void signalPreviewFailed();
145 
146  void signalEntryUploadFinished();
147  void signalEntryUploadFailed();
148 
149  void signalDownloadDialogDone(KNS3::EntryInternal::List);
150  void jobStarted(KJob*,const QString&);
151 
152  void signalError(const QString&);
153  void signalBusy(const QString&);
154  void signalIdle(const QString&);
155 
156 private Q_SLOTS:
157  // the .knsrc file was loaded
158  void slotProviderFileLoaded(const QDomDocument& doc);
159  // instead of getting providers from knsrc, use what was configured in ocs systemsettings
160  void atticaProviderLoaded(const Attica::Provider& provider);
161 
162  // loading the .knsrc file failed
163  void slotProvidersFailed();
164 
165  // called when a provider is ready to work
166  void providerInitialized(KNS3::Provider*);
167 
168  void slotEntriesLoaded(const KNS3::Provider::SearchRequest&, KNS3::EntryInternal::List);
169  void slotEntryDetailsLoaded(const KNS3::EntryInternal& entry);
170  void slotPreviewLoaded(const KNS3::EntryInternal& entry, KNS3::EntryInternal::PreviewType type);
171 
172  void slotSearchTimerExpired();
173 
174  void slotEntryChanged(const KNS3::EntryInternal& entry);
175  void slotInstallationFinished();
176  void slotInstallationFailed(const QString& message);
177  void downloadLinkLoaded(const KNS3::EntryInternal& entry);
178 
179  void providerJobStarted(KJob*);
180 
181 private:
186  void loadProviders();
187 
191  void addProvider(QSharedPointer<KNS3::Provider> provider);
192 
193  void updateStatus();
194 
195  void doRequest();
196 
197  // If the provider is ready to be used
198  bool m_initialized;
199  // handle installation of entries
200  Installation* m_installation;
201  // read/write cache of entries
202  QSharedPointer<Cache> m_cache;
203  QTimer* m_searchTimer;
204  // The url of the file containing information about content providers
205  QString m_providerFileUrl;
206  // Categories from knsrc file
207  QStringList m_categories;
208 
209  QHash<QString, QSharedPointer<KNS3::Provider> > m_providers;
210 
211  // the name of the app that uses hot new stuff
212  QString m_applicationName;
213 
214  // the current request from providers
215  Provider::SearchRequest m_currentRequest;
216 
217  // the page that is currently displayed, so it is not requested repeatedly
218  int m_currentPage;
219 
220  // when requesting entries from a provider, how many to ask for
221  int m_pageSize;
222 
223  int m_numDataJobs;
224  int m_numPictureJobs;
225  int m_numInstallJobs;
226  Attica::ProviderManager* m_atticaProviderManager;
227 
228  Q_DISABLE_COPY(Engine)
229 };
230 
231 }
232 
233 #endif
message
void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
KNS3::Provider
KNewStuff Base Provider class.
Definition: knewstuff3/core/provider.h:46
KNS3::Engine::signalUpdateableEntriesLoaded
void signalUpdateableEntriesLoaded(const KNS3::EntryInternal::List &entries)
KNS3::Engine::Engine
Engine(QObject *parent=0)
Constructor.
Definition: knewstuff3/core/engine.cpp:65
KNS3::Engine::becomeFan
void becomeFan(const EntryInternal &entry)
Definition: knewstuff3/core/engine.cpp:520
KNS3::Engine::signalEntryUploadFinished
void signalEntryUploadFinished()
KNS3::Engine::requestData
void requestData(int page, int pageSize)
Definition: knewstuff3/core/engine.cpp:372
KNS3::EntryInternal
KNewStuff data entry container.
Definition: entryinternal.h:54
KNS3::Engine::signalBusy
void signalBusy(const QString &)
provider.h
KNS3::Engine
KNewStuff engine.
Definition: knewstuff3/core/engine.h:52
KNS3::Engine::signalEntryUploadFailed
void signalEntryUploadFailed()
KNS3::Engine::loadDetails
void loadDetails(const KNS3::EntryInternal &entry)
Definition: knewstuff3/core/engine.cpp:463
KNS3::Engine::setSearchTerm
void setSearchTerm(const QString &searchString)
Definition: knewstuff3/core/engine.cpp:343
KNS3::Engine::contactAuthor
void contactAuthor(const EntryInternal &entry)
Try to contact the author of the entry by email or showing their homepage.
Definition: knewstuff3/core/engine.cpp:487
KNS3::Engine::signalEntryPreviewLoaded
void signalEntryPreviewLoaded(const KNS3::EntryInternal &, KNS3::EntryInternal::PreviewType)
QString
KNS3::Provider::SortMode
SortMode
Definition: knewstuff3/core/provider.h:52
QHash
QObject
KNS3::Engine::requestMoreData
void requestMoreData()
Definition: knewstuff3/core/engine.cpp:360
KNS3::Engine::signalPreviewFailed
void signalPreviewFailed()
KNS3::Engine::signalError
void signalError(const QString &)
KNS3::Engine::signalEntryDetailsLoaded
void signalEntryDetailsLoaded(const KNS3::EntryInternal &entry)
KNS3::Provider::SearchRequest
used to keep track of a search
Definition: knewstuff3/core/provider.h:64
KNS3::Engine::signalMessage
void signalMessage(const QString &message)
Indicates a message to be added to the ui's log, or sent to a messagebox.
KNS3::Engine::userCanVote
bool userCanVote(const EntryInternal &entry)
Definition: knewstuff3/core/engine.cpp:502
KNS3::Engine::categoriesFilter
QStringList categoriesFilter() const
Definition: knewstuff3/core/engine.cpp:161
KNS3::Engine::signalProvidersLoaded
void signalProvidersLoaded()
KNS3::Engine::signalEntriesLoaded
void signalEntriesLoaded(const KNS3::EntryInternal::List &entries)
KNS3::Engine::userCanBecomeFan
bool userCanBecomeFan(const EntryInternal &entry)
Definition: knewstuff3/core/engine.cpp:514
QStringList
KNS3::Engine::categories
QStringList categories() const
Definition: knewstuff3/core/engine.cpp:156
KNS3::Engine::setSortMode
void setSortMode(Provider::SortMode mode)
Definition: knewstuff3/core/engine.cpp:334
KNS3::Engine::jobStarted
void jobStarted(KJob *, const QString &)
KNS3::EntryInternal::PreviewType
PreviewType
Definition: entryinternal.h:70
KNS3::Engine::init
bool init(const QString &configfile)
Initializes the engine.
Definition: knewstuff3/core/engine.cpp:96
KNS3::Engine::install
void install(KNS3::EntryInternal entry, int linkId=1)
Installs an entry's payload file.
Definition: knewstuff3/core/engine.cpp:390
entryinternal.h
KNS3::Engine::checkForUpdates
void checkForUpdates()
Definition: knewstuff3/core/engine.cpp:539
KNS3::Engine::vote
void vote(const EntryInternal &entry, uint rating)
Definition: knewstuff3/core/engine.cpp:508
KNS3::Engine::signalDownloadDialogDone
void signalDownloadDialogDone(KNS3::EntryInternal::List)
KNS3::Engine::reloadEntries
void reloadEntries()
Definition: knewstuff3/core/engine.cpp:287
KNS3::Engine::setCategoriesFilter
void setCategoriesFilter(const QStringList &categories)
Set the categories that will be included in searches.
Definition: knewstuff3/core/engine.cpp:328
KNS3::Engine::signalIdle
void signalIdle(const QString &)
KNS3::Installation
KNewStuff entry installation.
Definition: knewstuff3/core/installation.h:45
KNS3::Engine::signalResetView
void signalResetView()
KNS3::Engine::~Engine
~Engine()
Destructor.
Definition: knewstuff3/core/engine.cpp:86
KJob
KNS3::Engine::loadPreview
void loadPreview(const KNS3::EntryInternal &entry, EntryInternal::PreviewType type)
Definition: knewstuff3/core/engine.cpp:469
QList< EntryInternal >
KNS3::Engine::uninstall
void uninstall(KNS3::EntryInternal entry)
Uninstalls an entry.
Definition: knewstuff3/core/engine.cpp:432
KNS3::Engine::signalEntryChanged
void signalEntryChanged(const KNS3::EntryInternal &entry)
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