From 13afdc560063b8852cbc7b5dc37d4e5661c60bd1 Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Mon, 11 Mar 2013 19:53:25 +0000 Subject: [PATCH] If we use a port<1024 for HTTP server, then just assign a 'dynamic'/random port --- gui/settings.cpp | 2 +- http/httpserversettings.cpp | 5 ++++- http/httpserversettings.ui | 4 ++-- http/httpsocket.cpp | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gui/settings.cpp b/gui/settings.cpp index 72ed4df3b..cc12d54bb 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -521,7 +521,7 @@ int Settings::stopFadeDuration() #ifdef TAGLIB_FOUND int Settings::httpPort() { - return GET_INT("httpPort", 9001); + return GET_INT("httpPort", 1023); } QString Settings::httpAddress() diff --git a/http/httpserversettings.cpp b/http/httpserversettings.cpp index dc387b02d..d22261157 100644 --- a/http/httpserversettings.cpp +++ b/http/httpserversettings.cpp @@ -23,18 +23,21 @@ #include "httpserversettings.h" #include "settings.h" +#include "localize.h" HttpServerSettings::HttpServerSettings(QWidget *p) : QWidget(p) { setupUi(this); + httpPort->setSpecialValueText(i18n("Dynamic")); } void HttpServerSettings::load() { + int port=Settings::self()->httpPort(); enableHttp->setChecked(Settings::self()->enableHttp()); alwaysUseHttp->setChecked(Settings::self()->alwaysUseHttp()); - httpPort->setValue(Settings::self()->httpPort()); + httpPort->setValue(port<1024 ? 1023 : port); httpAddress->setText(Settings::self()->httpAddress()); } diff --git a/http/httpserversettings.ui b/http/httpserversettings.ui index 20c9b1fbb..8b78baadd 100644 --- a/http/httpserversettings.ui +++ b/http/httpserversettings.ui @@ -66,7 +66,7 @@ - 1 + 1023 65535 @@ -108,7 +108,7 @@ <i><b>NOTE:</b> MPD usually only plays songs that are stored within its folders. If you have connected via a local socket, then MPD can also play files located on your filesystem. If you are using a non local socket (e.g. you have entered a hostname or IP address in the 'Host' field of the 'Connection' settings page), then Cantata contains a minimal HTTP server that can be used to serve files to MPD. This, however, will only work whilst Cantata is running. If you enable 'Always use server', then Cantata will always pass server URLs to MPD for files, even when you have connected via a local socket.<br/><br/> -<b>NOTE:</b> 'Address/interface' may contain either the IP address, or interface (e.g. eth0), that you wish to listen for connections on. Leave blank to use the local loopback address (127.0.0.1).</i></i> +<b>NOTE:</b> 'Address/interface' may contain either the IP address, or interface (e.g. eth0), that you wish to listen for connections on. Leave blank to use the local loopback address (127.0.0.1).<br/><br/><b>NOTE:</b> Leave port set to 'Dynamic' to have Cantata choose a random port number.</i> true diff --git a/http/httpsocket.cpp b/http/httpsocket.cpp index bef534b28..5ef4e2411 100644 --- a/http/httpsocket.cpp +++ b/http/httpsocket.cpp @@ -186,7 +186,7 @@ HttpSocket::HttpSocket(const QString &addr, quint16 p) } } } - listen(a.isNull() ? QHostAddress::LocalHost : a, p); + listen(a.isNull() ? QHostAddress::LocalHost : a, p<1024 ? 0 : p); } void HttpSocket::terminate()