diff --git a/http/httpserver.cpp b/http/httpserver.cpp index e03774ec8..6b73b3130 100644 --- a/http/httpserver.cpp +++ b/http/httpserver.cpp @@ -26,6 +26,7 @@ #include "tags.h" #include "settings.h" #include "thread.h" +#include #include #if QT_VERSION >= 0x050000 #include @@ -187,7 +188,15 @@ QByteArray HttpServer::encodeUrl(const QString &file) const { #ifdef Q_OS_WIN QString f=fixWindowsPath(file); - DBUG << "file" << f; + DBUG << "file" << f << "orig" << file; + // For some reason, drag'n' drop of \\share\path\file.mp3 is changed to share/path/file.mp3! + if (!f.startsWith(QLatin1String("//")) && !QFile::exists(f)) { + QString share=f.startsWith(QLatin1Char('/')) ? (QLatin1Char('/')+f) : (QLatin1String("//")+f); + if (QFile::exists(share)) { + f=share; + DBUG << "converted to share-path" << f; + } + } Song s=Tags::read(f); s.file=f; #else diff --git a/http/httpsocket.cpp b/http/httpsocket.cpp index 21d1f8e87..128c4e7c0 100644 --- a/http/httpsocket.cpp +++ b/http/httpsocket.cpp @@ -327,7 +327,7 @@ void HttpSocket::readClient() if (tokens.length()>=2 && "GET"==tokens[0]) { QStringList params = QString(socket->readAll()).split(QRegExp("[\r\n][\r\n]*")); - DBUG << "params" << params; + DBUG << "params" << params << "tokens" << tokens; if (!isFromMpd(params)) { return; } @@ -403,6 +403,16 @@ void HttpSocket::readClient() } #endif } else if (!song.file.isEmpty()) { + #ifdef Q_OS_WIN + if (tokens[1].startsWith("//") && !song.file.startsWith(QLatin1String("//")) && !QFile::exists(song.file)) { + QString share=QLatin1String("//")+url.host()+song.file; + if (QFile::exists(share)) { + song.file=share; + DBUG << "fixed share-path" << song.file; + } + } + #endif + QFile f(song.file); if (f.open(QIODevice::ReadOnly)) { @@ -464,7 +474,7 @@ void HttpSocket::readClient() if (!ok) { QTextStream os(socket); os.setAutoDetectUnicode(true); - os << "HTTP/1.0 404 Ok\r\n" + os << "HTTP/1.0 404 OK\r\n" "Content-Type: text/html; charset=\"utf-8\"\r\n" "\r\n" "

Nothing to see here

\n";