mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
merged
This commit is contained in:
commit
e3af72da44
@ -37,10 +37,7 @@ LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32
|
||||
LIBS += -lpoppler-qt5
|
||||
INCLUDEPATH += ../dependencies/poppler/include/qt5
|
||||
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT
|
||||
!CONFIG(no_opengl) {
|
||||
QMAKE_CXXFLAGS_RELEASE += /GL
|
||||
}
|
||||
QMAKE_CXXFLAGS_RELEASE += /02 /MP /Ob2 /Oi /Ot /GT /GL
|
||||
QMAKE_LFLAGS_RELEASE += /LTCG
|
||||
CONFIG -= embed_manifest_exe
|
||||
}
|
||||
|
@ -32,10 +32,7 @@ LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32
|
||||
LIBS += -lpoppler-qt5
|
||||
INCLUDEPATH += ../dependencies/poppler/include/qt5
|
||||
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT
|
||||
!CONFIG(no_opengl) {
|
||||
QMAKE_CXXFLAGS_RELEASE += /GL
|
||||
}
|
||||
QMAKE_CXXFLAGS_RELEASE += /02 /MP /Ob2 /Oi /Ot /GT /GL
|
||||
QMAKE_LFLAGS_RELEASE += /LTCG
|
||||
CONFIG -= embed_manifest_exe
|
||||
}
|
||||
|
@ -391,6 +391,44 @@ void DBHelper::updateProgress(qulonglong libraryId, const ComicInfo &comicInfo)
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
}
|
||||
|
||||
void DBHelper::updateReadingRemoteProgress(const ComicInfo &comicInfo, QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery updateComicInfo(db);
|
||||
updateComicInfo.prepare("UPDATE comic_info SET "
|
||||
"read = :read, "
|
||||
"currentPage = :currentPage, "
|
||||
"hasBeenOpened = :hasBeenOpened"
|
||||
" WHERE id = :id ");
|
||||
|
||||
updateComicInfo.bindValue(":read", comicInfo.read?1:0);
|
||||
updateComicInfo.bindValue(":currentPage", comicInfo.currentPage);
|
||||
updateComicInfo.bindValue(":hasBeenOpened", comicInfo.hasBeenOpened?1:0);
|
||||
updateComicInfo.bindValue(":id", comicInfo.id);
|
||||
updateComicInfo.exec();
|
||||
}
|
||||
|
||||
|
||||
void DBHelper::updateFromRemoteClient(qulonglong libraryId,const ComicInfo & comicInfo)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
ComicDB comic = DBHelper::loadComic(comicInfo.id,db);
|
||||
|
||||
if(comic.info.hash == comicInfo.hash)
|
||||
{
|
||||
if(comic.info.currentPage == comic.info.numPages)
|
||||
comic.info.read = true;
|
||||
comic.info.currentPage = comicInfo.currentPage;
|
||||
comic.info.hasBeenOpened = true;
|
||||
|
||||
DBHelper::updateReadingRemoteProgress(comic.info,db);
|
||||
}
|
||||
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
}
|
||||
|
||||
void DBHelper::renameLabel(qulonglong id, const QString &name, QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery renameLabelQuery(db);
|
||||
|
@ -57,6 +57,8 @@ public:
|
||||
static void updateRead(ComicInfo * comicInfo, QSqlDatabase & db);
|
||||
static void update(const Folder & folder, QSqlDatabase & db);
|
||||
static void updateProgress(qulonglong libraryId,const ComicInfo & comicInfo);
|
||||
static void updateReadingRemoteProgress(const ComicInfo & comicInfo, QSqlDatabase & db);
|
||||
static void updateFromRemoteClient(qulonglong libraryId,const ComicInfo & comicInfo);
|
||||
static void renameLabel(qulonglong id, const QString & name, QSqlDatabase & db);
|
||||
static void renameList(qulonglong id, const QString & name, QSqlDatabase & db);
|
||||
static void reasignOrderToSublists(QList<qulonglong> ids, QSqlDatabase & db);
|
||||
|
@ -570,7 +570,7 @@ void LibraryWindow::createActions()
|
||||
setAllAsNonReadAction->setIcon(QIcon(":/images/setAllUnread.png"));*/
|
||||
|
||||
showHideMarksAction = new QAction(tr("Show/Hide marks"),this);
|
||||
showHideMarksAction->setToolTip(tr("Show or hide readed marks"));
|
||||
showHideMarksAction->setToolTip(tr("Show or hide read marks"));
|
||||
showHideMarksAction->setData(SHOW_HIDE_MARKS_ACTION_YL);
|
||||
showHideMarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_HIDE_MARKS_ACTION_YL));
|
||||
showHideMarksAction->setCheckable(true);
|
||||
|
55
YACReaderLibrary/server/controllers/synccontroller.cpp
Normal file
55
YACReaderLibrary/server/controllers/synccontroller.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "synccontroller.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
#include <QUrl>
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "db_helper.h"
|
||||
|
||||
SyncController::SyncController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SyncController::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
|
||||
QLOG_INFO() << "POST DATA: " << postData;
|
||||
|
||||
if(postData.length()>0) {
|
||||
QList<QString> data = postData.split("\n");
|
||||
|
||||
qulonglong libraryId;
|
||||
qulonglong comicId;
|
||||
int currentPage;
|
||||
QString hash;
|
||||
foreach(QString comicInfo, data)
|
||||
{
|
||||
QList<QString> comicInfoProgress = comicInfo.split("\t");
|
||||
|
||||
if(comicInfoProgress.length() == 4)
|
||||
{
|
||||
libraryId = comicInfoProgress.at(0).toULongLong();
|
||||
comicId = comicInfoProgress.at(1).toULongLong();
|
||||
hash = comicInfoProgress.at(2);
|
||||
currentPage = comicInfoProgress.at(3).toInt();
|
||||
|
||||
ComicInfo info;
|
||||
info.currentPage = currentPage;
|
||||
info.hash = hash; //TODO remove the hash check and add UUIDs for libraries
|
||||
info.id = comicId;
|
||||
DBHelper::updateFromRemoteClient(libraryId,info);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(412,"No comic info received");
|
||||
response.writeText("",true);
|
||||
return;
|
||||
}
|
||||
|
||||
response.write("OK",true);
|
||||
}
|
||||
|
21
YACReaderLibrary/server/controllers/synccontroller.h
Normal file
21
YACReaderLibrary/server/controllers/synccontroller.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef SYNCCONTROLLER_H
|
||||
#define SYNCCONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class SyncController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(SyncController);
|
||||
public:
|
||||
/** Constructor */
|
||||
SyncController();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // SYNCCONTROLLER_H
|
@ -21,6 +21,7 @@
|
||||
#include "controllers/updatecomiccontroller.h"
|
||||
#include "controllers/errorcontroller.h"
|
||||
#include "controllers/comicdownloadinfocontroller.h"
|
||||
#include "controllers/synccontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
@ -105,10 +106,13 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
QRegExp comicPage("/library/.+/comic/[0-9]+/page/[0-9]+/?"); //get comic page
|
||||
QRegExp comicPageRemote("/library/.+/comic/[0-9]+/page/[0-9]+/remote?"); //get comic page (remote reading)
|
||||
|
||||
QRegExp sync("/sync");
|
||||
|
||||
QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe
|
||||
|
||||
path = QUrl::fromPercentEncoding(path).toUtf8();
|
||||
|
||||
if(!sync.exactMatch(path)) //no session is needed for syncback info, until security will be added
|
||||
loadSession(request, response);
|
||||
|
||||
//primera petición, se ha hecho un post, se sirven las bibliotecas si la seguridad mediante login no está habilitada
|
||||
@ -116,10 +120,12 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
{
|
||||
LibrariesController().service(request, response);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
if(sync.exactMatch(path))
|
||||
SyncController().service(request, response);
|
||||
else
|
||||
{
|
||||
//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"))
|
||||
@ -167,5 +173,5 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
ErrorController(300).service(request,response);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ HEADERS += \
|
||||
$$PWD/controllers/pagecontroller.h \
|
||||
$$PWD/controllers/sessionmanager.h \
|
||||
$$PWD/controllers/covercontroller.h \
|
||||
server/controllers/updatecomiccontroller.h \
|
||||
server/controllers/comicdownloadinfocontroller.h
|
||||
$$PWD/controllers/updatecomiccontroller.h \
|
||||
$$PWD/controllers/comicdownloadinfocontroller.h \
|
||||
$$PWD/controllers/synccontroller.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/static.cpp \
|
||||
@ -28,8 +29,9 @@ SOURCES += \
|
||||
$$PWD/controllers/pagecontroller.cpp \
|
||||
$$PWD/controllers/sessionmanager.cpp \
|
||||
$$PWD/controllers/covercontroller.cpp \
|
||||
server/controllers/updatecomiccontroller.cpp \
|
||||
server/controllers/comicdownloadinfocontroller.cpp
|
||||
$$PWD/controllers/updatecomiccontroller.cpp \
|
||||
$$PWD/controllers/comicdownloadinfocontroller.cpp \
|
||||
$$PWD/controllers/synccontroller.cpp
|
||||
|
||||
include(lib/bfLogging/bfLogging.pri)
|
||||
include(lib/bfHttpServer/bfHttpServer.pri)
|
||||
|
@ -5,11 +5,10 @@ body{
|
||||
|
||||
/* libraries */
|
||||
#contentLibraries{
|
||||
width: 300px;
|
||||
border: 1px solid #C6C6C6;
|
||||
background-color: white;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
margin-top: 9px;
|
||||
}
|
||||
|
||||
@ -62,7 +61,7 @@ body{
|
||||
|
||||
#contentLibraries .library-indicator
|
||||
{
|
||||
float: left;
|
||||
float: right;
|
||||
background-color: white;
|
||||
height: 8px;
|
||||
padding: 16px 16px 15px 16px;
|
||||
@ -181,10 +180,10 @@ body{
|
||||
|
||||
#itemContainer li
|
||||
{
|
||||
width: 300px;
|
||||
|
||||
height: 120px;
|
||||
border: 1px solid #E2E2E2;
|
||||
margin: 9px auto 0px auto;
|
||||
margin: 9px 10px 0px 10px;
|
||||
background-color: white;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
@ -218,22 +217,22 @@ overflow: hidden;
|
||||
.info
|
||||
{
|
||||
padding: 8px 0px 0px 0px;
|
||||
float: left;
|
||||
|
||||
position: relative;
|
||||
height: 115px;
|
||||
width: 212px;
|
||||
|
||||
padding-left: 82px;
|
||||
}
|
||||
|
||||
.buttons
|
||||
{
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:0px;
|
||||
left:80px;
|
||||
right: 0px;
|
||||
border-top: 1px solid #e2e2e2;
|
||||
padding-top: 3px;
|
||||
height: 25px;
|
||||
width: 220px;
|
||||
font-family: Arial;
|
||||
color: #6e6e6e;
|
||||
font-size: 10px;
|
||||
@ -245,7 +244,7 @@ width: 212px;
|
||||
bottom:24px;
|
||||
padding-top: 3px;
|
||||
height: 25px;
|
||||
width: 220px;
|
||||
width: 100%;
|
||||
font-family: Arial;
|
||||
color: #adadad;
|
||||
font-size: 10px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user