|
1 /* |
|
2 Copyright (C) 2007 Trolltech ASA |
|
3 |
|
4 This library is free software; you can redistribute it and/or |
|
5 modify it under the terms of the GNU Library General Public |
|
6 License as published by the Free Software Foundation; either |
|
7 version 2 of the License, or (at your option) any later version. |
|
8 |
|
9 This library is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 Library General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU Library General Public License |
|
15 along with this library; see the file COPYING.LIB. If not, write to |
|
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
17 Boston, MA 02110-1301, USA. |
|
18 |
|
19 This class provides all functionality needed for loading images, style sheets and html |
|
20 pages from the web. It has a memory cache for these objects. |
|
21 */ |
|
22 #ifndef QWEBNETWORKINTERFACE_H |
|
23 #define QWEBNETWORKINTERFACE_H |
|
24 |
|
25 #include <qobject.h> |
|
26 #include <qurl.h> |
|
27 #include <qhttp.h> |
|
28 #include <qbytearray.h> |
|
29 |
|
30 #include <qwebkitglobal.h> |
|
31 |
|
32 class QAuthenticator; |
|
33 class QNetworkProxy; |
|
34 class QSslError; |
|
35 class QWebFrame; |
|
36 class QWebNetworkJobPrivate; |
|
37 class QWebNetworkInterface; |
|
38 class QWebObjectPluginConnector; |
|
39 |
|
40 namespace WebCore { |
|
41 class WebCoreHttp; |
|
42 class ResourceRequest; |
|
43 class FrameLoaderClientQt; |
|
44 } |
|
45 |
|
46 struct QWebNetworkRequestPrivate; |
|
47 class QWEBKIT_EXPORT QWebNetworkRequest |
|
48 { |
|
49 public: |
|
50 enum Method { |
|
51 Get, |
|
52 Post |
|
53 //Head |
|
54 }; |
|
55 |
|
56 QWebNetworkRequest(); |
|
57 explicit QWebNetworkRequest(const QUrl &url, Method method = Get, const QByteArray &postData = QByteArray()); |
|
58 QWebNetworkRequest(const QWebNetworkRequest &other); |
|
59 |
|
60 QWebNetworkRequest &operator=(const QWebNetworkRequest &other); |
|
61 ~QWebNetworkRequest(); |
|
62 |
|
63 QUrl url() const; |
|
64 void setUrl(const QUrl &url); |
|
65 |
|
66 QHttpRequestHeader httpHeader() const; |
|
67 void setHttpHeader(const QHttpRequestHeader &header) const; |
|
68 |
|
69 QString httpHeaderField(const QString &key) const; |
|
70 void setHttpHeaderField(const QString &key, const QString &value); |
|
71 |
|
72 QByteArray postData() const; |
|
73 void setPostData(const QByteArray &data); |
|
74 |
|
75 private: |
|
76 explicit QWebNetworkRequest(const QWebNetworkRequestPrivate &priv); |
|
77 explicit QWebNetworkRequest(const WebCore::ResourceRequest &request); |
|
78 friend class QWebNetworkJob; |
|
79 friend class WebCore::FrameLoaderClientQt; |
|
80 |
|
81 QWebNetworkRequestPrivate *d; |
|
82 friend class QWebObjectPluginConnector; |
|
83 }; |
|
84 |
|
85 class QWEBKIT_EXPORT QWebNetworkJob |
|
86 { |
|
87 public: |
|
88 QUrl url() const; |
|
89 QByteArray postData() const; |
|
90 QHttpRequestHeader httpHeader() const; |
|
91 QWebNetworkRequest request() const; |
|
92 |
|
93 QHttpResponseHeader response() const; |
|
94 void setResponse(const QHttpResponseHeader &response); |
|
95 |
|
96 bool cancelled() const; |
|
97 |
|
98 void ref(); |
|
99 bool deref(); |
|
100 |
|
101 QWebNetworkInterface *networkInterface() const; |
|
102 |
|
103 QWebFrame *frame() const; |
|
104 |
|
105 private: |
|
106 QWebNetworkJob(); |
|
107 ~QWebNetworkJob(); |
|
108 |
|
109 friend class QWebNetworkManager; |
|
110 friend class QWebObjectPluginConnector; |
|
111 |
|
112 QWebNetworkJobPrivate *d; |
|
113 }; |
|
114 |
|
115 class QWebNetworkInterfacePrivate; |
|
116 |
|
117 class QWEBKIT_EXPORT QWebNetworkInterface : public QObject |
|
118 { |
|
119 Q_OBJECT |
|
120 public: |
|
121 QWebNetworkInterface(QObject *parent = 0); |
|
122 ~QWebNetworkInterface(); |
|
123 |
|
124 static void setDefaultInterface(QWebNetworkInterface *defaultInterface); |
|
125 static QWebNetworkInterface *defaultInterface(); |
|
126 |
|
127 virtual void addJob(QWebNetworkJob *job); |
|
128 virtual void cancelJob(QWebNetworkJob *job); |
|
129 |
|
130 signals: |
|
131 void started(QWebNetworkJob*); |
|
132 void data(QWebNetworkJob*, const QByteArray &data); |
|
133 void finished(QWebNetworkJob*, int errorCode); |
|
134 /** |
|
135 * Signal is emitted when an SSL error occurs. |
|
136 */ |
|
137 void sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway); |
|
138 /** |
|
139 * Signal is emitted when network authentication is required. |
|
140 */ |
|
141 void authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth); |
|
142 /** |
|
143 * Signal is emitted when proxy authentication is required. |
|
144 */ |
|
145 void authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth); |
|
146 |
|
147 private: |
|
148 friend class QWebNetworkInterfacePrivate; |
|
149 friend class WebCore::WebCoreHttp; |
|
150 QWebNetworkInterfacePrivate *d; |
|
151 }; |
|
152 |
|
153 #endif |