Format code using clang-format

This commit is contained in:
Luis Ángel San Martín
2019-05-30 19:46:37 +02:00
parent e0eb94e3ae
commit e3ec56aa43
356 changed files with 19824 additions and 21874 deletions

View File

@ -16,112 +16,100 @@
ComicControllerV2::ComicControllerV2() {}
void ComicControllerV2::service(HttpRequest& request, HttpResponse& response)
void ComicControllerV2::service(HttpRequest &request, HttpResponse &response)
{
QByteArray token = request.getHeader("x-request-id");
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
if (ySession == nullptr) {
response.setStatus(404,"not found");
response.write("404 not found",true);
response.setStatus(404, "not found");
response.write("404 not found", true);
return;
}
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/');
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;
// }
//}
//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();
YACReaderLibraries libraries = DBHelper::getLibraries();
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryId)+comic.path);
Comic *comicFile = FactoryComic::newComic(libraries.getPath(libraryId) + comic.path);
if(comicFile != NULL)
{
QThread * thread = NULL;
if (comicFile != NULL) {
QThread *thread = NULL;
thread = new QThread();
thread = new QThread();
comicFile->moveToThread(thread);
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()));
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
comicFile->load(libraries.getPath(libraryId)+comic.path);
comicFile->load(libraries.getPath(libraryId) + comic.path);
if(thread != NULL)
thread->start();
if (thread != NULL)
thread->start();
if(remoteComic)
{
if (remoteComic) {
QLOG_TRACE() << "remote comic requested";
ySession->setCurrentRemoteComic(comic.id, comicFile);
}
else
{
} 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!
//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
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)
{
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
{
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);
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);
}