• 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
  • core
coreengine.h
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  Copyright (c) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef KNEWSTUFF2_COREENGINE_H
20 #define KNEWSTUFF2_COREENGINE_H
21 
22 #include <knewstuff2/core/provider.h>
23 #include <knewstuff2/core/entry.h>
24 
25 #include <knewstuff2/knewstuff_export.h>
26 
27 #include <QtCore/QObject>
28 #include <QtCore/QString>
29 #include <QtCore/QMap>
30 
31 class KJob;
32 class KArchiveDirectory;
33 
34 namespace KNS
35 {
36 
37 class Installation;
38 
47 class KNEWSTUFF_EXPORT CoreEngine : public QObject
48 {
49  Q_OBJECT
50 public:
54  CoreEngine(QObject* parent);
55 
60  ~CoreEngine();
61 
75  enum CachePolicy {
77  CacheNever,
79  CacheReplaceable,
81  CacheResident,
83  CacheOnly
84  };
85 
98  enum AutomationPolicy {
100  AutomationOn,
102  AutomationOff
103  };
104 
105  void setAutomationPolicy(AutomationPolicy policy);
106  void setCachePolicy(CachePolicy policy);
107 
116  bool init(const QString &configfile);
117 
142  void start();
143 
159  void loadEntries(Provider *provider);
160  //void loadProvider(); // FIXME: for consistency?
161 
173  void downloadPreview(Entry *entry);
174 
186  void downloadPayload(Entry *entry);
187 
203  bool uploadEntry(Provider *provider, Entry *entry);
204 
221  bool install(const QString& payloadfile);
222 
233  bool uninstall(KNS::Entry *entry);
234 
239  QString componentName() const;
240 
241 Q_SIGNALS:
247  void signalProviderLoaded(KNS::Provider *provider);
248  void signalProviderChanged(KNS::Provider *provider);
249  void signalProvidersFailed();
250 
251  void signalEntryLoaded(KNS::Entry *entry, const KNS::Feed *feed, const KNS::Provider *provider);
252  void signalEntryRemoved(KNS::Entry *entry, const KNS::Feed *feed);
253  void signalEntryChanged(KNS::Entry *entry);
254  void signalEntriesFailed();
255 
256  void signalPreviewLoaded(KUrl preview); // FIXME: return Entry
257  void signalPreviewFailed();
258 
259  void signalPayloadLoaded(KUrl payload); // FIXME: return Entry
260  void signalPayloadFailed(KNS::Entry *entry);
261 
262  void signalEntryUploaded(); // FIXME: rename to signalEntryUploadFinished?
263  void signalEntryFailed(); // FIXME: rename to signalEntryUploadFailed?
264 
265  void signalProvidersFinished();
266  void signalEntriesFinished();
267  void signalEntriesFeedFinished(const KNS::Feed *feed);
268 
269  void signalInstallationFinished();
270  void signalInstallationFailed();
271 
272  void signalProgress(const QString & message, int percentage);
273 
274  void signalDownloadDialogDone(KNS::Entry::List);
275 protected:
276  void mergeEntries(Entry::List entries, Feed *feed, const Provider *provider);
277 private Q_SLOTS:
278  void slotProvidersLoaded(KNS::Provider::List list);
279  void slotProvidersFailed();
280 
281  void slotEntriesLoaded(KNS::Entry::List list);
282  void slotEntriesFailed();
283 
284  void slotPayloadResult(KJob *job);
285  void slotPreviewResult(KJob *job);
286 
287  void slotUploadPayloadResult(KJob *job);
288  void slotUploadPreviewResult(KJob *job);
289  void slotUploadMetaResult(KJob *job);
290 
291  void slotProgress(KJob *job, unsigned long percent);
292 
293  void slotInstallationVerification(int result);
294 
295 private:
296  void loadRegistry();
297  void loadProvidersCache();
298  KNS::Entry *loadEntryCache(const QString& filepath);
299 #if 0
300  void loadEntriesCache();
301 #endif
302  void loadFeedCache(Provider *provider);
303  void cacheProvider(Provider *provider);
304  void cacheEntry(Entry *entry);
305 
313  void cacheFeed(const Provider *provider, const QString & feedname, const Feed *feed, Entry::List entries);
314  void registerEntry(Entry *entry);
315  void unregisterEntry(Entry *entry);
316  void mergeProviders(Provider::List providers);
317  void shutdown();
318 
319  bool entryCached(Entry *entry);
320  bool entryChanged(Entry *oldentry, Entry *entry);
321  bool providerCached(Provider *provider);
322  bool providerChanged(Provider *oldprovider, Provider *provider);
323 
324  static QStringList archiveEntries(const QString& path, const KArchiveDirectory * dir);
325 
326  QString id(Entry *e);
327  QString pid(const Provider *p);
328 
329  QList<Provider*> m_provider_cache;
330 
331  // holds all the entries
332  QList<Entry*> m_entry_cache;
333 
334  // holds the registered entries mapped by their id
335  QMap<QString, Entry*> m_entry_registry;
336 
337  QMap<QString, Provider*> m_provider_index;
338  QMap<QString, Entry*> m_entry_index;
339 
340  Entry *m_uploadedentry;
341  Provider *m_uploadprovider;
342 
343  QString m_providersurl;
344  QString m_componentname;
345 
346  QMap<Entry*, QString> m_previewfiles;
347  QMap<Entry*, QString> m_payloadfiles;
348 
349  QMap<KJob*, Entry*> m_entry_jobs;
350 
351  Installation *m_installation;
352 
353  int m_activefeeds;
354 
355  bool m_initialized;
356  CachePolicy m_cachepolicy;
357  AutomationPolicy m_automationpolicy;
358 };
359 
360 }
361 
362 #endif
KNS::CoreEngine::AutomationPolicy
AutomationPolicy
Engine automation can be activated to let the engine take care by itself of all the method calls need...
Definition: coreengine.h:98
KNS::Entry
KNewStuff data entry container.
Definition: knewstuff2/core/entry.h:46
provider.h
entry.h
KNS::CoreEngine::CachePolicy
CachePolicy
Policy on how to cache the data received from the network.
Definition: coreengine.h:75
QString
QObject
knewstuff_export.h
KUrl
KNS::CoreEngine
KNewStuff core engine.
Definition: coreengine.h:47
QStringList
KNS::Installation
KNewStuff entry installation.
Definition: knewstuff2/core/installation.h:44
KArchiveDirectory
KNS::Feed
KNewStuff feed.
Definition: feed.h:45
KJob
KNS::Provider
KNewStuff provider container.
Definition: knewstuff2/core/provider.h:51
QMap
QList< 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