Enable API WebServices when GC is running

.. but disable logging if not running as a server
.. let user define if API services start in preferences
This commit is contained in:
Mark Liversedge
2015-09-17 14:21:21 +01:00
parent db8893c5df
commit 8b071ae3e1
13 changed files with 151 additions and 80 deletions

View File

@@ -15,7 +15,7 @@ HttpSessionStore::HttpSessionStore(QSettings* settings, QObject* parent)
cleanupTimer.start(60000);
cookieName=settings->value("cookieName","sessionid").toByteArray();
expirationTime=settings->value("expirationTime",3600000).toInt();
qDebug("HttpSessionStore: Sessions expire after %i milliseconds",expirationTime);
wDebug("HttpSessionStore: Sessions expire after %i milliseconds",expirationTime);
}
HttpSessionStore::~HttpSessionStore()
@@ -35,7 +35,7 @@ QByteArray HttpSessionStore::getSessionId(HttpRequest& request, HttpResponse& re
// Clear the session ID if there is no such session in the storage.
if (!sessionId.isEmpty()) {
if (!sessions.contains(sessionId)) {
qDebug("HttpSessionStore: received invalid session cookie with ID %s",sessionId.data());
wDebug("HttpSessionStore: received invalid session cookie with ID %s",sessionId.data());
sessionId.clear();
}
}
@@ -67,7 +67,7 @@ HttpSession HttpSessionStore::getSession(HttpRequest& request, HttpResponse& res
QByteArray cookieComment=settings->value("cookieComment").toByteArray();
QByteArray cookieDomain=settings->value("cookieDomain").toByteArray();
HttpSession session(true);
qDebug("HttpSessionStore: create new session with ID %s",session.getId().data());
wDebug("HttpSessionStore: create new session with ID %s",session.getId().data());
sessions.insert(session.getId(),session);
response.setCookie(HttpCookie(cookieName,session.getId(),expirationTime/1000,cookiePath,cookieComment,cookieDomain));
mutex.unlock();
@@ -97,7 +97,7 @@ void HttpSessionStore::timerEvent() {
HttpSession session=prev.value();
qint64 lastAccess=session.getLastAccess();
if (now-lastAccess>expirationTime) {
qDebug("HttpSessionStore: session %s expired",session.getId().data());
wDebug("HttpSessionStore: session %s expired",session.getId().data());
sessions.erase(prev);
}
}