This commit is contained in:
Luis Ángel San Martín
2015-03-21 14:40:25 +01:00
parent 8315e8ec34
commit 743d896649
15 changed files with 33 additions and 30 deletions

View File

@ -19,7 +19,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
{ {
HttpSession session=Static::sessionStore->getSession(request,response,false); HttpSession session=Static::sessionStore->getSession(request,response,false);
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1(); QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/'); QStringList pathElements = path.split('/');
qulonglong libraryId = pathElements.at(2).toLongLong(); qulonglong libraryId = pathElements.at(2).toLongLong();
QString libraryName = DBHelper::getLibraryName(libraryId); QString libraryName = DBHelper::getLibraryName(libraryId);
@ -76,7 +76,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
session.setCurrentComic(comic.id, comicFile); session.setCurrentComic(comic.id, comicFile);
} }
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1"); response.setHeader("Content-Type", "plain/text; charset=utf-8");
//TODO this field is not used by the client! //TODO this field is not used by the client!
response.writeText(QString("library:%1\r\n").arg(libraryName)); response.writeText(QString("library:%1\r\n").arg(libraryName));
response.writeText(QString("libraryId:%1\r\n").arg(libraryId)); response.writeText(QString("libraryId:%1\r\n").arg(libraryId));

View File

@ -10,7 +10,7 @@ ComicDownloadInfoController::ComicDownloadInfoController() {}
void ComicDownloadInfoController::service(HttpRequest& request, HttpResponse& response) void ComicDownloadInfoController::service(HttpRequest& request, HttpResponse& response)
{ {
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1(); QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/'); QStringList pathElements = path.split('/');
qulonglong libraryId = pathElements.at(2).toLongLong(); qulonglong libraryId = pathElements.at(2).toLongLong();

View File

@ -18,7 +18,7 @@ void CoverController::service(HttpRequest& request, HttpResponse& response)
YACReaderLibraries libraries = DBHelper::getLibraries(); YACReaderLibraries libraries = DBHelper::getLibraries();
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1(); QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/'); QStringList pathElements = path.split('/');
QString libraryName = DBHelper::getLibraryName(pathElements.at(2).toInt()); QString libraryName = DBHelper::getLibraryName(pathElements.at(2).toInt());
QString fileName = pathElements.at(4); QString fileName = pathElements.at(4);

View File

@ -27,7 +27,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
{ {
HttpSession session=Static::sessionStore->getSession(request,response,false); HttpSession session=Static::sessionStore->getSession(request,response,false);
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); response.setHeader("Content-Type", "text/html; charset=utf-8");
response.setHeader("Connection","close"); response.setHeader("Connection","close");
//QString y = session.get("xxx").toString(); //QString y = session.get("xxx").toString();
@ -35,7 +35,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
Template t=Static::templateLoader->getTemplate("folder_"+session.getDeviceType(),request.getHeader("Accept-Language")); Template t=Static::templateLoader->getTemplate("folder_"+session.getDeviceType(),request.getHeader("Accept-Language"));
t.enableWarnings(); t.enableWarnings();
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1(); QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/'); QStringList pathElements = path.split('/');
int libraryId = pathElements.at(2).toInt(); int libraryId = pathElements.at(2).toInt();
QString libraryName = DBHelper::getLibraryName(libraryId); QString libraryName = DBHelper::getLibraryName(libraryId);
@ -310,6 +310,6 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
t.setVariable("page",QString("%1").arg(page+1)); t.setVariable("page",QString("%1").arg(page+1));
t.setVariable("pages",QString("%1").arg(numPages)); t.setVariable("pages",QString("%1").arg(numPages));
response.write(t.toLatin1(),true); response.writeText(t, true);
} }

View File

@ -12,9 +12,9 @@ FolderInfoController::FolderInfoController() {}
void FolderInfoController::service(HttpRequest& request, HttpResponse& response) void FolderInfoController::service(HttpRequest& request, HttpResponse& response)
{ {
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1"); response.setHeader("Content-Type", "plain/text; charset=utf-8");
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1(); QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/'); QStringList pathElements = path.split('/');
int libraryId = pathElements.at(2).toInt(); int libraryId = pathElements.at(2).toInt();
QString libraryName = DBHelper::getLibraryName(libraryId); QString libraryName = DBHelper::getLibraryName(libraryId);

View File

@ -13,7 +13,7 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
{ {
HttpSession session=Static::sessionStore->getSession(request,response,false); HttpSession session=Static::sessionStore->getSession(request,response,false);
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); response.setHeader("Content-Type", "text/html; charset=utf-8");
response.setHeader("Connection","close"); response.setHeader("Connection","close");
session.clearNavigationPath(); session.clearNavigationPath();
@ -36,5 +36,5 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
} }
response.setStatus(200,"OK"); response.setStatus(200,"OK");
response.write(t.toLatin1(),true); response.writeText(t,true);
} }

