mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
controlador de p?ginas
corregido bug relacionado con los datos de sesi?n (delete comic)
This commit is contained in:
parent
b0cfaaf13c
commit
a39cc616f6
@ -45,6 +45,7 @@
|
||||
bool loaded();
|
||||
QPixmap * operator[](unsigned int index);
|
||||
QVector<QByteArray> * getRawData(){return &_pages;};
|
||||
QByteArray getRawPage(int page){return _pages[page];};
|
||||
public slots:
|
||||
void loadImages();
|
||||
void loadSizes();
|
||||
|
@ -18,12 +18,14 @@ int main( int argc, char ** argv )
|
||||
app.installTranslator(&translator);
|
||||
app.setApplicationName("YACReaderLibrary");
|
||||
|
||||
s = new Startup();
|
||||
s->start();
|
||||
|
||||
mw = new LibraryWindow();
|
||||
mw->resize(800,480);
|
||||
mw->showMaximized();
|
||||
|
||||
s = new Startup();
|
||||
s->start();
|
||||
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
}
|
||||
else
|
||||
{
|
||||
delete comicFile;
|
||||
//delete comicFile;
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
#include "pagecontroller.h"
|
||||
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic.h"
|
||||
|
||||
PageController::PageController() {}
|
||||
|
||||
void PageController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
|
||||
|
||||
HttpSession session=Static::sessionStore->getSession(request,response);
|
||||
|
||||
QStringList pathElements = ((QString)request.getPath()).split('/');
|
||||
QString libraryName = pathElements.at(2);
|
||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||
quint16 page = pathElements.at(6).toUInt();
|
||||
|
||||
Comic * comicFile = session.getCurrentComic();
|
||||
if((comicFile != 0) && comicId == session.getCurrentComicId())
|
||||
{
|
||||
response.setHeader("Content-Type", "image/page");
|
||||
QByteArray pageData = comicFile->getRawPage(page);
|
||||
response.write(pageData);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete comicFile;
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef PAGECONTROLLER_H
|
||||
#define PAGECONTROLLER_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class PageController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(PageController);
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
PageController();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // PAGECONTROLLER_H
|
@ -12,6 +12,7 @@
|
||||
HttpSession::HttpSession(bool canStore) {
|
||||
if (canStore) {
|
||||
dataPtr=new HttpSessionData();
|
||||
dataPtr->yacreaderSessionData.comic = 0;
|
||||
dataPtr->refCount=1;
|
||||
dataPtr->lastAccess=QDateTime::currentMSecsSinceEpoch();
|
||||
dataPtr->id=QUuid::createUuid().toString().toAscii();
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "controllers/covercontroller.h"
|
||||
#include "controllers/comiccontroller.h"
|
||||
#include "controllers/folderinfocontroller.h"
|
||||
#include "controllers/pagecontroller.h"
|
||||
|
||||
RequestMapper::RequestMapper(QObject* parent)
|
||||
:HttpRequestHandler(parent) {}
|
||||
@ -50,7 +51,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
}
|
||||
else if(path.contains("page"))
|
||||
{
|
||||
|
||||
PageController().service(request,response);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -53,7 +53,8 @@ QString Static::getConfigDir() {
|
||||
foreach (QString dir, searchList) {
|
||||
qWarning("%s/%s not found",qPrintable(dir),qPrintable(configFileName));
|
||||
}
|
||||
qFatal("Cannot find config file %s",qPrintable(configFileName));
|
||||
qWarning("Cannot find config file %s",qPrintable(configFileName)); //TODO establecer los valores por defecto
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget * parent)
|
||||
mainLayout->addWidget(accept,0,0);
|
||||
mainLayout->addWidget(qrCode,0,1);
|
||||
|
||||
|
||||
this->setLayout(mainLayout);
|
||||
generateQR();
|
||||
}
|
||||
|
||||
void ServerConfigDialog::generateQR()
|
||||
@ -42,11 +42,19 @@ void ServerConfigDialog::generateQR()
|
||||
QList<QHostAddress> list = QHostInfo::fromName( QHostInfo::localHostName() ).addresses();
|
||||
foreach(QHostAddress add, list)
|
||||
{
|
||||
dir = add.toString();
|
||||
if(dir.contains("."))
|
||||
QString tmp = add.toString();
|
||||
if(tmp.contains(".") && tmp != "127.0.0.1")
|
||||
{
|
||||
dir = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!dir.isEmpty())
|
||||
generateQR(dir+":"+s->getPort());
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
generateQR(dir+":"+s->getPort());
|
||||
//qrCode->setText(dir+":8080");
|
||||
|
||||
}
|
||||
@ -58,7 +66,7 @@ void ServerConfigDialog::generateQR(const QString & serverAddress)
|
||||
attributes << "-o" << QCoreApplication::applicationDirPath()+"/utils/tmp.png" << "-s" << "8" << "-l" << "H" << serverAddress;
|
||||
connect(qrGenerator,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateImage(void)));
|
||||
connect(qrGenerator,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError)));
|
||||
qrGenerator->start(QCoreApplication::applicationDirPath()+"/utils/qrcode",attributes);
|
||||
qrGenerator->start(QCoreApplication::applicationDirPath()+"/utils/qrencode",attributes);
|
||||
}
|
||||
|
||||
void ServerConfigDialog::updateImage()
|
||||
|
Loading…
x
Reference in New Issue
Block a user