X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=playlist.cpp;h=3c9f6ea03a15caa6028c82c577357595c894acd0;hb=dfc707053eff22b0af3a9f4b2a85c684d68a99aa;hp=3004f86aff91ff9eb7a600ad7b91a3196c4331df;hpb=761d03eb0416a4ce1b43fb9c3d84342458c1c54f;p=groove diff --git a/playlist.cpp b/playlist.cpp index 3004f86..3c9f6ea 100644 --- a/playlist.cpp +++ b/playlist.cpp @@ -73,16 +73,24 @@ void playlist::beginDownload(int position) req.setHeader(req.ContentTypeHeader,QVariant("application/x-www-form-urlencoded")); if(reply) { - reply->abort(); - delete reply; + reply->disconnect(); + reply->deleteLater(); } reply = manager->post(req,QString("streamKey=" + pList->at(this->currentdownloaditem)->streamkey->toAscii()).toAscii()); pList->at(this->currentdownloaditem)->buffer->open(QBuffer::ReadWrite | QBuffer::Truncate); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadSlot(qint64,qint64))); connect(reply,SIGNAL(finished()),this,SLOT(networkReplyFinish())); connect(this,SIGNAL(downloadComplete(int)),this,SLOT(downloadDone(int))); + connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(getNError(QNetworkReply::NetworkError))); startStreamT = QTime::currentTime(); } +void playlist::getNError(QNetworkReply::NetworkError error) +{ + qDebug() << "Network Error (if this is 99 then it will retry" << error; + if(error == QNetworkReply::UnknownNetworkError) + beginDownload(this->currentdownloaditem); + +} void playlist::setGscom(gscom *comm) { @@ -138,10 +146,17 @@ void playlist::networkReplyFinish() QNetworkRequest req; req.setUrl(url.toUrl()); qDebug() << url; + if(reply) + { + reply->disconnect(); + reply->deleteLater(); + } reply = manager->get(req); startStreamT = QTime::currentTime(); //connect(reply,SIGNAL(finished()),this,SLOT(start())); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadSlot(qint64,qint64))); + connect(reply,SIGNAL(finished()),this,SLOT(networkReplyFinish())); + connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(getNError(QNetworkReply::NetworkError))); } }