equal
deleted
inserted
replaced
21 |
21 |
22 #include <QNetworkRequest> |
22 #include <QNetworkRequest> |
23 #include <QNetworkReply> |
23 #include <QNetworkReply> |
24 #include <QAuthenticator> |
24 #include <QAuthenticator> |
25 #include <QNetworkInterface> |
25 #include <QNetworkInterface> |
26 |
|
27 #if QT_VERSION >= 0x040500 |
26 #if QT_VERSION >= 0x040500 |
28 #include <QNetworkDiskCache> |
27 #include <QNetworkDiskCache> |
29 // #include "networkdiskcache.h" |
28 // #include "networkdiskcache.h" |
30 #endif |
29 #endif |
31 |
30 |
66 } |
65 } |
67 |
66 |
68 void WebNetworkAccessManager::onfinished(QNetworkReply* reply) |
67 void WebNetworkAccessManager::onfinished(QNetworkReply* reply) |
69 { |
68 { |
70 QNetworkReply::NetworkError networkError = reply->error(); |
69 QNetworkReply::NetworkError networkError = reply->error(); |
71 QString replyUrl = reply->url().toString(); |
70 QString requestUrl = reply->request().url().toString(); |
72 |
71 |
73 if ( networkError != QNetworkReply::OperationCanceledError && |
72 if ( networkError != QNetworkReply::OperationCanceledError && |
74 networkError != QNetworkReply::NoError ) |
73 networkError != QNetworkReply::NoError ) |
75 { |
74 { |
76 QString errorMsg = reply->errorString(); |
75 QString errorMsg = reply->errorString(); |
77 if ( activeNetworkInterfaces() == 0 ) { |
76 if ( activeNetworkInterfaces() == 0 ) { |
83 QString httpReasonStr = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(); |
82 QString httpReasonStr = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(); |
84 errorMsg = httpErrorStr + httpReasonStr; |
83 errorMsg = httpErrorStr + httpReasonStr; |
85 } |
84 } |
86 } |
85 } |
87 emit networkErrorHappened(errorMsg); |
86 emit networkErrorHappened(errorMsg); |
88 emit networkErrorUrl(replyUrl); |
87 emit networkErrorUrl(requestUrl); |
89 } |
88 } |
90 } |
89 } |
91 |
90 |
92 WebNetworkAccessManager::~WebNetworkAccessManager() |
91 WebNetworkAccessManager::~WebNetworkAccessManager() |
93 { |
92 { |
94 delete m_cookieJar; |
93 delete m_cookieJar; |
95 setCache(NULL); |
94 setCache(NULL); |
96 delete m_reply; |
|
97 } |
95 } |
98 |
96 |
99 QNetworkReply* WebNetworkAccessManager::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) |
97 QNetworkReply* WebNetworkAccessManager::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) |
100 { |
98 { |
101 QNetworkRequest req = request; |
99 QNetworkRequest req = request; |
113 } |
111 } |
114 QNetworkReply* reply = NULL; |
112 QNetworkReply* reply = NULL; |
115 |
113 |
116 |
114 |
117 if(m_browserContainer->mainFrame()) { |
115 if(m_browserContainer->mainFrame()) { |
118 if(m_browserContainer->mainFrame()->url().scheme().contains("https")) { |
116 if(m_browserContainer->mainFrame()->url().scheme() == "https") { |
119 |
117 |
120 if (op == QNetworkAccessManager::PostOperation && req.url().scheme().contains("http")) { |
118 if (op == QNetworkAccessManager::PostOperation && req.url().scheme() == "http") { |
121 |
119 |
122 m_text = tr("Secure Page Warning:"); |
120 m_text = tr("Secure Page Warning:"); |
123 m_informativeText = tr("Do you want to continue?"); |
121 m_informativeText = tr("Do you want to continue?"); |
124 m_detailedText = tr("Submit your data over an unencrypted connection."); |
122 m_detailedText = tr("Submit your data over an unencrypted connection."); |
125 m_buttons = QMessageBox::Yes | QMessageBox::No; |
123 m_buttons = QMessageBox::Yes | QMessageBox::No; |
131 emit showMessageBox(this); |
129 emit showMessageBox(this); |
132 reply = m_reply; |
130 reply = m_reply; |
133 } |
131 } |
134 } |
132 } |
135 } |
133 } |
|
134 if(request.url().scheme() == "qrc") |
|
135 { |
|
136 reply = new NetworkErrorReply(QNetworkReply::ProtocolUnknownError, "Unknown scheme", request.url()); |
|
137 QMetaObject::invokeMethod(reply, "finished", Qt::QueuedConnection); |
|
138 } |
|
139 |
136 if (reply == NULL) { |
140 if (reply == NULL) { |
137 reply = createRequestHelper(op, req, outgoingData); |
141 reply = createRequestHelper(op, req, outgoingData); |
138 } |
142 } |
139 |
143 |
140 return reply; |
144 return reply; |
186 void WebNetworkAccessManager::setupNetworkProxy() |
190 void WebNetworkAccessManager::setupNetworkProxy() |
187 { |
191 { |
188 QNetworkProxy proxy; |
192 QNetworkProxy proxy; |
189 |
193 |
190 QString proxyString = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("NetworkProxy"); |
194 QString proxyString = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("NetworkProxy"); |
|
195 QString portString = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("NetworkPort"); |
191 |
196 |
192 if (proxyString.isEmpty()) |
197 if (proxyString.isEmpty()) |
193 { |
198 { |
194 proxy.setType(QNetworkProxy::NoProxy); |
199 proxy.setType(QNetworkProxy::NoProxy); |
195 proxy.setHostName(""); |
200 proxy.setHostName(""); |
197 } |
202 } |
198 else |
203 else |
199 { |
204 { |
200 proxy.setType(QNetworkProxy::HttpProxy); |
205 proxy.setType(QNetworkProxy::HttpProxy); |
201 proxy.setHostName(proxyString); |
206 proxy.setHostName(proxyString); |
202 proxy.setPort(8080); |
207 proxy.setPort(portString.toInt()); |
203 } |
208 } |
204 |
209 |
205 setProxy(proxy); |
210 setProxy(proxy); |
206 } |
211 } |
207 // Setup cache |
212 // Setup cache |