mirror of
https://github.com/YACReader/yacreader
synced 2025-07-23 15:35:03 -04:00
en macosx se usa el folder del sistema en la sidebar
This commit is contained in:
84
YACReaderLibrary/server/controllers/comiccontroller.cpp
Normal file
84
YACReaderLibrary/server/controllers/comiccontroller.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "comiccontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "comic.h"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
ComicController::ComicController() {}
|
||||
|
||||
void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||
QStringList pathElements = path.split('/');
|
||||
QString libraryName = pathElements.at(2);
|
||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||
|
||||
//TODO
|
||||
//if(pathElements.size() == 6)
|
||||
//{
|
||||
// QString action = pathElements.at(5);
|
||||
// if(!action.isEmpty() && (action == "close"))
|
||||
// {
|
||||
// session.dismissCurrentComic();
|
||||
// response.write("",true);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
//Aplicar a todos los controladores
|
||||
//TODO usar LibraryWindow para acceder a informaci<63>n de las bases de datos est<73> mal, hay
|
||||
//que crear una clase que se encargue de estas cosas
|
||||
//<2F>Se est<73> accediendo a la UI desde un hilo?
|
||||
|
||||
QMap<QString,QString> libraries = DBHelper::getLibraries();
|
||||
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryName, comicId);
|
||||
|
||||
session.setDownloadedComic(comic.info.hash);
|
||||
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.value(libraryName)+comic.path);
|
||||
|
||||
if(comicFile != NULL)
|
||||
{
|
||||
QThread * thread = NULL;
|
||||
if (typeid(*comicFile) != typeid(FileComic))
|
||||
{
|
||||
thread = new QThread();
|
||||
|
||||
comicFile->moveToThread(thread);
|
||||
|
||||
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
}
|
||||
|
||||
comicFile->load(libraries.value(libraryName)+comic.path);
|
||||
|
||||
if(thread != NULL)
|
||||
thread->start();
|
||||
|
||||
session.setCurrentComic(comic.id, comicFile);
|
||||
|
||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
|
||||
response.writeText(QString("library:%1\r\n").arg(libraryName));
|
||||
response.writeText(comic.toTXT(),true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//delete comicFile;
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
Reference in New Issue
Block a user