summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <qt-info@nokia.com>2011-05-10 15:04:33 +1000
committerAlex <qt-info@nokia.com>2011-05-10 15:04:33 +1000
commit50db7c24d8554dd4fab327d129ec603ed57a66ee (patch)
tree9d5b461bd834e991216cefae90f923ef155bda5e
parentd94e67fe339e89a2eeabc837bb9119f8b7be2807 (diff)
downloadqtlocation-50db7c24d8554dd4fab327d129ec603ed57a66ee.tar.gz
add Ovi rest plugin to Location
-rw-r--r--src/location/location.pro3
-rw-r--r--src/plugins/geoservices/geoservices.pro3
-rw-r--r--src/plugins/geoservices/nokia/OVI_SERVICES_TERMS_AND_CONDITIONS.txt202
-rw-r--r--src/plugins/geoservices/nokia/jsonparser.h241
-rw-r--r--src/plugins/geoservices/nokia/marclanguagecodes.h275
-rw-r--r--src/plugins/geoservices/nokia/nokia.pro54
-rw-r--r--src/plugins/geoservices/nokia/qgeocodexmlparser.cpp576
-rw-r--r--src/plugins/geoservices/nokia/qgeocodexmlparser.h90
-rw-r--r--src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp302
-rw-r--r--src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.h92
-rw-r--r--src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp137
-rw-r--r--src/plugins/geoservices/nokia/qgeomapreply_nokia.h78
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp122
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutereply_nokia.h74
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp560
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutexmlparser.h117
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp477
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h92
-rw-r--r--src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.cpp317
-rw-r--r--src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.h98
-rw-r--r--src/plugins/geoservices/nokia/qgeosearchreply_nokia.cpp131
-rw-r--r--src/plugins/geoservices/nokia/qgeosearchreply_nokia.h74
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp96
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h82
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp236
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h95
-rw-r--r--src/plugins/geoservices/nokia/resource.qrc5
-rw-r--r--src/plugins/geoservices/nokia/watermark.pngbin0 -> 1542 bytes
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/src.pro3
30 files changed, 4632 insertions, 2 deletions
diff --git a/src/location/location.pro b/src/location/location.pro
index 55abe286..5e9caf6e 100644
--- a/src/location/location.pro
+++ b/src/location/location.pro
@@ -2,7 +2,8 @@ TEMPLATE = lib
TARGET = QtLocation
QT = core gui network sql
-include(../../common.pri)
+#include(../../common.pri)
+MODULE_PRI = ../../modules/qt_location.pri
DEFINES += QT_BUILD_LOCATION_LIB QT_MAKEDLL
diff --git a/src/plugins/geoservices/geoservices.pro b/src/plugins/geoservices/geoservices.pro
new file mode 100644
index 00000000..85243cc6
--- /dev/null
+++ b/src/plugins/geoservices/geoservices.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+SUBDIRS = nokia
diff --git a/src/plugins/geoservices/nokia/OVI_SERVICES_TERMS_AND_CONDITIONS.txt b/src/plugins/geoservices/nokia/OVI_SERVICES_TERMS_AND_CONDITIONS.txt
new file mode 100644
index 00000000..14cf2b35
--- /dev/null
+++ b/src/plugins/geoservices/nokia/OVI_SERVICES_TERMS_AND_CONDITIONS.txt
@@ -0,0 +1,202 @@
+THE OVI MAPS API SERVICE IS GOVERNED BY THE TERMS SET FORTH BELOW. PLEASE NOTE THAT THERE ARE TERMS AND CONDITIONS FOLLOWING THE NOKIA CORPORATION DEVELOPER SOFTWARE AGREEMENT V. 1.0 THAT ARE SPECIFIC TO THE USE OF THE OVI MAPS API SERVICE. IF YOU DO NOT ACCEPT THE BELOW TERMS AND CONDITIONS, YOU MAY NOT USE THE OVI MAPS API SERVICE.
+
+
+NOKIA CORPORATION DEVELOPER SOFTWARE AGREEMENT
+Version 1.0
+
+This Nokia Corporation Developer Software Agreement ("Agreement") is between You (either an individual or an entity), the developer, and Nokia Corporation ("Nokia"). The Agreement authorizes You to use the Software specified in Clause 1 below, which may be stored on a CD-ROM, sent to You by electronic mail, or downloaded from Nokia's web pages or servers or from other sources under the terms and conditions set forth below.
+
+This is an agreement on end-user rights and not an agreement for sale. Nokia continues to own the copy of the Software and the physical media contained in the sales package and any other copy that You are authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before accessing, downloading, installing or using the Software or any part of it. By accessing, downloading, installing or using the Software, You agree to the terms and conditions of this Agreement. If You do not agree to all of the terms and conditions of this Agreement, promptly cancel the installation or downloading, or destroy or return the Software and accompanying documentation to Nokia.
+
+1. SOFTWARE
+
+As used in this Agreement, the term "Software" means, collectively: (i) the Nokia Qt SDK software product with the exception of Open Source Software (as defined below), (ii) all the contents of the disk(s), CD-ROM(s), electronic mail and its file attachments, or other media with which this Agreement is provided, including the object code form of the software delivered via a CD-ROM, electronic mail, or web page (iii) related explanatory written materials and any other possible documentation related thereto ("Documentation"); (v) fonts, and (vi) upgrades, modified versions, updates, additions, and copies of the Software (collectively "Updates"), if any, provided to You by Nokia under this Agreement.
+
+"Open Source Software" means any software, which is, as included in the Nokia Qt SDK, subject to a license terms and conditions currently listed at http://opensource.org/licenses/ or meeting the criteria listed at http://www.opensource.org/docs/definition.php or which is subject to any similar free or open source license terms. Open Source Software contained in the Nokia Qt SDK is licensed under the license terms accompanying such Open Source Software and not the terms of this Agreement.
+
+2. USE OF THE SOFTWARE
+
+The Software is made accessible to You for the sole purpose of developing and testing Applications by installing a reasonable number of copies of the Software on computers owned or controlled by You to be used by You or Your authorized users. "Application" means one or more software programs developed by or for You in compliance with the Documentation, including any bug fixes, updates, upgrades, modifications, enhancements, supplements to, revisions, new releases and new versions of such software programs.
+
+You acknowledge that the use of the Software may require licenses to third party patents and that Nokia does not grant any licenses to such third party patents under this Agreement to the You. Also, any and all standards related licenses with respect to Essential Patents (as defined below) are specifically excluded from the scope of this Agreement, and those licenses need to be acquired separately from Nokia or the respective right holders, as the case may be. "Essential Patent" means any patent claiming a feature necessarily and unavoidably required for compliance with industry standards (usually GSM, WCDMA or other similar mobile communications standard), to the limited extent only that infringement or use of such claims of a patent cannot be avoided in remaining compliant with industry standard either for technological reasons or for lack of commercially viable technical alternatives.
+
+No patent licenses to any patents of Nokia and/ or its Affiliates are granted under this Agreement.
+
+3. LIMITATIONS ON END USER RIGHTS
+
+You may not copy, distribute, or make derivative works of the Software except as follows:
+
+(a) You may not use, modify, translate, reproduce, or transfer the right to use the Software or copy the Software except as expressly provided in this Agreement.
+
+(b) You may not resell, sublicense, rent, lease, or lend the Software.
+
+(c) You may not reverse engineer, reverse compile, disassemble, or otherwise attempt to discover the source code of the Software (except to the extent that this restriction is expressly prohibited by law) or create derivative works based on the Software.
+
+(d) You agree that You shall only use the Software in a manner that complies with all applicable laws in the jurisdiction in which You use the Software, including, but not limited to, applicable restrictions concerning copyright and other intellectual property rights.
+
+4. INTELLECTUAL PROPERTY RIGHTS
+
+The Software and all rights, without limitation including title and intellectual property rights therein, are owned by Nokia and/or its licensors and affiliates and are protected by international treaty provisions and all other applicable national laws of the country in which it is being used. The structure, organization, and code of the Software are the valuable trade secrets and confidential information of Nokia and/or its licensors and affiliates. You must not copy the Software, except as set forth in clause 3 (Limitations On End-User Rights). Any copies which You are permitted to make pursuant to this Agreement must contain the same copyright and other proprietary notices that appear on the Software.
+
+5. FEEDBACK
+
+By submitting feedback ("Feedback") to Nokia related to the Software, including but not limited to information on bug fixes or error corrections, you acknowledge and agree that (1) Nokia may have similar development ideas to the Feedback; (2) your Feedback does not contain confidential or proprietary information related to your own activities or those of any third party; (3) Nokia is not under any obligation of confidentiality with respect to the Feedback; and (4) you are not entitled to any compensation of any kind from Nokia. You hereby grant Nokia a worldwide non-exclusive, assignable, fully paid, royalty-free, perpetual and irrevocable license to use, exploit, copy, publicly perform, display, distribute, further develop and modify for any purpose such Feedback, and to prepare derivative works thereof, or incorporate such Feedback into other works as well as sublicense products and services resulting from such works.
+
+6. SUPPORT AND MAINTENANCE
+
+Nokia has no obligation to furnish You with technical or other support unless separately agreed in writing between You and Nokia. In case of such support given by Nokia You understand and agree that the support has been given on "as is" and "as available" basis and Nokia will have no obligations or liabilities related to such support.
+
+Nokia, may, from time to time, make Updates available to You. You may use the previous version for ninety (90) days after You receive the Update in order to assist You in the transition to the Update. After such time You no longer have a right to use the previous version, except for the sole purpose of enabling You to install the Update. However, Nokia may provide You with Updates that are considered as important or critical by Nokia, and in such case You may not continue using the previous version of the Software and the use of the previous version of the Software may be prevented without installation of the Update.
+
+7. COMMENCEMENT & TERMINATION
+
+This Agreement is effective from the first date You install the Software. You may terminate this Agreement at any time by permanently deleting, destroying, and returning, at Your own costs, the Software, all backup copies, and all related materials provided by Nokia. Your end-user rights automatically and immediately terminate without notice from Nokia if You fail to comply with any provision of this Agreement. In such an event, You must immediately delete, destroy, or return at Your own cost, the Software, all backup copies, and all related material to Nokia.
+
+8. NO WARRANTIES
+
+YOU ACKNOWLEDGE THAT THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, AND TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW NEITHER NOKIA, ITS LICENSORS OR AFFILIATES, NOR THE COPYRIGHT HOLDERS MAKE ANY REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR THAT THE SOFTWARE WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS, OR OTHER RIGHTS. THERE IS NO WARRANTY BY NOKIA OR BY ANY OTHER PARTY THAT THE FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE. YOU ASSUME ALL RESPONSIBILITY AND RISK FOR THE SELECTION OF THE SOFTWARE TO ACHIEVE YOUR INTENDED RESULTS AND FOR THE INSTALLATION, USE, AND RESULTS OBTAINED FROM IT.
+
+9. NO OTHER OBLIGATIONS
+
+This Agreement creates no obligations on the part of Nokia other than as specifically set forth herein.
+
+10. LIMITATION OF LIABILITY
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL NOKIA, ITS EMPLOYEES OR LICENSORS OR AFFILIATES BE LIABLE FOR ANY LOST PROFITS, REVENUE, SALES, DATA, OR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, PROPERTY DAMAGE, PERSONAL INJURY, INTERRUPTION OF BUSINESS, LOSS OF BUSINESS INFORMATION, OR FOR ANY SPECIAL, DIRECT, INDIRECT, INCIDENTAL, ECONOMIC, COVER, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND WHETHER ARISING UNDER CONTRACT, TORT, NEGLIGENCE, OR OTHER THEORY OF LIABILITY ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF NOKIA OR ITS LICENSORS OR AFFILIATES ARE ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME COUNTRIES/STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF LIABILITY, BUT MAY ALLOW LIABILITY TO BE LIMITED, IN SUCH CASES, NOKIA, ITS EMPLOYEES OR LICENSORS OR AFFILIATES' LIABILITY SHALL BE LIMITED TO U.S. $50. Nothing contained in this Agreement shall prejudice the statutory rights of any party dealing as a consumer. Nothing contained in this Agreement limits Nokia's liability to You in the event of death or personal injury resulting from Nokia's negligence. Nokia is acting on behalf of its employees and licensors or affiliates for the purpose of disclaiming, excluding, and/or restricting obligations, warranties, and liability as provided in this clause 9, but in no other respects and for no other purpose.
+
+11. INDEMNITY
+
+You shall defend, indemnify and hold Nokia and its licensors harmless against any claims, damages, liabilities, losses, costs, suits or expenditures incurred by Nokia, its Affiliates, or licensors as a result of any infringement or alleged infringement of intellectual property rights of a third party caused by Your development or exploitation of the Software.
+
+12. EXPORT CONTROL
+
+You acknowledge that the Software may be subject to export control restrictions of various countries. You shall fully comply with all applicable export license restrictions and requirements as well as with all laws and regulations relating to the importation of the Software and/or Applications and shall procure all necessary governmental authorizations, including without limitation, all necessary licenses, approvals, permissions or consents, where necessary for the re-exportation of the Software or Applications.
+
+
+13. GOVERNMENT END USERS
+
+A "U.S. Government End User" shall mean any agency or entity of the government of the United States. The following shall apply if You are a U.S. Government End User. The Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire the Software with only those rights set forth herein. The Software (including related documentation) is provided to U.S. Government End Users: (a) only as a commercial end item; and (b) only pursuant to this Agreement.
+
+
+14. NOTICES
+
+All notices and return of the Software and Documentation should be delivered to:
+
+NOKIA CORPORATION
+P.O. Box 100
+FIN-00045 NOKIA GROUP
+FINLAND
+
+15. APPLICABLE LAW AND GENERAL PROVISIONS
+
+This Agreement is governed by the laws of Finland. All disputes arising from or relating to this Agreement shall be settled by a single arbitrator appointed by the Central Chamber of Commerce of Finland. The arbitration procedure shall take place in Helsinki, Finland in the English language. If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms. This Agreement may only be modified by a writing signed by an authorized officer of Nokia, although Nokia may vary the terms of this Agreement.
+
+This is the entire agreement between Nokia and You relating to the Software, and it supersedes any prior representations, discussions, undertakings, end-user agreements, communications, or advertising relating to the Software.
+
+There are no implied licenses or other implied rights granted under this Agreement, and all rights, save for those expressly granted hereunder, shall remain with Nokia and its licensors. In addition, no licenses or immunities are granted to the combination of the Software with any other software or hardware not delivered by Nokia under this Agreement.
+
+
+OVI MAPS API ADDITIONAL TERMS
+
+In addition to the terms set forth above, the Nokia Privacy Policy and following additional terms shall apply to Your use of the Ovi Maps and related services ("Service"):
+
+
+1. DEFINITIONS
+
+"Ovi Maps Content" means the maps content available from Nokia from time to time for the purpose of being rendered on the Ovi Maps, including data provided by Nokia that originates from third parties.
+
+"Ovi Maps API Service" means the service offered by Nokia that enables You to incorporate the Ovi Maps For Developers and the Ovi Maps Content, as made available by Nokia from time to time, into Your Applications and to have end-users access and use it on such Applications
+
+"Ovi Maps For Developers" means the software, as made available by Nokia from time to time that allows the rendering of Ovi Maps Content within Applications. For clarity, the Ovi Maps For Developers may include software components that are downloaded and installed on the users' mobile device(s) and/or JavaScript libraries that are invoked and downloaded by the Ovi Maps API.
+
+"Ovi Maps API Developer Package" means the Ovi Maps API, documentation and any and all other material made accessible to You by Nokia from time to time that enables You to incorporate the Ovi Maps For Developers into Your Applications and is designated by Nokia as being a part of the Ovi Maps API Developer Package.
+
+"Ovi Maps API(s)" means the interface information made accessible to You by Nokia from time to time that enables You to incorporate the Ovi Maps For Developers into Your Applications.
+
+2. REGISTRATION AND TERMINATION
+
+If registration is required, You agree to provide truthful and complete information when registering for the Service and to keep that information updated. Providing misleading information about Your identity is forbidden. Depending on the use of the Ovi Maps API(s), You may receive an identifier code or developer key in order to use the Service. You are personally responsible for any use of the Ovi Maps API Service. You agree to take due care in protecting Your Application using Ovi Maps API, Your identifier code and/or developer key against misuse by others and promptly notify Nokia about any misuse. Where requested by Nokia, You agree to include and use the identifier code and/or developer key, as applicable, in each request You make to access to the Ovi Maps API(s).
+
+You may terminate Your registration if You no longer wish to use the Service. After termination, You may not access the Service. Nokia may terminate Your registration or restrict Your access to certain parts of the Service if there is an indication that You have breached these terms or with a prior notice if You have not signed into the Service with Your identifier code in the past three (3) months.
+
+3. SERVICE CHANGES
+
+Nokia may, in its sole discretion, change, improve and correct the Service from time to time. Nokia may also provide with updates to the Service that are considered as important or critical by Nokia, and in such case You may not continue using the previous version of the Service and the use of the previous version of the Service may be prevented without installation of the update. The Service may not be available during maintenance breaks and other times. Nokia may also decide to discontinue the Service or any part thereof in its sole discretion. In such case You will be provided a prior notification and Nokia may terminate the Agreement accordingly.
+
+Except as set forth in Privacy Policy, Nokia shall not be responsible for any removal or loss of the information or content You have submitted ("Material") to the Service when Your registration is terminated. After the Material is removed from the Service by either You or Nokia, traces and copies of the Material may still remain.
+
+
+4. USE OF OVI MAPS API DEVELOPER PACKAGE
+
+The Ovi Maps API Developer Package is made accessible to You for the purposes of incorporating the Ovi Maps Service into Your Application and for the limited purposes of evaluating, testing, and controlling the Ovi Maps For Developers during the term of this Agreement.
+
+When using the Ovi Maps API Developer Package and/or the Ovi Maps Service, You hereby agree that You will not:
+
+(i) use or incorporate the Ovi Maps Service, Ovi Maps API Developer Package or any part thereof, in connection with any Application or other service (a) which has the primary functionality of providing turn-by-turn navigation services, real time navigation or route guidance; or (b) where such Application's functionality is substantially similar to the Ovi Maps or navigation/location-based products distributed by Nokia or its affiliates; or (c) which has the primary purpose of capturing or collecting end user data;
+
+(ii) use, without Nokia's prior written permission, the Ovi Maps Service or Ovi Maps For Developers, or any part thereof, in connection with any internal business Application the purpose of which is directly related to the operation of Your core business and where the users of such Application are Your employees or contractors (e.g. fleet or asset management and tracking);
+
+(iii)remove or obscure any copyright or trademark notices or other similar notices or markings or legends or branding requirements from the Ovi Maps API Developer Package, Ovi Maps For Developers or the Ovi Maps Content whether such notices, markings or legends or other branding requirements originate from Nokia or a third party;
+
+(iv) alter the order of search, geo-coding and/or reverse geo-coding results delivered by or through any Ovi Maps API to or as part of the Application (where applicable);
+
+(v) alter, delete or otherwise change any Ovi Maps Content, including third party content contained in the Ovi Maps Content, that is displayed through the use of the Ovi Maps Service or Ovi Maps For Developers;
+
+(vi) use the Ovi Maps API(s) or Ovi Maps Service to exceed any transaction volume limits (if any) set by Nokia for Applications, Ovi Maps APIs and/or Ovi Maps Services. The amount of the possible transaction volume limit is as set forth in the documentation included in the Ovi Maps API. Nokia may change the limit from time to time in its sole discretion, but will provide You with ninety (90) days' advance notice of a change in the volume limit. Any programmatic methods or other actions intended to circumvent the transaction volume limits shall be considered a material breach of this Agreement;
+
+(vii) access or use the Ovi Maps Service or any Ovi Maps Content through any technology or means other than those provided by the Ovi Maps Service or Ovi Maps API, or through other explicitly authorized means Nokia may designate;
+
+(viii) use the Ovi Maps Service, Ovi Maps API or Ovi Maps For Developers in a manner that gives You or any other person access to mass downloads or bulk fees of any Ovi Maps Content, including but not limited to numerical latitude or longitude coordinates;
+
+(ix) pre-fetch, cache, or store any Ovi Maps Content except that You may store limited amounts of Ovi Maps Content for the purpose of testing your Application, if You do so temporarily, securely, and in a manner that does not permit use of the Ovi Maps Content outside of the Ovi Maps Service; or
+
+(x) use the Ovi Maps API Developer Package, including the Ovi Maps For Developers, or the Ovi Maps Service in any manner or for any purpose that violates this Agreement or any law or regulation, including without limitation, any intellectual property or other proprietary rights, any right of any person, rights of privacy, or rights of personality.
+
+You also agree (i) to comply with these terms, applicable laws and good manners; (ii) not to distribute or post spam, unreasonably large files, chain letters, pyramid schemes, viruses or any other technologies that may harm the Ovi Maps Service, or the interest or property of the Ovi Maps Service users; (iii) not to use the Service in connection with any unlawful, offensive, abusive, pornographic, harassing, libelous or otherwise inappropriate Material and comply with Nokia Content Guidelines as may be provided by Nokia from time to time; and (iv) to respect the privacy of others. You agree to comply with Nokia Technical Guidelines and other guidelines as Nokia may provide from time to time.
+
+5. OVI MAPS CONTENT AND PUBLICATION
+
+Ovi Maps Content is provided to You and Your end users for planning purposes only and Nokia does not guarantee the accuracy or availability of any Ovi Maps Content. You may find that weather conditions, construction projects, closures or other events may cause road conditions, directions, positioning coordinates or other location information to differ from the results depicted in the Ovi Maps Content. All use of Ovi Maps Content is at Your own risk.
+
+6. PRIVACY AND OVI STORE PUBLICATION
+
+You agree that Your use of the Ovi Maps Services and Ovi Maps API will comply with the Nokia Privacy Policy (http://www.nokia.com/privacy-policy).
+
+If your Application enables You or any party to gain access to information about users, including but not limited to personally identifiable information, non-personally identifiable usage information or location information ("Information"), You must provide users with notice about what Information is accessible and how such Information will be used or disclosed so that users may make informed decisions about whether or not to use Your Application. Furthermore, you must make Your privacy policy regarding the use of Information publicly available.
+
+If You intend to publish your Application on Nokia's Ovi Store, please note that Your Application must comply with the Ovi Store Publication Requirements (https://publish.ovi.com/info/).
+
+7. FEES
+
+Your use of the Ovi Maps Service may be or may become subject to charges. Nokia reserves the right to charge for the Ovi Maps Service and to change its fees from time to time, at its discretion, but Nokia will provide You with ninety (90) days' advance notice if charges will be implemented for use of the Ovi Maps Service.
+
+8. AVAILABILITY
+
+The Ovi Maps Service may not be available in all countries and may be provided only in selected languages. The Ovi Maps Service may be network dependent, contact Your network service provider for more information.
+
+9. YOUR SERVICES
+
+You may interact with users, including consumers, on or through the Ovi Maps Service. You agree that any such interactions by You do not involve Nokia and are solely between You and the other user(s).
+
+10. LINKS TO THIRD PARTY SITES, CONTENT AND ADVERTISING
+
+Nokia may include links to sites on the Internet that are owned or operated by third parties and that are not part of the Ovi Maps Service. Upon following a link to such a third-party site, You shall review and agree to that site's rules of use before using such site.
+
+You agree that Nokia has no control over the content of third-party sites and cannot assume any responsibility for services provided or material created or published by such sites. A link to a third-party site does not imply that Nokia endorses the site or the products or services referenced in the site.
+
+In addition, users may create links within the Ovi Maps Service to content that has not otherwise been submitted to the Ovi Maps Service. You agree that Nokia is neither responsible nor liable for any such links. Moreover, Ovi Maps Content made available to You by Nokia, may include content and data that originates from third parties.
+
+Nokia reserves the right, in its sole discretion, to implement advertising in the Ovi Maps For Developers. If Nokia implements advertising, You agree not to remove or otherwise alter or tamper with such advertising. Nokia will provide You with ninety (90) days' advance written notice prior to implementing advertising in the Ovi Maps For Developers.
+
+11. REPORTING
+
+You agree to implement those reporting mechanisms specified by Nokia (if any). For example, if specified by Nokia, You agree to provide Nokia with reports if your Application which utilizes the Ovi Maps API detects its own location through the use of a sensor (including, but not limited to GPS, cell triangulation, WiFi or similar functionality) to display the location of the device on a map or to calculate a route.
+
+12. ADDITIONAL EXPORT CONTROL RESTRICTIONS
+
+The Ovi Maps Service and Ovi Maps API Developer Package, including technical data, includes cryptographic software subject to export controls under the U.S. Export Administration Regulations ("EAR") and may be subject to import or export controls in other countries. The EAR prohibits the use of the Ovi Maps Service and the Ovi Maps API Developer Package and technical data by a Government End User, as defined hereafter, without a license from the U.S. government. A Government End User is defined in Part 772 of the EAR as "any foreign central, regional, or local government department, agency, or other entity performing governmental functions; including governmental research institutions, governmental corporations, or their separate business units (as defined in part 772 of the EAR) which are engaged in the manufacture or distribution of items or services controlled on the Wassenaar Munitions List, and international governmental organizations. This term does not include: utilities, telecommunications companies and Internet service providers; banks and financial institutions; transportation; broadcast or entertainment; educational organizations; civil health and medical organizations; retail or wholesale firms; and manufacturing or industrial entities not engaged in the manufacture or distribution of items or services controlled on the Wassenaar Munitions List. You agree to strictly comply with all applicable import and export regulations and acknowledge that You have the responsibility to obtain licenses to export, re-export, transfer, or import the Ovi Maps Service and the Ovi Maps API Developer Package. You further represent that You are not a Government End User as defined above, and You will not transfer the Ovi Maps Service and the Ovi Maps API Developer Package to any Government End User without a license.
+
+
+Copyright (c) 2010 Nokia Corporation.
diff --git a/src/plugins/geoservices/nokia/jsonparser.h b/src/plugins/geoservices/nokia/jsonparser.h
new file mode 100644
index 00000000..49fdff0e
--- /dev/null
+++ b/src/plugins/geoservices/nokia/jsonparser.h
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef JSONPARSER_H
+#define JSONPARSER_H
+
+#include <QVariant>
+#include <QString>
+#include <QRegExp>
+
+class JSONParser
+{
+public:
+ QString data;
+ int pos;
+
+
+ JSONParser(QString data) : data(data), pos(0) {}
+
+ bool detectString(const QString & string) {
+ skipWhitespace();
+ return data.mid(pos, string.size()) == string;
+ }
+
+ void skipWhitespace() {
+ while (pos < data.size() && data[pos].isSpace())
+ ++pos;
+ }
+
+ char peek() const {
+ if (pos < data.size())
+ return data[pos].toLatin1();
+ else
+ return -1;
+ }
+
+ QChar peekQ() const {
+ if (pos < data.size())
+ return data[pos];
+ else
+ return QChar(short(-1));
+ }
+
+ bool next() {
+ if (pos < data.size()-1) {
+ ++pos;
+ return true;
+ }
+ return false;
+ }
+
+ QVariant parse() {
+ QVariant ret;
+
+ skipWhitespace();
+ switch (peek()) {
+ case '{':
+ ret = parseHash();
+ break;
+ case '[':
+ ret = parseList();
+ break;
+ case '"':
+ ret = parseString();
+ break;
+ case 't':
+ case 'f':
+ ret = parseBoolean();
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '.':
+ ret = parseNumber();
+ break;
+ case -1:
+ // we went off the end of the string
+ // return an invalid QVariant
+ break;
+ default:
+ ret = parseUnknown();
+ break;
+ }
+
+ return ret;
+ }
+
+ QVariantHash parseHash() {
+ bool hascomma = true;
+ QVariantHash ret;
+
+ Q_ASSERT(peek() == '{');
+ next();
+ do {
+ skipWhitespace();
+
+ QString key = parseString();
+ skipWhitespace();
+ Q_ASSERT(peek() == ':');
+ next();
+ QVariant value = parse();
+
+ ret[key] = value;
+
+ skipWhitespace();
+ if (peek() == ',') {
+ next();
+ }
+ else {
+ hascomma = false;
+ }
+ } while (hascomma);
+ skipWhitespace();
+ //Q_ASSERT(peek() == '}');
+ next();
+
+ return ret;
+ }
+
+ QVariantList parseList() {
+ bool hascomma = true;
+ QVariantList ret;
+
+ Q_ASSERT(peek() == '[');
+ next();
+ do {
+ skipWhitespace();
+ QVariant value = parse();
+
+ ret << value;
+
+ skipWhitespace();
+ if (peek() == ',') {
+ next();
+ }
+ else {
+ hascomma = false;
+ }
+ } while (hascomma);
+ skipWhitespace();
+ //Q_ASSERT(peek() == ']');
+ next();
+
+ return ret;
+ }
+
+ QString parseString() {
+ QString ret;
+
+ Q_ASSERT(peek() == '"');
+ while (true) {
+ if (!next()) return ret;
+ char c = peek();
+ switch (c) {
+ case '"':
+ next();
+ return ret;
+ case '\\':
+ next();
+ // fall-through
+ default:
+ ret += peekQ();
+ }
+ }
+ }
+
+ QVariant parseBoolean() {
+ bool retbool = detectString("true");
+ pos += retbool ? 4 : 5;
+ return retbool;
+ }
+
+ QVariant parseNumber() {
+ QRegExp r("[^-0-9.e+]");
+
+ int newPos = r.indexIn(data, pos, QRegExp::CaretAtOffset);
+ QVariant ret(data.mid(pos, newPos-pos).toDouble());
+ pos = newPos;
+ return ret;
+ }
+
+ QVariant parseUnknown() {
+ QVariant ret(QString("unknown(")+peekQ()+"|"+QString::number((int)peekQ().unicode())+")");
+ next();
+ return ret;
+ }
+};
+
+#endif // JSONPARSER_H
diff --git a/src/plugins/geoservices/nokia/marclanguagecodes.h b/src/plugins/geoservices/nokia/marclanguagecodes.h
new file mode 100644
index 00000000..766a0e19
--- /dev/null
+++ b/src/plugins/geoservices/nokia/marclanguagecodes.h
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef MARCLANGUAGECODES_H_
+#define MARCLANGUAGECODES_H_
+
+// MARC language codes for GeoCoding service language/locale support
+// http://www.loc.gov/marc/languages/language_code.html
+// Order matches QLocale::Language
+
+static const unsigned char marc_language_code_list[] =
+ "\0\0\0" // Unused
+ "\0\0\0" // C
+ "abk" // Abkhazian
+ "\0\0\0" // Afan
+ "aar" // Afar
+ "afr" // Afrikaans
+ "alb" // Albanian
+ "amh" // Amharic
+ "ara" // Arabic
+ "arm" // Armenian
+ "asm" // Assamese
+ "aym" // Aymara
+ "aze" // Azerbaijani
+ "bak" // Bashkir
+ "baq" // Basque
+ "ben" // Bengali
+ "\0\0\0" // Bhutani
+ "bih" // Bihari
+ "bis" // Bislama
+ "bre" // Breton
+ "bul" // Bulgarian
+ "bur" // Burmese
+ "bel" // Byelorussian
+ "khm" // Cambodian
+ "cat" // Catalan
+ "chi" // Chinese
+ "cos" // Corsican
+ "hrv" // Croatian
+ "cze" // Czech
+ "dan" // Danish
+ "dut" // Dutch
+ "eng" // English
+ "epo" // Esperanto
+ "est" // Estonian
+ "fao" // Faroese
+ "fij" // FijiLanguage
+ "fin" // Finnish
+ "fre" // French
+ "fry" // Frisian
+ "gla" // Gaelic
+ "glg" // Galician
+ "geo" // Georgian
+ "ger" // German
+ "gre" // Greek
+ "\0\0\0" // Greenlandic
+ "grn" // Guarani
+ "guj" // Gujarati
+ "hau" // Hausa
+ "heb" // Hebrew
+ "hin" // Hindi
+ "hun" // Hungarian
+ "ice" // Icelandic
+ "ind" // Indonesian
+ "ina" // Interlingua
+ "ile" // Interlingue
+ "iku" // Inuktitut
+ "ipk" // Inupiak
+ "gle" // Irish
+ "ita" // Italian
+ "jpn" // Japanese
+ "jav" // Javanese
+ "kan" // Kannada
+ "kas" // Kashmiri
+ "kaz" // Kazakh
+ "kin" // Kinyarwanda
+ "kir" // Kirghiz
+ "kor" // Korean
+ "kur" // Kurdish
+ "\0\0\0" // Kurundi
+ "lao" // Laothian
+ "lat" // Latin
+ "lav" // Latvian
+ "lin" // Lingala
+ "lit" // Lithuanian
+ "mac" // Macedonian
+ "mlg" // Malagasy
+ "may" // Malay
+ "mal" // Malayalam
+ "mlt" // Maltese
+ "mao" // Maori
+ "mar" // Marathi
+ "mol" // Moldavian
+ "mon" // Mongolian
+ "nau" // NauruLanguage
+ "nep" // Nepali
+ "nor" // Norwegian
+ "oci" // Occitan
+ "ori" // Oriya
+ "\0\0\0" // Pashto
+ "per" // Persian
+ "pol" // Polish
+ "por" // Portuguese
+ "pan" // Punjabi
+ "que" // Quechua
+ "roh" // RhaetoRomance
+ "rum" // Romanian
+ "rus" // Russian
+ "smo" // Samoan
+ "sag" // Sangho
+ "san" // Sanskrit
+ "srp" // Serbian
+ "\0\0\0" // SerboCroatian
+ "\0\0\0" // Sesotho
+ "\0\0\0" // Setswana
+ "sna" // Shona
+ "snd" // Sindhi
+ "\0\0\0" // Singhalese
+ "\0\0\0" // Siswati
+ "slo" // Slovak
+ "slv" // Slovenian
+ "som" // Somali
+ "spa" // Spanish
+ "sun" // Sundanese
+ "swa" // Swahili
+ "swe" // Swedish
+ "tgl" // Tagalog
+ "tgk" // Tajik
+ "tam" // Tamil
+ "tat" // Tatar
+ "tel" // Telugu
+ "tha" // Thai
+ "tib" // Tibetan
+ "tir" // Tigrinya
+ "tog" // TongaLanguage
+ "tso" // Tsonga
+ "tur" // Turkish
+ "tuk" // Turkmen
+ "twi" // Twi
+ "uig" // Uigur
+ "ukr" // Ukrainian
+ "urd" // Urdu
+ "uzb" // Uzbek
+ "vie" // Vietnamese
+ "vol" // Volapuk
+ "wel" // Welsh
+ "wol" // Wolof
+ "xho" // Xhosa
+ "yid" // Yiddish
+ "yor" // Yoruba
+ "zha" // Zhuang
+ "zul" // Zulu
+ "nno" // NorwegianNynorsk
+ "bos" // Bosnian
+ "div" // Divehi
+ "glv" // Manx
+ "cor" // Cornish
+ "aka" // Akan
+ "kok" // Konkani
+ "gaa" // Ga
+ "ibo" // Igbo
+ "kam" // Kamba
+ "syc" // Syriac
+ "\0\0\0" // Blin
+ "\0\0\0" // Geez
+ "\0\0\0" // Koro
+ "sid" // Sidamo
+ "\0\0\0" // Atsam
+ "tig" // Tigre
+ "\0\0\0" // Jju
+ "fur" // Friulian
+ "ven" // Venda
+ "ewe" // Ewe
+ "\0\0\0" // Walamo
+ "haw" // Hawaiian
+ "\0\0\0" // Tyap
+ "\0\0\0" // Chewa
+ "fil" // Filipino
+ "gsw" // SwissGerman
+ "iii" // SichuanYi
+ "kpe" // Kpelle
+ "nds" // LowGerman
+ "nbl" // SouthNdebele
+ "nso" // NorthernSotho
+ "sme" // NorthernSami
+ "\0\0\0" // Taroko
+ "\0\0\0" // Gusii
+ "\0\0\0" // Taita
+ "ful" // Fulah
+ "kik" // Kikuyu
+ "\0\0\0" // Samburu
+ "\0\0\0" // Sena
+ "nde" // NorthNdebele
+ "\0\0\0" // Rombo
+ "\0\0\0" // Tachelhit
+ "kab" // Kabyle
+ "nyn" // Nyankole
+ "\0\0\0" // Bena
+ "\0\0\0" // Vunjo
+ "bam" // Bambara
+ "\0\0\0" // Embu
+ "chr" // Cherokee
+ "\0\0\0" // Morisyen
+ "\0\0\0" // Makonde
+ "\0\0\0" // Langi
+ "lug" // Ganda
+ "bem" // Bemba
+ "\0\0\0" // Kabuverdianu
+ "\0\0\0" // Meru
+ "\0\0\0" // Kalenjin
+ "\0\0\0" // Nama
+ "\0\0\0" // Machame
+ "\0\0\0" // Colognian
+ "mas" // Masai
+ "\0\0\0" // Soga
+ "\0\0\0" // Luyia
+ "\0\0\0" // Asu
+ "\0\0\0" // Teso
+ "\0\0\0" // Saho
+ "\0\0\0" // KoyraChiini
+ "\0\0\0" // Rwa
+ "luo" // Luo
+ "\0\0\0" // Chiga
+ "\0\0\0" // CentralMoroccoTamazight
+ "\0\0\0" // KoyraboroSenni
+ "\0\0\0" // Shambala
+ ;
+
+
+#endif /* MARCLANGUAGECODES_H_ */
diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro
new file mode 100644
index 00000000..a3cffdf2
--- /dev/null
+++ b/src/plugins/geoservices/nokia/nokia.pro
@@ -0,0 +1,54 @@
+TARGET = qtgeoservices_nokia
+QT += location network
+
+include($$QT_SOURCE_TREE/src/plugins/qpluginbase.pri)
+
+DESTDIR = $$QT.location.plugins/geoservices
+#QTDIR_build:REQUIRES += "contains(QT_CONFIG, location)"
+
+HEADERS += \
+ qgeocodexmlparser.h \
+ qgeomappingmanagerengine_nokia.h \
+ qgeomapreply_nokia.h \
+ qgeoroutereply_nokia.h \
+ qgeoroutexmlparser.h \
+ qgeoroutingmanagerengine_nokia.h \
+ qgeosearchmanagerengine_nokia.h \
+ qgeosearchreply_nokia.h \
+ qgeoserviceproviderplugin_nokia.h \
+ marclanguagecodes.h \
+ qgeotiledmapdata_nokia.h
+
+SOURCES += \
+ qgeocodexmlparser.cpp \
+ qgeomappingmanagerengine_nokia.cpp \
+ qgeomapreply_nokia.cpp \
+ qgeoroutereply_nokia.cpp \
+ qgeoroutexmlparser.cpp \
+ qgeoroutingmanagerengine_nokia.cpp \
+ qgeosearchmanagerengine_nokia.cpp \
+ qgeosearchreply_nokia.cpp \
+ qgeoserviceproviderplugin_nokia.cpp \
+ qgeotiledmapdata_nokia.cpp
+
+RESOURCES += resource.qrc
+
+INCLUDEPATH += $$QT.location.includes
+
+#INCLUDEPATH += $$SOURCE_DIR/src/location \
+# $$SOURCE_DIR/src/location/maps \
+# $$SOURCE_DIR/src/location/maps/tiled
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0x2002BFCA
+ pluginDep.sources = $${TARGET}.dll
+ pluginDep.path = $${QT_PLUGINS_BASE_DIR}/$${PLUGIN_TYPE}
+ DEPLOYMENT += pluginDep
+ LIBS += -lefsrv
+}
+
+target.path += $$[QT_INSTALL_PLUGINS]/geoservices
+INSTALLS += target
+
diff --git a/src/plugins/geoservices/nokia/qgeocodexmlparser.cpp b/src/plugins/geoservices/nokia/qgeocodexmlparser.cpp
new file mode 100644
index 00000000..3e86b06e
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeocodexmlparser.cpp
@@ -0,0 +1,576 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeocodexmlparser.h"
+
+#include <QXmlStreamReader>
+#include <QIODevice>
+
+QGeoCodeXmlParser::QGeoCodeXmlParser()
+ : m_reader(0)
+{
+}
+
+QGeoCodeXmlParser::~QGeoCodeXmlParser()
+{
+ if (m_reader)
+ delete m_reader;
+}
+
+bool QGeoCodeXmlParser::parse(QIODevice* source)
+{
+ if (m_reader)
+ delete m_reader;
+ m_reader = new QXmlStreamReader(source);
+
+ if (!parseRootElement()) {
+ m_errorString = m_reader->errorString();
+ return false;
+ }
+
+ m_errorString = "";
+
+ return true;
+}
+
+QList<QGeoPlace> QGeoCodeXmlParser::results() const
+{
+ return m_results;
+}
+
+QString QGeoCodeXmlParser::errorString() const
+{
+ return m_errorString;
+}
+
+bool QGeoCodeXmlParser::parseRootElement()
+{
+ /*
+ <xsd:element name="places">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="place" type="gc:Place"/>
+ </xsd:sequence>
+ <xsd:attribute name="resultCode" type="gc:ResultCodes"/>
+ <xsd:attribute name="resultDescription" type="xsd:string"/>
+ <xsd:attribute name="resultsTotal" type="xsd:nonNegativeInteger"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="ResultCodes">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="OK"/>
+ <xsd:enumeration value="FAILED"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ */
+
+ if (m_reader->readNextStartElement()) {
+ if (m_reader->name() == "places") {
+ if (m_reader->attributes().hasAttribute("resultCode")) {
+ QStringRef result = m_reader->attributes().value("resultCode");
+ if (result == "FAILED") {
+ QString resultDesc = m_reader->attributes().value("resultDescription").toString();
+ if (resultDesc.isEmpty())
+ resultDesc = "The attribute \"resultCode\" of the element \"places\" indicates that the request failed.";
+
+ m_reader->raiseError(resultDesc);
+
+ return false;
+ } else if (result != "OK") {
+ m_reader->raiseError(QString("The attribute \"resultCode\" of the element \"places\" has an unknown value (value was %1).").arg(result.toString()));
+ return false;
+ }
+ }
+
+ while (m_reader->readNextStartElement()) {
+ if (m_reader->name() == "place") {
+ QGeoPlace place;
+
+ if (!parsePlace(&place))
+ return false;
+
+ m_results.append(place);
+ } else {
+ m_reader->raiseError(QString("The element \"places\" did not expect a child element named \"%1\".").arg(m_reader->name().toString()));
+ return false;
+ }
+ }
+ } else {
+ m_reader->raiseError(QString("The root element is expected to have the name \"places\" (root element was named \"%1\").").arg(m_reader->name().toString()));
+ return false;
+ }
+ } else {
+ m_reader->raiseError("Expected a root element named \"places\" (no root element found).");
+ return false;
+ }
+
+ if (m_reader->readNextStartElement()) {
+ m_reader->raiseError(QString("A single root element named \"places\" was expected (second root element was named \"%1\")").arg(m_reader->name().toString()));
+ return false;
+ }
+
+ return true;
+}
+
+bool QGeoCodeXmlParser::parsePlace(QGeoPlace *place)
+{
+ /*
+ <xsd:complexType name="Place">
+ <xsd:all>
+ <xsd:element name="location" type="gc:Location"/>
+ <xsd:element minOccurs="0" name="address" type="gc:Address"/>
+ <xsd:element minOccurs="0" name="alternatives" type="gc:Alternatives"/>
+ </xsd:all>
+ <xsd:attribute name="title" type="xsd:string" use="required"/>
+ <xsd:attribute name="language" type="gc:LanguageCode" use="required"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="LanguageCode">
+ <xsd:restriction base="xsd:string">
+ <xsd:length value="3"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ */
+
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "place");
+
+ if (!m_reader->attributes().hasAttribute("title")) {
+ m_reader->raiseError("The element \"place\" did not have the required attribute \"title\".");
+ return false;
+ }
+
+ if (!m_reader->attributes().hasAttribute("language")) {
+ //m_reader->raiseError("The element \"place\" did not have the required attribute \"language\".");
+ //return false;
+ } else {
+ QString lang = m_reader->attributes().value("language").toString();
+
+ if (lang.length() != 3) {
+ m_reader->raiseError(QString("The attribute \"language\" of the element \"place\" was not of length 3 (length was %1).").arg(lang.length()));
+ return false;
+ }
+ }
+
+ bool parsedLocation = false;
+ bool parsedAddress = false;
+ bool parsedAlternatives = false;
+
+ while (m_reader->readNextStartElement()) {
+ QString name = m_reader->name().toString();
+ if (name == "location") {
+ if (parsedLocation) {
+ m_reader->raiseError("The element \"place\" has multiple child elements named \"location\" (exactly one expected)");
+ return false;
+ }
+
+ if (!parseLocation(place))
+ return false;
+
+ parsedLocation = true;
+ } else if (name == "address") {
+ if (parsedAddress) {
+ m_reader->raiseError("The element \"place\" has multiple child elements named \"address\" (at most one expected)");
+ return false;
+ }
+
+ QGeoAddress address;
+ if (!parseAddress(&address))
+ return false;
+ else
+ place->setAddress(address);
+
+ place->setAddress(address);
+
+ parsedAddress = true;
+ } else if (name == "alternatives") {
+ if (parsedAlternatives) {
+ m_reader->raiseError("The element \"place\" has multiple child elements named \"alternatives\" (at most one expected)");
+ return false;
+ }
+
+ // skip alternatives for now
+ // need to work out if we have a use for them at all
+ // and how to store them if we get them
+ m_reader->skipCurrentElement();
+
+ parsedAlternatives = true;
+ } else {
+ m_reader->raiseError(QString("The element \"place\" did not expect a child element named \"%1\".").arg(m_reader->name().toString()));
+ return false;
+ }
+ }
+
+ if (!parsedLocation) {
+ m_reader->raiseError("The element \"place\" has no child elements named \"location\" (exactly one expected)");
+ return false;
+ }
+
+ return true;
+}
+
+bool QGeoCodeXmlParser::parseLocation(QGeoPlace *place)
+{
+ /*
+ <xsd:complexType name="Location">
+ <xsd:all>
+ <xsd:element name="position" type="gc:GeoCoord"/>
+ <xsd:element minOccurs="0" name="boundingBox" type="gc:GeoBox"/>
+ </xsd:all>
+ </xsd:complexType>
+
+ <xsd:complexType name="GeoBox">
+ <xsd:sequence>
+ <xsd:element name="northWest" type="gc:GeoCoord"/>
+ <xsd:element name="southEast" type="gc:GeoCoord"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ */
+
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "location");
+
+ bool parsedPosition = false;
+ bool parsedBounds = false;
+
+ while (m_reader->readNextStartElement()) {
+ QString name = m_reader->name().toString();
+ if (name == "position") {
+ if (parsedPosition) {
+ m_reader->raiseError("The element \"location\" has multiple child elements named \"position\" (exactly one expected)");
+ return false;
+ }
+
+ QGeoCoordinate coord;
+ if (!parseCoordinate(&coord, "position"))
+ return false;
+
+ place->setCoordinate(coord);
+
+ parsedPosition = true;
+ } else if (name == "boundingBox") {
+ if (parsedBounds) {
+ m_reader->raiseError("The element \"location\" has multiple child elements named \"boundingBox\" (at most one expected)");
+ return false;
+ }
+
+ QGeoBoundingBox bounds;
+
+ if (!parseBoundingBox(&bounds))
+ return false;
+
+ place->setViewport(bounds);
+
+ parsedBounds = true;
+ } else {
+ m_reader->raiseError(QString("The element \"location\" did not expect a child element named \"%1\".").arg(m_reader->name().toString()));
+ return false;
+ }
+ }
+
+ if (!parsedPosition) {
+ m_reader->raiseError("The element \"location\" has no child elements named \"position\" (exactly one expected)");
+ return false;
+ }
+
+ return true;
+}
+
+bool QGeoCodeXmlParser::parseAddress(QGeoAddress *address)
+{
+ /*
+ <xsd:complexType name="Address">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="country" type="xsd:string"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="countryCode" type="gc:CountryCode"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="state" type="xsd:string"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="county" type="xsd:string"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="city" type="xsd:string"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="district" type="xsd:string"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="thoroughfare" type="gc:Thoroughfare"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="postCode" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute name="type" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="CountryCode">
+ <xsd:restriction base="xsd:string">
+ <xsd:length value="3" fixed="true"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:complexType name="Thoroughfare">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="name" type="xsd:string"/>
+ <xsd:element minOccurs="0" name="number" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ */
+
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "address");
+
+ // currently ignoring the type of the address
+
+ if (!m_reader->readNextStartElement())
+ return true;
+
+ if (m_reader->name() == "country") {
+ address->setCountry(m_reader->readElementText());
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ if (m_reader->name() == "countryCode") {
+ address->setCountryCode(m_reader->readElementText());
+
+ if (address->countryCode().length() != 3) {
+ m_reader->raiseError(QString("The text of the element \"countryCode\" was not of length 3 (length was %1).").arg(address->countryCode().length()));
+ return false;
+ }
+
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ if (m_reader->name() == "state") {
+ address->setState(m_reader->readElementText());
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ if (m_reader->name() == "county") {
+ address->setCounty(m_reader->readElementText());
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ if (m_reader->name() == "city") {
+ address->setCity(m_reader->readElementText());
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ if (m_reader->name() == "district") {
+ address->setDistrict(m_reader->readElementText());
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ bool inThoroughfare = false;
+
+ if (m_reader->name() == "thoroughfare") {
+ inThoroughfare = m_reader->readNextStartElement();
+
+ if (inThoroughfare && (m_reader->name() == "name")) {
+ address->setStreet(m_reader->readElementText());
+ if (!m_reader->readNextStartElement())
+ inThoroughfare = false;
+ }
+
+ if (inThoroughfare && (m_reader->name() == "number")) {
+ address->setStreet(m_reader->readElementText() + " " + address->street());
+ if (!m_reader->readNextStartElement())
+ inThoroughfare = false;
+ }
+
+ if (inThoroughfare) {
+ m_reader->raiseError(QString("The element \"thoroughFare\" did not expect the child element \"%1\" at this point (unknown child element or child element out of order).").arg(m_reader->name().toString()));
+ return false;
+ }
+
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ if (m_reader->name() == "postCode") {
+ address->setPostcode(m_reader->readElementText());
+ if (!m_reader->readNextStartElement())
+ return true;
+ }
+
+ m_reader->raiseError(QString("The element \"address\" did not expect the child element \"%1\" at this point (unknown child element or child element out of order).").arg(m_reader->name().toString()));
+ return false;
+}
+
+bool QGeoCodeXmlParser::parseBoundingBox(QGeoBoundingBox *bounds)
+{
+ /*
+ <xsd:complexType name="GeoBox">
+ <xsd:sequence>
+ <xsd:element name="northWest" type="gc:GeoCoord"/>
+ <xsd:element name="southEast" type="gc:GeoCoord"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ */
+
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "boundingBox");
+
+ if (!m_reader->readNextStartElement()) {
+ m_reader->raiseError("The element \"boundingBox\" was expected to have 2 child elements (0 found)");
+ return false;
+ }
+
+ QGeoCoordinate nw;
+
+ if (m_reader->name() == "northWest") {
+ if (!parseCoordinate(&nw, "northWest"))
+ return false;
+ } else {
+ m_reader->raiseError(QString("The element \"boundingBox\" expected this child element to be named \"northWest\" (found an element named \"%1\")").arg(m_reader->name().toString()));
+ return false;
+ }
+
+ if (!m_reader->readNextStartElement()) {
+ m_reader->raiseError("The element \"boundingBox\" was expected to have 2 child elements (1 found)");
+ return false;
+ }
+
+ QGeoCoordinate se;
+
+ if (m_reader->name() == "southEast") {
+ if (!parseCoordinate(&se, "southEast"))
+ return false;
+ } else {
+ m_reader->raiseError(QString("The element \"boundingBox\" expected this child element to be named \"southEast\" (found an element named \"%1\")").arg(m_reader->name().toString()));
+ return false;
+ }
+
+ if (m_reader->readNextStartElement()) {
+ m_reader->raiseError("The element \"boundingBox\" was expected to have 2 child elements (more than 2 found)");
+ return false;
+ }
+
+ *bounds = QGeoBoundingBox(nw, se);
+
+ return true;
+}
+
+bool QGeoCodeXmlParser::parseCoordinate(QGeoCoordinate *coordinate, const QString &elementName)
+{
+ /*
+ <xsd:complexType name="GeoCoord">
+ <xsd:sequence>
+ <xsd:element name="latitude" type="gc:Latitude"/>
+ <xsd:element name="longitude" type="gc:Longitude"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:simpleType name="Latitude">
+ <xsd:restriction base="xsd:float">
+ <xsd:minInclusive value="-90.0"/>
+ <xsd:maxInclusive value="90.0"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="Longitude">
+ <xsd:restriction base="xsd:float">
+ <xsd:minInclusive value="-180.0"/>
+ <xsd:maxInclusive value="180.0"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ */
+
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == elementName);
+
+ if (!m_reader->readNextStartElement()) {
+ m_reader->raiseError(QString("The element \"%1\" was expected to have 2 child elements (0 found)").arg(elementName));
+ return false;
+ }
+
+ if (m_reader->name() == "latitude") {
+ bool ok = false;
+ QString s = m_reader->readElementText();
+ double lat = s.toDouble(&ok);
+
+ if (!ok) {
+ m_reader->raiseError(QString("The element \"latitude\" expected a value convertable to type float (value was \"%1\")").arg(s));
+ return false;
+ }
+
+ if (lat < -90.0 || 90.0 < lat) {
+ m_reader->raiseError(QString("The element \"latitude\" expected a value between -90.0 and 90.0 inclusive (value was %1)").arg(lat));
+ return false;
+ }
+
+ coordinate->setLatitude(lat);
+ } else {
+ m_reader->raiseError(QString("The element \"%1\" expected this child element to be named \"latitude\" (found an element named \"%2\")").arg(elementName).arg(m_reader->name().toString()));
+ }
+
+ if (!m_reader->readNextStartElement()) {
+ m_reader->raiseError(QString("The element \"%1\" was expected to have 2 child elements (1 found)").arg(elementName));
+ return false;
+ }
+
+ if (m_reader->name() == "longitude") {
+ bool ok = false;
+ QString s = m_reader->readElementText();
+ double lng = s.toDouble(&ok);
+
+ if (!ok) {
+ m_reader->raiseError(QString("The element \"longitude\" expected a value convertable to type float (value was \"%1\")").arg(s));
+ return false;
+ }
+
+ if (lng < -180.0 || 180.0 < lng) {
+ m_reader->raiseError(QString("The element \"longitude\" expected a value between -180.0 and 180.0 inclusive (value was %1)").arg(lng));
+ return false;
+ }
+
+ coordinate->setLongitude(lng);
+ } else {
+ m_reader->raiseError(QString("The element \"%1\" expected this child element to be named \"longitude\" (found an element named \"%2\")").arg(elementName).arg(m_reader->name().toString()));
+ }
+
+ if (m_reader->readNextStartElement()) {
+ m_reader->raiseError(QString("The element \"%1\" was expected to have 2 child elements (more than 2 found)").arg(elementName));
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/plugins/geoservices/nokia/qgeocodexmlparser.h b/src/plugins/geoservices/nokia/qgeocodexmlparser.h
new file mode 100644
index 00000000..16c72e27
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeocodexmlparser.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOCODEXMLPARSER_H
+#define QGEOCODEXMLPARSER_H
+
+#include <QString>
+#include <QList>
+#include <QXmlStreamReader>
+
+class QIODevice;
+
+#include <qgeocoordinate.h>
+#include <qgeoboundingbox.h>
+#include <qgeoplace.h>
+#include <qgeoaddress.h>
+
+QTM_USE_NAMESPACE
+
+class QGeoCodeXmlParser
+{
+public:
+ QGeoCodeXmlParser();
+ ~QGeoCodeXmlParser();
+
+ bool parse(QIODevice* source);
+
+ QList<QGeoPlace> results() const;
+ QString errorString() const;
+
+private:
+ bool parseRootElement();
+ bool parsePlace(QGeoPlace *place);
+ bool parseLocation(QGeoPlace *place);
+ bool parseAddress(QGeoAddress *address);
+ bool parseBoundingBox(QGeoBoundingBox *bounds);
+ bool parseCoordinate(QGeoCoordinate *coordinate, const QString &elementName);
+
+ QXmlStreamReader *m_reader;
+
+ QList<QGeoPlace> m_results;
+ QString m_errorString;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp
new file mode 100644
index 00000000..8c03e6c5
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp
@@ -0,0 +1,302 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeomappingmanagerengine_nokia.h"
+#include "qgeomapreply_nokia.h"
+#include "qgeotiledmapdata_nokia.h"
+
+#include <qgeotiledmaprequest.h>
+
+#include <QNetworkAccessManager>
+#include <QNetworkDiskCache>
+#include <QNetworkProxy>
+#include <QSize>
+#include <QDir>
+#include <QUrl>
+
+#define LARGE_TILE_DIMENSION 256
+
+#define DISK_CACHE_MAX_SIZE 50*1024*1024 //50MB
+
+#if defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+#undef DISK_CACHE_ENABLED
+#else
+#define DISK_CACHE_ENABLED 1
+#endif
+
+#if defined(Q_OS_SYMBIAN)
+#include <f32file.h>
+QChar QGeoMappingManagerEngineNokia::findFirstInternalFlashDrive()
+{
+ QChar flashDrive;
+ RFs fsSession;
+ // if something leaves just return an empty QChar
+ TRAP_IGNORE(
+ User::LeaveIfError(fsSession.Connect());
+ CleanupClosePushL(fsSession);
+ TDriveList drivelist;
+ User::LeaveIfError(fsSession.DriveList(drivelist));
+ for (int i = 0; i < KMaxDrives; ++i) {
+ if (drivelist[i] != 0) {
+ TChar driveChar;
+ User::LeaveIfError(RFs::DriveToChar(i, driveChar));
+ TDriveInfo driveInfo;
+ if (fsSession.Drive(driveInfo, i) != KErrNone)
+ continue;
+ if ((driveInfo.iDriveAtt & KDriveAttInternal) && driveInfo.iType == EMediaHardDisk) {
+ flashDrive = QChar(driveChar);
+ break;
+ }
+ }
+ }
+ CleanupStack::PopAndDestroy(&fsSession);
+ )
+ return flashDrive;
+}
+#endif //Q_OS_SYMBIAN
+
+QGeoMappingManagerEngineNokia::QGeoMappingManagerEngineNokia(const QMap<QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString)
+ : QGeoTiledMappingManagerEngine(parameters),
+ m_cache(0),
+ m_host("maptile.maps.svc.ovi.com"),
+ m_token(QGeoServiceProviderFactoryNokia::defaultToken),
+ m_referer(QGeoServiceProviderFactoryNokia::defaultReferer)
+{
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ setTileSize(QSize(256, 256));
+ setMinimumZoomLevel(0.0);
+ setMaximumZoomLevel(18.0);
+
+ QList<QGraphicsGeoMap::MapType> types;
+ types << QGraphicsGeoMap::StreetMap;
+ types << QGraphicsGeoMap::SatelliteMapDay;
+ types << QGraphicsGeoMap::TerrainMap;
+ setSupportedMapTypes(types);
+
+ QList<QGraphicsGeoMap::ConnectivityMode> modes;
+ modes << QGraphicsGeoMap::OnlineMode;
+ setSupportedConnectivityModes(modes);
+
+ m_networkManager = new QNetworkAccessManager(this);
+
+ if (parameters.contains("mapping.proxy")) {
+ QString proxy = parameters.value("mapping.proxy").toString();
+ if (!proxy.isEmpty()) {
+ QUrl proxyUrl(proxy);
+ if (proxyUrl.isValid()) {
+ m_networkManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,
+ proxyUrl.host(),
+ proxyUrl.port(8080),
+ proxyUrl.userName(),
+ proxyUrl.password()));
+ }
+ }
+ }
+
+ if (parameters.contains("mapping.host")) {
+ QString host = parameters.value("mapping.host").toString();
+ if (!host.isEmpty())
+ m_host = host;
+ }
+
+ if (parameters.contains("mapping.referer")) {
+ m_referer = parameters.value("mapping.referer").toString();
+ }
+
+ if (parameters.contains("mapping.token")) {
+ m_token = parameters.value("mapping.token").toString();
+ }
+ else if (parameters.contains("token")) {
+ m_token = parameters.value("token").toString();
+ }
+#ifdef DISK_CACHE_ENABLED
+ QString cacheDir;
+ if (parameters.contains("mapping.cache.directory"))
+ cacheDir = parameters.value("mapping.cache.directory").toString();
+
+ if (cacheDir.isEmpty()) {
+#if defined(Q_OS_SYMBIAN)
+ QChar driveLetter(findFirstInternalFlashDrive());
+ if (!driveLetter.isNull()) {
+ cacheDir = driveLetter;
+ cacheDir += ":/data/nokia/maptiles";
+ }
+#else
+ cacheDir = QDir::temp().path()+"/maptiles";
+#endif
+ }
+ if (!cacheDir.isEmpty()) {
+ m_cache = new QNetworkDiskCache(this);
+ QDir dir;
+ dir.mkpath(cacheDir);
+ dir.setPath(cacheDir);
+
+ m_cache->setCacheDirectory(dir.path());
+
+ if (parameters.contains("mapping.cache.size")) {
+ bool ok = false;
+ qint64 cacheSize = parameters.value("mapping.cache.size").toString().toLongLong(&ok);
+ if (ok)
+ m_cache->setMaximumCacheSize(cacheSize);
+ }
+
+ if (m_cache->maximumCacheSize() > DISK_CACHE_MAX_SIZE)
+ m_cache->setMaximumCacheSize(DISK_CACHE_MAX_SIZE);
+
+ m_networkManager->setCache(m_cache);
+ }
+#endif
+}
+
+QGeoMappingManagerEngineNokia::~QGeoMappingManagerEngineNokia() {}
+
+QGeoMapData* QGeoMappingManagerEngineNokia::createMapData()
+{
+ QGeoMapData *data = new QGeoTiledMapDataNokia(this);
+ if (!data)
+ return 0;
+
+ data->setConnectivityMode(QGraphicsGeoMap::OnlineMode);
+ return data;
+}
+
+QGeoTiledMapReply* QGeoMappingManagerEngineNokia::getTileImage(const QGeoTiledMapRequest &request)
+{
+ // TODO add error detection for if request.connectivityMode() != QGraphicsGeoMap::OnlineMode
+ QString rawRequest = getRequestString(request);
+
+ QNetworkRequest netRequest((QUrl(rawRequest))); // The extra pair of parens disambiguates this from a function declaration
+ netRequest.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+
+#ifdef DISK_CACHE_ENABLED
+ netRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+#endif
+
+ QNetworkReply* netReply = m_networkManager->get(netRequest);
+
+ QGeoTiledMapReply* mapReply = new QGeoMapReplyNokia(netReply, request);
+
+ // TODO goes badly on linux
+ //qDebug() << "request: " << QString::number(reinterpret_cast<int>(mapReply), 16) << " " << request.row() << "," << request.column();
+ // this one might work better. It follows defined behaviour, unlike reinterpret_cast
+ //qDebug("request: %p %i,%i @ %i", mapReply, request.row(), request.column(), request.zoomLevel());
+ return mapReply;
+}
+
+QString QGeoMappingManagerEngineNokia::getRequestString(const QGeoTiledMapRequest &request) const
+{
+ const int maxDomains = 11; // TODO: hmmm....
+ const char subdomain = 'a' + (request.row() + request.column()) % maxDomains; // a...k
+ static const QString http("http://");
+ static const QString path("/maptiler/maptile/newest/");
+ static const QChar dot('.');
+ static const QChar slash('/');
+
+ QString requestString = http;
+ requestString += subdomain;
+ requestString += dot;
+ requestString += m_host;
+ requestString += path;
+ requestString += mapTypeToStr(request.mapType());
+ requestString += slash;
+ requestString += QString::number(request.zoomLevel());
+ requestString += slash;
+ requestString += QString::number(request.column());
+ requestString += slash;
+ requestString += QString::number(request.row());
+ requestString += slash;
+ requestString += sizeToStr(tileSize());
+//#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ static const QString slashpng("/png8");
+//#else
+// static const QString slashpng("/png");
+//#endif
+ requestString += slashpng;
+
+ if (!m_token.isEmpty()) {
+ requestString += "?token=";
+ requestString += m_token;
+
+ if (!m_referer.isEmpty()) {
+ requestString += "&referer=";
+ requestString += m_referer;
+ }
+ } else if (!m_referer.isEmpty()) {
+ requestString += "?referer=";
+ requestString += m_referer;
+ }
+
+ return requestString;
+}
+
+QString QGeoMappingManagerEngineNokia::sizeToStr(const QSize &size)
+{
+ static const QString s256("256");
+ static const QString s128("128");
+ if (size.height() >= LARGE_TILE_DIMENSION ||
+ size.width() >= LARGE_TILE_DIMENSION)
+ return s256;
+ else
+ return s128;
+}
+
+QString QGeoMappingManagerEngineNokia::mapTypeToStr(QGraphicsGeoMap::MapType type)
+{
+ if (type == QGraphicsGeoMap::StreetMap)
+ return "normal.day";
+ else if (type == QGraphicsGeoMap::SatelliteMapDay ||
+ type == QGraphicsGeoMap::SatelliteMapNight) {
+ return "satellite.day";
+ } else if (type == QGraphicsGeoMap::TerrainMap)
+ return "terrain.day";
+ else
+ return "normal.day";
+}
+
diff --git a/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.h b/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.h
new file mode 100644
index 00000000..6854685c
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPINGMANAGERENGINE_NOKIA_H
+#define QGEOMAPPINGMANAGERENGINE_NOKIA_H
+
+#include "qgeoserviceproviderplugin_nokia.h"
+
+#include <qgeoserviceprovider.h>
+#include <qgeotiledmappingmanagerengine.h>
+
+class QNetworkAccessManager;
+class QNetworkDiskCache;
+
+QTM_USE_NAMESPACE
+
+class QGeoMappingManagerEngineNokia : public QGeoTiledMappingManagerEngine
+{
+ Q_OBJECT
+public:
+ QGeoMappingManagerEngineNokia(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString);
+ ~QGeoMappingManagerEngineNokia();
+
+ QGeoMapData* createMapData();
+ QGeoTiledMapReply* getTileImage(const QGeoTiledMapRequest &request);
+
+private:
+ Q_DISABLE_COPY(QGeoMappingManagerEngineNokia)
+
+ QString getRequestString(const QGeoTiledMapRequest &request) const;
+
+ static QString sizeToStr(const QSize &size);
+ static QString mapTypeToStr(QGraphicsGeoMap::MapType type);
+#if defined(Q_OS_SYMBIAN)
+ QChar findFirstInternalFlashDrive();
+#endif //Q_OS_SYMBIAN
+
+ QNetworkAccessManager *m_networkManager;
+ QNetworkDiskCache *m_cache;
+ QString m_host;
+ QString m_token;
+ QString m_referer;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
new file mode 100644
index 00000000..8c9014f4
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeomapreply_nokia.h"
+#include <QNetworkAccessManager>
+#include <QNetworkCacheMetaData>
+#include <QDateTime>
+
+QGeoMapReplyNokia::QGeoMapReplyNokia(QNetworkReply *reply, const QGeoTiledMapRequest &request, QObject *parent)
+ : QGeoTiledMapReply(request, parent),
+ m_reply(reply)
+{
+ m_reply->setParent(this);
+ connect(m_reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(networkFinished()));
+
+ connect(m_reply,
+ SIGNAL(error(QNetworkReply::NetworkError)),
+ this,
+ SLOT(networkError(QNetworkReply::NetworkError)));
+
+ connect(m_reply,
+ SIGNAL(destroyed()),
+ this,
+ SLOT(replyDestroyed()));
+}
+
+QGeoMapReplyNokia::~QGeoMapReplyNokia()
+{
+}
+
+QNetworkReply* QGeoMapReplyNokia::networkReply() const
+{
+ return m_reply;
+}
+
+void QGeoMapReplyNokia::abort()
+{
+ if (!m_reply)
+ return;
+
+ m_reply->abort();
+}
+
+void QGeoMapReplyNokia::replyDestroyed()
+{
+ m_reply = 0;
+}
+
+void QGeoMapReplyNokia::networkFinished()
+{
+ if (!m_reply)
+ return;
+
+ if (m_reply->error() != QNetworkReply::NoError)
+ return;
+
+ QVariant fromCache = m_reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute);
+ setCached(fromCache.toBool());
+
+ if (!isCached()) {
+ QAbstractNetworkCache *cache = m_reply->manager()->cache();
+ if (cache) {
+ QNetworkCacheMetaData metaData = cache->metaData(m_reply->url());
+ QDateTime exp = QDateTime::currentDateTime();
+ exp = exp.addDays(14);
+ metaData.setExpirationDate(exp);
+ cache->updateMetaData(metaData);
+ }
+ }
+
+ setMapImageData(m_reply->readAll());
+ setMapImageFormat("PNG");
+ setFinished(true);
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
+
+void QGeoMapReplyNokia::networkError(QNetworkReply::NetworkError error)
+{
+ if (!m_reply)
+ return;
+
+ if (error != QNetworkReply::OperationCanceledError)
+ setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString());
+ setFinished(true);
+ m_reply->deleteLater();
+ m_reply = 0;
+}
diff --git a/src/plugins/geoservices/nokia/qgeomapreply_nokia.h b/src/plugins/geoservices/nokia/qgeomapreply_nokia.h
new file mode 100644
index 00000000..031d550e
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeomapreply_nokia.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOMAPREPLY_NOKIA_H
+#define QGEOMAPREPLY_NOKIA_H
+
+#include <qgeotiledmapreply.h>
+#include <QNetworkReply>
+
+QTM_USE_NAMESPACE
+
+class QGeoMapReplyNokia : public QGeoTiledMapReply
+{
+ Q_OBJECT
+
+public:
+ QGeoMapReplyNokia(QNetworkReply *reply, const QGeoTiledMapRequest &request, QObject *parent = 0);
+ ~QGeoMapReplyNokia();
+
+ void abort();
+
+ QNetworkReply* networkReply() const;
+
+private slots:
+ void replyDestroyed();
+ void networkFinished();
+ void networkError(QNetworkReply::NetworkError error);
+
+private:
+ QNetworkReply *m_reply;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
new file mode 100644
index 00000000..107683a9
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeoroutereply_nokia.h"
+#include "qgeoroutexmlparser.h"
+
+#include <qgeorouterequest.h>
+
+QGeoRouteReplyNokia::QGeoRouteReplyNokia(const QGeoRouteRequest &request, QNetworkReply *reply, QObject *parent)
+ : QGeoRouteReply(request, parent),
+ m_reply(reply)
+{
+ connect(m_reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(networkFinished()));
+
+ connect(m_reply,
+ SIGNAL(error(QNetworkReply::NetworkError)),
+ this,
+ SLOT(networkError(QNetworkReply::NetworkError)));
+}
+
+QGeoRouteReplyNokia::~QGeoRouteReplyNokia()
+{
+}
+
+void QGeoRouteReplyNokia::abort()
+{
+ if (!m_reply)
+ return;
+
+ m_reply->abort();
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
+
+void QGeoRouteReplyNokia::networkFinished()
+{
+ if (!m_reply)
+ return;
+
+ if (m_reply->error() != QNetworkReply::NoError) {
+ // Removed because this is already done in networkError, which previously caused _two_ errors to be raised for every error.
+ //setError(QGeoRouteReply::CommunicationError, m_reply->errorString());
+ //m_reply->deleteLater();
+ //m_reply = 0;
+ return;
+ }
+
+ QGeoRouteXmlParser parser(request());
+
+ if (parser.parse(m_reply)) {
+ setRoutes(parser.results());
+ setFinished(true);
+ } else {
+ // add a qWarning with the actual parser.errorString()
+ setError(QGeoRouteReply::ParseError, "The response from the service was not in a recognisable format.");
+ }
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
+
+void QGeoRouteReplyNokia::networkError(QNetworkReply::NetworkError error)
+{
+ Q_UNUSED(error)
+
+ if (!m_reply)
+ return;
+
+ setError(QGeoRouteReply::CommunicationError, m_reply->errorString());
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.h b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.h
new file mode 100644
index 00000000..30cdd8a0
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOROUTEREPLY_NOKIA_H
+#define QGEOROUTEREPLY_NOKIA_H
+
+#include <qgeoroutereply.h>
+#include <QNetworkReply>
+
+QTM_USE_NAMESPACE
+
+class QGeoRouteReplyNokia : public QGeoRouteReply
+{
+ Q_OBJECT
+public:
+ QGeoRouteReplyNokia(const QGeoRouteRequest &request, QNetworkReply *reply, QObject *parent = 0);
+ ~QGeoRouteReplyNokia();
+
+ void abort();
+
+private slots:
+ void networkFinished();
+ void networkError(QNetworkReply::NetworkError error);
+
+private:
+ QNetworkReply *m_reply;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
new file mode 100644
index 00000000..cca9bd68
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
@@ -0,0 +1,560 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeoroutexmlparser.h"
+
+#include <QXmlStreamReader>
+#include <QIODevice>
+#include <QStringList>
+#include <QString>
+
+QGeoRouteXmlParser::QGeoRouteXmlParser(const QGeoRouteRequest &request)
+ : m_request(request),
+ m_reader(0)
+{
+}
+
+QGeoRouteXmlParser::~QGeoRouteXmlParser()
+{
+ if (m_reader)
+ delete m_reader;
+}
+
+bool QGeoRouteXmlParser::parse(QIODevice* source)
+{
+ if (m_reader)
+ delete m_reader;
+ m_reader = new QXmlStreamReader(source);
+
+ if (!parseRootElement()) {
+ m_errorString = m_reader->errorString();
+ return false;
+ }
+
+ m_errorString = "";
+
+ return true;
+}
+
+QList<QGeoRoute> QGeoRouteXmlParser::results() const
+{
+ return m_results;
+}
+
+QString QGeoRouteXmlParser::errorString() const
+{
+ return m_errorString;
+}
+
+bool QGeoRouteXmlParser::parseRootElement()
+{
+ if (!m_reader->readNextStartElement()) {
+ m_reader->raiseError("Expected a root element named \"CalculateRoute\" (no root element found).");
+ return false;
+ }
+
+ bool updateroute = false;
+ if (m_reader->name() != "CalculateRoute" && m_reader->name() != "GetRoute") {
+ m_reader->raiseError(QString("The root element is expected to have the name \"CalculateRoute\" or \"GetRoute\" (root element was named \"%1\").").arg(m_reader->name().toString()));
+ return false;
+ } else if (m_reader->name() == "GetRoute") {
+ updateroute = true;
+ }
+
+ if (m_reader->readNextStartElement()) {
+ if (m_reader->name() != "Response") {
+ m_reader->raiseError(QString("Expected a element named \"Response\" (element was named \"%1\").").arg(m_reader->name().toString()));
+ return false;
+ }
+ }
+
+ while (m_reader->readNextStartElement()) {
+ if (m_reader->name() == "MetaInfo") {
+ m_reader->skipCurrentElement();
+ } else if (m_reader->name() == "Route") {
+ QGeoRoute route;
+ route.setRequest(m_request);
+ if (updateroute)
+ route.setTravelMode(QGeoRouteRequest::TravelMode(int(m_request.travelModes())));
+ if (!parseRoute(&route))
+ continue; //route parsing failed move on to the next
+ m_results.append(route);
+ } else if (m_reader->name() == "Progress") {
+ //TODO: updated route progress
+ m_reader->skipCurrentElement();
+ } else {
+ m_reader->raiseError(QString("Did not expect a child element named \"%1\".").arg(
+ m_reader->name().toString()));
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool QGeoRouteXmlParser::parseRoute(QGeoRoute *route)
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Route");
+ maneuvers.clear();
+ segments.clear();
+
+ m_reader->readNext();
+ bool succeeded = true;
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Route")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement && succeeded) {
+ if (m_reader->name() == "RouteId") {
+ route->setRouteId(m_reader->readElementText());
+ }
+ //else if (m_reader->name() == "Waypoint") {
+ // succeeded = parseWaypoint(route);
+ //}
+ else if (m_reader->name() == "Mode") {
+ succeeded = parseMode(route);
+ } else if (m_reader->name() == "Shape") {
+ QString elementName = m_reader->name().toString();
+ QList<QGeoCoordinate> path;
+ succeeded = parseGeoPoints(m_reader->readElementText(), &path, elementName);
+ if (succeeded)
+ route->setPath(path);
+ } else if (m_reader->name() == "BoundingBox") {
+ QGeoBoundingBox bounds;
+ succeeded = parseBoundingBox(bounds);
+ if (succeeded)
+ route->setBounds(bounds);
+ } else if (m_reader->name() == "Leg") {
+ succeeded = parseLeg();
+ } else if (m_reader->name() == "Summary") {
+ succeeded = parseSummary(route);
+ } else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+ if (succeeded)
+ succeeded = postProcessRoute(route);
+
+ return succeeded;
+}
+
+bool QGeoRouteXmlParser::parseLeg()
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Leg");
+
+ m_reader->readNext();
+ bool succeeded = true;
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Leg")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement && succeeded) {
+ if (m_reader->name() == "Maneuver") {
+ succeeded = parseManeuver();
+ } else if (m_reader->name() == "Link") {
+ succeeded = parseLink();
+ } else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+
+ return succeeded;
+}
+
+bool QGeoRouteXmlParser::postProcessRoute(QGeoRoute *route)
+{
+ QList<QGeoRouteSegment> routeSegments;
+
+ int maneuverIndex = 0;
+ for (int i = 0; i < segments.count(); ++i) {
+ while ((maneuverIndex < maneuvers.size()) && maneuvers.at(maneuverIndex).toId.isEmpty()) {
+ QGeoRouteSegment segment;
+ segment.setManeuver(maneuvers.at(maneuverIndex).maneuver);
+ QList<QGeoCoordinate> path; // use instruction position as one point segment path
+ path.append(maneuvers.at(maneuverIndex).maneuver.position());
+ segment.setPath(path);
+ routeSegments.append(segment);
+ ++maneuverIndex;
+ }
+ QGeoRouteSegment segment = segments.at(i).segment;
+ if ((maneuverIndex < maneuvers.size()) && segments.at(i).id == maneuvers.at(maneuverIndex).toId) {
+ segment.setManeuver(maneuvers.at(maneuverIndex).maneuver);
+ ++maneuverIndex;
+ }
+ routeSegments.append(segment);
+ }
+
+
+ QList<QGeoRouteSegment> compactedRouteSegments;
+ compactedRouteSegments.append(routeSegments.first());
+ routeSegments.removeFirst();
+
+ while (routeSegments.size() > 0) {
+ QGeoRouteSegment segment = routeSegments.first();
+ routeSegments.removeFirst();
+
+ QGeoRouteSegment lastSegment = compactedRouteSegments.last();
+
+ if (lastSegment.maneuver().isValid())
+ compactedRouteSegments.append(segment);
+ else {
+ compactedRouteSegments.removeLast();
+ lastSegment.setDistance(lastSegment.distance() + segment.distance());
+ lastSegment.setTravelTime(lastSegment.travelTime() + segment.travelTime());
+ QList<QGeoCoordinate> path = lastSegment.path();
+ path.append(segment.path());
+ lastSegment.setPath(path);
+ lastSegment.setManeuver(segment.maneuver());
+ compactedRouteSegments.append(lastSegment);
+ }
+ }
+
+// //Add the first instruction as starting point
+// if (maneuvers.count() > 0) {
+// QGeoRouteSegment segment;
+// segment.setManeuver(maneuvers[0].maneuver);
+// QList<QGeoCoordinate> path; // use instruction position as one point segment path
+// path.append(maneuvers[0].maneuver.position());
+// segment.setPath(path);
+// routesegments.append(segment);
+// maneuvers.removeAt(0);
+// }
+
+// for (int i = 0; i < segments.count(); ++i) {
+// if (segments[i].maneuverId.isEmpty()) {
+// routesegments.append(segments[i].segment);
+// } else {
+// for (int j = 0; j < maneuvers.count(); ++j) {
+// if (maneuvers[j].id == segments[i].maneuverId
+// && segments[i].segment.maneuver().instructionText().isEmpty()) {
+// segments[i].segment.setManeuver(maneuvers[j].maneuver);
+// routesegments.append(segments[i].segment);
+// maneuvers.removeAt(j);
+// break;
+// } else {
+// //Add orphan instruction into new empty segment
+// QGeoRouteSegment segment;
+// segment.setManeuver(maneuvers[j].maneuver);
+// QList<QGeoCoordinate> path; // use instruction position as one point segment path
+// path.append(maneuvers[j].maneuver.position());
+// segment.setPath(path);
+// routesegments.append(segment);
+// maneuvers.removeAt(j);
+// --j;
+// }
+// }
+// }
+// }
+
+ if (compactedRouteSegments.size() > 0) {
+ route->setFirstRouteSegment(compactedRouteSegments.at(0));
+ for (int i = 0; i < compactedRouteSegments.size() - 1; ++i)
+ compactedRouteSegments[i].setNextRouteSegment(compactedRouteSegments.at(i + 1));
+ }
+
+ maneuvers.clear();
+ segments.clear();
+ return true;
+}
+
+/*
+bool QGeoRouteXmlParser::parseWaypoint(QGeoRoute *route)
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Waypoint");
+ m_reader->readNext();
+ QList<QGeoCoordinate> path(route->pathSummary());
+
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Waypoint")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
+ if (m_reader->name() == "MappedPosition") {
+ QGeoCoordinate coordinates;
+ if(!parseCoordinates(coordinates))
+ return false;
+ path.append(coordinates);
+ }
+ else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+ route->setPathSummary(path);
+ return true;
+}
+*/
+
+bool QGeoRouteXmlParser::parseMode(QGeoRoute *route)
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Mode");
+ m_reader->readNext();
+
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Mode")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
+ if (m_reader->name() == "TransportModes") {
+ QString value = m_reader->readElementText();
+ if (value == "car")
+ route->setTravelMode(QGeoRouteRequest::CarTravel);
+ else if (value == "pedestrian")
+ route->setTravelMode(QGeoRouteRequest::PedestrianTravel);
+ else if (value == "publicTransport")
+ route->setTravelMode(QGeoRouteRequest::PublicTransitTravel);
+ else if (value == "bicycle")
+ route->setTravelMode(QGeoRouteRequest::BicycleTravel);
+ else if (value == "truck")
+ route->setTravelMode(QGeoRouteRequest::TruckTravel);
+ else // unsupported optimization
+ return false;
+ } else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+ return true;
+}
+
+bool QGeoRouteXmlParser::parseSummary(QGeoRoute *route)
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Summary");
+ m_reader->readNext();
+
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Summary")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
+ if (m_reader->name() == "Distance") {
+ route->setDistance(m_reader->readElementText().toDouble());
+ } else if (m_reader->name() == "TrafficTime") {
+ route->setTravelTime(m_reader->readElementText().toDouble());
+ } else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+
+ return true;
+}
+
+bool QGeoRouteXmlParser::parseCoordinates(QGeoCoordinate &coord)
+{
+ QString currentElement = m_reader->name().toString();
+ m_reader->readNext();
+
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == currentElement)) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
+ QString name = m_reader->name().toString();
+ QString value = m_reader->readElementText();
+ if (name == "Latitude")
+ coord.setLatitude(value.toDouble());
+ else if (name == "Longitude")
+ coord.setLongitude(value.toDouble());
+ }
+ m_reader->readNext();
+ }
+
+ return true;
+}
+
+bool QGeoRouteXmlParser::parseManeuver()
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Maneuver");
+
+ if (!m_reader->attributes().hasAttribute("id")) {
+ m_reader->raiseError("The element \"Maneuver\" did not have the required attribute \"id\".");
+ return false;
+ }
+ QGeoManeuverContainer maneuverContainter;
+ maneuverContainter.id = m_reader->attributes().value("id").toString();
+
+ m_reader->readNext();
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Maneuver")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
+ if (m_reader->name() == "Position") {
+ QGeoCoordinate coordinates;
+ if (parseCoordinates(coordinates))
+ maneuverContainter.maneuver.setPosition(coordinates);
+ } else if (m_reader->name() == "Instruction") {
+ maneuverContainter.maneuver.setInstructionText(m_reader->readElementText());
+ } else if (m_reader->name() == "ToLink") {
+ maneuverContainter.toId = m_reader->readElementText();
+ } else if (m_reader->name() == "TravelTime") {
+ maneuverContainter.maneuver.setTimeToNextInstruction(m_reader->readElementText().toInt());
+ } else if (m_reader->name() == "Length") {
+ maneuverContainter.maneuver.setDistanceToNextInstruction(m_reader->readElementText().toDouble());
+ } else if (m_reader->name() == "Direction") {
+ QString value = m_reader->readElementText();
+ if (value == "forward")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionForward);
+ else if (value == "bearRight")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionBearRight);
+ else if (value == "lightRight")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionLightRight);
+ else if (value == "right")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionRight);
+ else if (value == "hardRight")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionHardRight);
+ else if (value == "uTurnRight")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionUTurnRight);
+ else if (value == "uTurnLeft")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionUTurnLeft);
+ else if (value == "hardLeft")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionHardLeft);
+ else if (value == "left")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionLeft);
+ else if (value == "lightLeft")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionLightLeft);
+ else if (value == "bearLeft")
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionBearLeft);
+ else
+ maneuverContainter.maneuver.setDirection(QGeoManeuver::NoDirection);
+ } else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+
+ maneuvers.append(maneuverContainter);
+ return true;
+}
+
+bool QGeoRouteXmlParser::parseLink()
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Link");
+ m_reader->readNext();
+
+ QGeoRouteSegmentContainer segmentContainer;
+
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Link")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
+ if (m_reader->name() == "LinkId") {
+ segmentContainer.id = m_reader->readElementText();
+ } else if (m_reader->name() == "Shape") {
+ QString elementName = m_reader->name().toString();
+ QList<QGeoCoordinate> path;
+ parseGeoPoints(m_reader->readElementText(), &path, elementName);
+ segmentContainer.segment.setPath(path);
+ } else if (m_reader->name() == "Length") {
+ segmentContainer.segment.setDistance(m_reader->readElementText().toDouble());
+ } else if (m_reader->name() == "Maneuver") {
+ segmentContainer.maneuverId = m_reader->readElementText();
+ } else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+ segments.append(segmentContainer);
+ return true;
+}
+
+bool QGeoRouteXmlParser::parseGeoPoints(const QString& strPoints, QList<QGeoCoordinate> *geoPoints, const QString &elementName)
+{
+ QStringList rawPoints = strPoints.split(' ');
+
+ for (int i = 0; i < rawPoints.length(); ++i) {
+ QStringList coords = rawPoints[i].split(',');
+
+ if (coords.length() != 2) {
+ m_reader->raiseError(QString("Each of the space separated values of \"%1\" is expected to be a comma separated pair of coordinates (value was \"%2\")").arg(elementName).arg(rawPoints[i]));
+ return false;
+ }
+
+ bool ok = false;
+ QString latString = coords[0];
+ double lat = latString.toDouble(&ok);
+
+ if (!ok) {
+ m_reader->raiseError(QString("The latitude portions of \"%1\" are expected to have a value convertable to a double (value was \"%2\")").arg(elementName).arg(latString));
+ return false;
+ }
+
+ QString lngString = coords[1];
+ double lng = lngString.toDouble(&ok);
+
+ if (!ok) {
+ m_reader->raiseError(QString("The longitude portions of \"%1\" are expected to have a value convertable to a double (value was \"%2\")").arg(elementName).arg(lngString));
+ return false;
+ }
+
+ QGeoCoordinate geoPoint(lat, lng);
+ geoPoints->append(geoPoint);
+ }
+
+ return true;
+}
+
+bool QGeoRouteXmlParser::parseBoundingBox(QGeoBoundingBox &bounds)
+{
+ Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "BoundingBox");
+
+ QGeoCoordinate tl;
+ QGeoCoordinate br;
+
+ m_reader->readNext();
+ while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "BoundingBox")) {
+ if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
+ if (m_reader->name() == "TopLeft") {
+ QGeoCoordinate coordinates;
+ if (parseCoordinates(coordinates))
+ tl = coordinates;
+ } else if (m_reader->name() == "BottomRight") {
+ QGeoCoordinate coordinates;
+ if (parseCoordinates(coordinates))
+ br = coordinates;
+ } else {
+ m_reader->skipCurrentElement();
+ }
+ }
+ m_reader->readNext();
+ }
+
+ if (tl.isValid() && br.isValid()) {
+ bounds = QGeoBoundingBox(tl, br);
+ return true;
+ }
+
+ return false;
+}
diff --git a/src/plugins/geoservices/nokia/qgeoroutexmlparser.h b/src/plugins/geoservices/nokia/qgeoroutexmlparser.h
new file mode 100644
index 00000000..257bc51a
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoroutexmlparser.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QROUTEXMLPARSER_H
+#define QROUTEXMLPARSER_H
+
+#include <QList>
+#include <QMap>
+#include <QString>
+#include <QXmlStreamReader>
+
+class QIODevice;
+
+#include <qgeoroute.h>
+#include <qgeoroutesegment.h>
+#include <qgeocoordinate.h>
+#include <qgeoboundingbox.h>
+#include <qgeorouterequest.h>
+#include <qgeomaneuver.h>
+
+QTM_USE_NAMESPACE
+
+class QGeoManeuverContainer
+{
+public:
+ QGeoManeuver maneuver;
+ QString id;
+ QString toId;
+};
+
+class QGeoRouteSegmentContainer
+{
+public:
+ QGeoRouteSegment segment;
+ QString id;
+ QString maneuverId;
+};
+
+class QGeoRouteXmlParser
+{
+public:
+ QGeoRouteXmlParser(const QGeoRouteRequest &request);
+ ~QGeoRouteXmlParser();
+
+ bool parse(QIODevice* source);
+ QList<QGeoRoute> results() const;
+ QString errorString() const;
+
+private:
+ bool parseRootElement();
+ bool parseRoute(QGeoRoute *route);
+ //bool parseWaypoint(QGeoRoute *route);
+ bool parseCoordinates(QGeoCoordinate &coord);
+ bool parseMode(QGeoRoute *route);
+ bool parseSummary(QGeoRoute *route);
+ bool parseGeoPoints(const QString& strPoints, QList<QGeoCoordinate> *geoPoints, const QString &elementName);
+ bool parseLeg();
+ bool parseManeuver();
+ bool parseLink();
+ bool postProcessRoute(QGeoRoute *route);
+
+ bool parseBoundingBox(QGeoBoundingBox &bounds);
+
+ QGeoRouteRequest m_request;
+ QXmlStreamReader *m_reader;
+ QList<QGeoRoute> m_results;
+ QString m_errorString;
+ QList<QGeoManeuverContainer> maneuvers;
+ QList<QGeoRouteSegmentContainer> segments;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
new file mode 100644
index 00000000..359ccd26
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
@@ -0,0 +1,477 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeoroutingmanagerengine_nokia.h"
+#include "qgeoroutereply_nokia.h"
+
+#include <QStringList>
+#include <QNetworkProxy>
+#include <QUrl>
+#include <qgeoboundingbox.h>
+
+QGeoRoutingManagerEngineNokia::QGeoRoutingManagerEngineNokia(const QMap<QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString)
+ : QGeoRoutingManagerEngine(parameters),
+ m_host("prd.lbsp.navteq.com"),
+ m_token(QGeoServiceProviderFactoryNokia::defaultToken),
+ m_referer(QGeoServiceProviderFactoryNokia::defaultReferer)
+{
+ m_networkManager = new QNetworkAccessManager(this);
+
+ if (parameters.contains("routing.proxy")) {
+ QString proxy = parameters.value("routing.proxy").toString();
+ if (!proxy.isEmpty()) {
+ QUrl proxyUrl(proxy);
+ if (proxyUrl.isValid()) {
+ m_networkManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,
+ proxyUrl.host(),
+ proxyUrl.port(8080),
+ proxyUrl.userName(),
+ proxyUrl.password()));
+ }
+ }
+ }
+
+ if (parameters.contains("routing.host")) {
+ QString host = parameters.value("routing.host").toString();
+ if (!host.isEmpty())
+ m_host = host;
+ }
+
+ if (parameters.contains("routing.referer")) {
+ m_referer = parameters.value("routing.referer").toString();
+ }
+
+ if (parameters.contains("routing.token")) {
+ m_token = parameters.value("routing.token").toString();
+ }
+ else if (parameters.contains("token")) {
+ m_token = parameters.value("token").toString();
+ }
+
+ setSupportsRouteUpdates(true);
+ setSupportsAlternativeRoutes(true);
+ setSupportsExcludeAreas(true);
+
+ QGeoRouteRequest::FeatureTypes featureTypes;
+ featureTypes |= QGeoRouteRequest::TollFeature;
+ featureTypes |= QGeoRouteRequest::HighwayFeature;
+ featureTypes |= QGeoRouteRequest::FerryFeature;
+ featureTypes |= QGeoRouteRequest::TunnelFeature;
+ featureTypes |= QGeoRouteRequest::DirtRoadFeature;
+ setSupportedFeatureTypes(featureTypes);
+
+ QGeoRouteRequest::FeatureWeights featureWeights;
+ featureWeights |= QGeoRouteRequest::AvoidFeatureWeight;
+ setSupportedFeatureWeights(featureWeights);
+
+ QGeoRouteRequest::ManeuverDetails maneuverDetails;
+ maneuverDetails |= QGeoRouteRequest::BasicManeuvers;
+ setSupportedManeuverDetails(maneuverDetails);
+
+ QGeoRouteRequest::RouteOptimizations optimizations;
+ optimizations |= QGeoRouteRequest::ShortestRoute;
+ optimizations |= QGeoRouteRequest::FastestRoute;
+ optimizations |= QGeoRouteRequest::MostEconomicRoute;
+ setSupportedRouteOptimizations(optimizations);
+
+ QGeoRouteRequest::TravelModes travelModes;
+ travelModes |= QGeoRouteRequest::CarTravel;
+ travelModes |= QGeoRouteRequest::PedestrianTravel;
+ travelModes |= QGeoRouteRequest::PublicTransitTravel;
+ setSupportedTravelModes(travelModes);
+
+ QGeoRouteRequest::SegmentDetails segmentDetails;
+ segmentDetails |= QGeoRouteRequest::BasicSegmentData;
+ setSupportedSegmentDetails(segmentDetails);
+
+ if (error)
+ *error = QGeoServiceProvider::NoError;
+
+ if (errorString)
+ *errorString = "";
+}
+
+QGeoRoutingManagerEngineNokia::~QGeoRoutingManagerEngineNokia() {}
+
+QGeoRouteReply* QGeoRoutingManagerEngineNokia::calculateRoute(const QGeoRouteRequest& request)
+{
+ QString reqString = calculateRouteRequestString(request);
+
+ if (reqString.isEmpty()) {
+ QGeoRouteReply *reply = new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError, "The given route request options are not supported by this service provider.", this);
+ emit error(reply, reply->error(), reply->errorString());
+ return reply;
+ }
+
+ QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(reqString)));
+ QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(request, networkReply, this);
+
+ connect(reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(routeFinished()));
+
+ connect(reply,
+ SIGNAL(error(QGeoRouteReply::Error, QString)),
+ this,
+ SLOT(routeError(QGeoRouteReply::Error, QString)));
+
+ return reply;
+}
+
+QGeoRouteReply* QGeoRoutingManagerEngineNokia::updateRoute(const QGeoRoute &route, const QGeoCoordinate &position)
+{
+ QString reqString = updateRouteRequestString(route, position);
+
+ if (reqString.isEmpty()) {
+ QGeoRouteReply *reply = new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError, "The given route request options are not supported by this service provider.", this);
+ emit error(reply, reply->error(), reply->errorString());
+ return reply;
+ }
+
+ QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(reqString)));
+ QGeoRouteRequest updateRequest(route.request());
+ updateRequest.setTravelModes(route.travelMode());
+ QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(updateRequest, networkReply, this);
+
+ connect(reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(routeFinished()));
+
+ connect(reply,
+ SIGNAL(error(QGeoRouteReply::Error, QString)),
+ this,
+ SLOT(routeError(QGeoRouteReply::Error, QString)));
+
+ return reply;
+}
+
+bool QGeoRoutingManagerEngineNokia::checkEngineSupport(const QGeoRouteRequest &request,
+ QGeoRouteRequest::TravelModes travelModes) const
+{
+ QList<QGeoRouteRequest::FeatureType> featureTypeList = request.featureTypes();
+ QGeoRouteRequest::FeatureTypes featureTypeFlag = QGeoRouteRequest::NoFeature;
+ QGeoRouteRequest::FeatureWeights featureWeightFlag = QGeoRouteRequest::NeutralFeatureWeight;
+
+ for (int i = 0; i < featureTypeList.size(); ++i) {
+ featureTypeFlag |= featureTypeList.at(i);
+ featureWeightFlag |= request.featureWeight(featureTypeList.at(i));
+ }
+
+ if ((featureTypeFlag & supportedFeatureTypes()) != featureTypeFlag)
+ return false;
+
+ if ((featureWeightFlag & supportedFeatureWeights()) != featureWeightFlag)
+ return false;
+
+
+ if ((request.maneuverDetail() & supportedManeuverDetails()) != request.maneuverDetail())
+ return false;
+
+ if ((request.segmentDetail() & supportedSegmentDetails()) != request.segmentDetail())
+ return false;
+
+ if ((request.routeOptimization() & supportedRouteOptimizations()) != request.routeOptimization())
+ return false;
+
+ if ((travelModes & supportedTravelModes()) != travelModes)
+ return false;
+
+ return true;
+}
+
+QString QGeoRoutingManagerEngineNokia::calculateRouteRequestString(const QGeoRouteRequest &request)
+{
+ bool supported = checkEngineSupport(request, request.travelModes());
+
+ if ((request.numberAlternativeRoutes() != 0) && !supportsAlternativeRoutes())
+ supported = false;
+
+ if (!supported)
+ return "";
+
+ QString requestString = "http://";
+ requestString += m_host;
+ requestString += "/routing/6.2/calculateroute.xml?referer=" + m_referer;
+
+ if (!m_token.isNull())
+ requestString += "&token=" + m_token;
+
+ int numWaypoints = request.waypoints().size();
+ if (numWaypoints < 2)
+ return "";
+
+ for (int i = 0;i < numWaypoints;++i) {
+ requestString += "&waypoint";
+ requestString += QString::number(i);
+ requestString += "=";
+ requestString += trimDouble(request.waypoints().at(i).latitude());
+ requestString += ",";
+ requestString += trimDouble(request.waypoints().at(i).longitude());
+ }
+
+ requestString += modesRequestString(request, request.travelModes());
+
+ requestString += "&alternatives=";
+ requestString += QString::number(request.numberAlternativeRoutes());
+
+ requestString += routeRequestString(request);
+
+ return requestString;
+}
+
+QString QGeoRoutingManagerEngineNokia::updateRouteRequestString(const QGeoRoute &route, const QGeoCoordinate &position)
+{
+ if (!checkEngineSupport(route.request(), route.travelMode()))
+ return "";
+
+ QString requestString = "http://";
+ requestString += m_host;
+ requestString += "/routing/6.2/getroute.xml";
+
+ requestString += "?routeid=";
+ requestString += route.routeId();
+
+ requestString += "&pos=";
+ requestString += QString::number(position.latitude());
+ requestString += ",";
+ requestString += QString::number(position.longitude());
+
+ requestString += modesRequestString(route.request(), route.travelMode());
+
+ requestString += routeRequestString(route.request());
+
+ return requestString;
+}
+
+QString QGeoRoutingManagerEngineNokia::modesRequestString(const QGeoRouteRequest &request,
+ QGeoRouteRequest::TravelModes travelModes) const
+{
+ QString requestString;
+
+ QGeoRouteRequest::RouteOptimizations optimization = request.routeOptimization();
+
+ QStringList types;
+ if (optimization.testFlag(QGeoRouteRequest::ShortestRoute))
+ types.append("shortest");
+ if (optimization.testFlag(QGeoRouteRequest::FastestRoute))
+ types.append("fastestNow");
+ if (optimization.testFlag(QGeoRouteRequest::MostEconomicRoute))
+ types.append("economic");
+ if (optimization.testFlag(QGeoRouteRequest::MostScenicRoute))
+ types.append("scenic");
+
+ QStringList modes;
+ if (travelModes.testFlag(QGeoRouteRequest::CarTravel))
+ modes.append("car");
+ if (travelModes.testFlag(QGeoRouteRequest::PedestrianTravel))
+ modes.append("pedestrian");
+ if (travelModes.testFlag(QGeoRouteRequest::PublicTransitTravel))
+ modes.append("publicTransport");
+
+ QStringList featureStrings;
+ QList<QGeoRouteRequest::FeatureType> featureTypes = request.featureTypes();
+ for (int i = 0; i < featureTypes.size(); ++i) {
+ QGeoRouteRequest::FeatureWeight weight = request.featureWeight(featureTypes.at(i));
+
+ if (weight == QGeoRouteRequest::NeutralFeatureWeight)
+ continue;
+
+ QString weightString = "";
+ switch (weight) {
+ case QGeoRouteRequest::PreferFeatureWeight:
+ weightString = "1";
+ break;
+ case QGeoRouteRequest::AvoidFeatureWeight:
+ weightString = "-1";
+ break;
+ case QGeoRouteRequest::DisallowFeatureWeight:
+ weightString = "-3";
+ break;
+ }
+
+ if (weightString.isEmpty())
+ continue;
+
+ switch (featureTypes.at(i)) {
+ case QGeoRouteRequest::TollFeature:
+ featureStrings.append("tollroad:" + weightString);
+ break;
+ case QGeoRouteRequest::HighwayFeature:
+ featureStrings.append("motorway:" + weightString);
+ break;
+ case QGeoRouteRequest::FerryFeature:
+ featureStrings.append("boatFerry:" + weightString);
+ featureStrings.append("railFerry:" + weightString);
+ break;
+ case QGeoRouteRequest::TunnelFeature:
+ featureStrings.append("tunnel:" + weightString);
+ break;
+ case QGeoRouteRequest::DirtRoadFeature:
+ featureStrings.append("dirtRoad:" + weightString);
+ break;
+ }
+ }
+
+ for (int i = 0;i < types.count();++i) {
+ requestString += "&mode" + QString::number(i) + "=";
+ requestString += types[i] + ";" + modes.join(",");
+ if (featureStrings.count())
+ requestString += ";" + featureStrings.join(",");
+ }
+ return requestString;
+}
+
+QString QGeoRoutingManagerEngineNokia::routeRequestString(const QGeoRouteRequest &request) const
+{
+ QString requestString;
+
+ int numAreas = request.excludeAreas().count();
+ if (numAreas > 0) {
+ requestString += "&avoidareas";
+ for (int i = 0;i < numAreas;++i) {
+ requestString += i == 0 ? "=" : ";";
+ QGeoBoundingBox box = request.excludeAreas().at(i);
+ requestString += trimDouble(box.topLeft().latitude());
+ requestString += ",";
+ requestString += trimDouble(box.topLeft().longitude());
+ requestString += ",";
+ requestString += trimDouble(box.bottomRight().latitude());
+ requestString += ",";
+ requestString += trimDouble(box.bottomRight().longitude());
+ }
+ }
+
+// TODO: work out what was going on here
+// - segment and instruction/maneuever functions are mixed and matched
+// - tried to implement sensible equivalents below
+// QStringList legAttributes;
+// if (request.instructionDetail() & QGeoRouteRequest::BasicSegmentData) {
+// requestString += "&linkattributes=sh,le"; //shape,length
+// legAttributes.append("links");
+// }
+//
+// if (request.instructionDetail() & QGeoRouteRequest::BasicInstructions) {
+// legAttributes.append("maneuvers");
+// requestString += "&maneuverattributes=po,tt,le,di"; //position,traveltime,length,direction
+// if (!(request.instructionDetail() & QGeoRouteRequest::NoSegmentData))
+// requestString += ",li"; //link
+// }
+
+ QStringList legAttributes;
+ if (request.segmentDetail() & QGeoRouteRequest::BasicSegmentData) {
+ requestString += "&linkattributes=sh,le"; //shape,length
+ legAttributes.append("links");
+ }
+
+ if (request.maneuverDetail() & QGeoRouteRequest::BasicManeuvers) {
+ legAttributes.append("maneuvers");
+ requestString += "&maneuverattributes=po,tt,le,di"; //position,traveltime,length,direction
+ if (!(request.segmentDetail() & QGeoRouteRequest::NoSegmentData))
+ requestString += ",li"; //link
+ }
+
+ requestString += "&routeattributes=sm,sh,bb,lg"; //summary,shape,boundingBox,legs
+ if (legAttributes.count() > 0) {
+ requestString += "&legattributes=";
+ requestString += legAttributes.join(",");
+ }
+
+ requestString += "&departure=";
+ requestString += QDateTime::currentDateTime().toUTC().toString("yyyy-MM-ddThh:mm:ssZ");
+
+ requestString += "&instructionformat=text";
+
+ requestString += "&language=";
+ requestString += locale().name();
+
+ return requestString;
+}
+
+QString QGeoRoutingManagerEngineNokia::trimDouble(qreal degree, int decimalDigits)
+{
+ QString sDegree = QString::number(degree, 'g', decimalDigits);
+
+ int index = sDegree.indexOf('.');
+
+ if (index == -1)
+ return sDegree;
+ else
+ return QString::number(degree, 'g', decimalDigits + index);
+}
+
+void QGeoRoutingManagerEngineNokia::routeFinished()
+{
+ QGeoRouteReply *reply = qobject_cast<QGeoRouteReply*>(sender());
+
+ if (!reply)
+ return;
+
+ if (receivers(SIGNAL(finished(QGeoRouteReply*))) == 0) {
+ reply->deleteLater();
+ return;
+ }
+
+ emit finished(reply);
+}
+
+void QGeoRoutingManagerEngineNokia::routeError(QGeoRouteReply::Error error, const QString &errorString)
+{
+ QGeoRouteReply *reply = qobject_cast<QGeoRouteReply*>(sender());
+
+ if (!reply)
+ return;
+
+ if (receivers(SIGNAL(error(QGeoRouteReply*, QGeoRouteReply::Error, QString))) == 0) {
+ reply->deleteLater();
+ return;
+ }
+
+ emit this->error(reply, error, errorString);
+}
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h
new file mode 100644
index 00000000..b4635032
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOROUTINGMANAGER_NOKIA_H
+#define QGEOROUTINGMANAGER_NOKIA_H
+
+#include "qgeoserviceproviderplugin_nokia.h"
+
+#include <qgeoserviceprovider.h>
+#include <qgeoroutingmanagerengine.h>
+#include <QNetworkAccessManager>
+
+QTM_USE_NAMESPACE
+
+class QGeoRoutingManagerEngineNokia : public QGeoRoutingManagerEngine
+{
+ Q_OBJECT
+public:
+ QGeoRoutingManagerEngineNokia(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString);
+ ~QGeoRoutingManagerEngineNokia();
+
+ QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request);
+ QGeoRouteReply* updateRoute(const QGeoRoute &route, const QGeoCoordinate &position);
+
+private slots:
+ void routeFinished();
+ void routeError(QGeoRouteReply::Error error, const QString &errorString);
+
+private:
+ QString calculateRouteRequestString(const QGeoRouteRequest &request);
+ QString updateRouteRequestString(const QGeoRoute &route, const QGeoCoordinate &position);
+ QString routeRequestString(const QGeoRouteRequest &request) const;
+ bool checkEngineSupport(const QGeoRouteRequest &request,
+ QGeoRouteRequest::TravelModes travelModes) const;
+ QString modesRequestString(const QGeoRouteRequest &request,
+ QGeoRouteRequest::TravelModes travelModes) const;
+ static QString trimDouble(qreal degree, int decimalDigits = 10);
+
+ QNetworkAccessManager *m_networkManager;
+ QString m_host;
+ QString m_token;
+ QString m_referer;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.cpp
new file mode 100644
index 00000000..c39fde60
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.cpp
@@ -0,0 +1,317 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeosearchmanagerengine_nokia.h"
+#include "qgeosearchreply_nokia.h"
+#include "marclanguagecodes.h"
+
+#include <qgeoaddress.h>
+#include <qgeocoordinate.h>
+#include <QNetworkProxy>
+#include <QUrl>
+#include <QMap>
+
+QGeoSearchManagerEngineNokia::QGeoSearchManagerEngineNokia(const QMap<QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString)
+ : QGeoSearchManagerEngine(parameters),
+ m_host("loc.desktop.maps.svc.ovi.com"),
+ m_token(QGeoServiceProviderFactoryNokia::defaultToken),
+ m_referer(QGeoServiceProviderFactoryNokia::defaultReferer)
+{
+ m_networkManager = new QNetworkAccessManager(this);
+
+ if (parameters.contains("places.proxy")) {
+ QString proxy = parameters.value("places.proxy").toString();
+ if (!proxy.isEmpty()) {
+ QUrl proxyUrl(proxy);
+ if (proxyUrl.isValid()) {
+ m_networkManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,
+ proxyUrl.host(),
+ proxyUrl.port(8080),
+ proxyUrl.userName(),
+ proxyUrl.password()));
+ }
+ }
+ }
+
+ if (parameters.contains("places.host")) {
+ QString host = parameters.value("places.host").toString();
+ if (!host.isEmpty())
+ m_host = host;
+ }
+
+ if (parameters.contains("places.referer")) {
+ m_referer = parameters.value("places.referer").toString();
+ }
+
+ if (parameters.contains("places.token")) {
+ m_token = parameters.value("places.token").toString();
+ }
+ else if (parameters.contains("token")) {
+ m_token = parameters.value("token").toString();
+ }
+
+
+ setSupportsGeocoding(true);
+ setSupportsReverseGeocoding(true);
+
+ QGeoSearchManager::SearchTypes supportedSearchTypes;
+ supportedSearchTypes |= QGeoSearchManager::SearchGeocode;
+ setSupportedSearchTypes(supportedSearchTypes);
+
+ if (error)
+ *error = QGeoServiceProvider::NoError;
+
+ if (errorString)
+ *errorString = "";
+}
+
+QGeoSearchManagerEngineNokia::~QGeoSearchManagerEngineNokia() {}
+
+QGeoSearchReply* QGeoSearchManagerEngineNokia::geocode(const QGeoAddress &address,
+ QGeoBoundingArea *bounds)
+{
+ if (!supportsGeocoding()) {
+ QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "Geocoding is not supported by this service provider.", this);
+ emit error(reply, reply->error(), reply->errorString());
+ return reply;
+ }
+
+ QString requestString = "http://";
+ requestString += m_host;
+ requestString += "/geocoder/gc/1.0?referer=" + m_referer;
+
+ if (!m_token.isNull())
+ requestString += "&token=" + m_token;
+
+ requestString += "&lg=";
+ requestString += languageToMarc(locale().language());
+
+ requestString += "&country=";
+ requestString += address.country();
+
+ if (!address.state().isEmpty()) {
+ requestString += "&state=";
+ requestString += address.state();
+ }
+
+ if (!address.city().isEmpty()) {
+ requestString += "&city=";
+ requestString += address.city();
+ }
+
+ if (!address.postcode().isEmpty()) {
+ requestString += "&zip=";
+ requestString += address.postcode();
+ }
+
+ if (!address.street().isEmpty()) {
+ requestString += "&street=";
+ requestString += address.street();
+ }
+
+ // TODO?
+ // street number has been removed from QGeoAddress
+ // do we need to try to split it out from QGeoAddress::street
+ // in order to geocode properly
+
+ // Old code:
+// if (!address.streetNumber().isEmpty()) {
+// requestString += "&number=";
+// requestString += address.streetNumber();
+// }
+
+ return search(requestString, bounds);
+}
+
+QGeoSearchReply* QGeoSearchManagerEngineNokia::reverseGeocode(const QGeoCoordinate &coordinate,
+ QGeoBoundingArea *bounds)
+{
+ if (!supportsReverseGeocoding()) {
+ QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "Reverse geocoding is not supported by this service provider.", this);
+ emit error(reply, reply->error(), reply->errorString());
+ return reply;
+ }
+
+ QString requestString = "http://";
+ requestString += m_host;
+ requestString += "/geocoder/rgc/1.0?referer=" + m_referer;
+ if (!m_token.isNull())
+ requestString += "&token=" + m_token;
+ requestString += "&long=";
+ requestString += trimDouble(coordinate.longitude());
+ requestString += "&lat=";
+ requestString += trimDouble(coordinate.latitude());
+
+ requestString += "&lg=";
+ requestString += languageToMarc(locale().language());
+
+ return search(requestString, bounds);
+}
+
+QGeoSearchReply* QGeoSearchManagerEngineNokia::search(const QString &searchString,
+ QGeoSearchManager::SearchTypes searchTypes,
+ int limit,
+ int offset,
+ QGeoBoundingArea *bounds)
+{
+ // NOTE this will eventually replaced by a much improved implementation
+ // which will make use of the additionLandmarkManagers()
+ if ((searchTypes != QGeoSearchManager::SearchTypes(QGeoSearchManager::SearchAll))
+ && ((searchTypes & supportedSearchTypes()) != searchTypes)) {
+
+ QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "The selected search type is not supported by this service provider.", this);
+ emit error(reply, reply->error(), reply->errorString());
+ return reply;
+ }
+
+ QString requestString = "http://";
+ requestString += m_host;
+ requestString += "/geocoder/gc/1.0?referer=" + m_referer;
+
+ if (!m_token.isNull())
+ requestString += "&token=" + m_token;
+
+ requestString += "&lg=";
+ requestString += languageToMarc(locale().language());
+
+ requestString += "&obloc=";
+ requestString += searchString;
+
+ if (limit > 0) {
+ requestString += "&total=";
+ requestString += QString::number(limit);
+ }
+
+ if (offset > 0) {
+ requestString += "&offset=";
+ requestString += QString::number(offset);
+ }
+
+ return search(requestString, bounds, limit, offset);
+}
+
+QGeoSearchReply* QGeoSearchManagerEngineNokia::search(QString requestString,
+ QGeoBoundingArea *bounds,
+ int limit,
+ int offset)
+{
+ QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(requestString)));
+ QGeoSearchReplyNokia *reply = new QGeoSearchReplyNokia(networkReply, limit, offset, bounds, this);
+
+ connect(reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(placesFinished()));
+
+ connect(reply,
+ SIGNAL(error(QGeoSearchReply::Error, QString)),
+ this,
+ SLOT(placesError(QGeoSearchReply::Error, QString)));
+
+ return reply;
+}
+
+QString QGeoSearchManagerEngineNokia::trimDouble(qreal degree, int decimalDigits)
+{
+ QString sDegree = QString::number(degree, 'g', decimalDigits);
+
+ int index = sDegree.indexOf('.');
+
+ if (index == -1)
+ return sDegree;
+ else
+ return QString::number(degree, 'g', decimalDigits + index);
+}
+
+void QGeoSearchManagerEngineNokia::placesFinished()
+{
+ QGeoSearchReply *reply = qobject_cast<QGeoSearchReply*>(sender());
+
+ if (!reply)
+ return;
+
+ if (receivers(SIGNAL(finished(QGeoSearchReply*))) == 0) {
+ reply->deleteLater();
+ return;
+ }
+
+ emit finished(reply);
+}
+
+void QGeoSearchManagerEngineNokia::placesError(QGeoSearchReply::Error error, const QString &errorString)
+{
+ QGeoSearchReply *reply = qobject_cast<QGeoSearchReply*>(sender());
+
+ if (!reply)
+ return;
+
+ if (receivers(SIGNAL(error(QGeoSearchReply*, QGeoSearchReply::Error, QString))) == 0) {
+ reply->deleteLater();
+ return;
+ }
+
+ emit this->error(reply, error, errorString);
+}
+
+QString QGeoSearchManagerEngineNokia::languageToMarc(QLocale::Language language)
+{
+ uint offset = 3 * (uint(language));
+ if (language == QLocale::C || offset + 3 > sizeof(marc_language_code_list))
+ return QLatin1String("eng");
+
+ const unsigned char *c = marc_language_code_list + offset;
+ if (c[0] == 0)
+ return QLatin1String("eng");
+
+ QString code(3, Qt::Uninitialized);
+ code[0] = ushort(c[0]);
+ code[1] = ushort(c[1]);
+ code[2] = ushort(c[2]);
+
+ return code;
+}
diff --git a/src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.h b/src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.h
new file mode 100644
index 00000000..1cc1468c
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeosearchmanagerengine_nokia.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHMANAGER_NOKIA_H
+#define QGEOSEARCHMANAGER_NOKIA_H
+
+#include "qgeoserviceproviderplugin_nokia.h"
+
+#include <qgeoserviceprovider.h>
+#include <qgeosearchmanagerengine.h>
+
+#include <QNetworkAccessManager>
+#include <QLocale>
+
+
+QTM_USE_NAMESPACE
+
+class QGeoSearchManagerEngineNokia : public QGeoSearchManagerEngine
+{
+ Q_OBJECT
+public:
+ QGeoSearchManagerEngineNokia(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString);
+ ~QGeoSearchManagerEngineNokia();
+
+ QGeoSearchReply* geocode(const QGeoAddress &address,
+ QGeoBoundingArea *bounds);
+ QGeoSearchReply* reverseGeocode(const QGeoCoordinate &coordinate,
+ QGeoBoundingArea *bounds);
+
+ QGeoSearchReply* search(const QString &searchString,
+ QGeoSearchManager::SearchTypes searchTypes,
+ int limit,
+ int offset,
+ QGeoBoundingArea *bounds);
+
+private slots:
+ void placesFinished();
+ void placesError(QGeoSearchReply::Error error, const QString &errorString);
+
+private:
+ static QString trimDouble(qreal degree, int decimalDigits = 10);
+ QGeoSearchReply* search(QString requestString, QGeoBoundingArea *bounds, int limit = -1, int offset = 0);
+ QString languageToMarc(QLocale::Language language);
+
+ QNetworkAccessManager *m_networkManager;
+ QString m_host;
+ QString m_token;
+ QString m_referer;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeosearchreply_nokia.cpp b/src/plugins/geoservices/nokia/qgeosearchreply_nokia.cpp
new file mode 100644
index 00000000..bc43d063
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeosearchreply_nokia.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeosearchreply_nokia.h"
+#include "qgeocodexmlparser.h"
+
+QGeoSearchReplyNokia::QGeoSearchReplyNokia(QNetworkReply *reply, int limit, int offset, QGeoBoundingArea *viewport, QObject *parent)
+ : QGeoSearchReply(parent),
+ m_reply(reply)
+{
+ connect(m_reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(networkFinished()));
+
+ connect(m_reply,
+ SIGNAL(error(QNetworkReply::NetworkError)),
+ this,
+ SLOT(networkError(QNetworkReply::NetworkError)));
+
+ setLimit(limit);
+ setOffset(offset);
+ setViewport(viewport);
+}
+
+QGeoSearchReplyNokia::~QGeoSearchReplyNokia()
+{
+ //TODO: possible mem leak -> m_reply->deleteLater() ?
+}
+
+void QGeoSearchReplyNokia::abort()
+{
+ if (!m_reply)
+ return;
+
+ m_reply->abort();
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
+
+void QGeoSearchReplyNokia::networkFinished()
+{
+ if (!m_reply)
+ return;
+
+ if (m_reply->error() != QNetworkReply::NoError) {
+ // Removed because this is already done in networkError, which previously caused _two_ errors to be raised for every error.
+ //setError(QGeoSearchReply::CommunicationError, m_reply->errorString());
+ //m_reply->deleteLater();
+ //m_reply = 0;
+ return;
+ }
+
+ QGeoCodeXmlParser parser;
+ if (parser.parse(m_reply)) {
+ QList<QGeoPlace> places = parser.results();
+ QGeoBoundingArea *bounds = viewport();
+ if (bounds) {
+ for (int i = places.size() - 1; i >= 0; --i) {
+ if (!bounds->contains(places[i].coordinate()))
+ places.removeAt(i);
+ }
+ }
+ setPlaces(places);
+ setFinished(true);
+ } else {
+ setError(QGeoSearchReply::ParseError, parser.errorString());
+ }
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
+
+void QGeoSearchReplyNokia::networkError(QNetworkReply::NetworkError error)
+{
+ Q_UNUSED(error)
+
+ if (!m_reply)
+ return;
+
+ setError(QGeoSearchReply::CommunicationError, m_reply->errorString());
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
diff --git a/src/plugins/geoservices/nokia/qgeosearchreply_nokia.h b/src/plugins/geoservices/nokia/qgeosearchreply_nokia.h
new file mode 100644
index 00000000..0e181017
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeosearchreply_nokia.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOPLACESREPLY_NOKIA_H
+#define QGEOPLACESREPLY_NOKIA_H
+
+#include <qgeosearchreply.h>
+#include <QNetworkReply>
+
+QTM_USE_NAMESPACE
+
+class QGeoSearchReplyNokia : public QGeoSearchReply
+{
+ Q_OBJECT
+public:
+ QGeoSearchReplyNokia(QNetworkReply *reply, int limit, int offset, QGeoBoundingArea *viewport, QObject *parent = 0);
+ ~QGeoSearchReplyNokia();
+
+ void abort();
+
+private slots:
+ void networkFinished();
+ void networkError(QNetworkReply::NetworkError error);
+
+private:
+ QNetworkReply *m_reply;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
new file mode 100644
index 00000000..88cdf87b
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#include "qgeoserviceproviderplugin_nokia.h"
+
+#include "qgeosearchmanagerengine_nokia.h"
+#include "qgeoroutingmanagerengine_nokia.h"
+#include "qgeomappingmanagerengine_nokia.h"
+
+#include <QtPlugin>
+#include <QNetworkProxy>
+
+QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia() {}
+
+QGeoServiceProviderFactoryNokia::~QGeoServiceProviderFactoryNokia() {}
+
+QString QGeoServiceProviderFactoryNokia::providerName() const
+{
+ return "nokia";
+}
+
+int QGeoServiceProviderFactoryNokia::providerVersion() const
+{
+ return 1;
+}
+
+QGeoSearchManagerEngine* QGeoServiceProviderFactoryNokia::createSearchManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const
+{
+ return new QGeoSearchManagerEngineNokia(parameters, error, errorString);
+}
+
+QGeoMappingManagerEngine* QGeoServiceProviderFactoryNokia::createMappingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const
+{
+ return new QGeoMappingManagerEngineNokia(parameters, error, errorString);
+}
+
+QGeoRoutingManagerEngine* QGeoServiceProviderFactoryNokia::createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const
+{
+ return new QGeoRoutingManagerEngineNokia(parameters, error, errorString);
+}
+
+const QString QGeoServiceProviderFactoryNokia::defaultToken("152022572f0e44e07489c35cd46fa246");
+const QString QGeoServiceProviderFactoryNokia::defaultReferer("qtlocationapi");
+
+Q_EXPORT_PLUGIN2(qtgeoservices_nokia, QGeoServiceProviderFactoryNokia)
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
new file mode 100644
index 00000000..d953762d
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file is part of the Ovi services plugin for the Maps and
+** Navigation API. The use of these services, whether by use of the
+** plugin or by other means, is governed by the terms and conditions
+** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+** this package, located in the directory containing the Ovi services
+** plugin source code.
+**
+****************************************************************************/
+
+#ifndef QGEOSERVICEPROVIDER_NOKIA_H
+#define QGEOSERVICEPROVIDER_NOKIA_H
+
+#include <qgeoserviceproviderfactory.h>
+#include <QObject>
+
+QTM_USE_NAMESPACE
+
+class QGeoServiceProviderFactoryNokia : public QObject, public QGeoServiceProviderFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QGeoServiceProviderFactory)
+public:
+ QGeoServiceProviderFactoryNokia();
+ ~QGeoServiceProviderFactoryNokia();
+
+ QString providerName() const;
+ int providerVersion() const;
+
+ QGeoSearchManagerEngine* createSearchManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+ QGeoMappingManagerEngine* createMappingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+ QGeoRoutingManagerEngine* createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+
+ static const QString defaultToken;
+ static const QString defaultReferer;
+};
+
+#endif
diff --git a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
new file mode 100644
index 00000000..2513d5d8
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
@@ -0,0 +1,236 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the Qt Mobility Components.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL$
+ ** No Commercial Usage
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file. Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights. These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ ** $QT_END_LICENSE$
+ **
+ ** This file is part of the Ovi services plugin for the Maps and
+ ** Navigation API. The use of these services, whether by use of the
+ ** plugin or by other means, is governed by the terms and conditions
+ ** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+ ** this package, located in the directory containing the Ovi services
+ ** plugin source code.
+ **
+ ****************************************************************************/
+
+#include "qgeotiledmapdata_nokia.h"
+#include "jsonparser.h"
+#include "qgeomappingmanagerengine_nokia.h"
+#include "qgeoboundingbox.h"
+#include "qgeocoordinate.h"
+
+#include <QNetworkAccessManager>
+#include <QNetworkProxy>
+
+QTM_USE_NAMESPACE
+
+/*!
+ Constructs a new tiled map data object, which stores the map data required by
+ \a geoMap and makes use of the functionality provided by \a engine.
+ */
+QGeoTiledMapDataNokia::QGeoTiledMapDataNokia(QGeoMappingManagerEngineNokia *engine) :
+ QGeoTiledMapData(engine),
+ watermark(":/images/watermark.png")
+{
+ m_networkManager = new QNetworkAccessManager(this);
+ connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(copyrightReplyFinished(QNetworkReply*)));
+
+ m_networkManager->get(QNetworkRequest(QUrl("http://maptile.maps.svc.ovi.com/maptiler/v2/copyright/newest")));
+}
+
+QGeoTiledMapDataNokia::~QGeoTiledMapDataNokia()
+{
+}
+
+static QGeoBoundingBox variantListToBoundingBox(const QVariantList & list) {
+ if (list.size() < 4) return QGeoBoundingBox();
+
+ qreal latTop = list[0].toReal();
+ qreal latBottom = list[2].toReal();
+ if (latTop < latBottom)
+ qSwap(latTop, latBottom);
+
+ return QGeoBoundingBox(QGeoCoordinate(latTop, list[1].toReal()), QGeoCoordinate(latBottom, list[3].toReal()));
+}
+
+void QGeoTiledMapDataNokia::copyrightReplyFinished(QNetworkReply * reply)
+{
+ if (reply->error() != QNetworkReply::NoError)
+ return;
+
+ JSONParser jp(reply->readAll());
+ QVariant root = jp.parse();
+
+ if (!root.isValid())
+ return;
+
+ copyrights.clear();
+
+ QVariantHash rootHash = root.toHash();
+
+ foreach (QString key, rootHash.keys()) {
+ QList<CopyrightDescriptor> copyrightDescriptorList;
+ foreach (QVariant copyrightSource, rootHash[key].toList()) {
+ QVariantHash copyrightSourceHash = copyrightSource.toHash();
+ CopyrightDescriptor copyrightDescriptor;
+ copyrightDescriptor.minLevel = copyrightSourceHash["minLevel"].toReal();
+ copyrightDescriptor.maxLevel = copyrightSourceHash["maxLevel"].toReal();
+ copyrightDescriptor.label = copyrightSourceHash["label"].toString();
+ copyrightDescriptor.alt = copyrightSourceHash["alt"].toString();
+
+ foreach (QVariant box, copyrightSourceHash["boxes"].toList()) {
+ copyrightDescriptor.boxes << variantListToBoundingBox(box.toList());
+ }
+
+ copyrightDescriptorList << copyrightDescriptor;
+ }
+
+ copyrights[key] = copyrightDescriptorList;
+ }
+}
+
+QString QGeoTiledMapDataNokia::getViewCopyright()
+{
+ QGeoBoundingBox viewport = this->viewport();
+
+ QString terraintype;
+
+ switch (mapType()) {
+ case QGraphicsGeoMap::StreetMap:
+ terraintype = "normal";
+ break;
+
+ case QGraphicsGeoMap::SatelliteMapDay:
+ case QGraphicsGeoMap::SatelliteMapNight:
+ terraintype = "hybrid";
+ break;
+
+ case QGraphicsGeoMap::TerrainMap:
+ terraintype = "terrain";
+ break;
+
+ default:
+ terraintype = "normal";
+ }
+
+ CopyrightDescriptor fallback;
+
+ QStringList copyrightStrings;
+ bool contained = false;
+ foreach (CopyrightDescriptor copyrightDescriptor, copyrights[terraintype]) {
+ if (zoomLevel() < copyrightDescriptor.minLevel) continue;
+ if (zoomLevel() > copyrightDescriptor.maxLevel) continue;
+
+ if (copyrightDescriptor.boxes.isEmpty()) {
+ fallback = copyrightDescriptor;
+ }
+ else {
+ foreach (QGeoBoundingBox box, copyrightDescriptor.boxes) {
+ if (box.intersects(viewport)) {
+ copyrightStrings << copyrightDescriptor.label;
+ if (box.contains(viewport)) {
+ contained = true;
+ break;
+ }
+ // TODO: consider the case where the viewport is fully contained by the combined bounding boxes, but not by one individual bounding box
+ }
+ }
+ }
+ }
+
+ if (copyrightStrings.isEmpty() || !contained) {
+ if (!fallback.label.isEmpty()) copyrightStrings << fallback.label;
+ }
+
+ copyrightStrings.removeDuplicates();
+
+ QString ret = copyrightStrings.join(", ");
+
+ return ret;
+}
+
+/*!
+ \reimp
+ */
+void QGeoTiledMapDataNokia::paintProviderNotices(QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ QRect viewport = painter->combinedTransform().inverted().mapRect(painter->viewport());
+
+ painter->drawPixmap(
+ viewport.bottomLeft()+QPoint(5,-5-watermark.height()),
+ watermark
+ );
+
+ QString copyrightText = getViewCopyright();
+
+ if (copyrightText != lastCopyrightText || lastViewport != viewport) {
+ lastCopyrightText = copyrightText;
+ lastViewport = viewport;
+
+ QRect maxBoundingRect(QPoint(viewport.left()+10+watermark.width(), viewport.top()), QPoint(viewport.right()-5, viewport.bottom()-5));
+
+ QRect textBoundingRect = painter->boundingRect(maxBoundingRect, Qt::AlignLeft | Qt::AlignBottom | Qt::TextWordWrap, copyrightText);
+ lastCopyrightRect = textBoundingRect.adjusted(-1, -1, 1, 1);
+
+ lastCopyright = QPixmap(lastCopyrightRect.size());
+ lastCopyright.fill(QColor(Qt::transparent));
+
+ {
+ QPainter painter2(&lastCopyright);
+
+ painter2.drawText(
+ QRect(QPoint(1, 2), textBoundingRect.size()),
+ Qt::TextWordWrap,
+ copyrightText
+ );
+
+ painter2.drawPixmap(QRect(QPoint(-1, -1), lastCopyrightRect.size()), lastCopyright);
+ painter2.drawPixmap(QRect(QPoint(1, -1), lastCopyrightRect.size()), lastCopyright);
+
+ painter2.setPen(QColor(Qt::white));
+ painter2.drawText(
+ QRect(QPoint(1, 1), textBoundingRect.size()),
+ Qt::TextWordWrap,
+ copyrightText
+ );
+ }
+ }
+
+ painter->drawPixmap(
+ lastCopyrightRect,
+ lastCopyright
+ );
+}
diff --git a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h
new file mode 100644
index 00000000..f35fc639
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the Qt Mobility Components.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL$
+ ** No Commercial Usage
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file. Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights. These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ ** $QT_END_LICENSE$
+ **
+ ** This file is part of the Ovi services plugin for the Maps and
+ ** Navigation API. The use of these services, whether by use of the
+ ** plugin or by other means, is governed by the terms and conditions
+ ** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
+ ** this package, located in the directory containing the Ovi services
+ ** plugin source code.
+ **
+ ****************************************************************************/
+#ifndef QGEOMAPDATA_NOKIA_H
+#define QGEOMAPDATA_NOKIA_H
+
+#include <qgeotiledmapdata.h>
+#include <QPixmap>
+#include <QNetworkReply>
+
+QTM_USE_NAMESPACE
+
+class QGeoMappingManagerEngineNokia;
+
+struct CopyrightDescriptor
+{
+ qreal maxLevel;
+ QString alt;
+ QString label;
+ qreal minLevel;
+ QList<QGeoBoundingBox> boxes;
+};
+
+class QGeoTiledMapDataNokia: public QGeoTiledMapData
+{
+Q_OBJECT
+public:
+ QGeoTiledMapDataNokia(QGeoMappingManagerEngineNokia *engine);
+ virtual ~QGeoTiledMapDataNokia();
+ void paintProviderNotices(QPainter *painter, const QStyleOptionGraphicsItem *option);
+
+ QString getViewCopyright();
+
+private:
+ Q_DISABLE_COPY(QGeoTiledMapDataNokia)
+
+ QPixmap watermark;
+
+ QPixmap lastCopyright;
+ QString lastCopyrightText;
+ QRect lastViewport;
+ QRect lastCopyrightRect;
+ QNetworkAccessManager *m_networkManager;
+
+ QHash<QString, QList<CopyrightDescriptor> > copyrights;
+
+private slots:
+ void copyrightReplyFinished(QNetworkReply*);
+};
+
+#endif // QGEOMAPDATA_NOKIA_H
diff --git a/src/plugins/geoservices/nokia/resource.qrc b/src/plugins/geoservices/nokia/resource.qrc
new file mode 100644
index 00000000..e2626c32
--- /dev/null
+++ b/src/plugins/geoservices/nokia/resource.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/images">
+ <file>watermark.png</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/geoservices/nokia/watermark.png b/src/plugins/geoservices/nokia/watermark.png
new file mode 100644
index 00000000..fe7abc3d
--- /dev/null
+++ b/src/plugins/geoservices/nokia/watermark.png
Binary files differ
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
new file mode 100644
index 00000000..94f3a9d9
--- /dev/null
+++ b/src/plugins/plugins.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += geoservices
diff --git a/src/src.pro b/src/src.pro
index a94410c9..5a61a11b 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += location
+CONFIG+=ordered
+SUBDIRS += location plugins