QtNetwork/qabstractnetworkcache.h Source File

qabstractnetworkcache.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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>
49 
51 
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:
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;
102 };
103 
104 Q_NETWORK_EXPORT QDataStream &operator<<(QDataStream &, const 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 
138 
140 
141 #endif
bool isValid() const
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
long long qint64
Definition: qglobal.h:947
#define Q_SLOTS
Definition: qobjectdefs.h:71
QHash< QNetworkRequest::Attribute, QVariant > AttributesMap
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
Definition: node.h:577
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
#define Q_OBJECT
Definition: qobjectdefs.h:157
Definition: qurl.h:61
QList< RawHeader > RawHeaderList
bool operator!=(const QNetworkCacheMetaData &other) const
#define QT_END_HEADER
Definition: qglobal.h:142
QPair< QByteArray, QByteArray > RawHeader
Q_NETWORK_EXPORT QDataStream & operator>>(QDataStream &, QNetworkCacheMetaData &)
Q_NETWORK_EXPORT QDataStream & operator<<(QDataStream &, const QNetworkCacheMetaData &)