~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to src/network/access/qnetworkaccessmanager_p.h

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 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 QNETWORKACCESSMANAGER_P_H
 
43
#define QNETWORKACCESSMANAGER_P_H
 
44
 
 
45
//
 
46
//  W A R N I N G
 
47
//  -------------
 
48
//
 
49
// This file is not part of the Qt API.  It exists for the convenience
 
50
// of the Network Access API.  This header file may change from
 
51
// version to version without notice, or even be removed.
 
52
//
 
53
// We mean it.
 
54
//
 
55
 
 
56
#include "qnetworkaccessmanager.h"
 
57
#include "qnetworkaccesscache_p.h"
 
58
#include "qnetworkaccessbackend_p.h"
 
59
#include "private/qobject_p.h"
 
60
#include "QtNetwork/qnetworkproxy.h"
 
61
#include "QtNetwork/qnetworksession.h"
 
62
#include "qnetworkaccessauthenticationmanager_p.h"
 
63
 
 
64
QT_BEGIN_NAMESPACE
 
65
 
 
66
class QAuthenticator;
 
67
class QAbstractNetworkCache;
 
68
class QNetworkAuthenticationCredential;
 
69
class QNetworkCookieJar;
 
70
 
 
71
class QNetworkAccessManagerPrivate: public QObjectPrivate
 
72
{
 
73
public:
 
74
    QNetworkAccessManagerPrivate()
 
75
        : networkCache(0), cookieJar(0),
 
76
          httpThread(0),
 
77
#ifndef QT_NO_NETWORKPROXY
 
78
          proxyFactory(0),
 
79
#endif
 
80
#ifndef QT_NO_BEARERMANAGEMENT
 
81
          lastSessionState(QNetworkSession::Invalid),
 
82
          networkAccessible(QNetworkAccessManager::Accessible),
 
83
          activeReplyCount(0),
 
84
          online(false),
 
85
          initializeSession(true),
 
86
#endif
 
87
          cookieJarCreated(false),
 
88
          authenticationManager(new QNetworkAccessAuthenticationManager)
 
89
    { }
 
90
    ~QNetworkAccessManagerPrivate();
 
91
 
 
92
    void _q_replyFinished();
 
93
    void _q_replySslErrors(const QList<QSslError> &errors);
 
94
    QNetworkReply *postProcess(QNetworkReply *reply);
 
95
    void createCookieJar() const;
 
96
 
 
97
    void authenticationRequired(QAuthenticator *authenticator,
 
98
                                QNetworkReply *reply,
 
99
                                bool synchronous,
 
100
                                QUrl &url,
 
101
                                QUrl *urlForLastAuthentication,
 
102
                                bool allowAuthenticationReuse = true);
 
103
    void cacheCredentials(const QUrl &url, const QAuthenticator *auth);
 
104
    QNetworkAuthenticationCredential *fetchCachedCredentials(const QUrl &url,
 
105
                                                             const QAuthenticator *auth = 0);
 
106
 
 
107
#ifndef QT_NO_NETWORKPROXY
 
108
    void proxyAuthenticationRequired(const QNetworkProxy &proxy,
 
109
                                bool synchronous,
 
110
                                QAuthenticator *authenticator,
 
111
                                QNetworkProxy *lastProxyAuthentication);
 
112
    void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth);
 
113
    QNetworkAuthenticationCredential *fetchCachedProxyCredentials(const QNetworkProxy &proxy,
 
114
                                                             const QAuthenticator *auth = 0);
 
115
    QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query);
 
116
#endif
 
117
 
 
118
    QNetworkAccessBackend *findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request);
 
119
 
 
120
#ifndef QT_NO_BEARERMANAGEMENT
 
121
    void createSession(const QNetworkConfiguration &config);
 
122
    QSharedPointer<QNetworkSession> getNetworkSession() const;
 
123
 
 
124
    void _q_networkSessionClosed();
 
125
    void _q_networkSessionNewConfigurationActivated();
 
126
    void _q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &config,
 
127
                                                        bool isSeamless);
 
128
    void _q_networkSessionStateChanged(QNetworkSession::State state);
 
129
#endif
 
130
 
 
131
    QNetworkRequest prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart);
 
132
 
 
133
    // this is the cache for storing downloaded files
 
134
    QAbstractNetworkCache *networkCache;
 
135
 
 
136
    QNetworkCookieJar *cookieJar;
 
137
 
 
138
    QThread *httpThread;
 
139
 
 
140
 
 
141
#ifndef QT_NO_NETWORKPROXY
 
142
    QNetworkProxy proxy;
 
143
    QNetworkProxyFactory *proxyFactory;
 
144
#endif
 
145
 
 
146
#ifndef QT_NO_BEARERMANAGEMENT
 
147
    QSharedPointer<QNetworkSession> networkSessionStrongRef;
 
148
    QWeakPointer<QNetworkSession> networkSessionWeakRef;
 
149
    QNetworkSession::State lastSessionState;
 
150
    QString networkConfiguration;
 
151
    QNetworkAccessManager::NetworkAccessibility networkAccessible;
 
152
    int activeReplyCount;
 
153
    bool online;
 
154
    bool initializeSession;
 
155
#endif
 
156
 
 
157
    bool cookieJarCreated;
 
158
 
 
159
    // The cache with authorization data:
 
160
    QSharedPointer<QNetworkAccessAuthenticationManager> authenticationManager;
 
161
 
 
162
    // this cache can be used by individual backends to cache e.g. their TCP connections to a server
 
163
    // and use the connections for multiple requests.
 
164
    QNetworkAccessCache objectCache;
 
165
    static inline QNetworkAccessCache *getObjectCache(QNetworkAccessBackend *backend)
 
166
    { return &backend->manager->objectCache; }
 
167
    Q_AUTOTEST_EXPORT static void clearCache(QNetworkAccessManager *manager);
 
168
#ifndef QT_NO_BEARERMANAGEMENT
 
169
    Q_AUTOTEST_EXPORT static const QWeakPointer<const QNetworkSession> getNetworkSession(const QNetworkAccessManager *manager);
 
170
#endif
 
171
    Q_DECLARE_PUBLIC(QNetworkAccessManager)
 
172
};
 
173
 
 
174
QT_END_NAMESPACE
 
175
 
 
176
#endif