View File

@ -17,7 +17,7 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
{ {
HttpSession session=Static::sessionStore->getSession(request,response,false); HttpSession session=Static::sessionStore->getSession(request,response,false);
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1(); QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
bool remote = path.endsWith("remote"); bool remote = path.endsWith("remote");
//QByteArray path2=request.getPath(); //QByteArray path2=request.getPath();
@ -34,13 +34,13 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
qulonglong currentComicId; qulonglong currentComicId;
if(remote) if(remote)
{ {
QLOG_INFO() << "se recupera comic remoto para servir p<EFBFBD>ginas"; QLOG_INFO() << "se recupera comic remoto para servir páginas";
comicFile = session.getCurrentRemoteComic(); comicFile = session.getCurrentRemoteComic();
currentComicId = session.getCurrentRemoteComicId(); currentComicId = session.getCurrentRemoteComicId();
} }
else else
{ {
QLOG_INFO() << "se recupera comic para servir p<EFBFBD>ginas"; QLOG_INFO() << "se recupera comic para servir páginas";
comicFile = session.getCurrentComic(); comicFile = session.getCurrentComic();
currentComicId = session.getCurrentComicId(); currentComicId = session.getCurrentComicId();
} }
@ -51,7 +51,7 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
{ {
if(comicFile->pageIsLoaded(page)) if(comicFile->pageIsLoaded(page))
{ {
//qDebug("PageController: La p<EFBFBD>gina estaba cargada -> %s ",path.data()); //qDebug("PageController: La página estaba cargada -> %s ",path.data());
response.setHeader("Content-Type", "image/jpeg"); response.setHeader("Content-Type", "image/jpeg");
response.setHeader("Transfer-Encoding","chunked"); response.setHeader("Transfer-Encoding","chunked");
QByteArray pageData = comicFile->getRawPage(page); QByteArray pageData = comicFile->getRawPage(page);
@ -66,8 +66,8 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
} }
else else
{ {
//qDebug("PageController: La p<EFBFBD>gina NO estaba cargada 404 -> %s ",path.data()); //qDebug("PageController: La página NO estaba cargada 404 -> %s ",path.data());
response.setStatus(404,"not found"); //TODO qu<EFBFBD> mensaje enviar response.setStatus(404,"not found"); //TODO qué mensaje enviar
response.write("404 not found",true); response.write("404 not found",true);
} }
} }
@ -81,7 +81,7 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
else else
session.dismissCurrentComic(); session.dismissCurrentComic();
} }
response.setStatus(404,"not found"); //TODO qu<EFBFBD> mensaje enviar response.setStatus(404,"not found"); //TODO qué mensaje enviar
response.write("404 not found",true); response.write("404 not found",true);
} }
} }

View File

