|
|
|
@ -8,6 +8,7 @@ |
|
|
|
|
#define __NETWORKACCESS_MANAGER_HXX__ |
|
|
|
|
|
|
|
|
|
#include <QNetworkAccessManager> |
|
|
|
|
#include <QNetworkReply> |
|
|
|
|
#include <QNetworkConfiguration> |
|
|
|
|
#include <QNetworkProxy> |
|
|
|
|
|
|
|
|
@ -15,7 +16,7 @@ class NetworkAccessManager: public QNetworkAccessManager { |
|
|
|
|
Q_OBJECT; |
|
|
|
|
public: |
|
|
|
|
NetworkAccessManager(QObject* parent = 0): QNetworkAccessManager(parent) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
connect(this, |
|
|
|
|
SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), |
|
|
|
|
SLOT(authenticationRequiredLog(QNetworkReply*, QAuthenticator*))); |
|
|
|
@ -40,122 +41,122 @@ class NetworkAccessManager: public QNetworkAccessManager { |
|
|
|
|
SLOT(sslErrorsLog(QNetworkReply*, const QList<QSslError>&))); |
|
|
|
|
} |
|
|
|
|
virtual ~NetworkAccessManager() { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
QNetworkConfiguration activeConfiguration() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::activeConfiguration(); |
|
|
|
|
} |
|
|
|
|
QAbstractNetworkCache* cache() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::cache(); |
|
|
|
|
} |
|
|
|
|
void clearAccessCache() { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::clearAccessCache(); |
|
|
|
|
} |
|
|
|
|
QNetworkConfiguration configuration() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::configuration(); |
|
|
|
|
} |
|
|
|
|
void connectToHost(const QString& hostName, quint16 port = 80) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
QNetworkAccessManager::connectToHost(hostName, port); |
|
|
|
|
} |
|
|
|
|
void connectToHostEncrypted(const QString& hostName, quint16 port = 443, |
|
|
|
|
const QSslConfiguration& sslConfiguration |
|
|
|
|
= QSslConfiguration::defaultConfiguration()) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
QNetworkAccessManager::connectToHostEncrypted(hostName, port, |
|
|
|
|
sslConfiguration); |
|
|
|
|
} |
|
|
|
|
QNetworkCookieJar* cookieJar() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::cookieJar(); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* deleteResource(const QNetworkRequest & request) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::deleteResource(request); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* get(const QNetworkRequest& request) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::get(request); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* head(const QNetworkRequest& request) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::head(request); |
|
|
|
|
} |
|
|
|
|
NetworkAccessibility networkAccessible() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::networkAccessible(); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* post(const QNetworkRequest & request, QIODevice * data) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::post(request, data); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* post(const QNetworkRequest& request, |
|
|
|
|
const QByteArray& data) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::post(request, data); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* post(const QNetworkRequest& request, |
|
|
|
|
QHttpMultiPart* multiPart) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::post(request, multiPart); |
|
|
|
|
} |
|
|
|
|
QNetworkProxy proxy() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::proxy(); |
|
|
|
|
} |
|
|
|
|
QNetworkProxyFactory* proxyFactory() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::proxyFactory(); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* put(const QNetworkRequest& request, QIODevice* data) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::put(request, data); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* put(const QNetworkRequest& request, |
|
|
|
|
QHttpMultiPart* multiPart) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::put(request, multiPart); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* put(const QNetworkRequest& request, const QByteArray& data) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::put(request, data); |
|
|
|
|
} |
|
|
|
|
QNetworkReply* sendCustomRequest(const QNetworkRequest& request, |
|
|
|
|
const QByteArray& verb, |
|
|
|
|
QIODevice* data = 0) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::sendCustomRequest(request, verb, data); |
|
|
|
|
} |
|
|
|
|
void setCache(QAbstractNetworkCache* cache) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::setCache(cache); |
|
|
|
|
} |
|
|
|
|
void setConfiguration(const QNetworkConfiguration& config) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::setConfiguration(config); |
|
|
|
|
} |
|
|
|
|
void setCookieJar(QNetworkCookieJar* cookieJar) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::setCookieJar(cookieJar); |
|
|
|
|
} |
|
|
|
|
void setNetworkAccessible(NetworkAccessibility accessible) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::setNetworkAccessible(accessible); |
|
|
|
|
} |
|
|
|
|
void setProxy(const QNetworkProxy& proxy) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::setProxy(proxy); |
|
|
|
|
} |
|
|
|
|
void setProxyFactory(QNetworkProxyFactory* factory) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::setProxyFactory(factory); |
|
|
|
|
} |
|
|
|
|
QStringList supportedSchemes() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::supportedSchemes(); |
|
|
|
|
} |
|
|
|
|
Q_SIGNALS: |
|
|
|
@ -170,7 +171,7 @@ class NetworkAccessManager: public QNetworkAccessManager { |
|
|
|
|
virtual QNetworkReply* createRequest(Operation op, |
|
|
|
|
const QNetworkRequest& req, |
|
|
|
|
QIODevice* outgoingData = 0) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
switch (op) { |
|
|
|
|
case QNetworkAccessManager::HeadOperation: break; |
|
|
|
|
case QNetworkAccessManager::GetOperation: break; |
|
|
|
@ -180,32 +181,54 @@ class NetworkAccessManager: public QNetworkAccessManager { |
|
|
|
|
case QNetworkAccessManager::CustomOperation: break; |
|
|
|
|
case QNetworkAccessManager::UnknownOperation: break; |
|
|
|
|
} |
|
|
|
|
return QNetworkAccessManager::createRequest(op, req, outgoingData); |
|
|
|
|
QNetworkReply* reply |
|
|
|
|
(QNetworkAccessManager::createRequest(op, req, outgoingData)); |
|
|
|
|
connect(reply, SIGNAL(encrypted()), SLOT(encryptedLog())); |
|
|
|
|
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), |
|
|
|
|
SLOT(errorLog(QNetworkReply::NetworkError))); |
|
|
|
|
connect(reply, SIGNAL(finished()), SLOT(finishedLog())); |
|
|
|
|
connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), |
|
|
|
|
SLOT(sslErrorsLog(const QList<QSslError>&))); |
|
|
|
|
return reply; |
|
|
|
|
} |
|
|
|
|
protected Q_SLOTS: |
|
|
|
|
QStringList supportedSchemesImplementation() const { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
return QNetworkAccessManager::supportedSchemesImplementation(); |
|
|
|
|
} |
|
|
|
|
private Q_SLOTS: |
|
|
|
|
void errorLog(QNetworkReply::NetworkError) { |
|
|
|
|
log("**** Network Error: " |
|
|
|
|
+ dynamic_cast<QNetworkReply*>(sender())->errorString()); |
|
|
|
|
} |
|
|
|
|
void authenticationRequiredLog(QNetworkReply*, QAuthenticator*) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
void encryptedLog() { |
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
void encryptedLog(QNetworkReply*) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
void finishedLog() { |
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
void finishedLog(QNetworkReply*) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
void networkAccessibleChangedLog |
|
|
|
|
(QNetworkAccessManager::NetworkAccessibility) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
void proxyAuthenticationRequiredLog(const QNetworkProxy&, QAuthenticator*) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
void sslErrorsLog(const QList<QSslError>& errors) { |
|
|
|
|
Q_FOREACH(const QSslError& error, errors)
|
|
|
|
|
log("**** SSL-Error: "+error.errorString()); |
|
|
|
|
} |
|
|
|
|
void sslErrorsLog(QNetworkReply*, const QList<QSslError>&) { |
|
|
|
|
// log(__PRETTY_FUNCTION__);
|
|
|
|
|
//log(__PRETTY_FUNCTION__);
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|