Improved encoding support for browsing and adding.
authordruid23 <usr@dru-id.co.uk>
Wed, 18 Aug 2010 02:32:56 +0000 (03:32 +0100)
committerdruid23 <usr@dru-id.co.uk>
Wed, 18 Aug 2010 02:32:56 +0000 (03:32 +0100)
modified:   browsemainwindow.cpp
modified:   playermainwindow.cpp

browsemainwindow.cpp
playermainwindow.cpp

index 874c384..e201851 100644 (file)
@@ -130,21 +130,27 @@ void BrowseMainWindow::onBrowse() {
 }
 
 void BrowseMainWindow::onAddToPlaylist() {
-    qDebug() << QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue&input=" + mCurrentElement.path.replace("\\", "\\\\")).toString();
-    /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
-                             }
+    QUrl url = QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue");
+    url.addEncodedQueryItem(QByteArray("input"), QUrl::toPercentEncoding(mCurrentElement.path.replace("\\", "\\\\")));
+    mNetManager->get(QNetworkRequest(url));
+    //mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
+}
 
 void BrowseMainWindow::onPlay() {
-    qDebug() << QUrl("http://"+mIp+"/requests/status.xml?command=in_play&input=" + mCurrentElement.path.replace("\\", "\\\\")).toString();
-    /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_play&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
-                             }
+    QUrl url = QUrl("http://"+mIp+"/requests/status.xml?command=in_play");
+    url.addEncodedQueryItem(QByteArray("input"), QUrl::toPercentEncoding(mCurrentElement.path.replace("\\", "\\\\")));
+    mNetManager->get(QNetworkRequest(url));
+    //mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_play&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
+}
 
 void BrowseMainWindow::browseDirectory(QString dir) {
     mContents->clear();
     ui->listWidget->clear();
     mResponse.clear();
-    qDebug() << QUrl("http://"+mIp+"/requests/browse.xml?dir=" + dir.replace("\\", "\\\\")).toString();
-    QNetworkReply * reply =  mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/browse.xml?dir=" + dir.replace("\\", "\\\\"))));
+    QUrl url = QUrl("http://"+mIp+"/requests/browse.xml");
+    url.addEncodedQueryItem(QByteArray("dir"), QUrl::toPercentEncoding(dir));
+    QNetworkReply * reply = mNetManager->get(QNetworkRequest(url));
+    //QNetworkReply * reply =  mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/browse.xml?dir=" + dir.replace("&", "%26").replace("\\", "\\\\"))));
     connect(reply,SIGNAL(readyRead()),this,SLOT(readReady()));
     connect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(finished(QNetworkReply *)));
 }
index b4b2ed4..2e42289 100644 (file)
 
   void PlayerMainWindow::play()
   {
-
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_play")));
-
   }
   void PlayerMainWindow::stop()
   {
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_stop")));
-
   }
   void PlayerMainWindow::pause()
   {
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_pause")));
-
   }
   void PlayerMainWindow::previous()
   {
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_previous")));
-
   }
   void PlayerMainWindow::next()
   {
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_next")));
-
   }
   void PlayerMainWindow::fullscreen()
   {
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=fullscreen")));
-
   }
   void PlayerMainWindow::volUp()
   {
   }
   void PlayerMainWindow::volDown()
   {
-
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val=-20")));
-
   }
   void PlayerMainWindow::volMute()
   {
       else {
          mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val="+QString::number(this->mVolume))));
       }
-
   }
   void PlayerMainWindow::slide(int value)
   {
       mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=seek&val="+QString::number(value)+"%25")));
-
   }
 
   void PlayerMainWindow::showConfig()
       mPlayListMainWindow->init();
       mBrowserMainWindow->init();
       mTimer->start(5000);
+      askStatus();
   }
   void PlayerMainWindow::showAbout()
   {
       QTime timeLength(0,0,0) ;
       timeLength =  timeLength.addSecs(time);
 
-      ui->timeLabel->setText(timeLength.toString("mm:ss"));
+      ui->timeLabel->setText(timeLength.toString("h:mm:ss"));
 
 
       QDomNode infoNode =  docElem.namedItem("information");
       QDomNode metaInfoNode =  infoNode.namedItem("meta-information");
-      QString title = metaInfoNode.namedItem("title").toElement().text();
+      QString title = metaInfoNode.namedItem("title").toElement().text().replace("\\\\", "\\");
 
       if ( position >= 0 && position <=100)
          ui->slider->setValue(position);