Simplify HTTP server settings. Now only the interface can be chosen. HTTP server is used for all non-MPD files. If computer has no active network connection (e.g. lo is the only interface), then the HTTP server settings page is hidden.

This commit is contained in:
craig.p.drummond
2013-05-13 20:40:37 +00:00
committed by craig.p.drummond
parent 0d5db70eb4
commit 23fac23d50
14 changed files with 153 additions and 345 deletions

View File

@@ -63,11 +63,9 @@ void HttpServer::stop()
bool HttpServer::readConfig()
{
QString addr=Settings::self()->httpAddress();
quint16 port=Settings::self()->httpPort();
quint16 prevPort=Settings::self()->httpAllocatedPort();
QString iface=Settings::self()->httpInterface();
if (socket && socket->isListening() && port==socket->serverPort() && addr==socket->configuredAddress() && Settings::self()->enableHttp()) {
if (socket && socket->isListening() && iface==socket->configuredInterface()) {
return true;
}
@@ -81,18 +79,15 @@ bool HttpServer::readConfig()
thread=0;
}
if (Settings::self()->enableHttp()) {
thread=new Thread("HttpServer");
socket=new HttpSocket(addr, port, prevPort);
if (socket->serverPort()!=port) {
Settings::self()->saveHttpAllocatedPort(socket->serverPort());
}
socket->moveToThread(thread);
thread->start();
return socket->isListening();
} else {
return true;
quint16 prevPort=Settings::self()->httpAllocatedPort();
thread=new Thread("HttpServer");
socket=new HttpSocket(iface, prevPort);
if (socket->serverPort()!=prevPort) {
Settings::self()->saveHttpAllocatedPort(socket->serverPort());
}
socket->moveToThread(thread);
thread->start();
return socket->isListening();
}
bool HttpServer::isAlive() const
@@ -103,7 +98,7 @@ bool HttpServer::isAlive() const
QString HttpServer::address() const
{
return socket ? QLatin1String("http://")+socket->address()+QChar(':')+QString::number(socket->serverPort())
: QLatin1String("http://127.0.0.1:")+QString::number(Settings::self()->httpPort());
: QLatin1String("http://127.0.0.1:*");
}
bool HttpServer::isOurs(const QString &url) const