Changeset 1ba9324 in confclerk_git


Ignore:
Timestamp:
04/18/12 20:26:48 (10 years ago)
Author:
gregor herrmann <gregoa@…>
Branches:
master, qt5
Children:
dadb922
Parents:
d466553
Message:

Handle redirects when importing schedules over the network.

Fixes: #39

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    rd466553 r1ba9324  
    335335}
    336336
    337 void MainWindow::networkQueryFinished(QNetworkReply *aReply)
    338 {
    339     if ( aReply->error() != QNetworkReply::NoError )
    340     {
     337void MainWindow::networkQueryFinished(QNetworkReply *aReply) {
     338    if (aReply->error() != QNetworkReply::NoError) {
    341339        error_message(QString("Error occured during download: ") + aReply->errorString());
    342     }
    343     else
    344     {
    345         importData(aReply->readAll(), aReply->url().toEncoded());
     340    } else {
     341        QUrl redirectUrl = aReply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
     342        if (!redirectUrl.isEmpty()) {
     343            if (redirectUrl != aReply->request().url()) {
     344                importFromNetwork(redirectUrl.toString());
     345                return; // don't enable controls
     346            } else {
     347                error_message(QString("Error: Cyclic redirection from %1 to itself.").arg(redirectUrl.toString()));
     348            }
     349        } else {
     350            importData(aReply->readAll(), aReply->url().toEncoded());
     351        }
    346352    }
    347353    setEnabled(true);
Note: See TracChangeset for help on using the changeset viewer.