-
- networkReply->deleteLater();
- return networkReply;
-
-}
-
-void NetworkAccess::syncMetaDataChanged() {
-
- QUrl redirection = networkReply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
- if (redirection.isValid()) {
-
- qDebug() << "Redirect" << redirection;
- networkReply->deleteLater();
- syncGet(redirection);
-
- /*
- QNetworkAccessManager *manager = The::networkAccessManager();
- networkReply->deleteLater();
- networkReply = manager->get(QNetworkRequest(redirection));
- connect(networkReply, SIGNAL(metaDataChanged()),
- this, SLOT(metaDataChanged()), Qt::AutoConnection);
- connect(networkReply, SIGNAL(finished()),
- this, SLOT(finished()), Qt::AutoConnection);
- */
- }
-
-}
-
-void NetworkAccess::syncFinished() {
- // got it!
- working = false;
-}
-
-void NetworkAccess::error(QNetworkReply::NetworkError code) {
- // get the QNetworkReply that sent the signal
- QNetworkReply *networkReply = static_cast<QNetworkReply *>(sender());
- if (!networkReply) {
- qDebug() << "Cannot get sender";
- return;
- }
-
- // Ignore HEADs
- if (networkReply->operation() == QNetworkAccessManager::HeadOperation)
- return;
-
- // report the error in the status bar
- QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(qApp->topLevelWidgets().first());
- if (mainWindow) mainWindow->statusBar()->showMessage(
- tr("Network error: %1").arg(networkReply->errorString()));
-
- qDebug() << "Network error:" << networkReply->errorString() << code;
-
- networkReply->deleteLater();
-}
-
-QByteArray NetworkAccess::syncGetBytes(QUrl url) {
- return syncGet(url)->readAll();
-}
-
-QString NetworkAccess::syncGetString(QUrl url) {
- return QString::fromUtf8(syncGetBytes(url));