@ -17,7 +17,7 @@ void UpdateComicController::service(HttpRequest &request, HttpResponse &response
{ {
HttpSession session=Static::sessionStore->getSession(request,response,false); HttpSession session=Static::sessionStore->getSession(request,response,false);
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1(); QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/'); QStringList pathElements = path.split('/');
qulonglong libraryId = pathElements.at(2).toULongLong(); qulonglong libraryId = pathElements.at(2).toULongLong();
QString libraryName = DBHelper::getLibraryName(libraryId); QString libraryName = DBHelper::getLibraryName(libraryId);

View File

@ -112,7 +112,7 @@ void HttpResponse::write(QByteArray data, bool lastPart) {
void HttpResponse::writeText(QString text, bool lastPart) void HttpResponse::writeText(QString text, bool lastPart)
{ {
write(text.toLatin1(),lastPart); write(QByteArray(text.toUtf8()),lastPart);
} }
bool HttpResponse::hasSentLastPart() const { bool HttpResponse::hasSentLastPart() const {

View File

@ -107,11 +107,11 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe
path = QUrl::fromPercentEncoding(path).toLatin1(); path = QUrl::fromPercentEncoding(path).toUtf8();
loadSession(request, response); loadSession(request, response);
//primera petici<EFBFBD>n, se ha hecho un post, se sirven las bibliotecas si la seguridad mediante login no est<EFBFBD> habilitada //primera petición, se ha hecho un post, se sirven las bibliotecas si la seguridad mediante login no está habilitada
if(path == "/") //Don't send data to the server using '/' !!!! if(path == "/") //Don't send data to the server using '/' !!!!
{ {
LibrariesController().service(request, response); LibrariesController().service(request, response);
@ -120,7 +120,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
else else
{ {
//se comprueba que la sesi<EFBFBD>n sea la correcta con el fin de evitar accesos no autorizados //se comprueba que la sesión sea la correcta con el fin de evitar accesos no autorizados
HttpSession session=Static::sessionStore->getSession(request,response,false); HttpSession session=Static::sessionStore->getSession(request,response,false);
if(!session.isNull() && session.contains("ySession")) if(!session.isNull() && session.contains("ySession"))
{ {
@ -162,7 +162,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
Static::staticFileController->service(request, response); Static::staticFileController->service(request, response);
} }
} }
else //acceso no autorizado, redirecci<EFBFBD>n else //acceso no autorizado, redirección
{ {
ErrorController(300).service(request,response); ErrorController(300).service(request,response);
} }

View File

@ -4,12 +4,11 @@
#include <QLibrary> #include <QLibrary>
#include <QFileInfo> #include <QFileInfo>
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QCoreApplication>
#include "open_callbacks.h" #include "open_callbacks.h"
#include "extract_callbacks.h" #include "extract_callbacks.h"
#include "yacreader_global.h"
//DEFINE_GUID(CLSID_CFormat7z,0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00); //DEFINE_GUID(CLSID_CFormat7z,0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
//DEFINE_GUID(IArchiveKK,0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00); //DEFINE_GUID(IArchiveKK,0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00);
@ -231,13 +230,13 @@ bool CompressedArchive::loadFunctions()
sevenzLib = new QLibrary(QString(LIBDIR)+"/p7zip/7z.so"); sevenzLib = new QLibrary(QString(LIBDIR)+"/p7zip/7z.so");
} }
#else #else
sevenzLib = new QLibrary(QApplication::applicationDirPath()+"/utils/7z"); sevenzLib = new QLibrary(QCoreApplication::applicationDirPath()+"/utils/7z");
#endif #endif
} }
if(!sevenzLib->load()) if(!sevenzLib->load())
{ {
qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << endl; qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << endl;
QApplication::exit(YACReader::SevenZNotFound); QCoreApplication::exit(700); //TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound
return false; return false;
} }
else else

View File

@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/css/reset.css" type="text/css" /> <link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" /> <link rel="stylesheet" href="/css/styles.css" type="text/css" />
<title>Folder</title> <title>Folder</title>

View File

@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/css/reset.css" type="text/css" /> <link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" /> <link rel="stylesheet" href="/css/styles.css" type="text/css" />
<title>Folder</title> <title>Folder</title>

View File

@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/css/reset.css" type="text/css" /> <link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" /> <link rel="stylesheet" href="/css/styles.css" type="text/css" />
<title>Libraries</title> <title>Libraries</title>

View File

@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/css/reset.css" type="text/css" /> <link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" /> <link rel="stylesheet" href="/css/styles.css" type="text/css" />
<title>Libraries</title> <title>Libraries</title>