diff --git a/ChangeLog b/ChangeLog index 9237b08cc..912662a50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ default, and can be toggled via the config file. 5. Dont re-load view when sort changes. 6. Simplify view config pages. +7. Use QUrl with server details to build HTTP address used to compare MPD http + file paths against. 1.4.0 ----- diff --git a/http/httpserver.cpp b/http/httpserver.cpp index e75f9835a..e3f1dff20 100644 --- a/http/httpserver.cpp +++ b/http/httpserver.cpp @@ -131,8 +131,7 @@ void HttpServer::readConfig() QString HttpServer::address() const { - return socket ? QLatin1String("http://")+socket->address()+QChar(':')+QString::number(socket->serverPort()) - : QLatin1String("http://127.0.0.1:*"); + return socket ? socket->urlAddress() : QLatin1String("http://127.0.0.1:*"); } bool HttpServer::isOurs(const QString &url) const diff --git a/http/httpsocket.cpp b/http/httpsocket.cpp index aaa689d88..76b4239e6 100644 --- a/http/httpsocket.cpp +++ b/http/httpsocket.cpp @@ -258,8 +258,9 @@ HttpSocket::HttpSocket(const QString &iface, quint16 port) if (isListening() && ifaceAddress.isEmpty()) { ifaceAddress=QLatin1String("127.0.0.1"); } + setUrlAddress(); - DBUG << isListening() << ifaceAddress << serverPort(); + DBUG << isListening() << urlAddr; connect(MPDConnection::self(), SIGNAL(socketAddress(QString)), this, SLOT(mpdAddress(QString))); connect(MPDConnection::self(), SIGNAL(cantataStreams(QList,bool)), this, SLOT(cantataStreams(QList,bool))); @@ -565,3 +566,16 @@ bool HttpSocket::write(QTcpSocket *socket, char *buffer, qint32 bytesRead, bool } return true; } + +void HttpSocket::setUrlAddress() +{ + if (ifaceAddress.isEmpty()) { + ifaceAddress=QString(); + } else { + QUrl url; + url.setScheme("http"); + url.setHost(ifaceAddress); + url.setPort(serverPort()); + urlAddr=url.toString(); + } +} diff --git a/http/httpsocket.h b/http/httpsocket.h index 0f32c7a46..c9c8de0d0 100644 --- a/http/httpsocket.h +++ b/http/httpsocket.h @@ -44,6 +44,7 @@ public: void incomingConnection(int socket); QString address() const { return ifaceAddress; } QString configuredInterface() { return cfgInterface; } + QString urlAddress() const { return urlAddr; } public Q_SLOTS: void terminate(); @@ -63,12 +64,14 @@ private Q_SLOTS: private: bool write(QTcpSocket *socket, char *buffer, qint32 bytesRead, bool &stop); + void setUrlAddress(); private: QSet newlyAddedFiles; // Holds cantata strema filenames as added to MPD via "add" QMap streamIds; // Maps MPD playqueue song ID to fileName QString cfgInterface; QString ifaceAddress; + QString urlAddr; QString mpdAddr; bool terminated; };