1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtLocation module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL3$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or later as published by the Free
28 ** Software Foundation and appearing in the file LICENSE.GPL included in
29 ** the packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 2.0 requirements will be
31 ** met: http://www.gnu.org/licenses/gpl-2.0.html.
32 **
33 ** $QT_END_LICENSE$
34 **
35 ****************************************************************************/
36 
37 #ifndef QGEOSERVICEPROVIDER_H
38 #define QGEOSERVICEPROVIDER_H
39 
40 #include <QtCore/QVariant>
41 #include <QtCore/QString>
42 #include <QtCore/QObject>
43 #include <QtLocation/qlocationglobal.h>
44 
45 QT_BEGIN_NAMESPACE
46 
47 class QLocale;
48 class QStringList;
49 class QGeoCodingManager;
50 class QGeoMappingManager;
51 class QGeoRoutingManager;
52 class QPlaceManager;
53 class QNavigationManager;
54 class QGeoCodingManagerEngine;
55 class QGeoMappingManagerEngine;
56 class QGeoRoutingManagerEngine;
57 class QPlaceManagerEngine;
58 class QNavigationManagerEngine;
59 class QGeoServiceProviderPrivate;
60 class QQmlEngine;
61 
62 class Q_LOCATION_EXPORT QGeoServiceProvider : public QObject
63 {
64     Q_OBJECT
65     Q_ENUMS(Error)
66 public:
67     enum Error {
68         NoError,
69         NotSupportedError,
70         UnknownParameterError,
71         MissingRequiredParameterError,
72         ConnectionError,
73         LoaderError
74     };
75 
76     enum RoutingFeature {
77         NoRoutingFeatures               = 0,
78         OnlineRoutingFeature            = (1<<0),
79         OfflineRoutingFeature           = (1<<1),
80         LocalizedRoutingFeature         = (1<<2),
81         RouteUpdatesFeature             = (1<<3),
82         AlternativeRoutesFeature        = (1<<4),
83         ExcludeAreasRoutingFeature      = (1<<5),
84         AnyRoutingFeatures              = ~(0)
85     };
86 
87     enum GeocodingFeature {
88         NoGeocodingFeatures             = 0,
89         OnlineGeocodingFeature          = (1<<0),
90         OfflineGeocodingFeature         = (1<<1),
91         ReverseGeocodingFeature         = (1<<2),
92         LocalizedGeocodingFeature       = (1<<3),
93         AnyGeocodingFeatures            = ~(0)
94     };
95 
96     enum MappingFeature {
97         NoMappingFeatures               = 0,
98         OnlineMappingFeature            = (1<<0),
99         OfflineMappingFeature           = (1<<1),
100         LocalizedMappingFeature         = (1<<2),
101         AnyMappingFeatures              = ~(0)
102     };
103 
104     enum PlacesFeature {
105         NoPlacesFeatures                = 0,
106         OnlinePlacesFeature             = (1<<0),
107         OfflinePlacesFeature            = (1<<1),
108         SavePlaceFeature                = (1<<2),
109         RemovePlaceFeature              = (1<<3),
110         SaveCategoryFeature             = (1<<4),
111         RemoveCategoryFeature           = (1<<5),
112         PlaceRecommendationsFeature     = (1<<6),
113         SearchSuggestionsFeature        = (1<<7),
114         LocalizedPlacesFeature          = (1<<8),
115         NotificationsFeature            = (1<<9),
116         PlaceMatchingFeature            = (1<<10),
117         AnyPlacesFeatures               = ~(0)
118     };
119 
120     enum NavigationFeature {
121         NoNavigationFeatures            = 0,
122         OnlineNavigationFeature         = (1<<0),
123         OfflineNavigationFeature        = (1<<1),
124         AnyNavigationFeatures           = ~(0)
125     };
126 
127     Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)
128     Q_FLAGS(RoutingFeatures)
129 
130     Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)
131     Q_FLAGS(GeocodingFeatures)
132 
133     Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)
134     Q_FLAGS(MappingFeatures)
135 
136     Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)
137     Q_FLAGS(PlacesFeatures)
138 
139     Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)
140     Q_FLAGS(NavigationFeatures)
141 
142     static QStringList availableServiceProviders();
143     QGeoServiceProvider(const QString &providerName,
144                         const QVariantMap &parameters = QVariantMap(),
145                         bool allowExperimental = false);
146 
147     ~QGeoServiceProvider();
148 
149     RoutingFeatures routingFeatures() const;
150     GeocodingFeatures geocodingFeatures() const;
151     MappingFeatures mappingFeatures() const;
152     PlacesFeatures placesFeatures() const;
153     NavigationFeatures navigationFeatures() const;
154 
155     QGeoCodingManager *geocodingManager() const;
156     QGeoMappingManager *mappingManager() const;
157     QGeoRoutingManager *routingManager() const;
158     QPlaceManager *placeManager() const;
159     QNavigationManager *navigationManager() const;
160 
161     Error error() const;
162     QString errorString() const;
163 
164     Error mappingError() const;
165     QString mappingErrorString() const;
166     Error geocodingError() const;
167     QString geocodingErrorString() const;
168     Error routingError() const;
169     QString routingErrorString() const;
170     Error placesError() const;
171     QString placesErrorString() const;
172     Error navigationError() const;
173     QString navigationErrorString() const;
174 
175     void setParameters(const QVariantMap &parameters);
176     void setLocale(const QLocale &locale);
177     void setAllowExperimental(bool allow);
178     void setQmlEngine(QQmlEngine *engine);
179 
180 private:
181     QGeoServiceProviderPrivate *d_ptr;
182 };
183 
184 Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoServiceProvider::RoutingFeatures)
185 Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoServiceProvider::GeocodingFeatures)
186 Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoServiceProvider::MappingFeatures)
187 Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoServiceProvider::PlacesFeatures)
188 Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoServiceProvider::NavigationFeatures)
189 
190 QT_END_NAMESPACE
191 
192 #endif
193