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
qgeoserviceproviderplugin_nokia.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
11#include "qgeoerror_messages.h"
12
13#include <QtPlugin>
14#include <QNetworkProxy>
15#include <QCoreApplication>
16
18
19namespace
20{
22 {
23 if (param.isEmpty())
24 return false;
25
26 if (param.length() > 512)
27 return false;
28
29 for (const auto &c : param) {
30 if (!c.isLetterOrNumber() && c.toLatin1() != '%' && c.toLatin1() != '-' &&
31 c.toLatin1() != '+' && c.toLatin1() != '_') {
32 return false;
33 }
34 }
35 return true;
36 }
37
39 {
40 return static_cast<QGeoNetworkAccessManager *>(qvariant_cast<void *>(parameters.value(QStringLiteral("nam"))));
41 }
42
43 void checkUsageTerms(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
44 {
45 const QString apiKey = parameters.value(QStringLiteral("here.apiKey")).toString();
46
47 if (isValidParameter(apiKey))
48 return;
49 else
50 qWarning() << "Invalid here.apiKey";
51
52 if (parameters.contains(QStringLiteral("apiKey")))
53 qWarning() << QStringLiteral("Please prefix 'apiKey' with prefix 'here' (e.g.: 'here.apiKey')");
54
57 }
58
59 template<class TInstance>
60 TInstance * CreateInstanceOf(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
61 {
62 checkUsageTerms(parameters, error, errorString);
63
65 return nullptr;
66
67 QGeoNetworkAccessManager *networkManager = tryGetNetworkAccessManager(parameters);
68 if (!networkManager)
69 networkManager = new QGeoIntrinsicNetworkAccessManager(parameters);
70
71 return new TInstance(networkManager, parameters, error, errorString);
72 }
73}
74
75QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia()
76{
77}
78
80 const QVariantMap &parameters,
82 QString *errorString) const
83{
84 return CreateInstanceOf<QGeoCodingManagerEngineNokia>(parameters, error, errorString);
85}
86
88 const QVariantMap &parameters,
90 QString *errorString) const
91{
92 return CreateInstanceOf<QGeoTiledMappingManagerEngineNokia>(parameters, error, errorString);
93}
94
96 const QVariantMap &parameters,
98 QString *errorString) const
99{
100 return CreateInstanceOf<QGeoRoutingManagerEngineNokia>(parameters, error, errorString);
101}
102
104 const QVariantMap &parameters,
106 QString *errorString) const
107{
108 return CreateInstanceOf<QPlaceManagerEngineNokiaV2>(parameters, error, errorString);
109}
110
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
QGeoMappingManagerEngine * createMappingManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const override
Returns a new QGeoMappingManagerEngine instance, initialized with parameters, which implements mappin...
Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/6.0" FILE "nokia_plugin.json") public QGeoCodingManagerEngine * createGeocodingManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const override
Returns a new QGeoCodingManagerEngine instance, initialized with parameters, which implements the loc...
QPlaceManagerEngine * createPlaceManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const override
Returns a new QPlaceManagerEngine instance, initialized with parameters, which implements the place s...
QGeoRoutingManagerEngine * createRoutingManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const override
Returns a new QGeoRoutingManagerEngine instance, initialized with parameters, which implements routin...
Error
Describes an error related to the loading and setup of a service provider plugin.
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:357
bool contains(const Key &key) const
Definition qmap.h:341
\inmodule QtLocation
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
Combined button and popup list for selecting options.
QGeoNetworkAccessManager * tryGetNetworkAccessManager(const QVariantMap &parameters)
bool isValidParameter(const QString &param)
TInstance * CreateInstanceOf(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
void checkUsageTerms(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
DBusConnection const char DBusError * error
QT_BEGIN_NAMESPACE const char NOKIA_PLUGIN_CONTEXT_NAME[]
const char MISSED_CREDENTIALS[]
#define qWarning
Definition qlogging.h:166
GLenum const GLint * param
const GLubyte * c
#define QStringLiteral(str)