mirror of
https://github.com/YACReader/yacreader
synced 2025-07-26 00:44:59 -04:00
fixed simultaneously importing and remote reading
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
#include "comic_db.h"
|
||||
#include "comic.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
ComicController::ComicController() {}
|
||||
@ -22,7 +24,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
QString libraryName = DBHelper::getLibraryName(pathElements.at(2).toInt());
|
||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||
|
||||
bool remoteComic = path.contains("remote");
|
||||
bool remoteComic = path.endsWith("remote");
|
||||
|
||||
//TODO
|
||||
//if(pathElements.size() == 6)
|
||||
@ -67,7 +69,17 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
if(thread != NULL)
|
||||
thread->start();
|
||||
|
||||
session.setCurrentComic(comic.id, comicFile);
|
||||
if(remoteComic)
|
||||
{
|
||||
QLOG_INFO() << "remote comic requested";
|
||||
session.setCurrentRemoteComic(comic.id, comicFile);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_INFO() << "comic requested";
|
||||
session.setCurrentComic(comic.id, comicFile);
|
||||
}
|
||||
|
||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
//TODO this field is not used by the client!
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
LibrariesController::LibrariesController() {}
|
||||
|
||||
@ -24,6 +25,14 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
session.setComicOnDevice(hash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(data.length()>1)
|
||||
{
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -41,6 +50,9 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
//response.writeText(postData);
|
||||
|
||||
QList<QString> data = postData.split("\n");
|
||||
|
||||
QLOG_INFO() << "Data lenght : " << data.length();
|
||||
|
||||
if(data.length() > 2)
|
||||
{
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <QDataStream>
|
||||
#include <QPointer>
|
||||
|
||||
#include <QsLog.h>
|
||||
|
||||
#include "db_helper.h"
|
||||
|
||||
PageController::PageController() {}
|
||||
@ -16,6 +18,7 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||
bool remote = path.endsWith("remote");
|
||||
|
||||
//QByteArray path2=request.getPath();
|
||||
//qDebug("PageController: request to -> %s ",path2.data());
|
||||
@ -27,10 +30,24 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
//qDebug("lib name : %s",pathElements.at(2).data());
|
||||
|
||||
Comic * comicFile = session.getCurrentComic();
|
||||
if(session.getCurrentComicId() != 0 && !QPointer<Comic>(comicFile).isNull())
|
||||
Comic * comicFile;
|
||||
qulonglong currentComicId;
|
||||
if(remote)
|
||||
{
|
||||
QLOG_INFO() << "se recupera comic remoto para servir p<>ginas";
|
||||
comicFile = session.getCurrentRemoteComic();
|
||||
currentComicId = session.getCurrentRemoteComicId();
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_INFO() << "se recupera comic para servir p<>ginas";
|
||||
comicFile = session.getCurrentComic();
|
||||
currentComicId = session.getCurrentComicId();
|
||||
}
|
||||
|
||||
if(currentComicId != 0 && !QPointer<Comic>(comicFile).isNull())
|
||||
{
|
||||
if(comicId == session.getCurrentComicId() && page < comicFile->numPages())
|
||||
if(comicId == currentComicId && page < comicFile->numPages())
|
||||
{
|
||||
if(comicFile->pageIsLoaded(page))
|
||||
{
|
||||
@ -56,11 +73,14 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(comicId != session.getCurrentComicId())
|
||||
if(comicId != currentComicId)
|
||||
{
|
||||
//delete comicFile;
|
||||
session.dismissCurrentComic();
|
||||
}
|
||||
//delete comicFile;
|
||||
if(remote)
|
||||
session.dismissCurrentRemoteComic();
|
||||
else
|
||||
session.dismissCurrentComic();
|
||||
}
|
||||
response.setStatus(404,"not found"); //TODO qu<71> mensaje enviar
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
@ -73,4 +93,4 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user