mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
updated compressed_archive_test for being able to use unarr, remove unecessary includes in compressed_archive within unarr-wrapper.pri
This commit is contained in:
commit
43aeb9d242
@ -19,7 +19,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
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('/');
|
||||
qulonglong libraryId = pathElements.at(2).toLongLong();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
@ -76,7 +76,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
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!
|
||||
response.writeText(QString("library:%1\r\n").arg(libraryName));
|
||||
response.writeText(QString("libraryId:%1\r\n").arg(libraryId));
|
||||
|
@ -10,7 +10,7 @@ ComicDownloadInfoController::ComicDownloadInfoController() {}
|
||||
|
||||
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('/');
|
||||
|
||||
qulonglong libraryId = pathElements.at(2).toLongLong();
|
||||
|
@ -18,7 +18,7 @@ void CoverController::service(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
QString libraryName = DBHelper::getLibraryName(pathElements.at(2).toInt());
|
||||
QString fileName = pathElements.at(4);
|
||||
|
@ -27,7 +27,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
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");
|
||||
|
||||
//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"));
|
||||
t.enableWarnings();
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(2).toInt();
|
||||
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("pages",QString("%1").arg(numPages));
|
||||
|
||||
response.write(t.toLatin1(),true);
|
||||
response.writeText(t, true);
|
||||
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ FolderInfoController::FolderInfoController() {}
|
||||
|
||||
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('/');
|
||||
int libraryId = pathElements.at(2).toInt();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
|
@ -13,7 +13,7 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
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");
|
||||
|
||||
session.clearNavigationPath();
|
||||
@ -36,5 +36,5 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
}
|
||||
|
||||
response.setStatus(200,"OK");
|
||||
response.write(t.toLatin1(),true);
|
||||
response.writeText(t,true);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
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");
|
||||
|
||||
//QByteArray path2=request.getPath();
|
||||
@ -34,13 +34,13 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
qulonglong currentComicId;
|
||||
if(remote)
|
||||
{
|
||||
QLOG_INFO() << "se recupera comic remoto para servir páginas";
|
||||
QLOG_INFO() << "se recupera comic remoto para servir páginas";
|
||||
comicFile = session.getCurrentRemoteComic();
|
||||
currentComicId = session.getCurrentRemoteComicId();
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_INFO() << "se recupera comic para servir páginas";
|
||||
QLOG_INFO() << "se recupera comic para servir páginas";
|
||||
comicFile = session.getCurrentComic();
|
||||
currentComicId = session.getCurrentComicId();
|
||||
}
|
||||
@ -51,7 +51,7 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
if(comicFile->pageIsLoaded(page))
|
||||
{
|
||||
//qDebug("PageController: La página estaba cargada -> %s ",path.data());
|
||||
//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);
|
||||
@ -66,8 +66,8 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug("PageController: La página NO estaba cargada 404 -> %s ",path.data());
|
||||
response.setStatus(404,"not found"); //TODO qué mensaje enviar
|
||||
//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);
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
else
|
||||
session.dismissCurrentComic();
|
||||
}
|
||||
response.setStatus(404,"not found"); //TODO qué mensaje enviar
|
||||
response.setStatus(404,"not found"); //TODO qué mensaje enviar
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ void UpdateComicController::service(HttpRequest &request, HttpResponse &response
|
||||
{
|
||||
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('/');
|
||||
qulonglong libraryId = pathElements.at(2).toULongLong();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
|
@ -112,7 +112,7 @@ void HttpResponse::write(QByteArray data, bool lastPart) {
|
||||
|
||||
void HttpResponse::writeText(QString text, bool lastPart)
|
||||
{
|
||||
write(text.toLatin1(),lastPart);
|
||||
write(QByteArray(text.toUtf8()),lastPart);
|
||||
}
|
||||
|
||||
bool HttpResponse::hasSentLastPart() const {
|
||||
|
@ -107,11 +107,11 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
|
||||
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);
|
||||
|
||||
//primera petición, se ha hecho un post, se sirven las bibliotecas si la seguridad mediante login no está 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 '/' !!!!
|
||||
{
|
||||
LibrariesController().service(request, response);
|
||||
@ -120,7 +120,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
else
|
||||
{
|
||||
|
||||
//se comprueba que la sesió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);
|
||||
if(!session.isNull() && session.contains("ySession"))
|
||||
{
|
||||
@ -162,7 +162,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
Static::staticFileController->service(request, response);
|
||||
}
|
||||
}
|
||||
else //acceso no autorizado, redirección
|
||||
else //acceso no autorizado, redirección
|
||||
{
|
||||
ErrorController(300).service(request,response);
|
||||
}
|
||||
|
@ -4,12 +4,11 @@
|
||||
#include <QLibrary>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "open_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(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");
|
||||
}
|
||||
#else
|
||||
sevenzLib = new QLibrary(QApplication::applicationDirPath()+"/utils/7z");
|
||||
sevenzLib = new QLibrary(QCoreApplication::applicationDirPath()+"/utils/7z");
|
||||
#endif
|
||||
}
|
||||
if(!sevenzLib->load())
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
#include "yacreader_global.h"
|
||||
#include "extract_delegate.h"
|
||||
|
||||
extern"C" {
|
||||
|
@ -1,6 +1,7 @@
|
||||
<!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">
|
||||
<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/styles.css" type="text/css" />
|
||||
<title>Folder</title>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<!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">
|
||||
<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/styles.css" type="text/css" />
|
||||
<title>Folder</title>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<!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">
|
||||
<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/styles.css" type="text/css" />
|
||||
<title>Libraries</title>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<!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">
|
||||
<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/styles.css" type="text/css" />
|
||||
<title>Libraries</title>
|
||||
|
21
tests/compressed_archive_test/compressed_archive_test.pro
Normal file
21
tests/compressed_archive_test/compressed_archive_test.pro
Normal file
@ -0,0 +1,21 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
|
||||
win32 {
|
||||
LIBS += -loleaut32 -lole32
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT
|
||||
QMAKE_LFLAGS_RELEASE += /LTCG
|
||||
CONFIG -= embed_manifest_exe
|
||||
}
|
||||
|
||||
!CONFIG(unarr){
|
||||
include(../../compressed_archive/wrapper.pri)
|
||||
} else {
|
||||
include(../../compressed_archive/unarr/unarr-wrapper.pri)
|
||||
}
|
||||
|
||||
|
||||
|
82
tests/compressed_archive_test/main.cpp
Normal file
82
tests/compressed_archive_test/main.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "compressed_archive.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//This program uses PROTOS Genome Test Suite c10-archive [0] for testing the CompressedArchive wrapper files support
|
||||
//It tests the following formats: RAR, ZIP, TAR
|
||||
//Arter downloading c10-archive-r1.iso, open it and full extract RAR_TAR.BZ2, ZIP_TAR.BZ2, TAR_TAR.BZ2 files into a folder
|
||||
//This program takes the path to that folder as an argument
|
||||
//
|
||||
// [0] https://www.ee.oulu.fi/research/ouspg/PROTOS_Test-Suite_c10-archive#Download
|
||||
//
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
cout << "Usage: compressed_archive_test PATH" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
QString s(argv[1]);
|
||||
|
||||
QStringList supportedFormats;
|
||||
supportedFormats << "rar" << "zip" << "tar";
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
quint32 totalFiles = 0;
|
||||
foreach (QString format, supportedFormats) {
|
||||
QDir rootDir(s);
|
||||
if(!rootDir.cd(format))
|
||||
{
|
||||
cout << "Folder for format '" << format.toStdString() << "' not found" << endl;
|
||||
continue;
|
||||
}
|
||||
rootDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
|
||||
QFileInfoList files = rootDir.entryInfoList();
|
||||
quint32 totalFormat = 0;
|
||||
quint32 errors = 0;
|
||||
quint64 init = timer.elapsed();
|
||||
|
||||
foreach(QFileInfo fileInfo, files)
|
||||
{
|
||||
totalFiles++;
|
||||
totalFormat++;
|
||||
CompressedArchive archive(fileInfo.filePath());
|
||||
if(!archive.isValid())
|
||||
errors++;
|
||||
else
|
||||
{
|
||||
int i = archive.getNumFiles();
|
||||
cerr << i;
|
||||
cerr << archive.getFileNames().at(0).toStdString();
|
||||
}
|
||||
}
|
||||
quint64 end = timer.elapsed();
|
||||
|
||||
|
||||
cout << "Format '" << format.toStdString() <<"'" << endl;
|
||||
cout << "Total files : " << totalFormat << endl;
|
||||
cout << "Errors : " << errors << endl;
|
||||
cout << "Elapsed time : " << (end - init) / 1000000 <<"s" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
cout << "Total time : " << timer.elapsed() / 1000000 <<"s" <<endl;
|
||||
cout << endl;
|
||||
|
||||
return app.exec();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user