Qt 6.x
The Qt SDK
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 QString appId, token;
46
47 appId = parameters.value(QStringLiteral("here.app_id")).toString();
48 token = parameters.value(QStringLiteral("here.token")).toString();
49
51 return;
52 else if (!isValidParameter(appId))
53 qWarning() << "Invalid here.app_id";
54 else
55 qWarning() << "Invalid here.token";
56
57 if (parameters.contains(QStringLiteral("app_id")) || parameters.contains(QStringLiteral("token")))
58 qWarning() << QStringLiteral("Please prefix 'app_id' and 'token' with prefix 'here' (e.g.: 'here.app_id')");
59
62 }
63
64 template<class TInstance>
65 TInstance * CreateInstanceOf(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
66 {
67 checkUsageTerms(parameters, error, errorString);
68
70 return nullptr;
71
72 QGeoNetworkAccessManager *networkManager = tryGetNetworkAccessManager(parameters);
73 if (!networkManager)
74 networkManager = new QGeoIntrinsicNetworkAccessManager(parameters);
75
76 return new TInstance(networkManager, parameters, error, errorString);
77 }
78}
79
80QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia()
81{
82}
83
85 const QVariantMap &parameters,
87 QString *errorString) const
88{
89 return CreateInstanceOf<QGeoCodingManagerEngineNokia>(parameters, error, errorString);
90}
91
93 const QVariantMap &parameters,
95 QString *errorString) const
96{
97 return CreateInstanceOf<QGeoTiledMappingManagerEngineNokia>(parameters, error, errorString);
98}
99
101 const QVariantMap &parameters,
103 QString *errorString) const
104{
105 return CreateInstanceOf<QGeoRoutingManagerEngineNokia>(parameters, error, errorString);
106}
107
109 const QVariantMap &parameters,
111 QString *errorString) const
112{
113 return CreateInstanceOf<QPlaceManagerEngineNokiaV2>(parameters, error, errorString);
114}
115
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:356
bool contains(const Key &key) const
Definition qmap.h:340
\inmodule QtLocation
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
Token token
Definition keywords.cpp:444
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:162
GLenum const GLint * param
const GLubyte * c
#define QStringLiteral(str)