Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QNetworkAccessCacheBackend Class Reference

#include <qnetworkaccesscachebackend_p.h>

Inheritance diagram for QNetworkAccessCacheBackend:
QNetworkAccessBackend QObject

Public Functions

void closeDownstreamChannel ()
 
void closeUpstreamChannel ()
 
void downstreamReadyWrite ()
 
void open ()
 
 QNetworkAccessCacheBackend ()
 
void upstreamReadyRead ()
 
 ~QNetworkAccessCacheBackend ()
 
- Public Functions inherited from QNetworkAccessBackend
QVariant attribute (QNetworkRequest::Attribute code) const
 
virtual bool canResume () const
 
virtual void copyFinished (QIODevice *)
 
virtual void emitReadBufferFreed (qint64 size)
 
virtual QNetworkCacheMetaData fetchCacheMetaData (const QNetworkCacheMetaData &metaData) const
 
virtual void fetchSslConfiguration (QSslConfiguration &configuration) const
 
bool hasRawHeader (const QByteArray &headerName) const
 
QVariant header (QNetworkRequest::KnownHeaders header) const
 
virtual void ignoreSslErrors ()
 
virtual void ignoreSslErrors (const QList< QSslError > &errors)
 
bool isCachingEnabled () const
 
bool isSynchronous ()
 
virtual bool needsResetableUploadData ()
 
QAbstractNetworkCachenetworkCache () const
 
QNetworkAccessManager::Operation operation () const
 
virtual bool processRequestSynchronously ()
 
QList< QNetworkProxyproxyList () const
 
 QNetworkAccessBackend ()
 
QByteArray rawHeader (const QByteArray &headerName) const
 
QList< QByteArrayrawHeaderList () const
 
QNetworkRequest request () const
 
void setAttribute (QNetworkRequest::Attribute code, const QVariant &value)
 
void setCachingEnabled (bool enable)
 
virtual void setDownstreamLimited (bool b)
 
void setHeader (QNetworkRequest::KnownHeaders header, const QVariant &value)
 
void setRawHeader (const QByteArray &headerName, const QByteArray &value)
 
virtual void setReadBufferSize (qint64 size)
 
virtual void setResumeOffset (quint64 offset)
 
virtual void setSslConfiguration (const QSslConfiguration &configuration)
 
void setSynchronous (bool sync)
 
void setUrl (const QUrl &url)
 
virtual bool start ()
 Starts the backend. More...
 
QUrl url () const
 
virtual ~QNetworkAccessBackend ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Functions

bool sendCacheContents ()
 

Properties

QIODevicedevice
 

Additional Inherited Members

- Public Slots inherited from QNetworkAccessBackend
void writeDownstreamData (QIODevice *data)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QNetworkAccessBackend
void authenticationRequired (QAuthenticator *auth)
 
void emitReplyUploadProgress (qint64 bytesSent, qint64 bytesTotal)
 
void error (QNetworkReply::NetworkError code, const QString &errorString)
 
void finished ()
 
void metaDataChanged ()
 
void proxyAuthenticationRequired (const QNetworkProxy &proxy, QAuthenticator *auth)
 
void redirectionRequested (const QUrl &destination)
 
void sslErrors (const QList< QSslError > &errors)
 
- Protected Functions inherited from QNetworkAccessBackend
QNonContiguousByteDevicecreateUploadByteDevice ()
 
char * getDownloadBuffer (qint64)
 
qint64 nextDownstreamBlockSize () const
 
void writeDownstreamData (QByteDataBuffer &list)
 
void writeDownstreamDataDownloadBuffer (qint64, qint64)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QNetworkAccessBackend
QNetworkAccessManagerPrivatemanager
 
QNetworkReplyImplPrivatereply
 
QSharedPointer< QNonContiguousByteDeviceuploadByteDevice
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 62 of file qnetworkaccesscachebackend_p.h.

Constructors and Destructors

◆ QNetworkAccessCacheBackend()

QNetworkAccessCacheBackend::QNetworkAccessCacheBackend ( )

◆ ~QNetworkAccessCacheBackend()

QNetworkAccessCacheBackend::~QNetworkAccessCacheBackend ( )

Definition at line 59 of file qnetworkaccesscachebackend.cpp.

60 {
61 }

Functions

◆ closeDownstreamChannel()

void QNetworkAccessCacheBackend::closeDownstreamChannel ( )
virtual

Implements QNetworkAccessBackend.

