From 47ddcf0d11f626e8a6fe6d3142bd38f9c129ef8b Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 4 Nov 2009 10:01:23 +0000 Subject: Prepare for SSL encrypted connection (https). --- client/netcom.cc | 34 +++++++++++++++++++++++++++++++++- client/netcom.h | 5 +++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/netcom.cc b/client/netcom.cc index 6150227..5cbcd22 100644 --- a/client/netcom.cc +++ b/client/netcom.cc @@ -26,6 +26,8 @@ */ #include "netcom.h" +#include + #include #include @@ -33,13 +35,31 @@ #include "widgets/widget.h" +#ifdef USE_SSL +#include +#include +#include +#include + +#ifdef QT_NO_OPENSSL +#error "QT not compiled with SSL support." +#endif +#endif + NetCom::NetCom(QString host, quint16 port, QString user, QString cpr) { this->user = user; this->cpr = cpr; connect(&http, SIGNAL(done(bool)), this, SLOT(done(bool))); - http.setHost(host, port); + +#ifdef USE_SSL + connect(&http, SIGNAL(sslErrors(const QList &)), + this, SLOT(sslError(const QList &))); + http.setHost(host, QHttp::ConnectionModeHttps, port); +#else + http.setHost(host, QHttp::ConnectionModeHttp, port); +#endif transfering = false; } @@ -146,3 +166,15 @@ void NetCom::done(bool) buffer = http.readAll(); transfering = false; } + +#ifdef USE_SSL +void NetCom::sslError(const QList &errlst) +{ + QList::const_iterator i = errlst.begin(); + while(i != errlst.end()) { + QMessageBox::warning(qApp->activeWindow(), "SSL Error", i->errorString()); + i++; + } + http.ignoreSslErrors(); +} +#endif diff --git a/client/netcom.h b/client/netcom.h index e11509b..c40f85c 100644 --- a/client/netcom.h +++ b/client/netcom.h @@ -33,6 +33,8 @@ #include #include +//#define USE_SSL + //#include "widgets/widget.h" class Widget; @@ -47,6 +49,9 @@ public: public slots: void done(bool); +#ifdef USE_SSL + void sslError(const QList &errlst); +#endif private: volatile bool transfering; -- cgit v1.2.3