mirror of
https://github.com/YACReader/yacreader
synced 2026-03-17 11:10:07 -04:00
Separate v1 and v2 server api classes and execution path.
This commit is contained in:
124
YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp
Normal file
124
YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
#include "comiccontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_http_session.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "comic.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
ComicControllerV2::ComicControllerV2() {}
|
||||
|
||||
void ComicControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
qulonglong libraryId = pathElements.at(3).toLongLong();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong comicId = pathElements.at(5).toULongLong();
|
||||
|
||||
bool remoteComic = path.endsWith("remote");
|
||||
|
||||
//TODO
|
||||
//if(pathElements.size() == 6)
|
||||
//{
|
||||
// QString action = pathElements.at(5);
|
||||
// if(!action.isEmpty() && (action == "close"))
|
||||
// {
|
||||
// session.dismissCurrentComic();
|
||||
// response.write("",true);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
if(!remoteComic)
|
||||
ySession->setDownloadedComic(comic.info.hash);
|
||||
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryId)+comic.path);
|
||||
|
||||
if(comicFile != NULL)
|
||||
{
|
||||
QThread * thread = NULL;
|
||||
|
||||
thread = new QThread();
|
||||
|
||||
comicFile->moveToThread(thread);
|
||||
|
||||
connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit()));
|
||||
connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit()));
|
||||
connect(comicFile, SIGNAL(imagesLoaded()), thread, SLOT(quit()));
|
||||
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
comicFile->load(libraries.getPath(libraryId)+comic.path);
|
||||
|
||||
if(thread != NULL)
|
||||
thread->start();
|
||||
|
||||
if(remoteComic)
|
||||
{
|
||||
QLOG_TRACE() << "remote comic requested";
|
||||
ySession->setCurrentRemoteComic(comic.id, comicFile);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_TRACE() << "comic requested";
|
||||
ySession->setCurrentComic(comic.id, comicFile);
|
||||
}
|
||||
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
//TODO this field is not used by the client!
|
||||
response.write(QString("library:%1\r\n").arg(libraryName).toUtf8());
|
||||
response.write(QString("libraryId:%1\r\n").arg(libraryId).toUtf8());
|
||||
if(remoteComic) //send previous and next comics id
|
||||
{
|
||||
QList<LibraryItem *> siblings = DBHelper::getFolderComicsFromLibrary(libraryId, comic.parentId, true);
|
||||
bool found = false;
|
||||
int i;
|
||||
for(i = 0; i < siblings.length(); i++)
|
||||
{
|
||||
if (siblings.at(i)->id == comic.id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found)
|
||||
{
|
||||
if(i>0)
|
||||
response.write(QString("previousComic:%1\r\n").arg(siblings.at(i-1)->id).toUtf8());
|
||||
if(i<siblings.length()-1)
|
||||
response.write(QString("nextComic:%1\r\n").arg(siblings.at(i+1)->id).toUtf8());
|
||||
}
|
||||
else
|
||||
{
|
||||
//ERROR
|
||||
}
|
||||
qDeleteAll(siblings);
|
||||
}
|
||||
response.write(comic.toTXT().toUtf8(),true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//delete comicFile;
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
||||
23
YACReaderLibrary/server/controllers/v2/comiccontroller_v2.h
Normal file
23
YACReaderLibrary/server/controllers/v2/comiccontroller_v2.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef COMICCONTROLLER_V2_H
|
||||
#define COMICCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
#include <QThread>
|
||||
class Comic;
|
||||
class QString;
|
||||
|
||||
class ComicControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ComicControllerV2)
|
||||
public:
|
||||
/** Constructor */
|
||||
ComicControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // COMICCONTROLLER_H
|
||||
@ -0,0 +1,26 @@
|
||||
#include "comicdownloadinfocontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
ComicDownloadInfoControllerV2::ComicDownloadInfoControllerV2() {}
|
||||
|
||||
|
||||
void ComicDownloadInfoControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
|
||||
qulonglong libraryId = pathElements.at(3).toLongLong();
|
||||
qulonglong comicId = pathElements.at(5).toULongLong();
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
//TODO: check if the comic wasn't found;
|
||||
response.write(QString("fileName:%1\r\n").arg(comic.getFileName()).toUtf8());
|
||||
response.write(QString("fileSize:%1\r\n").arg(comic.getFileSize()).toUtf8(),true);
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
#ifndef COMICDOWNLOADINFOCONTROLLER_V2_H
|
||||
#define COMICDOWNLOADINFOCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ComicDownloadInfoControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ComicDownloadInfoControllerV2)
|
||||
public:
|
||||
/** Constructor **/
|
||||
ComicDownloadInfoControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // COMICDOWNLOADINFOCONTROLLER_H
|
||||
@ -0,0 +1,89 @@
|
||||
#include "covercontroller_v2.h"
|
||||
#include "db_helper.h" //get libraries
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_http_session.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
CoverControllerV2::CoverControllerV2() {}
|
||||
|
||||
void CoverControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
|
||||
|
||||
response.setHeader("Content-Type", "image/jpeg");
|
||||
response.setHeader("Connection","close");
|
||||
//response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
QString libraryName = DBHelper::getLibraryName(pathElements.at(3).toInt());
|
||||
QString fileName = pathElements.at(5);
|
||||
|
||||
bool folderCover = request.getParameter("folderCover").length()>0;
|
||||
|
||||
//response.writeText(path+"<br/>");
|
||||
//response.writeText(libraryName+"<br/>");
|
||||
//response.writeText(libraries.value(libraryName)+"/.yacreaderlibrary/covers/"+fileName+"<br/>");
|
||||
|
||||
//QFile file(libraries.value(libraryName)+"/.yacreaderlibrary/covers/"+fileName);
|
||||
//if (file.exists()) {
|
||||
// if (file.open(QIODevice::ReadOnly))
|
||||
// {
|
||||
// qDebug("StaticFileController: Open file %s",qPrintable(file.fileName()));
|
||||
// // Return the file content, do not store in cache
|
||||
// while (!file.atEnd() && !file.error()) {
|
||||
// response.write(file.read(131072));
|
||||
// }
|
||||
// }
|
||||
|
||||
// file.close();
|
||||
//}
|
||||
|
||||
QImage img(libraries.getPath(libraryName)+"/.yacreaderlibrary/covers/"+fileName);
|
||||
if (!img.isNull()) {
|
||||
|
||||
int width = 80, height = 120;
|
||||
if(ySession->getDisplayType()=="@2x")
|
||||
{
|
||||
width = 160;
|
||||
height = 240;
|
||||
}
|
||||
|
||||
if(float(img.width())/img.height() < 0.66666)
|
||||
img = img.scaledToWidth(width,Qt::SmoothTransformation);
|
||||
else
|
||||
img = img.scaledToHeight(height,Qt::SmoothTransformation);
|
||||
|
||||
QImage destImg(width,height,QImage::Format_RGB32);
|
||||
destImg.fill(Qt::black);
|
||||
QPainter p(&destImg);
|
||||
|
||||
p.drawImage((width-img.width())/2,(height-img.height())/2,img);
|
||||
|
||||
if(folderCover)
|
||||
{
|
||||
if(ySession->getDisplayType()=="@2x")
|
||||
p.drawImage(0,0,QImage(":/images/f_overlayed_retina.png"));
|
||||
else
|
||||
p.drawImage(0,0,QImage(":/images/f_overlayed.png"));
|
||||
}
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
destImg.save(&buffer, "JPG");
|
||||
response.write(ba,true);
|
||||
}
|
||||
//DONE else, hay que devolver un 404
|
||||
else
|
||||
{
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
}
|
||||
|
||||
20
YACReaderLibrary/server/controllers/v2/covercontroller_v2.h
Normal file
20
YACReaderLibrary/server/controllers/v2/covercontroller_v2.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef COVERCONTROLLER_V2_H
|
||||
#define COVERCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class CoverControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(CoverControllerV2)
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
CoverControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // COVERCONTROLLER_H
|
||||
@ -0,0 +1,26 @@
|
||||
#include "errorcontroller_v2.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
|
||||
ErrorControllerV2::ErrorControllerV2(int errorCode)
|
||||
:error(errorCode)
|
||||
{}
|
||||
|
||||
void ErrorControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
switch(error)
|
||||
{
|
||||
case 300:
|
||||
response.setStatus(300,"redirect");
|
||||
response.write("<html> <head> <meta http-equiv=\"refresh\" content=\"0; URL=/\"> </head> <body> </body> </html>", true);
|
||||
break;
|
||||
case 404:
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
22
YACReaderLibrary/server/controllers/v2/errorcontroller_v2.h
Normal file
22
YACReaderLibrary/server/controllers/v2/errorcontroller_v2.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef ERRORCONTROLLER_V2_H
|
||||
#define ERRORCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ErrorControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ErrorControllerV2)
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
ErrorControllerV2(int errorCode);
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
private:
|
||||
int error;
|
||||
};
|
||||
|
||||
#endif // ERRORCONTROLLER_H
|
||||
@ -0,0 +1,33 @@
|
||||
#include "favoritescontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
FavoritesControllerV2::FavoritesControllerV2() {}
|
||||
|
||||
void FavoritesControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
|
||||
serviceContent(libraryId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void FavoritesControllerV2::serviceContent(const int library, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> tagComics = DBHelper::getFavorites(library);
|
||||
|
||||
for(const ComicDB &comic : tagComics)
|
||||
{
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
#ifndef FAVORITESCONTROLLER_V2_H
|
||||
#define FAVORITESCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class FavoritesControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(FavoritesControllerV2)
|
||||
public:
|
||||
FavoritesControllerV2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int library, HttpResponse &response);
|
||||
};
|
||||
|
||||
|
||||
#endif // FAVORITESCONTROLLER_H
|
||||
@ -0,0 +1,72 @@
|
||||
#include "foldercontentcontroller_v2.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
#include "folder.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
struct LibraryItemSorter
|
||||
{
|
||||
bool operator()(const LibraryItem * a,const LibraryItem * b) const
|
||||
{
|
||||
return naturalSortLessThanCI(a->name,b->name);
|
||||
}
|
||||
};
|
||||
|
||||
FolderContentControllerV2::FolderContentControllerV2() {}
|
||||
|
||||
void FolderContentControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
qulonglong parentId = pathElements.at(5).toULongLong();
|
||||
|
||||
serviceContent(libraryId, parentId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void FolderContentControllerV2::serviceContent(const int &library, const qulonglong &folderId, HttpResponse &response)
|
||||
{
|
||||
//clock_t begin = clock();
|
||||
|
||||
QList<LibraryItem *> folderContent = DBHelper::getFolderSubfoldersFromLibrary(library,folderId);
|
||||
QList<LibraryItem *> folderComics = DBHelper::getFolderComicsFromLibrary(library,folderId);
|
||||
|
||||
folderContent.append(folderComics);
|
||||
qSort(folderContent.begin(),folderContent.end(),LibraryItemSorter());
|
||||
|
||||
folderComics.clear();
|
||||
|
||||
ComicDB * currentComic;
|
||||
Folder * currentFolder;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderContent.constBegin();itr!=folderContent.constEnd();itr++)
|
||||
{
|
||||
if((*itr)->isDir())
|
||||
{
|
||||
currentFolder = (Folder *)(*itr);
|
||||
response.write(YACReaderServerDataHelper::folderToYSFormat(library, *currentFolder).toUtf8());
|
||||
}
|
||||
else
|
||||
{
|
||||
currentComic = (ComicDB *)(*itr);
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, *currentComic).toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
/*clock_t end = clock();
|
||||
double msecs = double(end - begin);
|
||||
|
||||
response.write(QString("%1ms").arg(msecs).toUtf8());*/
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
#ifndef FOLDERCONTENTCONTROLLER_V2_H
|
||||
#define FOLDERCONTENTCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class FolderContentControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(FolderContentControllerV2)
|
||||
public:
|
||||
/** Constructor */
|
||||
FolderContentControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, const qulonglong &folderId, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // FOLDERCONTENTCONTROLLER_H
|
||||
@ -0,0 +1,48 @@
|
||||
#include "folderinfocontroller_v2.h"
|
||||
#include "db_helper.h" //get libraries
|
||||
|
||||
#include "folder.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
|
||||
FolderInfoControllerV2::FolderInfoControllerV2() {}
|
||||
|
||||
void FolderInfoControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong parentId = pathElements.at(5).toULongLong();
|
||||
|
||||
serviceComics(libraryId, parentId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void FolderInfoControllerV2::serviceComics(const int &library, const qulonglong &folderId, HttpResponse &response)
|
||||
{
|
||||
QList<LibraryItem *> folderContent = DBHelper::getFolderSubfoldersFromLibrary(library,folderId);
|
||||
QList<LibraryItem *> folderComics = DBHelper::getFolderComicsFromLibrary(library,folderId);
|
||||
|
||||
ComicDB * currentComic;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderComics.constBegin();itr!=folderComics.constEnd();itr++)
|
||||
{
|
||||
currentComic = (ComicDB *)(*itr);
|
||||
response.write(QString("/library/%1/comic/%2:%3:%4\r\n").arg(library).arg(currentComic->id).arg(currentComic->getFileName()).arg(currentComic->getFileSize()).toUtf8());
|
||||
delete currentComic;
|
||||
}
|
||||
|
||||
Folder * currentFolder;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderContent.constBegin();itr!=folderContent.constEnd();itr++)
|
||||
{
|
||||
currentFolder = (Folder *)(*itr);
|
||||
serviceComics(library, currentFolder->id, response);
|
||||
delete currentFolder;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#ifndef FOLDERINFOCONTROLLER_V2_H
|
||||
#define FOLDERINFOCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class FolderInfoControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(FolderInfoControllerV2)
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
FolderInfoControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceComics(const int &library, const qulonglong & folderId, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // FOLDERINFOCONTROLLER_H
|
||||
@ -0,0 +1,42 @@
|
||||
#include "librariescontroller_v2.h"
|
||||
#include "db_helper.h" //get libraries
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_http_session.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
LibrariesControllerV2::LibrariesControllerV2() {}
|
||||
|
||||
void LibrariesControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
|
||||
|
||||
response.setHeader("Content-Type", "text/html; charset=utf-8");
|
||||
response.setHeader("Connection","close");
|
||||
|
||||
ySession->clearNavigationPath();
|
||||
|
||||
Template t=Static::templateLoader->getTemplate("libraries_"+ySession->getDeviceType(),request.getHeader("Accept-Language"));
|
||||
t.enableWarnings();
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
QList<QString> names = DBHelper::getLibrariesNames();
|
||||
|
||||
t.loop("library",names.length());
|
||||
|
||||
int currentId = 0;
|
||||
int i = 0;
|
||||
foreach (QString name,names) {
|
||||
currentId = libraries.getId(name);
|
||||
t.setVariable(QString("library%1.name").arg(i),QString::number(currentId));
|
||||
t.setVariable(QString("library%1.label").arg(i),name);
|
||||
i++;
|
||||
}
|
||||
|
||||
response.setStatus(200,"OK");
|
||||
response.write(t.toUtf8(),true);
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
#ifndef LIBRARIESCONTROLLER_V2_H
|
||||
#define LIBRARIESCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
/**
|
||||
This controller displays a HTML form and dumps the submitted input.
|
||||
*/
|
||||
|
||||
|
||||
class LibrariesControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(LibrariesControllerV2)
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
LibrariesControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // LIBRARIESCONTROLLER_H
|
||||
99
YACReaderLibrary/server/controllers/v2/pagecontroller_v2.cpp
Normal file
99
YACReaderLibrary/server/controllers/v2/pagecontroller_v2.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include "pagecontroller_v2.h"
|
||||
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic.h"
|
||||
#include "comiccontroller.h"
|
||||
#include "yacreader_http_session.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QPointer>
|
||||
|
||||
#include <QsLog.h>
|
||||
|
||||
#include "db_helper.h"
|
||||
|
||||
PageControllerV2::PageControllerV2() {}
|
||||
|
||||
void PageControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
bool remote = path.endsWith("remote");
|
||||
|
||||
//QByteArray path2=request.getPath();
|
||||
//qDebug("PageController: request to -> %s ",path2.data());
|
||||
|
||||
QStringList pathElements = path.split('/');
|
||||
QString libraryName = DBHelper::getLibraryName(pathElements.at(2).toInt());
|
||||
qulonglong comicId = pathElements.at(5).toULongLong();
|
||||
unsigned int page = pathElements.at(7).toUInt();
|
||||
|
||||
//qDebug("lib name : %s",pathElements.at(2).data());
|
||||
|
||||
Comic * comicFile;
|
||||
qulonglong currentComicId;
|
||||
if(remote)
|
||||
{
|
||||
QLOG_TRACE() << "se recupera comic remoto para servir páginas";
|
||||
comicFile = ySession->getCurrentRemoteComic();
|
||||
currentComicId = ySession->getCurrentRemoteComicId();
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_TRACE() << "se recupera comic para servir páginas";
|
||||
comicFile = ySession->getCurrentComic();
|
||||
currentComicId = ySession->getCurrentComicId();
|
||||
}
|
||||
|
||||
if(currentComicId != 0 && !QPointer<Comic>(comicFile).isNull())
|
||||
{
|
||||
if(comicId == currentComicId && page < comicFile->numPages())
|
||||
{
|
||||
if(comicFile->pageIsLoaded(page))
|
||||
{
|
||||
//qDebug("PageController: La página estaba cargada -> %s ",path.data());
|
||||
response.setHeader("Content-Type", "image/jpeg");
|
||||
response.setHeader("Transfer-Encoding","chunked");
|
||||
QByteArray pageData = comicFile->getRawPage(page);
|
||||
QDataStream data(pageData);
|
||||
char buffer[4096];
|
||||
while (!data.atEnd()) {
|
||||
int len = data.readRawData(buffer,4096);
|
||||
response.write(QByteArray(buffer,len));
|
||||
}
|
||||
//response.write(pageData,true);
|
||||
response.write(QByteArray(),true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug("PageController: La página NO estaba cargada 404 -> %s ",path.data());
|
||||
response.setStatus(404,"not found"); //TODO qué mensaje enviar
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(comicId != currentComicId)
|
||||
{
|
||||
//delete comicFile;
|
||||
if(remote)
|
||||
ySession->dismissCurrentRemoteComic();
|
||||
else
|
||||
ySession->dismissCurrentComic();
|
||||
}
|
||||
response.setStatus(404,"not found"); //TODO qué mensaje enviar
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
||||
20
YACReaderLibrary/server/controllers/v2/pagecontroller_v2.h
Normal file
20
YACReaderLibrary/server/controllers/v2/pagecontroller_v2.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef PAGECONTROLLER_V2_H
|
||||
#define PAGECONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class PageControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(PageControllerV2)
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
PageControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // PAGECONTROLLER_H
|
||||
@ -0,0 +1,34 @@
|
||||
#include "readingcomicscontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
ReadingComicsControllerV2::ReadingComicsControllerV2()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReadingComicsControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
|
||||
serviceContent(libraryId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void ReadingComicsControllerV2::serviceContent(const int &library, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> readingComics = DBHelper::getReading(library);
|
||||
|
||||
for(const ComicDB &comic : readingComics)
|
||||
{
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
#ifndef READINGCOMICSCONTROLLER_V2_H
|
||||
#define READINGCOMICSCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ReadingComicsControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ReadingComicsControllerV2)
|
||||
public:
|
||||
ReadingComicsControllerV2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // READINGCOMICSCONTROLLER_H
|
||||
@ -0,0 +1,35 @@
|
||||
#include "readinglistcontentcontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
ReadingListContentControllerV2::ReadingListContentControllerV2()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReadingListContentControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
qulonglong readingListId = pathElements.at(5).toULongLong();
|
||||
|
||||
serviceContent(libraryId, readingListId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void ReadingListContentControllerV2::serviceContent(const int &library, const qulonglong &readingListId, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> comics = DBHelper::getReadingListFullContent(library, readingListId);
|
||||
|
||||
for(const ComicDB &comic : comics)
|
||||
{
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
#ifndef READINGLISTCONTENTCONTROLLER_V2_H
|
||||
#define READINGLISTCONTENTCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ReadingListContentControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ReadingListContentControllerV2)
|
||||
public:
|
||||
ReadingListContentControllerV2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, const qulonglong &readingListId, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // READINGLISTCONTENTCONTROLLER_H
|
||||
@ -0,0 +1,32 @@
|
||||
#include "readinglistscontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "reading_list.h"
|
||||
|
||||
ReadingListsControllerV2::ReadingListsControllerV2()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReadingListsControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
|
||||
serviceContent(libraryId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void ReadingListsControllerV2::serviceContent(const int library, HttpResponse &response)
|
||||
{
|
||||
QList<ReadingList> readingLists = DBHelper::getReadingLists(library);
|
||||
|
||||
foreach(const ReadingList &item, readingLists)
|
||||
{
|
||||
response.write(QString("%1\t%2\t%3\r\n").arg(library).arg(item.getId()).arg(item.getName()).toUtf8());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
#ifndef READINGLISTSCONTROLLER_V2_H
|
||||
#define READINGLISTSCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ReadingListsControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ReadingListsControllerV2)
|
||||
public:
|
||||
ReadingListsControllerV2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int library, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // READINGLISTSCONTROLLER_H
|
||||
64
YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp
Normal file
64
YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "synccontroller_v2.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
#include <QUrl>
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "db_helper.h"
|
||||
|
||||
SyncControllerV2::SyncControllerV2()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SyncControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
|
||||
QLOG_TRACE() << "POST DATA: " << postData;
|
||||
|
||||
if(postData.length()>0) {
|
||||
QList<QString> data = postData.split("\n");
|
||||
|
||||
qulonglong libraryId;
|
||||
qulonglong comicId;
|
||||
int currentPage;
|
||||
int currentRating;
|
||||
QString hash;
|
||||
foreach(QString comicInfo, data)
|
||||
{
|
||||
QList<QString> comicInfoProgress = comicInfo.split("\t");
|
||||
|
||||
if(comicInfoProgress.length() == 4 || comicInfoProgress.length() == 5)
|
||||
{
|
||||
libraryId = comicInfoProgress.at(0).toULongLong();
|
||||
comicId = comicInfoProgress.at(1).toULongLong();
|
||||
hash = comicInfoProgress.at(2);
|
||||
currentPage = comicInfoProgress.at(3).toInt();
|
||||
|
||||
ComicInfo info;
|
||||
info.currentPage = currentPage;
|
||||
info.hash = hash; //TODO remove the hash check and add UUIDs for libraries
|
||||
info.id = comicId;
|
||||
|
||||
//Client 2.1+ version
|
||||
if(comicInfoProgress.length() > 4)
|
||||
{
|
||||
currentRating = comicInfoProgress.at(4).toInt();
|
||||
info.rating = currentRating;
|
||||
}
|
||||
|
||||
DBHelper::updateFromRemoteClient(libraryId,info);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(412,"No comic info received");
|
||||
response.write("",true);
|
||||
return;
|
||||
}
|
||||
|
||||
response.write("OK",true);
|
||||
}
|
||||
|
||||
21
YACReaderLibrary/server/controllers/v2/synccontroller_v2.h
Normal file
21
YACReaderLibrary/server/controllers/v2/synccontroller_v2.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef SYNCCONTROLLER_V2_H
|
||||
#define SYNCCONTROLLER_V2_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class SyncControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(SyncControllerV2)
|
||||
public:
|
||||
/** Constructor */
|
||||
SyncControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // SYNCCONTROLLER_H
|
||||
@ -0,0 +1,37 @@
|
||||
#include "tagcontentcontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
TagContentControllerV2::TagContentControllerV2()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TagContentControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
qulonglong tagId = pathElements.at(5).toULongLong();
|
||||
|
||||
serviceContent(libraryId, tagId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void TagContentControllerV2::serviceContent(const int &library, const qulonglong &tagId, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> tagComics = DBHelper::getLabelComics(library, tagId);
|
||||
|
||||
for(const ComicDB &comic : tagComics)
|
||||
{
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
#ifndef TAGCONTENTCONTROLLER_V2_H
|
||||
#define TAGCONTENTCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class TagContentControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(TagContentControllerV2)
|
||||
public:
|
||||
/** Constructor */
|
||||
TagContentControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, const qulonglong &tagId, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // TAGCONTENTCONTROLLER_H
|
||||
30
YACReaderLibrary/server/controllers/v2/tagscontroller_v2.cpp
Normal file
30
YACReaderLibrary/server/controllers/v2/tagscontroller_v2.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "tagscontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "reading_list.h"
|
||||
#include "../static.h"
|
||||
#include "yacreader_global.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
TagsControllerV2::TagsControllerV2() {}
|
||||
|
||||
void TagsControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
|
||||
QList<Label> tags = DBHelper::getLabels(libraryId);
|
||||
|
||||
foreach(const Label &tag, tags)
|
||||
{
|
||||
response.write(QString("%1\t%2\t%3\t%4\r\n").arg(libraryId).arg(tag.getId()).arg(tag.getName()).arg(labelColorToRGBString(tag.getColorID())).toUtf8());
|
||||
}
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
22
YACReaderLibrary/server/controllers/v2/tagscontroller_v2.h
Normal file
22
YACReaderLibrary/server/controllers/v2/tagscontroller_v2.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef TAGSCONTROLLER_V2_H
|
||||
#define TAGSCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
|
||||
|
||||
class TagsControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(TagsControllerV2)
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
TagsControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // TAGSCONTROLLER_H
|
||||
@ -0,0 +1,46 @@
|
||||
#include "updatecomiccontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "comic.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
UpdateComicControllerV2::UpdateComicControllerV2(){}
|
||||
|
||||
void UpdateComicControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
qulonglong libraryId = pathElements.at(3).toULongLong();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong comicId = pathElements.at(5).toULongLong();
|
||||
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
|
||||
QLOG_TRACE() << "POST DATA: " << postData;
|
||||
|
||||
if(postData.length()>0) {
|
||||
QList<QString> data = postData.split("\n");
|
||||
int currentPage = data.at(0).split(":").at(1).toInt();
|
||||
ComicInfo info;
|
||||
info.currentPage = currentPage;
|
||||
info.id = comicId;
|
||||
DBHelper::updateProgress(libraryId,info);
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(412,"No comic info received");
|
||||
response.write("",true);
|
||||
return;
|
||||
}
|
||||
|
||||
response.write("OK",true);
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
#ifndef UPDATECOMICCONTROLLER_V2_H
|
||||
#define UPDATECOMICCONTROLLER_V2_H
|
||||
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
|
||||
class UpdateComicControllerV2 : public HttpRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(UpdateComicControllerV2)
|
||||
|
||||
public:
|
||||
UpdateComicControllerV2();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // UPDATECOMICCONTROLLER_H
|
||||
Reference in New Issue
Block a user