added a dummy (yet) SyncController for testing sync info from iOS

This commit is contained in:
Luis Ángel San Martín 2015-03-26 22:10:51 +01:00
parent a4230699b1
commit e00d76b81a
4 changed files with 128 additions and 76 deletions

View File

@ -0,0 +1,25 @@
#include "synccontroller.h"
#include "QsLog.h"
#include <QUrl>
SyncController::SyncController()
{
}
void SyncController::service(HttpRequest &request, HttpResponse &response)
{
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/');
qulonglong libraryId = pathElements.at(2).toULongLong();
QString postData = QString::fromUtf8(request.getBody());
QLOG_INFO() << "POST DATA: " << postData;
//TODO Process postData and update the comics
response.write("OK",true);
}

View File

@ -0,0 +1,21 @@
#ifndef SYNCCONTROLLER_H
#define SYNCCONTROLLER_H
#include <QObject>
#include "httprequest.h"
#include "httpresponse.h"
#include "httprequesthandler.h"
class SyncController : public HttpRequestHandler {
Q_OBJECT
Q_DISABLE_COPY(SyncController);
public:
/** Constructor */
SyncController();
/** Generates the response */
void service(HttpRequest& request, HttpResponse& response);
};
#endif // SYNCCONTROLLER_H

View File

@ -21,6 +21,7 @@
#include "controllers/updatecomiccontroller.h"
#include "controllers/errorcontroller.h"
#include "controllers/comicdownloadinfocontroller.h"
#include "controllers/synccontroller.h"
#include "db_helper.h"
#include "yacreader_libraries.h"
@ -105,6 +106,8 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
QRegExp comicPage("/library/.+/comic/[0-9]+/page/[0-9]+/?"); //get comic page
QRegExp comicPageRemote("/library/.+/comic/[0-9]+/page/[0-9]+/remote?"); //get comic page (remote reading)
QRegExp sync("/library/.+/sync");
QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe
path = QUrl::fromPercentEncoding(path).toUtf8();
@ -116,10 +119,11 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
{
LibrariesController().service(request, response);
}
else
{
if(sync.exactMatch(path))
SyncController().service(request, response);
{
//se comprueba que la sesión sea la correcta con el fin de evitar accesos no autorizados
HttpSession session=Static::sessionStore->getSession(request,response,false);
if(!session.isNull() && session.contains("ySession"))
@ -167,5 +171,5 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
ErrorController(300).service(request,response);
}
}
}
}

View File

@ -13,8 +13,9 @@ HEADERS += \
$$PWD/controllers/pagecontroller.h \
$$PWD/controllers/sessionmanager.h \
$$PWD/controllers/covercontroller.h \
server/controllers/updatecomiccontroller.h \
server/controllers/comicdownloadinfocontroller.h
$$PWD/controllers/updatecomiccontroller.h \
$$PWD/controllers/comicdownloadinfocontroller.h \
$$PWD/controllers/synccontroller.h
SOURCES += \
$$PWD/static.cpp \
@ -28,8 +29,9 @@ SOURCES += \
$$PWD/controllers/pagecontroller.cpp \
$$PWD/controllers/sessionmanager.cpp \
$$PWD/controllers/covercontroller.cpp \
server/controllers/updatecomiccontroller.cpp \
server/controllers/comicdownloadinfocontroller.cpp
$$PWD/controllers/updatecomiccontroller.cpp \
$$PWD/controllers/comicdownloadinfocontroller.cpp \
$$PWD/controllers/synccontroller.cpp
include(lib/bfLogging/bfLogging.pri)
include(lib/bfHttpServer/bfHttpServer.pri)