Initial import of *VERY* incomplete, and not fully functional Cantata
webapp. Mainly used to test SQLite backend for storing MPD db.
This commit is contained in:
49
web/http/basichttpserver.cpp
Normal file
49
web/http/basichttpserver.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Petr Bravenec petr.bravenec@hobrasoft.cz
|
||||
* @author Craig Drummond
|
||||
*/
|
||||
|
||||
#include "basichttpserver.h"
|
||||
#include "httpconnection.h"
|
||||
#include "httprequesthandler.h"
|
||||
#include "staticfilecontroller.h"
|
||||
#include <QSettings>
|
||||
#include <QDebug>
|
||||
|
||||
bool BasicHttpServer::dbgEnabled=false;
|
||||
|
||||
#define DBUG if (BasicHttpServer::debugEnabled()) qWarning() << metaObject()->className() << (void *)this << __FUNCTION__
|
||||
|
||||
BasicHttpServer::BasicHttpServer(QObject *parent, const QSettings *s)
|
||||
: QTcpServer(parent)
|
||||
, serverSettings(s)
|
||||
, staticFiles(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool BasicHttpServer::start()
|
||||
{
|
||||
close();
|
||||
connect(this, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
|
||||
listen(QHostAddress::Any, serverSettings->value("http/port", 80).toInt());
|
||||
return isListening();
|
||||
}
|
||||
|
||||
void BasicHttpServer::slotNewConnection()
|
||||
{
|
||||
while (hasPendingConnections()) {
|
||||
DBUG;
|
||||
new HttpConnection(this, nextPendingConnection());
|
||||
}
|
||||
}
|
||||
|
||||
HttpRequestHandler * BasicHttpServer::getHandler(const QString &path)
|
||||
{
|
||||
Q_UNUSED(path)
|
||||
if (!staticFiles) {
|
||||
staticFiles=new StaticFileController(serverSettings);
|
||||
}
|
||||
return staticFiles;
|
||||
}
|
||||
Reference in New Issue
Block a user