mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
A?adida la informaci?n de descarga de folders y c?mcs
A?adidos los atributos necesarios a la sesi?n relacionados con YACReader
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
#include "comiccontroller.h"
|
||||
|
||||
#include "library_window.h"
|
||||
|
||||
extern LibraryWindow * mw;
|
||||
@ -7,25 +8,47 @@ extern LibraryWindow * mw;
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "comic.h"
|
||||
|
||||
ComicController::ComicController() {}
|
||||
|
||||
void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
|
||||
|
||||
HttpSession session=Static::sessionStore->getSession(request,response);
|
||||
|
||||
QStringList pathElements = ((QString)request.getPath()).split('/');
|
||||
QString libraryName = pathElements.at(2);
|
||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||
|
||||
QMap<QString,QString> libraries = mw->getLibraries();
|
||||
|
||||
|
||||
ComicDB comic = mw->getComicInfo(libraryName, comicId);
|
||||
|
||||
response.writeText(QString("comicid:%1\n").arg(comic.id));
|
||||
response.writeText(QString("hash:%1\n").arg(comic.info.hash));
|
||||
response.writeText(QString("path:%1\n").arg(comic.path));
|
||||
response.writeText(QString("numpages:%1\n").arg(*comic.info.numPages));
|
||||
response.writeText(QString("library:%1\n").arg(libraryName),true);
|
||||
Comic * comicFile = new Comic;
|
||||
if(comicFile->load(libraries.value(libraryName)+comic.path))
|
||||
{
|
||||
session.setCurrentComic(comic.id, comicFile);
|
||||
|
||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
response.writeText(QString("comicid:%1\n").arg(comic.id));
|
||||
response.writeText(QString("hash:%1\n").arg(comic.info.hash));
|
||||
response.writeText(QString("path:%1\n").arg(comic.path));
|
||||
response.writeText(QString("numpages:%1\n").arg(*comic.info.numPages));
|
||||
response.writeText(QString("library:%1\n").arg(libraryName),true);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete comicFile;
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
@ -65,6 +65,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
t.setVariable(QString("element%1.name").arg(i),folderContent.at(i + (page*10))->name);
|
||||
t.setVariable(QString("element%1.url").arg(i),"/library/"+libraryName+"/folder/"+QString("%1").arg(folderContent.at(i + (page*10))->id));
|
||||
t.setVariable(QString("element%1.downloadurl").arg(i),"/library/"+libraryName+"/folder/"+QString("%1/info").arg(folderContent.at(i + (page*10))->id));
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
#include "folderinfocontroller.h"
|
||||
#include "library_window.h" //get libraries
|
||||
|
||||
#include "folder.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
extern LibraryWindow * mw;
|
||||
|
||||
FolderInfoController::FolderInfoController() {}
|
||||
|
||||
void FolderInfoController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
|
||||
QString path = request.getPath();
|
||||
QStringList pathElements = path.split('/');
|
||||
QString libraryName = pathElements.at(2);
|
||||
qulonglong parentId = pathElements.at(4).toULongLong();
|
||||
QList<LibraryItem *> folderContent = mw->getFolderContentFromLibrary(libraryName,parentId);
|
||||
QList<LibraryItem *> folderComics = mw->getFolderComicsFromLibrary(libraryName,parentId);
|
||||
|
||||
Folder * currentFolder;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderContent.constBegin();itr!=folderContent.constEnd();itr++)
|
||||
{
|
||||
currentFolder = (Folder *)(*itr);
|
||||
response.writeText(QString("/library/%1/folder/%2/info\n").arg(libraryName).arg(currentFolder->id));
|
||||
}
|
||||
|
||||
ComicDB * currentComic;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderComics.constBegin();itr!=folderComics.constEnd();itr++)
|
||||
{
|
||||
currentComic = (ComicDB *)(*itr);
|
||||
response.writeText(QString("/library/%1/comic/%2\n").arg(libraryName).arg(currentComic->id));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef FOLDERINFOCONTROLLER_H
|
||||
#define FOLDERINFOCONTROLLER_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class FolderInfoController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(FolderInfoController);
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
FolderInfoController();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // FOLDERINFOCONTROLLER_H
|
||||
|
Reference in New Issue
Block a user