mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Added a new class for storing specific YACReader's http session data.
This commit is contained in:
parent
d2b7487149
commit
e67d34a511
@ -19,7 +19,8 @@ HEADERS += \
|
|||||||
#v2
|
#v2
|
||||||
$$PWD/controllers/versioncontroller.h \
|
$$PWD/controllers/versioncontroller.h \
|
||||||
$$PWD/controllers/foldercontentcontroller.h \
|
$$PWD/controllers/foldercontentcontroller.h \
|
||||||
$$PWD/controllers/tagscontroller.h
|
$$PWD/controllers/tagscontroller.h \
|
||||||
|
$$PWD/yacreader_http_session.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/static.cpp \
|
$$PWD/static.cpp \
|
||||||
@ -39,7 +40,8 @@ SOURCES += \
|
|||||||
#v2
|
#v2
|
||||||
$$PWD/controllers/versioncontroller.cpp \
|
$$PWD/controllers/versioncontroller.cpp \
|
||||||
$$PWD/controllers/foldercontentcontroller.cpp \
|
$$PWD/controllers/foldercontentcontroller.cpp \
|
||||||
$$PWD/controllers/tagscontroller.cpp
|
$$PWD/controllers/tagscontroller.cpp \
|
||||||
|
$$PWD/yacreader_http_session.cpp
|
||||||
|
|
||||||
include(lib/logging/logging.pri)
|
include(lib/logging/logging.pri)
|
||||||
include(lib/httpserver/httpserver.pri)
|
include(lib/httpserver/httpserver.pri)
|
||||||
|
165
YACReaderLibrary/server/yacreader_http_session.cpp
Normal file
165
YACReaderLibrary/server/yacreader_http_session.cpp
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
#include "yacreader_http_session.h"
|
||||||
|
|
||||||
|
YACReaderHttpSession::YACReaderHttpSession(QObject *parent)
|
||||||
|
: QObject(parent), comic(nullptr), remoteComic(nullptr), comicId(0), remoteComicId(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderHttpSession::isComicOnDevice(const QString & hash)
|
||||||
|
{
|
||||||
|
return comicsOnDevice.contains(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderHttpSession::isComicDownloaded(const QString & hash)
|
||||||
|
{
|
||||||
|
return downloadedComics.contains(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::setComicOnDevice(const QString & hash)
|
||||||
|
{
|
||||||
|
comicsOnDevice.insert(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::setComicsOnDevice(const QSet<QString> & set)
|
||||||
|
{
|
||||||
|
comicsOnDevice = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::setDownloadedComic(const QString & hash)
|
||||||
|
{
|
||||||
|
downloadedComics.insert(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<QString> YACReaderHttpSession::getComicsOnDevice()
|
||||||
|
{
|
||||||
|
return comicsOnDevice ;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<QString> YACReaderHttpSession::getDownloadedComics()
|
||||||
|
{
|
||||||
|
return downloadedComics ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::clearComics()
|
||||||
|
{
|
||||||
|
comicsOnDevice.clear();
|
||||||
|
downloadedComics.clear();
|
||||||
|
}
|
||||||
|
//current comic (import)
|
||||||
|
qulonglong YACReaderHttpSession::getCurrentComicId()
|
||||||
|
{
|
||||||
|
return comicId;
|
||||||
|
}
|
||||||
|
|
||||||
|
Comic* YACReaderHttpSession::getCurrentComic()
|
||||||
|
{
|
||||||
|
comic;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::dismissCurrentComic()
|
||||||
|
{
|
||||||
|
if(comic != nullptr)
|
||||||
|
{
|
||||||
|
comic->deleteLater();
|
||||||
|
comic = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::setCurrentComic(qulonglong id, Comic * comic)
|
||||||
|
{
|
||||||
|
dismissCurrentComic();
|
||||||
|
comicId = id;
|
||||||
|
comic = comic;
|
||||||
|
}
|
||||||
|
|
||||||
|
//current comic (read)
|
||||||
|
qulonglong YACReaderHttpSession::getCurrentRemoteComicId()
|
||||||
|
{
|
||||||
|
return remoteComicId ;
|
||||||
|
}
|
||||||
|
|
||||||
|
Comic* YACReaderHttpSession::getCurrentRemoteComic()
|
||||||
|
{
|
||||||
|
return remoteComic ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::dismissCurrentRemoteComic()
|
||||||
|
{
|
||||||
|
if(remoteComic != nullptr)
|
||||||
|
{
|
||||||
|
remoteComic->deleteLater();
|
||||||
|
remoteComic = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::setCurrentRemoteComic(qulonglong id, Comic * comic)
|
||||||
|
{
|
||||||
|
dismissCurrentRemoteComic();
|
||||||
|
remoteComicId = id;
|
||||||
|
remoteComic = comic;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString YACReaderHttpSession::getDeviceType()
|
||||||
|
{
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString YACReaderHttpSession::getDisplayType()
|
||||||
|
{
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::setDeviceType(const QString & device)
|
||||||
|
{
|
||||||
|
//comicsOnDevice.clear(); //TODO crear un m<>todo clear que limpie la sesi<73>n completamente
|
||||||
|
//downloadedComics.clear();
|
||||||
|
device = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::setDisplayType(const QString & display)
|
||||||
|
{
|
||||||
|
display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::clearNavigationPath()
|
||||||
|
{
|
||||||
|
navigationPath.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<qulonglong, quint32> YACReaderHttpSession::popNavigationItem()
|
||||||
|
{
|
||||||
|
if(navigationPath.isEmpty() == false)
|
||||||
|
return navigationPath.pop();
|
||||||
|
return QPair<qulonglong, quint32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<qulonglong, quint32> YACReaderHttpSession::topNavigationItem()
|
||||||
|
{
|
||||||
|
if(navigationPath.isEmpty() == false)
|
||||||
|
return navigationPath.top();
|
||||||
|
return QPair<qulonglong, quint32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::pushNavigationItem(const QPair<qulonglong, quint32> &item)
|
||||||
|
{
|
||||||
|
navigationPath.push(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderHttpSession::updateTopItem(const QPair<qulonglong, quint32> &item)
|
||||||
|
{
|
||||||
|
if(navigationPath.isEmpty() == false)
|
||||||
|
{
|
||||||
|
navigationPath.pop();
|
||||||
|
navigationPath.push(item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
navigationPath.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStack<QPair<qulonglong, quint32> > YACReaderHttpSession::getNavigationPath()
|
||||||
|
{
|
||||||
|
return navigationPath;
|
||||||
|
}
|
71
YACReaderLibrary/server/yacreader_http_session.h
Normal file
71
YACReaderLibrary/server/yacreader_http_session.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#ifndef YACREADERHTTPSESSION_H
|
||||||
|
#define YACREADERHTTPSESSION_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "comic.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class YACReaderHttpSession : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit YACReaderHttpSession(QObject *parent = 0);
|
||||||
|
|
||||||
|
void setComicsOnDevice(const QSet<QString> & set);
|
||||||
|
void setComicOnDevice(const QString & hash);
|
||||||
|
void setDownloadedComic(const QString & hash);
|
||||||
|
bool isComicOnDevice(const QString & hash);
|
||||||
|
bool isComicDownloaded(const QString & hash);
|
||||||
|
QSet<QString> getComicsOnDevice();
|
||||||
|
QSet<QString> getDownloadedComics();
|
||||||
|
void clearComics();
|
||||||
|
|
||||||
|
//current comic (import)
|
||||||
|
qulonglong getCurrentComicId();
|
||||||
|
Comic * getCurrentComic();
|
||||||
|
void dismissCurrentComic();
|
||||||
|
void setCurrentComic(qulonglong id, Comic * comic);
|
||||||
|
|
||||||
|
//current comic (read)
|
||||||
|
qulonglong getCurrentRemoteComicId();
|
||||||
|
Comic * getCurrentRemoteComic();
|
||||||
|
void dismissCurrentRemoteComic();
|
||||||
|
void setCurrentRemoteComic(qulonglong id, Comic * comic);
|
||||||
|
|
||||||
|
//device identification
|
||||||
|
QString getDeviceType();
|
||||||
|
QString getDisplayType();
|
||||||
|
void setDeviceType(const QString & device);
|
||||||
|
void setDisplayType(const QString & display);
|
||||||
|
|
||||||
|
void clearNavigationPath();
|
||||||
|
QPair<qulonglong, quint32> popNavigationItem();
|
||||||
|
QPair<qulonglong, quint32> topNavigationItem();
|
||||||
|
void pushNavigationItem(const QPair<qulonglong, quint32> & item);
|
||||||
|
void updateTopItem(const QPair<qulonglong, quint32> & item);
|
||||||
|
|
||||||
|
//TODO replace QPair by a custom class for storing folderId, page and folderName(save some DB accesses)
|
||||||
|
QStack<QPair<qulonglong, quint32> > getNavigationPath();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSet<QString> comicsOnDevice;
|
||||||
|
QSet<QString> downloadedComics;
|
||||||
|
|
||||||
|
QString device;
|
||||||
|
QString display;
|
||||||
|
|
||||||
|
qulonglong comicId;
|
||||||
|
qulonglong remoteComicId;
|
||||||
|
Comic * comic;
|
||||||
|
Comic * remoteComic;
|
||||||
|
|
||||||
|
QStack<QPair<qulonglong, quint32> > navigationPath; /* folder_id, page_number */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // YACREADERHTTPSESSION_H
|
Loading…
x
Reference in New Issue
Block a user