1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

SkyMap: Fix CORS and enabling caching.

This commit is contained in:
srcejon 2024-02-27 15:40:48 +00:00
parent e0839fce82
commit c9c605f448
4 changed files with 15 additions and 7 deletions

View File

@ -80,12 +80,6 @@ target_link_libraries(${TARGET_NAME}
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
if(WIN32)
# Run deployqt for QtQuick etc
include(DeployQt)
windeployqt(${TARGET_NAME} ${SDRANGEL_BINARY_BIN_DIR} ${PROJECT_SOURCE_DIR}/skymap)
endif()
# Install debug symbols
if (WIN32)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}> CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${INSTALL_FOLDER} )

View File

@ -97,7 +97,7 @@ void WebServer::addFile(const QString &path, const QByteArray &data)
void WebServer::sendFile(QTcpSocket* socket, const QByteArray &data, MimeType *mimeType, const QString &path)
{
QString header = QString("HTTP/1.0 200 Ok\r\nContent-Type: %1\r\nAccess-Control-Allow-Origin \"*\"\r\n\r\n").arg(mimeType->m_type);
QString header = QString("HTTP/1.0 200 Ok\r\nContent-Type: %1\r\nAccess-Control-Allow-Headers: *\r\nAccess-Control-Allow-Methods: *\r\nAccess-Control-Allow-Origin: *\r\n\r\n").arg(mimeType->m_type);
if (mimeType->m_binary)
{
// Send file as binary

View File

@ -21,11 +21,23 @@
#include <QNetworkReply>
#include <QXmlStreamReader>
#include <QDebug>
#include <QNetworkDiskCache>
WTML::WTML()
{
m_networkManager = new QNetworkAccessManager();
QObject::connect(m_networkManager, &QNetworkAccessManager::finished, this, &WTML::handleReply);
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
QDir writeableDir(locations[0]);
if (!writeableDir.mkpath(QStringLiteral("cache") + QDir::separator() + QStringLiteral("wtml"))) {
qDebug() << "Failed to create cache/wtml";
}
m_cache = new QNetworkDiskCache();
m_cache->setCacheDirectory(locations[0] + QDir::separator() + QStringLiteral("cache") + QDir::separator() + QStringLiteral("wtml"));
m_cache->setMaximumCacheSize(100000000);
m_networkManager->setCache(m_cache);
}
WTML::~WTML()

View File

@ -22,6 +22,7 @@
class QNetworkAccessManager;
class QNetworkReply;
class QNetworkDiskCache;
// World Wide Telescope WTML files containing imageset catalogs
class WTML : public QObject
@ -48,6 +49,7 @@ signals:
private:
QNetworkAccessManager *m_networkManager;
QNetworkDiskCache *m_cache;
};