From 2b5ac4716899e468d31fbdcd244aa36d44f82ed7 Mon Sep 17 00:00:00 2001 From: druid23 Date: Wed, 18 Aug 2010 03:32:56 +0100 Subject: [PATCH] Improved encoding support for browsing and adding. modified: browsemainwindow.cpp modified: playermainwindow.cpp --- browsemainwindow.cpp | 22 ++++++++++++++-------- playermainwindow.cpp | 16 +++------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/browsemainwindow.cpp b/browsemainwindow.cpp index 874c384..e201851 100644 --- a/browsemainwindow.cpp +++ b/browsemainwindow.cpp @@ -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 *))); } diff --git a/playermainwindow.cpp b/playermainwindow.cpp index b4b2ed4..2e42289 100644 --- a/playermainwindow.cpp +++ b/playermainwindow.cpp @@ -116,34 +116,27 @@ 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() { @@ -153,9 +146,7 @@ } void PlayerMainWindow::volDown() { - mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val=-20"))); - } void PlayerMainWindow::volMute() { @@ -166,12 +157,10 @@ 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() @@ -185,6 +174,7 @@ mPlayListMainWindow->init(); mBrowserMainWindow->init(); mTimer->start(5000); + askStatus(); } void PlayerMainWindow::showAbout() { @@ -227,12 +217,12 @@ 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); -- 1.7.9.5