mirror of
https://github.com/YACReader/yacreader
synced 2025-07-27 01:15:07 -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");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user