mirror of
https://github.com/YACReader/yacreader
synced 2025-07-27 01:15:07 -04:00
updated web library with new style and features
added remote reading from iOS
This commit is contained in:
@ -12,8 +12,8 @@ HttpRequest::HttpRequest(QSettings* settings) {
|
||||
status=waitForRequest;
|
||||
currentSize=0;
|
||||
expectedBodySize=0;
|
||||
maxSize=settings->value("maxRequestSize","16000000").toInt();
|
||||
maxMultiPartSize=settings->value("maxMultiPartSize","1000000").toInt();
|
||||
maxSize=settings->value("maxRequestSize","32000000").toInt();
|
||||
maxMultiPartSize=settings->value("maxMultiPartSize","32000000").toInt();
|
||||
}
|
||||
|
||||
void HttpRequest::readRequest(QTcpSocket& socket) {
|
||||
|
@ -307,3 +307,36 @@ int HttpSession::topPage()
|
||||
return dataPtr->yacreaderSessionData.navigationPath.top();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HttpSession::clearFoldersPath()
|
||||
{
|
||||
if(dataPtr)
|
||||
dataPtr->yacreaderSessionData.foldersPath.clear();
|
||||
}
|
||||
|
||||
int HttpSession::popFolder()
|
||||
{
|
||||
if(dataPtr && !(dataPtr->yacreaderSessionData.foldersPath.isEmpty()))
|
||||
return dataPtr->yacreaderSessionData.foldersPath.pop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HttpSession::pushFolder(int page)
|
||||
{
|
||||
if(dataPtr)
|
||||
dataPtr->yacreaderSessionData.foldersPath.push(page);
|
||||
}
|
||||
|
||||
int HttpSession::topFolder()
|
||||
{
|
||||
if(dataPtr)
|
||||
return dataPtr->yacreaderSessionData.foldersPath.top();
|
||||
return 0;
|
||||
}
|
||||
|
||||
QStack<int> HttpSession::getFoldersPath()
|
||||
{
|
||||
if(dataPtr)
|
||||
return dataPtr->yacreaderSessionData.foldersPath;
|
||||
return QStack<int>();
|
||||
}
|
||||
|
@ -119,6 +119,12 @@ public:
|
||||
void pushPage(int page);
|
||||
int topPage();
|
||||
|
||||
void clearFoldersPath();
|
||||
int popFolder();
|
||||
void pushFolder(int page);
|
||||
int topFolder();
|
||||
QStack<int> getFoldersPath();
|
||||
|
||||
private:
|
||||
|
||||
struct YACReaderSessionData {
|
||||
@ -132,6 +138,7 @@ private:
|
||||
qulonglong comicId;
|
||||
|
||||
QStack<int> navigationPath;
|
||||
QStack<int> foldersPath;
|
||||
|
||||
Comic * comic;
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ HttpSessionStore::HttpSessionStore(QSettings* settings, QObject* parent)
|
||||
connect(&cleanupTimer,SIGNAL(timeout()),this,SLOT(timerEvent()));
|
||||
cleanupTimer.start(60000);
|
||||
cookieName=settings->value("cookieName","sessionid").toByteArray();
|
||||
expirationTime=settings->value("expirationTime",18000000).toInt();
|
||||
expirationTime=settings->value("expirationTime",86400000).toInt();
|
||||
qDebug("HttpSessionStore: Sessions expire after %i milliseconds",expirationTime);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,11 @@ void StaticFileController::service(HttpRequest& request, HttpResponse& response)
|
||||
stringPath.remove(fileName);
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
QString device = session.getDeviceType();
|
||||
fileName = getDeviceAwareFileName(fileName, device, request.getHeader("Accept-Language"), stringPath);
|
||||
QString display = session.getDisplayType();
|
||||
if(fileName.endsWith(".png"))
|
||||
fileName = getDeviceAwareFileName(fileName, device, display, request.getHeader("Accept-Language"), stringPath);
|
||||
else
|
||||
fileName = getDeviceAwareFileName(fileName, device, request.getHeader("Accept-Language"), stringPath);
|
||||
QString newPath = stringPath.append(fileName);
|
||||
path = newPath.toLocal8Bit();
|
||||
|
||||
@ -207,5 +211,24 @@ QString StaticFileController::getDeviceAwareFileName(QString fileName, QString d
|
||||
if(QFile(docroot+"/"+path+completeFileName).exists())
|
||||
return completeFileName; //existe un archivo espec<65>fico para este dispositivo y locales
|
||||
else
|
||||
return getLocalizedFileName(fileName,locales,path); //no hay archivo espec<65>fico para el dispositivo, pero puede haberlo para estas locales
|
||||
return getLocalizedFileName(fileName,locales,path); //no hay archivo espec<65>fico para el dispositivo, pero puede haberlo para estas locales
|
||||
}
|
||||
|
||||
QString StaticFileController::getDeviceAwareFileName(QString fileName, QString device, QString display, QString locales, QString path) const
|
||||
{
|
||||
QFileInfo fi(fileName);
|
||||
QString baseName = fi.baseName();
|
||||
QString extension = fi.completeSuffix();
|
||||
|
||||
QString completeFileName = completeFileName = baseName+display+"."+extension;
|
||||
if(QFile(docroot+"/"+path+completeFileName).exists())
|
||||
return completeFileName;
|
||||
else
|
||||
{
|
||||
completeFileName = baseName+"_"+device+display+"."+extension;
|
||||
if((QFile(docroot+"/"+path+completeFileName).exists()))
|
||||
return completeFileName;
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ private:
|
||||
|
||||
QString getLocalizedFileName(QString fileName, QString locales, QString path) const;
|
||||
QString getDeviceAwareFileName(QString fileName, QString device, QString locales, QString path) const;
|
||||
QString getDeviceAwareFileName(QString fileName, QString device, QString display, QString locales, QString path) const;
|
||||
|
||||
bool exists(QString localizedName, QString path) const;
|
||||
};
|
||||
|
Reference in New Issue
Block a user