Fixed download bug
authorElias Woods <EliasWoods@gmail.com>
Thu, 1 Jul 2010 07:16:54 +0000 (03:16 -0400)
committerElias Woods <EliasWoods@gmail.com>
Thu, 1 Jul 2010 07:16:54 +0000 (03:16 -0400)
Groove.pro.user
playlist.cpp
playlist.h

index ecdfbb8..9863bf3 100644 (file)
@@ -2,7 +2,7 @@
 <qtcreator>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
-  <value type="int">1</value>
+  <value type="int">0</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.EditorSettings</variable>
     </valuemap>
     <value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">1</value>
     <valuemap key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployed" type="QVariantMap">
-     <value key="192.168.1.3" type="QDateTime">2010-07-01T01:31:56</value>
+     <value key="192.168.1.3" type="QDateTime">2010-07-01T03:13:16</value>
     </valuemap>
     <value key="Qt4ProjectManager.MaemoRunConfiguration.Simulator" type="QString"></value>
    </valuemap>
index 3004f86..3c9f6ea 100644 (file)
@@ -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)));
     }
 }
 
index 2fe1acb..48966ff 100644 (file)
@@ -50,6 +50,7 @@ private slots:
     void downloadDone(int position);
     void skeyFound();
     void setBufferRdy(int b);
+    void getNError(QNetworkReply::NetworkError);
 private: