From 2bc9f88400e0c57dc8b3df6917b8d482a050e676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Tue, 1 Dec 2015 22:50:02 +0100 Subject: [PATCH] added support for updating comics rating from clients --- YACReaderLibrary/db_helper.cpp | 26 +++++++++++++------ .../server/controllers/synccontroller.cpp | 11 +++++++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/YACReaderLibrary/db_helper.cpp b/YACReaderLibrary/db_helper.cpp index d7f9911a..f46b589f 100644 --- a/YACReaderLibrary/db_helper.cpp +++ b/YACReaderLibrary/db_helper.cpp @@ -395,15 +395,17 @@ void DBHelper::updateReadingRemoteProgress(const ComicInfo &comicInfo, QSqlDatab { QSqlQuery updateComicInfo(db); updateComicInfo.prepare("UPDATE comic_info SET " - "read = :read, " - "currentPage = :currentPage, " - "hasBeenOpened = :hasBeenOpened" - " WHERE id = :id "); + "read = :read, " + "currentPage = :currentPage, " + "hasBeenOpened = :hasBeenOpened, " + "rating = :rating" + " 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.bindValue(":rating", comicInfo.rating); updateComicInfo.exec(); } @@ -417,10 +419,18 @@ void DBHelper::updateFromRemoteClient(qulonglong libraryId,const ComicInfo & com 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; + if(comicInfo.currentPage > 0) + { + if(comic.info.currentPage == comic.info.numPages) + comic.info.read = true; + + comic.info.currentPage = comicInfo.currentPage; + + comic.info.hasBeenOpened = true; + } + + if(comicInfo.rating > 0) + comic.info.rating = comicInfo.rating; DBHelper::updateReadingRemoteProgress(comic.info,db); } diff --git a/YACReaderLibrary/server/controllers/synccontroller.cpp b/YACReaderLibrary/server/controllers/synccontroller.cpp index 7c4c1859..6756fa3f 100644 --- a/YACReaderLibrary/server/controllers/synccontroller.cpp +++ b/YACReaderLibrary/server/controllers/synccontroller.cpp @@ -23,12 +23,13 @@ void SyncController::service(HttpRequest &request, HttpResponse &response) qulonglong libraryId; qulonglong comicId; int currentPage; + int currentRating; QString hash; foreach(QString comicInfo, data) { QList comicInfoProgress = comicInfo.split("\t"); - if(comicInfoProgress.length() == 4) + if(comicInfoProgress.length() == 4 || comicInfoProgress.length() == 5) { libraryId = comicInfoProgress.at(0).toULongLong(); comicId = comicInfoProgress.at(1).toULongLong(); @@ -39,6 +40,14 @@ void SyncController::service(HttpRequest &request, HttpResponse &response) info.currentPage = currentPage; info.hash = hash; //TODO remove the hash check and add UUIDs for libraries info.id = comicId; + + //Client 2.1+ version + if(comicInfoProgress.length() > 4) + { + currentRating = comicInfoProgress.at(4).toInt(); + info.rating = currentRating; + } + DBHelper::updateFromRemoteClient(libraryId,info); } }