Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
18
21, m_customProxyToken(token)
22, m_networkManager(new QNetworkAccessManager(this))
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(
41 proxyUrl.host(),
42 proxyUrl.port(8080),
43 proxyUrl.userName(),
44 proxyUrl.password()));
45 }
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
62
\inmodule QtCore
Definition qbytearray.h:57
QNetworkReply * post(const QNetworkRequest &request, const QByteArray &data) override
QNetworkReply * get(const QNetworkRequest &request) override
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:357
The QNetworkAccessManager class allows the application to send network requests and receive replies.
QNetworkReply * post(const QNetworkRequest &request, QIODevice *data)
Sends an HTTP POST request to the destination specified by request and returns a new QNetworkReply ob...
void setProxy(const QNetworkProxy &proxy)
Sets the proxy to be used in future requests to be proxy.
QNetworkReply * get(const QNetworkRequest &request)
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object o...
static void setUseSystemConfiguration(bool enable)
The QNetworkProxy class provides a network layer proxy.
static QNetworkProxy applicationProxy()
Returns the application level network proxying.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
\inmodule QtCore
Definition qurl.h:94
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
#define this
Definition dialogs.cpp:9
Token token
Definition keywords.cpp:444
Combined button and popup list for selecting options.
#define qDebug
[1]
Definition qlogging.h:164
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
#define QStringLiteral(str)
QNetworkRequest request(url)
QNetworkProxy proxy
[0]