• Skip to content
  • Skip to link menu
KDE 4.2 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 (c) 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 Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 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     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public
00017     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 #ifndef KNEWSTUFF2_COREENGINE_H
00020 #define KNEWSTUFF2_COREENGINE_H
00021 
00022 #include <knewstuff2/core/provider.h>
00023 #include <knewstuff2/core/entry.h>
00024 
00025 #include <knewstuff2/knewstuff_export.h>
00026 
00027 #include <QtCore/QObject>
00028 #include <QtCore/QString>
00029 #include <QtCore/QMap>
00030 
00031 class KJob;
00032 class KArchiveDirectory;
00033 
00034 namespace KNS
00035 {
00036 
00037 class Installation;
00038 
00047 class KNEWSTUFF_EXPORT CoreEngine : public QObject
00048 {
00049     Q_OBJECT
00050 public:
00054     CoreEngine(QObject* parent);
00055 
00060     ~CoreEngine();
00061 
00075     enum CachePolicy {
00077         CacheNever,
00079         CacheReplaceable,
00081         CacheResident,
00083         CacheOnly
00084     };
00085 
00098     enum AutomationPolicy {
00100         AutomationOn,
00102         AutomationOff
00103     };
00104 
00105     void setAutomationPolicy(AutomationPolicy policy);
00106     void setCachePolicy(CachePolicy policy);
00107 
00116     bool init(const QString &configfile);
00117 
00142     void start();
00143 
00159     void loadEntries(Provider *provider);
00160     //void loadProvider(); // FIXME: for consistency?
00161 
00173     void downloadPreview(Entry *entry);
00174 
00186     void downloadPayload(Entry *entry);
00187 
00203     bool uploadEntry(Provider *provider, Entry *entry);
00204 
00221     bool install(const QString& payloadfile);
00222 
00233     bool uninstall(KNS::Entry *entry);
00234 
00235 Q_SIGNALS:
00241     void signalProviderLoaded(KNS::Provider *provider);
00242     void signalProviderChanged(KNS::Provider *provider);
00243     void signalProvidersFailed();
00244 
00245     void signalEntryLoaded(KNS::Entry *entry, const KNS::Feed *feed, const KNS::Provider *provider);
00246     void signalEntryRemoved(KNS::Entry *entry, const KNS::Feed *feed);
00247     void signalEntryChanged(KNS::Entry *entry);
00248     void signalEntriesFailed();
00249 
00250     void signalPreviewLoaded(KUrl preview); // FIXME: return Entry
00251     void signalPreviewFailed();
00252 
00253     void signalPayloadLoaded(KUrl payload); // FIXME: return Entry
00254     void signalPayloadFailed(KNS::Entry *entry);
00255 
00256     void signalEntryUploaded(); // FIXME: rename to signalEntryUploadFinished?
00257     void signalEntryFailed(); // FIXME: rename to signalEntryUploadFailed?
00258 
00259     void signalProvidersFinished();
00260     void signalEntriesFinished();
00261     void signalEntriesFeedFinished(const KNS::Feed *feed);
00262 
00263     void signalInstallationFinished();
00264     void signalInstallationFailed();
00265 
00266     void signalProgress(const QString & message, int percentage);
00267 
00268 protected:
00269     void mergeEntries(Entry::List entries, Feed *feed, const Provider *provider);
00270 private Q_SLOTS:
00271     void slotProvidersLoaded(KNS::Provider::List list);
00272     void slotProvidersFailed();
00273 
00274     void slotEntriesLoaded(KNS::Entry::List list);
00275     void slotEntriesFailed();
00276 
00277     void slotPayloadResult(KJob *job);
00278     void slotPreviewResult(KJob *job);
00279 
00280     void slotUploadPayloadResult(KJob *job);
00281     void slotUploadPreviewResult(KJob *job);
00282     void slotUploadMetaResult(KJob *job);
00283 
00284     void slotProgress(KJob *job, unsigned long percent);
00285 
00286     void slotInstallationVerification(int result);
00287 
00288 private:
00289     void loadRegistry();
00290     void loadProvidersCache();
00291     KNS::Entry *loadEntryCache(const QString& filepath);
00292 #if 0
00293     void loadEntriesCache();
00294 #endif
00295     void loadFeedCache(Provider *provider);
00296     void cacheProvider(Provider *provider);
00297     void cacheEntry(Entry *entry);
00298 
00306     void cacheFeed(const Provider *provider, const QString & feedname, const Feed *feed, Entry::List entries);
00307     void registerEntry(Entry *entry);
00308     void unregisterEntry(Entry *entry);
00309     void mergeProviders(Provider::List providers);
00310     void shutdown();
00311 
00312     bool entryCached(Entry *entry);
00313     bool entryChanged(Entry *oldentry, Entry *entry);
00314     bool providerCached(Provider *provider);
00315     bool providerChanged(Provider *oldprovider, Provider *provider);
00316 
00317     static QStringList archiveEntries(const QString& path, const KArchiveDirectory * dir);
00318 
00319     QString id(Entry *e);
00320     QString pid(const Provider *p);
00321 
00322     QList<Provider*> m_provider_cache;
00323 
00324     // holds all the entries
00325     QList<Entry*> m_entry_cache;
00326 
00327     // holds the registered entries mapped by their id
00328     QMap<QString, Entry*> m_entry_registry;
00329 
00330     QMap<QString, Provider*> m_provider_index;
00331     QMap<QString, Entry*> m_entry_index;
00332 
00333     Entry *m_uploadedentry;
00334     Provider *m_uploadprovider;
00335 
00336     QString m_providersurl;
00337     QString m_componentname;
00338 
00339     QMap<Entry*, QString> m_previewfiles;
00340     QMap<Entry*, QString> m_payloadfiles;
00341 
00342     QMap<KJob*, Entry*> m_entry_jobs;
00343 
00344     Installation *m_installation;
00345 
00346     int m_activefeeds;
00347 
00348     bool m_initialized;
00349     CachePolicy m_cachepolicy;
00350     AutomationPolicy m_automationpolicy;
00351 };
00352 
00353 }
00354 
00355 #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
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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