Changeset f94ab1d


Ignore:
Timestamp:
01/23/17 18:59:07 (5 years ago)
Author:
gregor herrmann <gregoa@…>
Branches:
master, qt5
Children:
6984e9d
Parents:
0d41eb2
Message:

Handle SSL errors.

Show warning with error messages, offer to ignore them or abort download.

Location:
src/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    r0d41eb2 rf94ab1d  
    132132    }
    133133
     134    connect(mNetworkAccessManager, SIGNAL(sslErrors(QNetworkReply*, QList<QSslError>)), SLOT(sslErrors(QNetworkReply*, QList<QSslError>)));
    134135    connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), SLOT(networkQueryFinished(QNetworkReply*)));
    135136    connect(mXmlParser, SIGNAL(parsingScheduleBegin()), conferenceModel, SLOT(newConferenceBegin()));
     
    410411}
    411412
     413void MainWindow::sslErrors(QNetworkReply *aReply, const QList<QSslError> &errors) {
     414    QString errorString;
     415    foreach (const QSslError &error, errors) {
     416        if (!errorString.isEmpty()) {
     417            errorString += ", ";
     418        }
     419        errorString += error.errorString();
     420    }
     421
     422    if (QMessageBox::warning(
     423                this,
     424                QString("SSL errors"),
     425                QString("One or more SSL errors have occurred: ") + errorString,
     426                QMessageBox::Ignore | QMessageBox::Cancel) == QMessageBox::Ignore) {
     427        aReply->ignoreSslErrors();
     428    } else {
     429        aReply->abort();
     430    }
     431}
     432
    412433void MainWindow::networkQueryFinished(QNetworkReply *aReply) {
    413434    if (aReply->error() != QNetworkReply::NoError) {
  • src/gui/mainwindow.h

    r0d41eb2 rf94ab1d  
    2222
    2323#include <QtGui/QMainWindow>
     24#include <QSslError>
    2425
    2526#include "ui_mainwindow.h"
     
    5253    void onSearchResultChanged();
    5354
     55    void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
    5456    void networkQueryFinished(QNetworkReply*);
    5557    void importFromNetwork(const QString&, int conferenceId);
Note: See TracChangeset for help on using the changeset viewer.