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

KNewStuff

engine.h

Go to the documentation of this file.
00001 /*
00002     knewstuff3/engine.h.
00003     Copyright (c) 2007 Josef Spillner <spillner@kde.org>
00004     Copyright (C) 2007-2010 Frederik Gladhorn <gladhorn@kde.org>
00005     Copyright (c) 2009 Jeremy Whiting <jpwhiting@kde.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef KNEWSTUFF3_ENGINE_H
00022 #define KNEWSTUFF3_ENGINE_H
00023 
00024 #include <QtCore/QObject>
00025 #include <QtCore/QString>
00026 #include <QtCore/QMap>
00027 
00028 #include "provider.h"
00029 #include "entryinternal.h"
00030 
00031 class QTimer;
00032 class KJob;
00033 
00034 namespace Attica {
00035     class ProviderManager;
00036     class Provider;
00037 }
00038 
00039 namespace KNS3
00040 {
00041 class Cache;
00042 class Installation;
00043 
00052 class Engine : public QObject
00053 {
00054     Q_OBJECT
00055 public:
00059     Engine(QObject* parent = 0);
00060 
00065     ~Engine();
00066 
00075     bool init(const QString &configfile);
00076 
00089     void install(KNS3::EntryInternal entry, int linkId = 1);
00090 
00097     void uninstall(KNS3::EntryInternal entry);
00098 
00099     void loadPreview(const KNS3::EntryInternal& entry, EntryInternal::PreviewType type);
00100     void loadDetails(const KNS3::EntryInternal& entry);
00101 
00102     void setSortMode(Provider::SortMode mode);
00103 
00107     void setCategoriesFilter(const QStringList& categories);
00108     void setSearchTerm(const QString& searchString);
00109     void reloadEntries();
00110     void requestMoreData();
00111     void requestData(int page, int pageSize);
00112 
00113     void checkForUpdates();
00114 
00118     void contactAuthor(const EntryInternal& entry);
00119 
00120     bool userCanVote(const EntryInternal& entry);
00121     void vote(const EntryInternal& entry, uint rating);
00122     bool userCanBecomeFan(const EntryInternal& entry);
00123     void becomeFan(const EntryInternal& entry);
00124 
00125     QStringList categories() const;
00126     QStringList categoriesFilter() const;
00127 
00128 Q_SIGNALS:
00132     void signalMessage(const QString& message);
00133 
00134     void signalProvidersLoaded();
00135     void signalEntriesLoaded(const KNS3::EntryInternal::List& entries);
00136     void signalUpdateableEntriesLoaded(const KNS3::EntryInternal::List& entries);
00137     void signalEntryChanged(const KNS3::EntryInternal& entry);
00138     void signalEntryDetailsLoaded(const KNS3::EntryInternal& entry);
00139 
00140     // a new search result is there, clear the list of items
00141     void signalResetView();
00142 
00143     void signalEntryPreviewLoaded(const KNS3::EntryInternal&, KNS3::EntryInternal::PreviewType);
00144     void signalPreviewFailed();
00145 
00146     void signalEntryUploadFinished();
00147     void signalEntryUploadFailed();
00148 
00149     void signalDownloadDialogDone(KNS3::EntryInternal::List);
00150     void jobStarted(KJob*,const QString&);
00151 
00152     void signalError(const QString&);
00153     void signalBusy(const QString&);
00154     void signalIdle(const QString&);
00155 
00156 private Q_SLOTS:
00157     // the .knsrc file was loaded
00158     void slotProviderFileLoaded(const QDomDocument& doc);
00159     // instead of getting providers from knsrc, use what was configured in ocs systemsettings
00160     void atticaProviderLoaded(const Attica::Provider& provider);
00161 
00162     // loading the .knsrc file failed
00163     void slotProvidersFailed();
00164 
00165     // called when a provider is ready to work
00166     void providerInitialized(KNS3::Provider*);
00167 
00168     void slotEntriesLoaded(const KNS3::Provider::SearchRequest&, KNS3::EntryInternal::List);
00169     void slotEntryDetailsLoaded(const KNS3::EntryInternal& entry);
00170     void slotPreviewLoaded(const KNS3::EntryInternal& entry, KNS3::EntryInternal::PreviewType type);
00171 
00172     void slotSearchTimerExpired();
00173 
00174     void slotEntryChanged(const KNS3::EntryInternal& entry);
00175     void slotInstallationFinished();
00176     void slotInstallationFailed(const QString& message);
00177     void downloadLinkLoaded(const KNS3::EntryInternal& entry);
00178     
00179     void providerJobStarted(KJob*);
00180 
00181 private:
00186     void loadProviders();
00187 
00191     void addProvider(QSharedPointer<KNS3::Provider> provider);
00192 
00193     void updateStatus();
00194     
00195     void doRequest();
00196 
00197     // If the provider is ready to be used
00198     bool m_initialized;
00199     // handle installation of entries
00200     Installation* m_installation;
00201     // read/write cache of entries
00202     QSharedPointer<Cache> m_cache;
00203     QTimer* m_searchTimer;
00204     // The url of the file containing information about content providers
00205     QString m_providerFileUrl;
00206     // Categories from knsrc file
00207     QStringList m_categories;
00208 
00209     QHash<QString, QSharedPointer<KNS3::Provider> > m_providers;
00210 
00211     // the name of the app that uses hot new stuff
00212     QString m_applicationName;
00213 
00214     // the current request from providers
00215     Provider::SearchRequest m_currentRequest;
00216 
00217     // the page that is currently displayed, so it is not requested repeatedly
00218     int m_currentPage;
00219 
00220     // when requesting entries from a provider, how many to ask for
00221     int m_pageSize;
00222 
00223     int m_numDataJobs;
00224     int m_numPictureJobs;
00225     int m_numInstallJobs;
00226     Attica::ProviderManager* m_atticaProviderManager;
00227 
00228     Q_DISABLE_COPY(Engine)
00229 };
00230 
00231 }
00232 
00233 #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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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