summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2009-11-04 10:01:23 +0000
committerdeva <deva>2009-11-04 10:01:23 +0000
commit47ddcf0d11f626e8a6fe6d3142bd38f9c129ef8b (patch)
tree3ea32ab6845b14197c2dc6d0c4e9b431618d6571 /client
parent1782d12938ba89b67a52677d162d4c865f00cbe0 (diff)
Prepare for SSL encrypted connection (https).
Diffstat (limited to 'client')
-rw-r--r--client/netcom.cc34
-rw-r--r--client/netcom.h5
2 files changed, 38 insertions, 1 deletions
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 <QtNetwork>
+
#include <QApplication>
#include <QByteArray>
@@ -33,13 +35,31 @@
#include "widgets/widget.h"
+#ifdef USE_SSL
+#include <QMessageBox>
+#include <QList>
+#include <QSslError>
+#include <QSslSocket>
+
+#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<QSslError> &)),
+ this, SLOT(sslError(const QList<QSslError> &)));
+ 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<QSslError> &errlst)
+{
+ QList<QSslError>::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 <QDomDocument>
#include <QHttp>
+//#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<QSslError> &errlst);
+#endif
private:
volatile bool transfering;