summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/osm/qgeotileproviderosm.cpp
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2019-03-14 13:52:33 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2019-03-25 14:17:18 +0000
commit5c3e3464c2ccf960ef3aaee4286f3d5b4cde12ac (patch)
tree1eb0558a758bb96c5dfb3c51513889600ae08c8b /src/plugins/geoservices/osm/qgeotileproviderosm.cpp
parent0af21b1f95180949f75ee2933d4147f610a29b6b (diff)
downloadqtlocation-5c3e3464c2ccf960ef3aaee4286f3d5b4cde12ac.tar.gz
Display a notice when requesting a SSL map type without SSL support
Some plugins request map data for some map types over HTTPS. Without SSL support (Qt built without SSL support, or missing OpenSSL libraries) this typically translates into blank maps. This is very evident on the MapViewer example. This patch makes sure that the example displays a notice when this situation happens. [ChangeLog] Added a notice to the MapViewer example to inform when a HTTPS-based map is selected without SSL support. Change-Id: I85428bb0536f33089a0e6045301c089fafe69d74 Fixes: QTBUG-74195 Fixes: QTBUG-74294 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/plugins/geoservices/osm/qgeotileproviderosm.cpp')
-rw-r--r--src/plugins/geoservices/osm/qgeotileproviderosm.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp
index f7ab8c99..e0008068 100644
--- a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp
@@ -45,6 +45,16 @@ QT_BEGIN_NAMESPACE
static const int maxValidZoom = 30;
static const QDateTime defaultTs = QDateTime::fromString(QStringLiteral("2016-06-01T00:00:00"), Qt::ISODate);
+static void setSSL(QGeoMapType &mapType, bool isHTTPS)
+{
+ QVariantMap metadata = mapType.metadata();
+ metadata["isHTTPS"] = isHTTPS;
+
+ mapType = QGeoMapType(mapType.style(), mapType.name(), mapType.description(), mapType.mobile(),
+ mapType.night(), mapType.mapId(), mapType.pluginName(), mapType.cameraCapabilities(),
+ metadata);
+}
+
QGeoTileProviderOsm::QGeoTileProviderOsm(QNetworkAccessManager *nm,
const QGeoMapType &mapType,
const QVector<TileProvider *> &providers,
@@ -61,6 +71,9 @@ QGeoTileProviderOsm::QGeoTileProviderOsm(QNetworkAccessManager *nm,
if (!m_provider || m_provider->isValid())
m_status = Resolved;
+ if (m_provider && m_provider->isValid())
+ setSSL(m_mapType, m_provider->isHTTPS());
+
connect(this, &QGeoTileProviderOsm::resolutionFinished, this, &QGeoTileProviderOsm::updateCameraCapabilities);
}
@@ -237,7 +250,11 @@ void QGeoTileProviderOsm::updateCameraCapabilities()
m_cameraCapabilities.setMaximumZoomLevel(maximumZoomLevel());
m_mapType = QGeoMapType(m_mapType.style(), m_mapType.name(), m_mapType.description(), m_mapType.mobile(),
- m_mapType.night(), m_mapType.mapId(), m_mapType.pluginName(), m_cameraCapabilities);
+ m_mapType.night(), m_mapType.mapId(), m_mapType.pluginName(), m_cameraCapabilities,
+ m_mapType.metadata());
+
+ if (m_provider && m_provider->isValid())
+ setSSL(m_mapType, m_provider->isHTTPS());
}
void QGeoTileProviderOsm::addProvider(TileProvider *provider)
@@ -604,6 +621,11 @@ bool TileProvider::isHighDpi() const
return m_highDpi;
}
+bool TileProvider::isHTTPS() const
+{
+ return m_urlTemplate.startsWith(QStringLiteral("https"));
+}
+
void TileProvider::setStyleCopyRight(const QString &copyright)
{
m_copyRightStyle = copyright;