1 /* This file is part of the KDE project
3 * Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
20 #ifndef __khtml_pagecache_h__
21 #define __khtml_pagecache_h__
23 #include <QtCore/QObject>
25 class KHTMLPageCachePrivate
;
28 * Singleton Object that handles a binary cache on top of
29 * the http cache management of kio.
31 * A limited number of HTML pages are stored in this cache. This
32 * cache is used for the history and operations like "view source".
33 * These operations always want to use the original document and
34 * don't want to fetch the data from the network again.
36 * It operates completely independent from the kio_http cache.
38 class KHTMLPageCache
: public QObject
43 * static "constructor".
44 * @return returns a pointer to the cache, if it exists.
45 * creates a new cache otherwise.
47 static KHTMLPageCache
*self();
51 * Create a new cache entry.
53 * @return a cache entry ID is returned.
55 long createCacheEntry();
58 * Add @p data to the cache entry with id @p id.
60 void addData(long id
, const QByteArray
&data
);
63 * Signal end of data for the cache entry with id @p id.
64 * After calling this the entry is marked complete
66 void endData(long id
);
71 void cancelEntry(long id
);
74 * @return true when the cache entry with id @p is still valid,
75 * and at least some of the data is available for reading (the
76 * complete data may not yet be loaded)
78 bool isValid(long id
);
81 * @return true when the cache entry with id @p is still valid,
82 * and the complete data is available for reading
84 bool isComplete(long id
);
87 * Fetch data for cache entry @p id and send it to slot @p recvSlot
88 * in the object @p recvObj
90 void fetchData(long id
, QObject
*recvObj
, const char *recvSlot
);
93 * Cancel sending data to @p recvObj
95 void cancelFetch(QObject
*recvObj
);
99 * Save the data of cache entry @p id to the datastream @p str
101 void saveData(long id
, QDataStream
*str
);
109 KHTMLPageCachePrivate
* const d
;
113 class KHTMLPageCacheDelivery
: public QObject
115 friend class KHTMLPageCache
;
118 KHTMLPageCacheDelivery(QIODevice
*_file
): file(_file
) {}
119 ~KHTMLPageCacheDelivery();
122 void emitData(const QByteArray
&data
);