mirror of
https://github.com/YACReader/yacreader
synced 2025-11-13 21:42:50 -05:00
controlador de p?ginas
corregido bug relacionado con los datos de sesi?n (delete comic)
This commit is contained in:
@ -41,7 +41,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
}
|
||||
else
|
||||
{
|
||||
delete comicFile;
|
||||
//delete comicFile;
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
#include "pagecontroller.h"
|
||||
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic.h"
|
||||
|
||||
PageController::PageController() {}
|
||||
|
||||
void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
|
||||
|
||||
HttpSession session=Static::sessionStore->getSession(request,response);
|
||||
|
||||
QStringList pathElements = ((QString)request.getPath()).split('/');
|
||||
QString libraryName = pathElements.at(2);
|
||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||
quint16 page = pathElements.at(6).toUInt();
|
||||
|
||||
Comic * comicFile = session.getCurrentComic();
|
||||
if((comicFile != 0) && comicId == session.getCurrentComicId())
|
||||
{
|
||||
response.setHeader("Content-Type", "image/page");
|
||||
QByteArray pageData = comicFile->getRawPage(page);
|
||||
response.write(pageData);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete comicFile;
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
#ifndef PAGECONTROLLER_H
|
||||
#define PAGECONTROLLER_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class PageController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(PageController);
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
PageController();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // PAGECONTROLLER_H
|
||||
|
||||
Reference in New Issue
Block a user