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

KNewStuff

coreengine.h

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     Copyright 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 #ifndef KNEWSTUFF2_COREENGINE_H
00022 #define KNEWSTUFF2_COREENGINE_H
00023 
00024 #include <knewstuff2/core/provider.h>
00025 #include <knewstuff2/core/entry.h>
00026 
00027 #include <knewstuff2/knewstuff_export.h>
00028 
00029 #include <QtCore/QObject>
00030 #include <QtCore/QString>
00031 #include <QtCore/QMap>
00032 
00033 class KJob;
00034 class KArchiveDirectory;
00035 
00036 namespace KNS
00037 {
00038 
00039 class Installation;
00040 
00049 class KNEWSTUFF_EXPORT CoreEngine : public QObject
00050 {
00051     Q_OBJECT
00052 public:
00056     CoreEngine(QObject* parent);
00057 
00062     ~CoreEngine();
00063 
00077     enum CachePolicy {
00079         CacheNever,
00081         CacheReplaceable,
00083         CacheResident,
00085         CacheOnly
00086     };
00087 
00100     enum AutomationPolicy {
00102         AutomationOn,
00104         AutomationOff
00105     };
00106 
00107     void setAutomationPolicy(AutomationPolicy policy);
00108     void setCachePolicy(CachePolicy policy);
00109 
00118     bool init(const QString &configfile);
00119 
00144     void start();
00145 
00161     void loadEntries(Provider *provider);
00162     //void loadProvider(); // FIXME: for consistency?
00163 
00175     void downloadPreview(Entry *entry);
00176 
00188     void downloadPayload(Entry *entry);
00189 
00205     bool uploadEntry(Provider *provider, Entry *entry);
00206 
00223     bool install(const QString& payloadfile);
00224 
00235     bool uninstall(KNS::Entry *entry);
00236 
00237 Q_SIGNALS:
00243     void signalProviderLoaded(KNS::Provider *provider);
00244     void signalProviderChanged(KNS::Provider *provider);
00245     void signalProvidersFailed();
00246 
00247     void signalEntryLoaded(KNS::Entry *entry, const KNS::Feed *feed, const KNS::Provider *provider);
00248     void signalEntryRemoved(KNS::Entry *entry, const KNS::Feed *feed);
00249     void signalEntryChanged(KNS::Entry *entry);
00250     void signalEntriesFailed();
00251 
00252     void signalPreviewLoaded(KUrl preview); // FIXME: return Entry
00253     void signalPreviewFailed();
00254 
00255     void signalPayloadLoaded(KUrl payload); // FIXME: return Entry
00256     void signalPayloadFailed(KNS::Entry *entry);
00257 
00258     void signalEntryUploaded(); // FIXME: rename to signalEntryUploadFinished?
00259     void signalEntryFailed(); // FIXME: rename to signalEntryUploadFailed?
00260 
00261     void signalProvidersFinished();
00262     void signalEntriesFinished();
00263     void signalEntriesFeedFinished(const KNS::Feed *feed);
00264 
00265     void signalInstallationFinished();
00266     void signalInstallationFailed();
00267 
00268     void signalProgress(const QString & message, int percentage);
00269 
00270 protected:
00271     void mergeEntries(Entry::List entries, Feed *feed, const Provider *provider);
00272 private Q_SLOTS:
00273     void slotProvidersLoaded(KNS::Provider::List list);
00274     void slotProvidersFailed();
00275 
00276     void slotEntriesLoaded(KNS::Entry::List list);
00277     void slotEntriesFailed();
00278 
00279     void slotPayloadResult(KJob *job);
00280     void slotPreviewResult(KJob *job);
00281 
00282     void slotUploadPayloadResult(KJob *job);
00283     void slotUploadPreviewResult(KJob *job);
00284     void slotUploadMetaResult(KJob *job);
00285 
00286     void slotProgress(KJob *job, unsigned long percent);
00287 
00288     void slotInstallationVerification(int result);
00289 
00290 private:
00291     void loadRegistry();
00292     void loadProvidersCache();
00293     KNS::Entry *loadEntryCache(const QString& filepath);
00294 #if 0
00295     void loadEntriesCache();
00296 #endif
00297     void loadFeedCache(Provider *provider);
00298     void cacheProvider(Provider *provider);
00299     void cacheEntry(Entry *entry);
00300 
00308     void cacheFeed(const Provider *provider, const QString & feedname, const Feed *feed, Entry::List entries);
00309     void registerEntry(Entry *entry);
00310     void unregisterEntry(Entry *entry);
00311     void mergeProviders(Provider::List providers);
00312     void shutdown();
00313 
00314     bool entryCached(Entry *entry);
00315     bool entryChanged(Entry *oldentry, Entry *entry);
00316     bool providerCached(Provider *provider);
00317     bool providerChanged(Provider *oldprovider, Provider *provider);
00318 
00319     static QStringList archiveEntries(const QString& path, const KArchiveDirectory * dir);
00320 
00321     QString id(Entry *e);
00322     QString pid(const Provider *p);
00323 
00324     QList<Provider*> m_provider_cache;
00325 
00326     // holds all the entries
00327     QList<Entry*> m_entry_cache;
00328 
00329     // holds the registered entries mapped by their id
00330     QMap<QString, Entry*> m_entry_registry;
00331 
00332     QMap<QString, Provider*> m_provider_index;
00333     QMap<QString, Entry*> m_entry_index;
00334 
00335     Entry *m_uploadedentry;
00336     Provider *m_uploadprovider;
00337 
00338     QString m_providersurl;
00339     QString m_componentname;
00340 
00341     QMap<Entry*, QString> m_previewfiles;
00342     QMap<Entry*, QString> m_payloadfiles;
00343 
00344     QMap<KJob*, Entry*> m_entry_jobs;
00345 
00346     Installation *m_installation;
00347 
00348     int m_activefeeds;
00349 
00350     bool m_initialized;
00351     CachePolicy m_cachepolicy;
00352     AutomationPolicy m_automationpolicy;
00353 };
00354 
00355 }
00356 
00357 #endif

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