From 9121d0e4b45fb3a1401554bc48c77f17ce40a7f9 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Fri, 5 Nov 2021 15:10:13 +0100 Subject: Plugins: port to QPluginParsedMetaData and CBOR QFactoryLoader now no longer converts its internal metadata to JSON, so we may as well not do it here either. All of this is internal API, so we can change. Task-number: QTBUG-97769 Change-Id: I91f9fd5a3a843befff2fb29be7659b7520be16bc Reviewed-by: Alex Blasche Reviewed-by: Thiago Macieira --- src/location/maps/qgeoserviceprovider.cpp | 25 +++++++++++++------------ src/location/maps/qgeoserviceprovider_p.h | 9 ++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp index 4873da22..292e981a 100644 --- a/src/location/maps/qgeoserviceprovider.cpp +++ b/src/location/maps/qgeoserviceprovider.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -282,8 +283,8 @@ Flags QGeoServiceProviderPrivate::features(const char *enumName) Flags ret = typename Flags::enum_type(0); if (this->metaData.contains(QStringLiteral("Features")) && this->metaData.value(QStringLiteral("Features")).isArray()) { - QJsonArray features = this->metaData.value(QStringLiteral("Features")).toArray(); - foreach (const QJsonValue &v, features) { + QCborArray features = this->metaData.value(QStringLiteral("Features")).toArray(); + for (const QCborValue &v : features) { int val = en.keyToValue(v.toString().toLatin1().constData()); if (v.isString() && val != -1) { ret |= typename Flags::enum_type(val); @@ -799,7 +800,7 @@ void QGeoServiceProviderPrivate::unload() factory = factoryV2 = factoryV3 = nullptr; error = QGeoServiceProvider::NoError; errorString = QLatin1String(""); - metaData = QJsonObject(); + metaData = QCborMap(); metaData.insert(QStringLiteral("index"), -1); } @@ -827,12 +828,12 @@ void QGeoServiceProviderPrivate::filterParameterMap() void QGeoServiceProviderPrivate::loadMeta() { factory = factoryV2 = factoryV3 = nullptr; - metaData = QJsonObject(); + metaData = QCborMap(); metaData.insert(QStringLiteral("index"), -1); error = QGeoServiceProvider::NotSupportedError; errorString = QString(QLatin1String("The geoservices provider %1 is not supported.")).arg(providerName); - QList candidates = QGeoServiceProviderPrivate::plugins().values(providerName); + QList candidates = QGeoServiceProviderPrivate::plugins().values(providerName); int versionFound = -1; int idx = -1; @@ -840,9 +841,9 @@ void QGeoServiceProviderPrivate::loadMeta() // figure out which version of the plugin we want // (always latest unless experimental) for (int i = 0; i < candidates.size(); ++i) { - QJsonObject meta = candidates[i]; + QCborMap meta = candidates[i]; if (meta.contains(QStringLiteral("Version")) - && meta.value(QStringLiteral("Version")).isDouble() + && meta.value(QStringLiteral("Version")).isInteger() && meta.contains(QStringLiteral("Experimental")) && meta.value(QStringLiteral("Experimental")).isBool()) { int ver = int(meta.value(QStringLiteral("Version")).toDouble()); @@ -896,9 +897,9 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap ¶meters) } } -QMultiHash QGeoServiceProviderPrivate::plugins(bool reload) +QMultiHash QGeoServiceProviderPrivate::plugins(bool reload) { - static QMultiHash plugins; + static QMultiHash plugins; static bool alreadyDiscovered = false; if (reload == true) @@ -911,12 +912,12 @@ QMultiHash QGeoServiceProviderPrivate::plugins(bool reload return plugins; } -void QGeoServiceProviderPrivate::loadPluginMetadata(QMultiHash &list) +void QGeoServiceProviderPrivate::loadPluginMetadata(QMultiHash &list) { QFactoryLoader *l = loader(); - QList meta = l->metaData(); + QList meta = l->metaData(); for (int i = 0; i < meta.size(); ++i) { - QJsonObject obj = meta.at(i).value(QStringLiteral("MetaData")).toObject(); + QCborMap obj = meta.at(i).value(QtPluginMetaDataKeys::MetaData).toMap(); obj.insert(QStringLiteral("index"), i); list.insert(obj.value(QStringLiteral("Provider")).toString(), obj); } diff --git a/src/location/maps/qgeoserviceprovider_p.h b/src/location/maps/qgeoserviceprovider_p.h index 22dcedd6..de44054a 100644 --- a/src/location/maps/qgeoserviceprovider_p.h +++ b/src/location/maps/qgeoserviceprovider_p.h @@ -51,8 +51,7 @@ #include "qgeoserviceprovider.h" #include -#include -#include +#include #include QT_BEGIN_NAMESPACE @@ -87,7 +86,7 @@ public: QGeoServiceProviderFactory *factory; QGeoServiceProviderFactoryV2 *factoryV2 = nullptr; QGeoServiceProviderFactoryV3 *factoryV3 = nullptr; - QJsonObject metaData; + QCborMap metaData; QVariantMap parameterMap; QVariantMap cleanedParameterMap; @@ -121,8 +120,8 @@ public: QLocale locale; bool localeSet; - static QMultiHash plugins(bool reload = false); - static void loadPluginMetadata(QMultiHash &list); + static QMultiHash plugins(bool reload = false); + static void loadPluginMetadata(QMultiHash &list); }; QT_END_NAMESPACE -- cgit v1.2.1