Kgapi

networkaccessmanagerfactory.cpp
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2018 - 2020 Daniel Vrátil <dvratil@kde.org>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "debug.h"
10#include "networkaccessmanagerfactory_p.h"
11
12#include <QNetworkAccessManager>
13
14using namespace KGAPI2;
15
16std::unique_ptr<NetworkAccessManagerFactory> NetworkAccessManagerFactory::sInstance;
17
18class QtNetworkAccessManagerFactory : public NetworkAccessManagerFactory
19{
20public:
21 QNetworkAccessManager *networkAccessManager(QObject *parent) const override
22 {
23 auto nam = new QNetworkAccessManager(parent);
24 nam->setStrictTransportSecurityEnabled(true);
25 nam->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy);
26 return nam;
27 }
28};
29
30void NetworkAccessManagerFactory::setFactory(NetworkAccessManagerFactory *factory)
31{
32 sInstance.reset(factory);
33}
34
35NetworkAccessManagerFactory *NetworkAccessManagerFactory::instance()
36{
37 if (!sInstance) {
38 setFactory(new QtNetworkAccessManagerFactory);
39 }
40 return sInstance.get();
41}
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.