LeechCraft
0.6.70-19214-g121e5318a7
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
standardnamfactory.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
standardnamfactory.h
"
10
#include <chrono>
11
#include <QNetworkAccessManager>
12
#include <QQmlEngine>
13
#include <
util/network/networkdiskcache.h
>
14
#include <xmlsettingsdialog/basesettingsmanager.h>
15
16
namespace
LC::Util
17
{
18
StandardNAMFactory::StandardNAMFactory
(QString subpath,
19
CacheSizeGetter_f
getter,
20
BaseSettingsManager& settings,
21
QQmlEngine *engine)
22
: Subpath_ (std::move (subpath))
23
, CacheSizeGetter_ (std::move (getter))
24
{
25
settings.RegisterObject (
"TransferTimeout"
,
26
this
,
27
[
this
] (
int
seconds)
28
{
29
const
auto
newTimeout = std::chrono::seconds { seconds };
30
RequestTimeout_ = newTimeout;
31
emit
requestTimeoutChanged
(newTimeout);
32
});
33
34
if
(engine)
35
engine->setNetworkAccessManagerFactory (
this
);
36
}
37
38
QNetworkAccessManager*
StandardNAMFactory::create
(QObject *parent)
39
{
40
auto
nam =
new
QNetworkAccessManager (parent);
41
connect (
this
,
42
&
StandardNAMFactory::requestTimeoutChanged
,
43
nam,
44
qOverload<std::chrono::milliseconds> (&QNetworkAccessManager::setTransferTimeout));
45
46
auto
cache =
new
NetworkDiskCache
(Subpath_, nam);
47
cache->setMaximumCacheSize (CacheSizeGetter_ ());
48
nam->setCache (cache);
49
nam->setTransferTimeout (RequestTimeout_.load ());
50
51
return
nam;
52
}
53
}
LC::Util::NetworkDiskCache::NetworkDiskCache
NetworkDiskCache(const QString &subpath, QObject *parent=nullptr)
Constructs the new disk cache.
Definition
networkdiskcache.cpp:27
LC::Util::StandardNAMFactory::StandardNAMFactory
StandardNAMFactory(QString subpath, CacheSizeGetter_f getter, BaseSettingsManager &settings, QQmlEngine *engine=nullptr)
Constructs a new StandardNAMFactory.
Definition
standardnamfactory.cpp:18
LC::Util::StandardNAMFactory::create
QNetworkAccessManager * create(QObject *parent) override
Creates the network access manager with the given parent.
Definition
standardnamfactory.cpp:38
LC::Util::StandardNAMFactory::requestTimeoutChanged
void requestTimeoutChanged(std::chrono::milliseconds)
LC::Util::StandardNAMFactory::CacheSizeGetter_f
std::function< int()> CacheSizeGetter_f
The type of the function used to query the cache size by the factory.
Definition
standardnamfactory.h:55
LC::Util
Definition
icoreproxy.h:34
networkdiskcache.h
standardnamfactory.h
src
util
qml
standardnamfactory.cpp
Generated by
1.18.0