summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-08-06 16:22:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-22 08:48:20 +0200
commit7a53f30ee48b1073333cd40bed1ab7473e3bf1f6 (patch)
treeb29398e02900fb68d1f706e2552a86e0ba5567a2
parent23544d87a196a7306f87a09ca799baada6c45729 (diff)
downloadqtlocation-7a53f30ee48b1073333cd40bed1ab7473e3bf1f6.tar.gz
QGeoAreaMonitor becomes loadable via plugins.
The polling-based default implementation is separated out into its own plugin. Task-number: QTBUG-31960 Change-Id: Ife25f6a83dd51f32fcd9ee3bfde1ca51291c78e4 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/location/location.pro2
-rw-r--r--src/location/qgeoareamonitor.cpp67
-rw-r--r--src/location/qgeoareamonitor.h3
-rw-r--r--src/location/qgeopositioninfosource.cpp40
-rw-r--r--src/location/qgeopositioninfosourcefactory.cpp16
-rw-r--r--src/location/qgeopositioninfosourcefactory.h2
-rw-r--r--src/location/qgeosatelliteinfosource.cpp36
-rw-r--r--src/plugins/position/geoclue/plugin.json1
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp6
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.h4
-rw-r--r--src/plugins/position/gypsy/plugin.json1
-rw-r--r--src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp6
-rw-r--r--src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h4
-rw-r--r--src/plugins/position/position.pro3
-rw-r--r--src/plugins/position/positionpoll/plugin.json8
-rw-r--r--src/plugins/position/positionpoll/positionpoll.pro18
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.cpp65
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.h60
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp (renamed from src/location/qgeoareamonitor_polling.cpp)9
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.h (renamed from src/location/qgeoareamonitor_polling_p.h)13
-rw-r--r--src/plugins/position/simulator/plugin.json1
-rw-r--r--src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp6
-rw-r--r--src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.h1
-rw-r--r--tests/auto/positionplugin/plugin.cpp7
-rw-r--r--tests/auto/positionplugin/plugin.json1
-rw-r--r--tests/auto/positionplugintest/tst_positionplugin.cpp2
-rw-r--r--tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp12
27 files changed, 318 insertions, 76 deletions
diff --git a/src/location/location.pro b/src/location/location.pro
index f36fd8ff..5a053632 100644
--- a/src/location/location.pro
+++ b/src/location/location.pro
@@ -30,7 +30,6 @@ PRIVATE_HEADERS += \
qgeolocation_p.h \
qlocationutils_p.h \
qnmeapositioninfosource_p.h \
- qgeoareamonitor_polling_p.h \
qgeocoordinate_p.h \
qgeopositioninfosource_p.h
@@ -48,7 +47,6 @@ SOURCES += \
qgeosatelliteinfosource.cpp \
qlocationutils.cpp \
qnmeapositioninfosource.cpp \
- qgeoareamonitor_polling.cpp \
qgeopositioninfosourcefactory.cpp \
qlocation.cpp
diff --git a/src/location/qgeoareamonitor.cpp b/src/location/qgeoareamonitor.cpp
index 5985113d..7462e1df 100644
--- a/src/location/qgeoareamonitor.cpp
+++ b/src/location/qgeoareamonitor.cpp
@@ -38,9 +38,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qgeoareamonitor.h"
-
-#include "qgeoareamonitor_polling_p.h"
+#include <qgeoareamonitor.h>
+#include "qgeopositioninfosourcefactory.h"
+#include "qgeopositioninfosource_p.h"
/*!
\class QGeoAreaMonitor
@@ -175,14 +175,67 @@ qreal QGeoAreaMonitor::radius() const
*/
QGeoAreaMonitor *QGeoAreaMonitor::createDefaultMonitor(QObject *parent)
{
- QGeoAreaMonitorPolling *ret = NULL;
- ret = new QGeoAreaMonitorPolling(parent);
- if (ret && ret->isValid())
- return ret;
+ QList<QJsonObject> plugins = QGeoPositionInfoSourcePrivate::pluginsSorted();
+ foreach (const QJsonObject &obj, plugins) {
+ if (obj.value(QStringLiteral("Monitor")).isBool()
+ && obj.value(QStringLiteral("Monitor")).toBool())
+ {
+ QGeoPositionInfoSourcePrivate d;
+ d.metaData = obj;
+ d.loadPlugin();
+ QGeoAreaMonitor *s = 0;
+ if (d.factory)
+ s = d.factory->areaMonitor(parent);
+ return s;
+ }
+ }
+
return 0;
}
/*!
+ Creates and returns a monitor with the given \a parent,
+ by loading the plugin named \a sourceName.
+
+ Returns 0 if the plugin cannot be found.
+*/
+QGeoAreaMonitor *QGeoAreaMonitor::createMonitor(const QString &sourceName, QObject *parent)
+{
+ QHash<QString, QJsonObject> plugins = QGeoPositionInfoSourcePrivate::plugins();
+ if (plugins.contains(sourceName)) {
+ QGeoPositionInfoSourcePrivate d;
+ d.metaData = plugins.value(sourceName);
+ d.loadPlugin();
+ QGeoAreaMonitor *s = 0;
+ if (d.factory)
+ s = d.factory->areaMonitor(parent);
+ return s;
+ }
+
+ return 0;
+}
+
+/*!
+ Returns a list of available monitor plugins, including the default system
+ backend if one is available.
+*/
+QStringList QGeoAreaMonitor::availableMonitors()
+{
+ QStringList plugins;
+ QHash<QString, QJsonObject> meta = QGeoPositionInfoSourcePrivate::plugins();
+ foreach (const QString &name, meta.keys()) {
+ if (meta.value(name).value(QStringLiteral("Monitor")).isBool()
+ && meta.value(name).value(QStringLiteral("Monitor")).toBool()) {
+ plugins << name;
+ }
+ }
+
+ return plugins;
+}
+
+
+
+/*!
\fn void QGeoAreaMonitor::areaEntered(const QGeoPositionInfo &update);
Emitted when the current position has moved from a position outside the
diff --git a/src/location/qgeoareamonitor.h b/src/location/qgeoareamonitor.h
index 361ec633..62438d0b 100644
--- a/src/location/qgeoareamonitor.h
+++ b/src/location/qgeoareamonitor.h
@@ -44,6 +44,7 @@
#include <QtLocation/QGeoCoordinate>
#include <QObject>
+#include <QStringList>
QT_BEGIN_NAMESPACE
@@ -66,6 +67,8 @@ public:
qreal radius() const;
static QGeoAreaMonitor *createDefaultMonitor(QObject *parent);
+ static QGeoAreaMonitor *createMonitor(const QString& sourceName, QObject *parent);
+ static QStringList availableMonitors();
Q_SIGNALS:
void areaEntered(const QGeoPositionInfo &update);
diff --git a/src/location/qgeopositioninfosource.cpp b/src/location/qgeopositioninfosource.cpp
index 87e00b4c..15f65f46 100644
--- a/src/location/qgeopositioninfosource.cpp
+++ b/src/location/qgeopositioninfosource.cpp
@@ -273,24 +273,23 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSource::preferredPosi
*/
QGeoPositionInfoSource *QGeoPositionInfoSource::createDefaultSource(QObject *parent)
{
- QGeoPositionInfoSourcePrivate *d = new QGeoPositionInfoSourcePrivate;
-
QList<QJsonObject> plugins = QGeoPositionInfoSourcePrivate::pluginsSorted();
foreach (const QJsonObject &obj, plugins) {
if (obj.value(QStringLiteral("Position")).isBool()
- && obj.value(QStringLiteral("Position")).toBool()) {
- d->metaData = obj;
- d->loadPlugin();
- QGeoPositionInfoSource *s = d->factory->positionInfoSource(parent);
+ && obj.value(QStringLiteral("Position")).toBool())
+ {
+ QGeoPositionInfoSourcePrivate d;
+ d.metaData = obj;
+ d.loadPlugin();
+ QGeoPositionInfoSource *s = 0;
+ if (d.factory)
+ s = d.factory->positionInfoSource(parent);
if (s) {
- s->d->metaData = d->metaData;
- delete d;
+ s->d->metaData = d.metaData;
return s;
}
}
}
-
- delete d;
return 0;
}
@@ -303,20 +302,21 @@ QGeoPositionInfoSource *QGeoPositionInfoSource::createDefaultSource(QObject *par
*/
QGeoPositionInfoSource *QGeoPositionInfoSource::createSource(const QString &sourceName, QObject *parent)
{
- QGeoPositionInfoSourcePrivate *d = new QGeoPositionInfoSourcePrivate;
QHash<QString, QJsonObject> plugins = QGeoPositionInfoSourcePrivate::plugins();
- if (plugins.contains(sourceName)) {
- d->metaData = plugins.value(sourceName);
- d->loadPlugin();
- QGeoPositionInfoSource *src = d->factory->positionInfoSource(parent);
- if (src) {
- src->d->metaData = d->metaData;
- delete d;
+ if (plugins.contains(sourceName))
+ {
+ QGeoPositionInfoSourcePrivate d;
+ d.metaData = plugins.value(sourceName);
+ d.loadPlugin();
+ QGeoPositionInfoSource *src = 0;
+ if (d.factory)
+ src = d.factory->positionInfoSource(parent);
+ if (src)
+ {
+ src->d->metaData = d.metaData;
return src;
}
}
-
- delete d;
return 0;
}
diff --git a/src/location/qgeopositioninfosourcefactory.cpp b/src/location/qgeopositioninfosourcefactory.cpp
index 68cba1f7..0c0a0404 100644
--- a/src/location/qgeopositioninfosourcefactory.cpp
+++ b/src/location/qgeopositioninfosourcefactory.cpp
@@ -61,16 +61,24 @@ QT_BEGIN_NAMESPACE
\fn QGeoPositionInfoSource *QGeoPositionInfoSourceFactory::positionInfoSource(QObject *parent)
Returns a new QGeoPositionInfoSource associated with this plugin
- with parent \a parent . Can also return 0, in which case the factory
- with the next highest priority will be used instead.
+ with parent \a parent. Can also return 0, in which case the plugin
+ loader will use the factory with the next highest priority.
*/
/*!
\fn QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactory::satelliteInfoSource(QObject *parent)
Returns a new QGeoSatelliteInfoSource associated with this plugin
- with parent \a parent. Can also return 0, in which case the factory
- with the next highest priority will be used instead.
+ with parent \a parent. Can also return 0, in which case the plugin
+ loader will use the factory with the next highest priority.
+ */
+
+/*!
+ \fn QGeoAreaMonitor *QGeoPositionInfoSourceFactory::areaMonitor(QObject *parent);
+
+ Returns a new QGeoAreaMonitor associated with this plugin with parent \a parent.
+ Can also return 0, in which case the plugin loader will use the factory with the
+ next highest priority.
*/
/*!
diff --git a/src/location/qgeopositioninfosourcefactory.h b/src/location/qgeopositioninfosourcefactory.h
index 26283a97..7ddb801d 100644
--- a/src/location/qgeopositioninfosourcefactory.h
+++ b/src/location/qgeopositioninfosourcefactory.h
@@ -44,6 +44,7 @@
#include <QtLocation/QGeoPositionInfoSource>
#include <QtLocation/QGeoSatelliteInfoSource>
+#include <QtLocation/QGeoAreaMonitor>
#include <QList>
QT_BEGIN_NAMESPACE
@@ -55,6 +56,7 @@ public:
virtual QGeoPositionInfoSource *positionInfoSource(QObject *parent) = 0;
virtual QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent) = 0;
+ virtual QGeoAreaMonitor *areaMonitor(QObject *parent) = 0;
};
#define QT_POSITION_SOURCE_INTERFACE
diff --git a/src/location/qgeosatelliteinfosource.cpp b/src/location/qgeosatelliteinfosource.cpp
index a926b1c8..509d4781 100644
--- a/src/location/qgeosatelliteinfosource.cpp
+++ b/src/location/qgeosatelliteinfosource.cpp
@@ -157,23 +157,21 @@ int QGeoSatelliteInfoSource::updateInterval() const
*/
QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *parent)
{
- QGeoPositionInfoSourcePrivate *d = new QGeoPositionInfoSourcePrivate;
-
QList<QJsonObject> plugins = QGeoPositionInfoSourcePrivate::pluginsSorted();
foreach (const QJsonObject &obj, plugins) {
if (obj.value(QStringLiteral("Satellite")).isBool()
- && obj.value(QStringLiteral("Satellite")).toBool()) {
- d->metaData = obj;
- d->loadPlugin();
- QGeoSatelliteInfoSource *s = d->factory->satelliteInfoSource(parent);
- if (s) {
- delete d;
- return s;
- }
+ && obj.value(QStringLiteral("Satellite")).toBool())
+ {
+ QGeoPositionInfoSourcePrivate d;
+ d.metaData = obj;
+ d.loadPlugin();
+ QGeoSatelliteInfoSource *s = 0;
+ if (d.factory)
+ s = d.factory->satelliteInfoSource(parent);
+ return s;
}
}
- delete d;
return 0;
}
@@ -185,19 +183,17 @@ QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *p
*/
QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createSource(const QString &sourceName, QObject *parent)
{
- QGeoPositionInfoSourcePrivate *d = new QGeoPositionInfoSourcePrivate;
QHash<QString, QJsonObject> plugins = QGeoPositionInfoSourcePrivate::plugins();
if (plugins.contains(sourceName)) {
- d->metaData = plugins.value(sourceName);
- d->loadPlugin();
- QGeoSatelliteInfoSource *src = d->factory->satelliteInfoSource(parent);
- if (src) {
- delete d;
- return src;
- }
+ QGeoPositionInfoSourcePrivate d;
+ d.metaData = plugins.value(sourceName);
+ d.loadPlugin();
+ QGeoSatelliteInfoSource *src = 0;
+ if (d.factory)
+ src = d.factory->satelliteInfoSource(parent);
+ return src;
}
- delete d;
return 0;
}
diff --git a/src/plugins/position/geoclue/plugin.json b/src/plugins/position/geoclue/plugin.json
index 12970207..cac7345b 100644
--- a/src/plugins/position/geoclue/plugin.json
+++ b/src/plugins/position/geoclue/plugin.json
@@ -3,5 +3,6 @@
"Provider": "geoclue",
"Position": true,
"Satellite": false,
+ "Monitor": false,
"Priority": 1000
}
diff --git a/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp b/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp
index 48612245..5ad3dd58 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp
+++ b/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp
@@ -57,3 +57,9 @@ QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGeoclue::satelliteInfoSour
Q_UNUSED(parent);
return 0;
}
+
+QGeoAreaMonitor *QGeoPositionInfoSourceFactoryGeoclue::areaMonitor(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
diff --git a/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.h b/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.h
index 48d17801..e18c27e8 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.h
+++ b/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.h
@@ -43,8 +43,7 @@
#define QGEOPOSITIONINFOSOURCEFACTORY_GEOCLUE_H
#include <QObject>
-#include "qgeopositioninfosource.h"
-#include "qgeopositioninfosourcefactory.h"
+#include <qgeopositioninfosourcefactory.h>
class QGeoPositionInfoSourceFactoryGeoclue : public QObject, public QGeoPositionInfoSourceFactory
{
@@ -56,6 +55,7 @@ class QGeoPositionInfoSourceFactoryGeoclue : public QObject, public QGeoPosition
public:
QGeoPositionInfoSource *positionInfoSource(QObject *parent);
QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitor *areaMonitor(QObject *parent);
};
#endif
diff --git a/src/plugins/position/gypsy/plugin.json b/src/plugins/position/gypsy/plugin.json
index faa990cc..b3ecc0f7 100644
--- a/src/plugins/position/gypsy/plugin.json
+++ b/src/plugins/position/gypsy/plugin.json
@@ -3,5 +3,6 @@
"Provider": "gypsy",
"Position": false,
"Satellite": true,
+ "Monitor" : false,
"Priority": 1000
}
diff --git a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp
index bae882dd..77c8d1d7 100644
--- a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp
+++ b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp
@@ -57,3 +57,9 @@ QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGypsy::satelliteInfoSource
}
return src;
}
+
+QGeoAreaMonitor *QGeoPositionInfoSourceFactoryGypsy::areaMonitor(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
diff --git a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h
index 3f3a2259..f44d47f7 100644
--- a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h
+++ b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h
@@ -43,8 +43,7 @@
#define QGEOPOSITIONINFOSOURCEFACTORY_GYPSY_H
#include <QObject>
-#include "qgeopositioninfosource.h"
-#include "qgeopositioninfosourcefactory.h"
+#include <qgeopositioninfosourcefactory.h>
class QGeoPositionInfoSourceFactoryGypsy : public QObject, public QGeoPositionInfoSourceFactory
{
@@ -56,6 +55,7 @@ class QGeoPositionInfoSourceFactoryGypsy : public QObject, public QGeoPositionIn
public:
QGeoPositionInfoSource *positionInfoSource(QObject *parent);
QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitor *areaMonitor(QObject *parent);
};
#endif
diff --git a/src/plugins/position/position.pro b/src/plugins/position/position.pro
index d3453910..c73ba9e1 100644
--- a/src/plugins/position/position.pro
+++ b/src/plugins/position/position.pro
@@ -3,3 +3,6 @@ TEMPLATE = subdirs
config_geoclue:SUBDIRS += geoclue
config_gypsy:SUBDIRS += gypsy
simulator:SUBDIRS += simulator
+
+SUBDIRS += \
+ positionpoll
diff --git a/src/plugins/position/positionpoll/plugin.json b/src/plugins/position/positionpoll/plugin.json
new file mode 100644
index 00000000..a5b2f602
--- /dev/null
+++ b/src/plugins/position/positionpoll/plugin.json
@@ -0,0 +1,8 @@
+{
+ "Keys": ["positionpoll"],
+ "Provider": "positionpoll",
+ "Position": false,
+ "Satellite": false,
+ "Monitor": true,
+ "Priority": 1000
+}
diff --git a/src/plugins/position/positionpoll/positionpoll.pro b/src/plugins/position/positionpoll/positionpoll.pro
new file mode 100644
index 00000000..8c871947
--- /dev/null
+++ b/src/plugins/position/positionpoll/positionpoll.pro
@@ -0,0 +1,18 @@
+TARGET = qtposition_positionpoll
+QT += location gui
+
+PLUGIN_TYPE = position
+load(qt_plugin)
+
+SOURCES += \
+ qgeoareamonitor_polling.cpp \
+ positionpollfactory.cpp
+
+HEADERS += \
+ qgeoareamonitor_polling.h \
+ positionpollfactory.h
+
+INCLUDEPATH += $$QT.location.includes
+
+OTHER_FILES += \
+ plugin.json
diff --git a/src/plugins/position/positionpoll/positionpollfactory.cpp b/src/plugins/position/positionpoll/positionpollfactory.cpp
new file mode 100644
index 00000000..a35b6c1e
--- /dev/null
+++ b/src/plugins/position/positionpoll/positionpollfactory.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "positionpollfactory.h"
+#include "qgeoareamonitor_polling.h"
+
+QGeoPositionInfoSource *PositionPollFactory::positionInfoSource(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
+
+QGeoSatelliteInfoSource *PositionPollFactory::satelliteInfoSource(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
+
+QGeoAreaMonitor *PositionPollFactory::areaMonitor(QObject *parent)
+{
+ QGeoAreaMonitorPolling *ret = 0;
+ ret = new QGeoAreaMonitorPolling(parent);
+ if (ret && ret->isValid())
+ return ret;
+ delete ret;
+ return 0;
+}
diff --git a/src/plugins/position/positionpoll/positionpollfactory.h b/src/plugins/position/positionpoll/positionpollfactory.h
new file mode 100644
index 00000000..50658eb7
--- /dev/null
+++ b/src/plugins/position/positionpoll/positionpollfactory.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POSITIONPOLLFACTORY_H
+#define POSITIONPOLLFACTORY_H
+
+#include <QObject>
+#include <QGeoPositionInfoSourceFactory>
+
+class PositionPollFactory : public QObject, public QGeoPositionInfoSourceFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/5.0"
+ FILE "plugin.json")
+ Q_INTERFACES(QGeoPositionInfoSourceFactory)
+public:
+ QGeoPositionInfoSource *positionInfoSource(QObject *parent);
+ QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitor *areaMonitor(QObject *parent);
+};
+
+#endif // POSITIONPOLLFACTORY_H
diff --git a/src/location/qgeoareamonitor_polling.cpp b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
index 30a25560..5fc4794b 100644
--- a/src/location/qgeoareamonitor_polling.cpp
+++ b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
@@ -39,13 +39,11 @@
**
****************************************************************************/
-#include "qgeoareamonitor_polling_p.h"
-#include "qgeocoordinate.h"
+#include "qgeoareamonitor_polling.h"
+#include <qgeocoordinate.h>
#include <QtCore/qmetaobject.h>
-QT_BEGIN_NAMESPACE
-
#define UPDATE_INTERVAL_5S 5000
QGeoAreaMonitorPolling::QGeoAreaMonitorPolling(QObject *parent) : QGeoAreaMonitor(parent)
@@ -133,5 +131,4 @@ void QGeoAreaMonitorPolling::positionUpdated(const QGeoPositionInfo &info)
}
}
-#include "moc_qgeoareamonitor_polling_p.cpp"
-QT_END_NAMESPACE
+#include "moc_qgeoareamonitor_polling.cpp"
diff --git a/src/location/qgeoareamonitor_polling_p.h b/src/plugins/position/positionpoll/qgeoareamonitor_polling.h
index 938561b1..d798c2bf 100644
--- a/src/location/qgeoareamonitor_polling_p.h
+++ b/src/plugins/position/positionpoll/qgeoareamonitor_polling.h
@@ -42,21 +42,9 @@
#ifndef QGEOAREAMONITORPOLLING_H
#define QGEOAREAMONITORPOLLING_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
#include "qgeoareamonitor.h"
#include "qgeopositioninfosource.h"
-QT_BEGIN_NAMESPACE
/**
* QGeoAreaMonitorPolling
@@ -87,5 +75,4 @@ private:
void checkStartStop();
};
-QT_END_NAMESPACE
#endif // QGEOAREAMONITORPOLLING_H
diff --git a/src/plugins/position/simulator/plugin.json b/src/plugins/position/simulator/plugin.json
index 257640e0..8aa5e79f 100644
--- a/src/plugins/position/simulator/plugin.json
+++ b/src/plugins/position/simulator/plugin.json
@@ -3,5 +3,6 @@
"Provider": "simulator",
"Position": true,
"Satellite": true,
+ "Monitor" : false,
"Priority": 1000
}
diff --git a/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp b/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp
index 51fcb485..c8f11aae 100644
--- a/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp
+++ b/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp
@@ -55,3 +55,9 @@ QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactorySimulator::satelliteInfoSo
}
return src;
}
+
+QGeoAreaMonitor *QGeoPositionInfoSourceFactorySimulator::areaMonitor(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
diff --git a/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.h b/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.h
index 70b29019..262f9098 100644
--- a/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.h
+++ b/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.h
@@ -57,6 +57,7 @@ class QGeoPositionInfoSourceFactorySimulator : public QObject, public QGeoPositi
public:
QGeoPositionInfoSource *positionInfoSource(QObject *parent);
QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitor *areaMonitor(QObject *parent);
};
#endif // QGEOPOSITIONINFOSOURCEFACTORY_SIMULATOR_H
diff --git a/tests/auto/positionplugin/plugin.cpp b/tests/auto/positionplugin/plugin.cpp
index a18f1db8..26f8ed34 100644
--- a/tests/auto/positionplugin/plugin.cpp
+++ b/tests/auto/positionplugin/plugin.cpp
@@ -190,6 +190,7 @@ class QGeoPositionInfoSourceFactoryTest : public QObject, public QGeoPositionInf
public:
QGeoPositionInfoSource *positionInfoSource(QObject *parent);
QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitor *areaMonitor(QObject *parent);
};
QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryTest::positionInfoSource(QObject *parent)
@@ -204,4 +205,10 @@ QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryTest::satelliteInfoSource(
return 0;
}
+QGeoAreaMonitor *QGeoPositionInfoSourceFactoryTest::areaMonitor(QObject* parent)
+{
+ Q_UNUSED(parent)
+ return 0;
+}
+
#include "plugin.moc"
diff --git a/tests/auto/positionplugin/plugin.json b/tests/auto/positionplugin/plugin.json
index 147b7d40..c16b7a8d 100644
--- a/tests/auto/positionplugin/plugin.json
+++ b/tests/auto/positionplugin/plugin.json
@@ -3,5 +3,6 @@
"Provider": "test.source",
"Position": true,
"Satellite": false,
+ "Monitor": false,
"Priority": 0
}
diff --git a/tests/auto/positionplugintest/tst_positionplugin.cpp b/tests/auto/positionplugintest/tst_positionplugin.cpp
index 42e9b058..384f7a80 100644
--- a/tests/auto/positionplugintest/tst_positionplugin.cpp
+++ b/tests/auto/positionplugintest/tst_positionplugin.cpp
@@ -45,6 +45,7 @@
#include <QSignalSpy>
#include <qgeopositioninfosource.h>
#include <qgeosatelliteinfosource.h>
+#include <qgeoareamonitor.h>
#include <qgeocoordinate.h>
QT_USE_NAMESPACE
@@ -77,6 +78,7 @@ void tst_PositionPlugin::availableSources()
{
QVERIFY(QGeoPositionInfoSource::availableSources().contains("test.source"));
QVERIFY(!QGeoSatelliteInfoSource::availableSources().contains("test.source"));
+ QVERIFY(!QGeoAreaMonitor::availableMonitors().contains("test.source"));
}
void tst_PositionPlugin::create()
diff --git a/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp b/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp
index 7d2230ab..347fca19 100644
--- a/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp
+++ b/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp
@@ -140,6 +140,18 @@ private slots:
QGeoAreaMonitor* obj = QGeoAreaMonitor::createDefaultMonitor(parent);
QVERIFY(obj != 0);
delete parent;
+
+ const QStringList monitors = QGeoAreaMonitor::availableMonitors();
+ QVERIFY(!monitors.isEmpty());
+ QVERIFY(monitors.contains(QStringLiteral("positionpoll")));
+
+ parent = new QObject;
+ obj = QGeoAreaMonitor::createMonitor(QStringLiteral("positionpoll"), parent);
+ QVERIFY(obj != 0);
+ delete parent;
+
+ obj = QGeoAreaMonitor::createMonitor(QStringLiteral("randomNonExistingName"), 0);
+ QVERIFY(obj == 0);
}
//TC_ID_4_x_1