KNewStuff
cache.h
Go to the documentation of this file.
00001 /* 00002 Copyright (c) 2009 Frederik Gladhorn <gladhorn@kde.org> 00003 Copyright (c) 2010 Matthias Fuchs <mat69@gmx.net> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #ifndef CACHE_H 00020 #define CACHE_H 00021 00022 #include <QtCore/QObject> 00023 #include <QtCore/QSet> 00024 00025 #include "engine.h" 00026 #include "entryinternal.h" 00027 00028 namespace KNS3 { 00029 00030 class Cache : public QObject 00031 { 00032 Q_OBJECT 00033 00034 public: 00042 static QSharedPointer<Cache> getCache(const QString &appName); 00043 00044 ~Cache(); 00045 00047 void readRegistry(); 00049 EntryInternal::List registryForProvider(const QString& providerId); 00050 00052 void writeRegistry(); 00053 00054 void insertRequest(const KNS3::Provider::SearchRequest&, const KNS3::EntryInternal::List& entries); 00055 EntryInternal::List requestFromCache(const KNS3::Provider::SearchRequest&); 00056 00057 public Q_SLOTS: 00058 void registerChangedEntry(const KNS3::EntryInternal& entry); 00059 00060 private: 00061 Q_DISABLE_COPY(Cache) 00062 Cache(const QString& appName); 00063 00064 // compatibility with KNS2 00065 void readKns2MetaFiles(); 00066 00067 private: 00068 // The file that is used to keep track of downloaded entries 00069 QString registryFile; 00070 00071 // The component name that was used in KNS2 to keep track of .meta files 00072 // This is only for compatibility with the former version - KNewStuff2. 00073 QString m_kns2ComponentName; 00074 00075 QSet<EntryInternal> cache; 00076 QHash<QString, EntryInternal::List> requestCache; 00077 }; 00078 00079 } 00080 00081 #endif
KDE 4.6 API Reference