KHtml

khtml_pagecache.h
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2000 Waldo Bastian <[email protected]>
4  *
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.
9  *
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.
14  *
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.
19  */
20 #ifndef __khtml_pagecache_h__
21 #define __khtml_pagecache_h__
22 
23 #include <QObject>
24 
25 class KHTMLPageCachePrivate;
26 
27 /**
28  * Singleton Object that handles a binary cache on top of
29  * the http cache management of kio.
30  *
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.
35  *
36  * It operates completely independent from the kio_http cache.
37  */
38 class KHTMLPageCache : public QObject
39 {
40  Q_OBJECT
41 public:
42  /**
43  * static "constructor".
44  * @return returns a pointer to the cache, if it exists.
45  * creates a new cache otherwise.
46  */
47  static KHTMLPageCache *self();
48  ~KHTMLPageCache();
49 
50  /**
51  * Create a new cache entry.
52  *
53  * @return a cache entry ID is returned.
54  */
55  long createCacheEntry();
56 
57  /**
58  * Add @p data to the cache entry with id @p id.
59  */
60  void addData(long id, const QByteArray &data);
61 
62  /**
63  * Signal end of data for the cache entry with id @p id.
64  * After calling this the entry is marked complete
65  */
66  void endData(long id);
67 
68  /**
69  * Cancel the entry.
70  */
71  void cancelEntry(long id);
72 
73  /**
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)
77  */
78  bool isValid(long id);
79 
80  /**
81  * @return true when the cache entry with id @p is still valid,
82  * and the complete data is available for reading
83  */
84  bool isComplete(long id);
85 
86  /**
87  * Fetch data for cache entry @p id and send it to slot @p recvSlot
88  * in the object @p recvObj
89  */
90  void fetchData(long id, QObject *recvObj, const char *recvSlot);
91 
92  /**
93  * Cancel sending data to @p recvObj
94  */
95  void cancelFetch(QObject *recvObj);
96 
97 public Q_SLOTS:
98  /**
99  * Save the data of cache entry @p id to the datastream @p str
100  */
101  void saveData(long id, QDataStream *str);
102 
103 private Q_SLOTS:
104  void sendData();
105 
106 private:
107  KHTMLPageCache();
108 
109  KHTMLPageCachePrivate *const d;
110 
111  friend class KHTMLPageCacheSingleton;
112 };
113 
114 class QIODevice;
115 class KHTMLPageCacheDelivery : public QObject
116 {
117  friend class KHTMLPageCache;
118  Q_OBJECT
119 public:
120  KHTMLPageCacheDelivery(QIODevice *_file): file(_file) {}
121  ~KHTMLPageCacheDelivery();
122 
123 Q_SIGNALS:
124  void emitData(const QByteArray &data);
125 
126 public:
127  QObject *recvObj;
128  QIODevice *file;
129 };
130 
131 #endif
void fetchData(long id, QObject *recvObj, const char *recvSlot)
Fetch data for cache entry id and send it to slot recvSlot in the object recvObj. ...
Q_SIGNALSQ_SIGNALS
bool isComplete(long id)
bool isValid(long id)
Q_OBJECTQ_OBJECT
void cancelFetch(QObject *recvObj)
Cancel sending data to recvObj.
void cancelEntry(long id)
Cancel the entry.
Singleton Object that handles a binary cache on top of the http cache management of kio...
long createCacheEntry()
Create a new cache entry.
void saveData(long id, QDataStream *str)
Save the data of cache entry id to the datastream str.
Q_SLOTSQ_SLOTS
void addData(long id, const QByteArray &data)
Add data to the cache entry with id id.
void endData(long id)
Signal end of data for the cache entry with id id.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 22 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.