TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tdehtml_pagecache.h 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* This file is part of the KDE project
  2. *
  3. * Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
  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 __tdehtml_pagecache_h__
  21. #define __tdehtml_pagecache_h__
  22. #include <tqobject.h>
  23. #include <tqcstring.h>
  24. #include <tqvaluelist.h>
  25. #include <tqptrlist.h>
  26. class TDEHTMLPageCachePrivate;
  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 tdeio_http cache.
  37. */
  38. class TDEHTMLPageCache : public TQObject
  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 TDEHTMLPageCache *self();
  48. ~TDEHTMLPageCache();
  49. /**
  50. * Create a new cache entry.
  51. *
  52. * @return a cache entry ID is returned.
  53. */
  54. long createCacheEntry();
  55. /**
  56. * Add @p data to the cache entry with id @p id.
  57. */
  58. void addData(long id, const TQByteArray &data);
  59. /**
  60. * Signal end of data for the cache entry with id @p id.
  61. * After calling this the entry is marked complete
  62. */
  63. void endData(long id);
  64. /**
  65. * Cancel the entry.
  66. */
  67. void cancelEntry(long id);
  68. /**
  69. * @return true when the cache entry with id @p is still valid,
  70. * and at least some of the data is available for reading (the
  71. * complete data may not yet be loaded)
  72. */
  73. bool isValid(long id);
  74. /**
  75. * @return true when the cache entry with id @p is still valid,
  76. * and the complete data is available for reading
  77. */
  78. bool isComplete(long id);
  79. /**
  80. * Fetch data for cache entry @p id and send it to slot @p recvSlot
  81. * in the object @p recvObj
  82. */
  83. void fetchData(long id, TQObject *recvObj, const char *recvSlot);
  84. /**
  85. * Cancel sending data to @p recvObj
  86. */
  87. void cancelFetch(TQObject *recvObj);
  88. /**
  89. * Save the data of cache entry @p id to the datastream @p str
  90. */
  91. void saveData(long id, TQDataStream *str);
  92. private slots:
  93. void sendData();
  94. private:
  95. TDEHTMLPageCache();
  96. static TDEHTMLPageCache *_self;
  97. TDEHTMLPageCachePrivate *d;
  98. };
  99. class TDEHTMLPageCacheDelivery : public TQObject
  100. {
  101. friend class TDEHTMLPageCache;
  102. Q_OBJECT
  103. public:
  104. TDEHTMLPageCacheDelivery(int _fd)
  105. : fd(_fd) { }
  106. ~TDEHTMLPageCacheDelivery();
  107. signals:
  108. void emitData(const TQByteArray &data);
  109. public:
  110. TQObject *recvObj;
  111. int fd;
  112. };
  113. #endif