Files
surfer/src/sslclientnetworkmanager.hxx

59 lines
1.4 KiB
C++
Raw Normal View History

2011-01-19 15:04:11 +00:00
/*! @file
@id $Id$
*/
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkAccessManager>
2011-06-08 13:00:40 +00:00
#include <smartcardauth.hxx>
2011-01-19 15:04:11 +00:00
#include <QtCore/QDebug>
#ifndef LOG
#define LOG qDebug()<<__PRETTY_FUNCTION__
#endif
class SslClientAuthNetworkAccessManager: public QNetworkAccessManager {
Q_OBJECT;
public:
SslClientAuthNetworkAccessManager(QObject* parent = 0):
QNetworkAccessManager(parent) {
LOG;
}
virtual ~SslClientAuthNetworkAccessManager() {
LOG;
}
2011-06-08 13:00:40 +00:00
void scAuth(SmartCardAuth* auth) {
_scAuth = std::auto_ptr<SmartCardAuth>(auth);
}
2011-01-19 15:04:11 +00:00
Q_SIGNALS:
void created(QNetworkReply*);
protected:
virtual QNetworkReply* createRequest(Operation op,
const QNetworkRequest& req,
QIODevice* outgoingData = 0 ) {
LOG<<req.url();
2011-06-08 13:00:40 +00:00
if (req.url().scheme()=="https") {
LOG<<"Need to login";
if (_scAuth.get()) _scAuth->login(false);
}
2011-01-19 15:04:11 +00:00
QNetworkReply* rep
(QNetworkAccessManager::createRequest(op, req, outgoingData));
created(rep);
LOG<<"Reply to URL: "<<rep->url().toString();
return rep;
}
2011-06-08 13:00:40 +00:00
private:
std::auto_ptr<SmartCardAuth> _scAuth;
2011-01-19 15:04:11 +00:00
};