| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtNetwork module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QABSTRACTNETWORKCACHE_H
|
|---|
| 43 | #define QABSTRACTNETWORKCACHE_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qobject.h>
|
|---|
| 46 | #include <QtCore/qshareddata.h>
|
|---|
| 47 | #include <QtCore/qpair.h>
|
|---|
| 48 | #include <QtNetwork/qnetworkrequest.h>
|
|---|
| 49 |
|
|---|
| 50 | QT_BEGIN_HEADER
|
|---|
| 51 |
|
|---|
| 52 | QT_BEGIN_NAMESPACE
|
|---|
| 53 |
|
|---|
| 54 | QT_MODULE(Network)
|
|---|
| 55 |
|
|---|
| 56 | class QIODevice;
|
|---|
| 57 | class QDateTime;
|
|---|
| 58 | class QUrl;
|
|---|
| 59 | template<class T> class QList;
|
|---|
| 60 |
|
|---|
| 61 | class QNetworkCacheMetaDataPrivate;
|
|---|
| 62 | class Q_NETWORK_EXPORT QNetworkCacheMetaData
|
|---|
| 63 | {
|
|---|
| 64 |
|
|---|
| 65 | public:
|
|---|
| 66 | typedef QPair<QByteArray, QByteArray> RawHeader;
|
|---|
| 67 | typedef QList<RawHeader> RawHeaderList;
|
|---|
| 68 | typedef QHash<QNetworkRequest::Attribute, QVariant> AttributesMap;
|
|---|
| 69 |
|
|---|
| 70 | QNetworkCacheMetaData();
|
|---|
| 71 | QNetworkCacheMetaData(const QNetworkCacheMetaData &other);
|
|---|
| 72 | ~QNetworkCacheMetaData();
|
|---|
| 73 |
|
|---|
| 74 | QNetworkCacheMetaData &operator=(const QNetworkCacheMetaData &other);
|
|---|
| 75 | bool operator==(const QNetworkCacheMetaData &other) const;
|
|---|
| 76 | inline bool operator!=(const QNetworkCacheMetaData &other) const
|
|---|
| 77 | { return !(*this == other); }
|
|---|
| 78 |
|
|---|
| 79 | bool isValid() const;
|
|---|
| 80 |
|
|---|
| 81 | QUrl url() const;
|
|---|
| 82 | void setUrl(const QUrl &url);
|
|---|
| 83 |
|
|---|
| 84 | RawHeaderList rawHeaders() const;
|
|---|
| 85 | void setRawHeaders(const RawHeaderList &headers);
|
|---|
| 86 |
|
|---|
| 87 | QDateTime lastModified() const;
|
|---|
| 88 | void setLastModified(const QDateTime &dateTime);
|
|---|
| 89 |
|
|---|
| 90 | QDateTime expirationDate() const;
|
|---|
| 91 | void setExpirationDate(const QDateTime &dateTime);
|
|---|
| 92 |
|
|---|
| 93 | bool saveToDisk() const;
|
|---|
| 94 | void setSaveToDisk(bool allow);
|
|---|
| 95 |
|
|---|
| 96 | AttributesMap attributes() const;
|
|---|
| 97 | void setAttributes(const AttributesMap &attributes);
|
|---|
| 98 |
|
|---|
| 99 | private:
|
|---|
| 100 | friend class QNetworkCacheMetaDataPrivate;
|
|---|
| 101 | QSharedDataPointer<QNetworkCacheMetaDataPrivate> d;
|
|---|
| 102 | };
|
|---|
| 103 |
|
|---|
| 104 | Q_NETWORK_EXPORT QDataStream &operator<<(QDataStream &, const QNetworkCacheMetaData &);
|
|---|
| 105 | Q_NETWORK_EXPORT QDataStream &operator>>(QDataStream &, QNetworkCacheMetaData &);
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | class QAbstractNetworkCachePrivate;
|
|---|
| 109 | class Q_NETWORK_EXPORT QAbstractNetworkCache : public QObject
|
|---|
| 110 | {
|
|---|
| 111 | Q_OBJECT
|
|---|
| 112 |
|
|---|
| 113 | public:
|
|---|
| 114 | virtual ~QAbstractNetworkCache();
|
|---|
| 115 |
|
|---|
| 116 | virtual QNetworkCacheMetaData metaData(const QUrl &url) = 0;
|
|---|
| 117 | virtual void updateMetaData(const QNetworkCacheMetaData &metaData) = 0;
|
|---|
| 118 | virtual QIODevice *data(const QUrl &url) = 0;
|
|---|
| 119 | virtual bool remove(const QUrl &url) = 0;
|
|---|
| 120 | virtual qint64 cacheSize() const = 0;
|
|---|
| 121 |
|
|---|
| 122 | virtual QIODevice *prepare(const QNetworkCacheMetaData &metaData) = 0;
|
|---|
| 123 | virtual void insert(QIODevice *device) = 0;
|
|---|
| 124 |
|
|---|
| 125 | public Q_SLOTS:
|
|---|
| 126 | virtual void clear() = 0;
|
|---|
| 127 |
|
|---|
| 128 | protected:
|
|---|
| 129 | explicit QAbstractNetworkCache(QObject *parent = 0);
|
|---|
| 130 | QAbstractNetworkCache(QAbstractNetworkCachePrivate &dd, QObject *parent);
|
|---|
| 131 |
|
|---|
| 132 | private:
|
|---|
| 133 | Q_DECLARE_PRIVATE(QAbstractNetworkCache)
|
|---|
| 134 | Q_DISABLE_COPY(QAbstractNetworkCache)
|
|---|
| 135 | };
|
|---|
| 136 |
|
|---|
| 137 | QT_END_NAMESPACE
|
|---|
| 138 |
|
|---|
| 139 | QT_END_HEADER
|
|---|
| 140 |
|
|---|
| 141 | #endif
|
|---|