Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgeointrinsicnetworkaccessmanager.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QDebug>
7#include <QVariant>
8#include <QNetworkProxy>
9#include <QNetworkAccessManager>
10
12
15, m_networkManager(new QNetworkAccessManager(this))
16{
17}
18
19QGeoIntrinsicNetworkAccessManager::QGeoIntrinsicNetworkAccessManager(const QVariantMap &parameters, const QString &token, QObject *parent)
23{
24 configure(parameters);
25}
26
27void QGeoIntrinsicNetworkAccessManager::configure(const QVariantMap &parameters)
28{
29 QString proxy = parameters.value(QStringLiteral("here.proxy")).toString();
30 if (proxy.isEmpty() && !m_customProxyToken.isEmpty())
31 proxy = parameters.value(m_customProxyToken).toString();
32
33 if (!proxy.isEmpty()) {
34#ifndef QT_NO_NETWORKPROXY
35 if (proxy.toLower() != QStringLiteral("system")) {
36 QUrl proxyUrl(proxy);
37 if (proxyUrl.isValid()) {
38 qDebug() << "Setting proxy to " << proxyUrl.toString();
39 m_networkManager->setProxy(
40 QNetworkProxy(QNetworkProxy::HttpProxy,
41 proxyUrl.host(),
42 proxyUrl.port(8080),
43 proxyUrl.userName(),
44 proxyUrl.password()));
45 }
46 } else if (QNetworkProxy::applicationProxy().type() == QNetworkProxy::NoProxy) {
47 QNetworkProxyFactory::setUseSystemConfiguration(true);
48 qDebug() << "Setting system proxy.";
49 }
50#else
51 qDebug() << "No proxy support";
52#endif
53 } else {
54 qDebug() << "No proxy parameter specified.";
55 }
56}
57
58QNetworkReply *QGeoIntrinsicNetworkAccessManager::get(const QNetworkRequest &request)
59{
60 return m_networkManager->get(request);
61}
62
63QNetworkReply *QGeoIntrinsicNetworkAccessManager::post(const QNetworkRequest &request, const QByteArray &data)
64{
65 return m_networkManager->post(request, data);
66}
67QT_END_NAMESPACE
QNetworkReply * post(const QNetworkRequest &request, const QByteArray &data) override
QNetworkReply * get(const QNetworkRequest &request) override
QGeoIntrinsicNetworkAccessManager(const QVariantMap &parameters, const QString &token=QString(), QObject *parent=nullptr)
QObject * parent
Definition qobject.h:73
\inmodule QtCore
Definition qobject.h:103
Combined button and popup list for selecting options.