1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 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 #include <QtLocation/private/qmapiconobject_p.h>
38 #include <QtLocation/private/qmapobjectview_p.h>
39 #include <QtLocation/private/qmaprouteobject_p.h>
40 #include <QtLocation/private/qmapcircleobject_p.h>
41 #include <QtLocation/private/qmappolygonobject_p.h>
42 #include <QtLocation/private/qmappolylineobject_p.h>
43 #include <QtLocation/private/qdeclarativenavigator_p.h>
44 #include <QtLocation/private/qdeclarativenavigator_p_p.h>
45 #include <QtLocation/private/qnavigationmanagerengine_p.h>
46 #include <QtQml/qqmlextensionplugin.h>
47 #include <QtQml/qqml.h>
48 #include <QtCore/QDebug>
49 #include "locationlabssingleton_p.h"
50 
51 QT_BEGIN_NAMESPACE
52 
singleton_type_factory(QQmlEngine * engine,QJSEngine * jsEngine)53 static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine)
54 {
55     Q_UNUSED(engine)
56     Q_UNUSED(jsEngine)
57 
58     return new LocationLabsSingleton;
59 }
60 
61 class QtLocationLabsDeclarativeModule: public QQmlExtensionPlugin
62 {
63     Q_OBJECT
64 
65     Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid
66                       FILE "plugin.json")
67 
68 public:
QtLocationLabsDeclarativeModule(QObject * parent=nullptr)69     QtLocationLabsDeclarativeModule(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
registerTypes(const char * uri)70     virtual void registerTypes(const char *uri)
71     {
72         if (QLatin1String(uri) == QLatin1String("Qt.labs.location")) {
73 
74             // @uri QtLocationLabs
75             int major = 1;
76             int minor = 0;
77 
78             // Register the 1.0 labs types
79             qmlRegisterType<QMapIconObject>(uri, major, minor, "MapIconObject");
80             qmlRegisterType<QMapObjectView>(uri, major, minor, "MapObjectView");
81             qmlRegisterType<QMapRouteObject>(uri, major, minor, "MapRouteObject");
82             qmlRegisterType<QMapCircleObject>(uri, major, minor, "MapCircleObject");
83             qmlRegisterType<QMapPolygonObject>(uri, major, minor, "MapPolygonObject");
84             qmlRegisterType<QMapPolylineObject>(uri, major, minor, "MapPolylineObject");
85             qmlRegisterAnonymousType<QDeclarativeNavigationBasicDirections>(uri, major);
86             qmlRegisterType<QDeclarativeNavigator>(uri, major, minor, "Navigator");
87             qmlRegisterAnonymousType<QAbstractNavigator>(uri, major);
88             qmlRegisterSingletonType<LocationLabsSingleton>(uri, major, minor, "QtLocationLabs", singleton_type_factory);
89         } else {
90             qDebug() << "Unsupported URI given to load location QML plugin: " << QLatin1String(uri);
91         }
92     }
93 };
94 
95 QT_END_NAMESPACE
96 
97 #include "locationlabs.moc"
98