Definition at line 126 of file qnetworkaccesscachebackend.cpp.

127 {
129  device->close();
130  delete device;
131  device = 0;
132  }
133 }
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
Definition: qiodevice.cpp:590
QNetworkAccessManager::Operation operation() const

◆ closeUpstreamChannel()

void QNetworkAccessCacheBackend::closeUpstreamChannel ( )

Definition at line 135 of file qnetworkaccesscachebackend.cpp.

136 {
137  Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!");
138 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ downstreamReadyWrite()

void QNetworkAccessCacheBackend::downstreamReadyWrite ( )
virtual

Reimplemented from QNetworkAccessBackend.

Definition at line 145 of file qnetworkaccesscachebackend.cpp.

146 {
147  Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!");
148 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ open()

void QNetworkAccessCacheBackend::open ( )
virtual

Implements QNetworkAccessBackend.

Definition at line 63 of file qnetworkaccesscachebackend.cpp.

64 {
66  QString msg = QCoreApplication::translate("QNetworkAccessCacheBackend", "Error opening %1")
67  .arg(this->url().toString());
69  } else {
71  }
72  finished();
73 }
void setAttribute(QNetworkRequest::Attribute code, const QVariant &value)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
static QString toString(Register *reg, int type, bool *ok=0)
QNetworkAccessManager::Operation operation() const
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
void error(QNetworkReply::NetworkError code, const QString &errorString)

◆ sendCacheContents()

bool QNetworkAccessCacheBackend::sendCacheContents ( )
private

Definition at line 75 of file qnetworkaccesscachebackend.cpp.

Referenced by open().

76 {
77  setCachingEnabled(false);
79  if (!nc)
80  return false;
81 
82  QNetworkCacheMetaData item = nc->metaData(url());
83  if (!item.isValid())
84  return false;
85 
89 
90  // set the raw headers
93  end = rawHeaders.constEnd();
94  for ( ; it != end; ++it) {
95  if (it->first.toLower() == "cache-control" &&
96  it->second.toLower().contains("must-revalidate")) {
97  return false;
98  }
99  setRawHeader(it->first, it->second);
100  }
101 
102  // handle a possible redirect
103  QVariant redirectionTarget = attributes.value(QNetworkRequest::RedirectionTargetAttribute);
104  if (redirectionTarget.isValid()) {
106  redirectionRequested(redirectionTarget.toUrl());
107  }
108 
109  // signal we're open
110  metaDataChanged();
111 
113  QIODevice *contents = nc->data(url());
114  if (!contents)
115  return false;
116  contents->setParent(this);
117  writeDownstreamData(contents);
118  }
119 
120 #if defined(QNETWORKACCESSCACHEBACKEND_DEBUG)
121  qDebug() << "Successfully sent cache:" << url();
122 #endif
123  return true;
124 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setAttribute(QNetworkRequest::Attribute code, const QVariant &value)
#define it(className, varName)
bool isValid() const
Returns true if this network cache meta data has attributes that have been set otherwise false...
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
virtual QIODevice * data(const QUrl &url)=0
Returns the data associated with url.
RawHeaderList rawHeaders() const
Returns a list of all raw headers that are set in this meta data.
Q_CORE_EXPORT void qDebug(const char *,...)
void setRawHeader(const QByteArray &headerName, const QByteArray &value)
AttributesMap attributes() const
Returns all the attributes stored with this cache item.
QNetworkAccessManager::Operation operation() const
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
Definition: qvariant.cpp:2528
QAbstractNetworkCache * networkCache() const
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
virtual QNetworkCacheMetaData metaData(const QUrl &url)=0
Returns the meta data for the url url.
void writeDownstreamData(QByteDataBuffer &list)
void setCachingEnabled(bool enable)
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
static const KeyPair *const end
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
The QNetworkCacheMetaData class provides cache information.
void redirectionRequested(const QUrl &destination)
The QAbstractNetworkCache class provides the interface for cache implementations. ...

◆ upstreamReadyRead()

void QNetworkAccessCacheBackend::upstreamReadyRead ( )

Definition at line 140 of file qnetworkaccesscachebackend.cpp.

141 {
142  Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!");
143 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Properties

◆ device

QIODevice* QNetworkAccessCacheBackend::device
private

Definition at line 78 of file qnetworkaccesscachebackend_p.h.

Referenced by closeDownstreamChannel().


The documentation for this class was generated from the following files: