diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/netcom.cc | 34 | ||||
| -rw-r--r-- | client/netcom.h | 5 | 
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; | 
