pNetworkAccessManager.sip 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. class pNetworkAccessManager : QNetworkAccessManager
  2. {
  3. %TypeHeaderCode
  4. #include <../src/core/pNetworkAccessManager.h>
  5. %End
  6. public:
  7. /*!
  8. Returns the global instance of the pNetworkAccessManager.
  9. */
  10. static pNetworkAccessManager* instance();
  11. /*!
  12. Construct a pNetworkAccessManager instance and set the parent to \a parent.
  13. */
  14. pNetworkAccessManager( QObject* parent = 0 );
  15. /*!
  16. Destroy the pNetworkAccessManager and free all its resources.
  17. */
  18. virtual ~pNetworkAccessManager();
  19. /*!
  20. Set the directory where to cache the QNetworkReply to \a cacheDir.
  21. */
  22. void setCacheDirectory( const QString& cacheDir );
  23. /*!
  24. Returns the directory where are cached the QNetworkReply.
  25. \sa QNetworkDiskCache.
  26. */
  27. QString cacheDirectory() const;
  28. /*!
  29. Set the maximum cache size of the cache directory to \a size bytes.
  30. \sa QNetworkDiskCache.
  31. */
  32. void setMaximumCacheSize( qint64 size );
  33. /*!
  34. Returns the maximum size of the cache directory in bytes.
  35. \sa QNetworkDiskCache.
  36. */
  37. qint64 maximumCacheSize() const;
  38. /*!
  39. Set the maximum try an url will be sent to \a max.
  40. */
  41. void setMaxRetryPerUrl( int max );
  42. /*!
  43. Returns the maximum number of time an url is allowed to be sent.
  44. If a request is sent and max retry has been reach, then the request will
  45. not be sent and an error will be triggered.
  46. */
  47. int maxRetryPerUrl() const;
  48. /*!
  49. Returns the current cache size in bytes.
  50. \sa QNetworkDiskCache.
  51. */
  52. qint64 cacheSize() const;
  53. /*!
  54. Clear the cache, all cache files are deleted from the disk.
  55. \sa QNetworkDiskCache.
  56. */
  57. void clearCache();
  58. /*!
  59. Remove the cache file for \a url and return true on success, else false.
  60. \sa QNetworkDiskCache.
  61. */
  62. bool removeCache( const QUrl& url ) const;
  63. /*!
  64. Return a QIODevice for the cached data \a url if exists, else 0.
  65. \sa QNetworkDiskCache.
  66. */
  67. QIODevice* cacheData( const QUrl& url ) const;
  68. /*!
  69. Return true if cache data exists for \a url, else false.
  70. \sa QNetworkDiskCache.
  71. */
  72. bool hasCacheData( const QUrl& url ) const;
  73. /*!
  74. Return the meta data associated with \a url.
  75. \sa QNetworkDiskCache.
  76. */
  77. QNetworkCacheMetaData cacheMetaData( const QUrl& url ) const;
  78. /*!
  79. Return the meta data associated with \a fileName.
  80. \sa QNetworkDiskCache.
  81. */
  82. QNetworkCacheMetaData cacheFileMetaData( const QString& fileName ) const;
  83. /*!
  84. Return a QPixmap from the cache content of \a url if it exists, else an invalid QPixmap.
  85. \note This member is only defined when the macro QT_GUI_LIB is defined.
  86. */
  87. QPixmap cachedPixmap( const QUrl& url ) const;
  88. protected:
  89. /*!
  90. Reimplemented.
  91. */
  92. virtual QNetworkReply* createRequest( Operation op, const QNetworkRequest& req, QIODevice* outgoingData = 0 );
  93. protected slots:
  94. void _q_finished( QNetworkReply* reply );
  95. signals:
  96. /*!
  97. This signal is emitted when a request at \a url is successfuly cached.
  98. */
  99. void cached( const QUrl& url );
  100. /*!
  101. This signal is emitted when a request at \a url fails.
  102. The error associated is set in \a message.
  103. */
  104. void error( const QUrl& url, const QString& message );
  105. /*!
  106. This signal is emmited when the cache has been cleared.
  107. */
  108. void cacheCleared();
  109. };