summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Gressmann <jean.gressmann@nokia.com>2012-03-26 11:43:31 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-26 17:00:52 +0200
commit07846bc812be2a454ad7b70f7677407e80305372 (patch)
tree2cefc83625281027b88c8826c6f5f11968056583
parent81b6dd047ae6939f2d743cc7b6d0ef8794b6aab7 (diff)
downloadqtlocation-07846bc812be2a454ad7b70f7677407e80305372.tar.gz
QtLocation: Nokia plugin now returns an error on invalid travel modes
The plugin now returns an error if more than one travel mode flag is set at the same time. Change-Id: Iee8254c53c599b0e79ff701dc4e000ba4659a400 Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp5
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp10
2 files changed, 14 insertions, 1 deletions
diff --git a/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
index 223fa733..f331c229 100644
--- a/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
@@ -333,8 +333,11 @@ bool QGeoRouteXmlParser::parseMode(QGeoRoute *route)
route->setTravelMode(QGeoRouteRequest::BicycleTravel);
else if (value == "truck")
route->setTravelMode(QGeoRouteRequest::TruckTravel);
- else // unsupported optimization
+ else {
+ // unsupported mode
+ m_reader->raiseError(QString("Unsupported travel mode '\"%1\"'").arg(value));
return false;
+ }
} else {
m_reader->skipCurrentElement();
}
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
index b509c748..bc6e8234 100644
--- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
@@ -223,6 +223,16 @@ bool QGeoRoutingManagerEngineNokia::checkEngineSupport(const QGeoRouteRequest &r
if ((travelModes & supportedTravelModes()) != travelModes)
return false;
+ // Count the number of set bits (= number of travel modes) (popcount)
+ int count = 0;
+
+ for (unsigned bits = travelModes; bits; bits >>= 1)
+ count += (bits & 1);
+
+ // We only allow one travel mode at a time
+ if (count != 1)
+ return false;
+
return true;
}