Improved encoding support for browsing and adding.
[vlc-remote] / browsemainwindow.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 *)));
 }