mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 13:04:28 -04:00
added support for opening next/previous comics from iOS remote viewer
This commit is contained in:
@ -22,6 +22,8 @@ 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");
|
||||
|
||||
//TODO
|
||||
//if(pathElements.size() == 6)
|
||||
//{
|
||||
@ -44,7 +46,8 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryName, comicId);
|
||||
|
||||
session.setDownloadedComic(comic.info.hash);
|
||||
if(!remoteComic)
|
||||
session.setDownloadedComic(comic.info.hash);
|
||||
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryName)+comic.path);
|
||||
|
||||
@ -69,7 +72,34 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
//TODO this field is not used by the client!
|
||||
response.writeText(QString("library:%1\r\n").arg(libraryName));
|
||||
response.writeText(comic.toTXT(),true);
|
||||
response.writeText(QString("libraryId:%1\r\n").arg(pathElements.at(2)));
|
||||
if(remoteComic) //send previous and next comics id
|
||||
{
|
||||
QList<LibraryItem *> siblings = DBHelper::getFolderComicsFromLibrary(libraryName, comic.parentId);
|
||||
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.writeText(QString("previousComic:%1\r\n").arg(siblings.at(i-1)->id));
|
||||
if(i<siblings.length()-1)
|
||||
response.writeText(QString("nextComic:%1\r\n").arg(siblings.at(i+1)->id));
|
||||
}
|
||||
else
|
||||
{
|
||||
//ERROR
|
||||
}
|
||||
response.writeText(comic.toTXT(),true);
|
||||
qDeleteAll(siblings);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,8 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
if(postData.length()>0) {
|
||||
QList<QString> data = postData.split("\n");
|
||||
if(data.length() > 2) {
|
||||
//ONLY COMICS ARE UPDATED, DEVICE CHARACTERISTICS ARE INMUTABLE
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
|
||||
foreach(QString hash,comics) {
|
||||
session.setComicOnDevice(hash);
|
||||
@ -52,7 +53,7 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
}
|
||||
else //values by default, only for debug purposes.
|
||||
{
|
||||
session.setDeviceType("iphone");
|
||||
session.setDeviceType("ipad");
|
||||
session.setDisplayType("@2x");
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
QRegExp folder("/library/.+/folder/[0-9]+/?");//get comic content
|
||||
QRegExp folderInfo("/library/.+/folder/[0-9]+/info/?"); //get folder info
|
||||
QRegExp comic("/library/.+/comic/[0-9]+/?"); //get comic info
|
||||
QRegExp comicOpen("/library/.+/comic/[0-9]+/open/?"); //the server will open for reading the comic
|
||||
QRegExp comicOpen("/library/.+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
||||
QRegExp comicClose("/library/.+/comic/[0-9]+/close/?"); //the server will close the comic and free memory
|
||||
QRegExp cover("/library/.+/cover/[0-9a-f]+.jpg"); //get comic cover (navigation)
|
||||
QRegExp comicPage("/library/.+/comic/[0-9]+/page/[0-9]+/?"); //get comic page
|
||||
@ -69,7 +69,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
{
|
||||
CoverController().service(request, response);
|
||||
}
|
||||
else if(comic.exactMatch(path))
|
||||
else if(comic.exactMatch(path) || comicOpen.exactMatch(path))
|
||||
{
|
||||
ComicController().service(request, response);
|
||||
}
|
||||
|
Reference in New Issue
Block a user