diff --git a/CMakeLists.txt b/CMakeLists.txt index 002194c..99119f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,8 @@ find_package(Qt6 6.8 REQUIRED COMPONENTS Core Gui Widgets Qml Quick QuickControl qt_standard_project_setup() qt_add_executable(${CMAKE_PROJECT_NAME} - README.md) + README.md + LICENSE) qt_add_resources(${CMAKE_PROJECT_NAME} "configuration" PREFIX "/" FILES diff --git a/KomplexHubPlugin/CMakeLists.txt b/KomplexHubPlugin/CMakeLists.txt index 55ee5bb..f06928c 100644 --- a/KomplexHubPlugin/CMakeLists.txt +++ b/KomplexHubPlugin/CMakeLists.txt @@ -19,15 +19,15 @@ qt_add_qml_module( newestpacksmodel.cpp common/komplex_global.h common/slidingcachecontroller.h - common/slidingcachecontroller.cpp + common/paginator.h - common/paginator.cpp + common/coreservices.h common/coreservices.cpp common/logging.h common/fetchresult.h paginators/newestpackspaginator.h - paginators/newestpackspaginator.cpp + ) target_compile_definitions( diff --git a/KomplexHubPlugin/common/coreservices.cpp b/KomplexHubPlugin/common/coreservices.cpp index 4997afb..4ddb998 100644 --- a/KomplexHubPlugin/common/coreservices.cpp +++ b/KomplexHubPlugin/common/coreservices.cpp @@ -1,18 +1,52 @@ #include "coreservices.h" #include "logging.h" -QNetworkAccessManager *CoreServices::m_networkAccessManager = new QNetworkAccessManager(); +QNetworkAccessManager *CoreServices::s_networkAccessManager = new QNetworkAccessManager(); +QMutex CoreServices::s_networkAccessMutex; +QSharedPointer CoreServices::s_networkAccessPointer; -auto CoreServices::networkAccessManager() -> QNetworkAccessManager * +auto CoreServices::networkAccessManager() -> QWeakPointer { - return m_networkAccessManager; + QMutexLocker locker(&s_networkAccessMutex); + + if(!s_networkAccessPointer) + { + s_networkAccessManager = new QNetworkAccessManager; + + QObject::connect( + s_networkAccessManager, + &QNetworkAccessManager::sslErrors, + s_networkAccessManager, + [] (QNetworkReply *reply, const QList &errors) + { + for(const auto &error : errors) + { + LOG_ERROR( + "CoreServices::networkAccessManager", + error.errorString().toStdString().c_str() + ); + } + +#ifdef KOMPLEX_LOCAL_DEV + reply->ignoreSslErrors(); +#endif + } + ); + + s_networkAccessPointer = QSharedPointer( + s_networkAccessManager, + &QNetworkAccessManager::deleteLater + ); + } + + return s_networkAccessPointer.toWeakRef(); } auto CoreServices::sessionToken() -> QByteArray { LOG_ERROR_X(true, "CoreServices::sessionToken", - "User services not yet implements", + "User services not yet implemented", {} ); } diff --git a/KomplexHubPlugin/common/coreservices.h b/KomplexHubPlugin/common/coreservices.h index dedf66a..63f8903 100644 --- a/KomplexHubPlugin/common/coreservices.h +++ b/KomplexHubPlugin/common/coreservices.h @@ -1,8 +1,31 @@ +/* + * Komplex Wallpaper Engine + * Copyright (C) 2026 @DigitalArtifex + * https://digitalartifex.dev - https://github.com/DigitalArtifex + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ #ifndef CORESERVICES_H #define CORESERVICES_H #include #include +#include +#include +#include +#include +#include class CoreServices { @@ -13,7 +36,7 @@ public: * Plugin-wide QNetworkAccessManager * @return */ - static auto networkAccessManager() -> QNetworkAccessManager*; + static auto networkAccessManager() -> QWeakPointer; /** * @brief getSessionToken @@ -23,6 +46,14 @@ public: static auto sessionToken() -> QByteArray; private: - static QNetworkAccessManager *m_networkAccessManager; + + CoreServices() = default; + ~CoreServices() = default; + CoreServices(const CoreServices&) = delete; + CoreServices& operator=(const CoreServices&) = delete; + + static QMutex s_networkAccessMutex; + static QNetworkAccessManager *s_networkAccessManager; + static QSharedPointer s_networkAccessPointer; }; #endif // CORESERVICES_H diff --git a/KomplexHubPlugin/common/paginator.cpp b/KomplexHubPlugin/common/paginator.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/KomplexHubPlugin/common/slidingcachecontroller.cpp b/KomplexHubPlugin/common/slidingcachecontroller.cpp deleted file mode 100644 index e69de29..0000000