5#include <QtCore/QTimerEvent>
6#include <QtCore/QDebug>
7#include <QtCore/qdatetime.h>
8#include <QtCore/qglobal.h>
9#include <QtCore/private/qglobal_p.h>
10#include <QtCore/qtimezone.h>
11#include <QtCore/QPermission>
12#include <QtCore/QCoreApplication>
15#define MINIMUM_UPDATE_INTERVAL 1000
27 if ((self = [self
init])) {
28 m_positionInfoSource = positionInfoSource;
33- (
void)locationManagerDidChangeAuthorization: (CLLocationManager *)
manager
38 m_positionInfoSource->changeAuthorizationStatus([
manager authorizationStatus]);
41- (
void)locationManager:(CLLocationManager *)
manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
47 NSTimeInterval locationTimeStamp = [newLocation.timestamp timeIntervalSince1970];
53 newLocation.coordinate.longitude,
54 newLocation.altitude),
56 if (newLocation.horizontalAccuracy >= 0)
58 if (newLocation.verticalAccuracy >= 0)
60 if (newLocation.course >= 0) {
62 if (__builtin_available(
iOS 13.4, macOS 10.15.4, *)) {
63 if (newLocation.courseAccuracy >= 0) {
65 newLocation.courseAccuracy);
69 if (newLocation.speed >= 0)
72 m_positionInfoSource->locationDataAvailable(
location);
75- (
void)locationManager:(CLLocationManager *)
manager didFailWithError:(NSError *)
error
80 qWarning() << QString::fromNSString([
error localizedDescription]);
84 qWarning() <<
"(is Wi-Fi turned on?)";
93 m_updatesWanted(
false),
103 [m_locationManager release];
116 m_updateTimeout = msec;
118 setTimeoutInterval(m_updateTimeout);
121bool QGeoPositionInfoSourceCL::enableLocationManager()
123 if (!m_locationManager) {
124 m_locationManager = [[CLLocationManager alloc] init];
127 NSDictionary<NSString *, id> *infoDict = [[NSBundle mainBundle] infoDictionary];
128 if (
id value = [infoDict objectForKey:
@"UIBackgroundModes"]) {
129 if ([
value isKindOfClass:[NSArray class]]) {
130 NSArray *modes =
static_cast<NSArray *
>(
value);
132 if ([
@"location" isEqualToString:
mode]) {
133 m_locationManager.allowsBackgroundLocationUpdates = YES;
141 m_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
148void QGeoPositionInfoSourceCL::setTimeoutInterval(
int msec)
151 if (m_updateTimer)
killTimer(m_updateTimer);
152 if (msec > 0) m_updateTimer =
startTimer(msec);
153 else m_updateTimer = 0;
159 m_updatesWanted =
true;
160 if (enableLocationManager()) {
161 [m_locationManager startUpdatingLocation];
162 setTimeoutInterval(m_updateTimeout);
170 if (m_locationManager) {
171 [m_locationManager stopUpdatingLocation];
172 m_updatesWanted =
false;
175 setTimeoutInterval(0);
187 else if (enableLocationManager()) {
189 [m_locationManager stopUpdatingLocation];
190 [m_locationManager startUpdatingLocation];
200 if (status == kCLAuthorizationStatusAuthorizedAlways
201 || status == kCLAuthorizationStatusAuthorizedWhenInUse
203 if (status == kCLAuthorizationStatusAuthorized
214 if (
event->timerId() == m_updateTimer) {
218 setTimeoutInterval(0);
221 if (!m_updatesWanted)
244 if (!m_updatesWanted)
247 else setTimeoutInterval(m_updateTimeout);
252 Q_UNUSED(fromSatellitePositioningMethodsOnly);
259 return m_positionError;
264 m_positionError = positionError;
271#include "moc_qgeopositioninfosource_cl_p.cpp"
\inmodule QtCore\reentrant
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
QGeoPositionInfoSourceCL(QObject *parent=0)
void setUpdateInterval(int msec) override
void requestUpdate(int timeout=0) override
void startUpdates() override
void locationDataAvailable(QGeoPositionInfo location)
int minimumUpdateInterval() const override
Error error() const override
Returns the type of error that last occurred.
QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly=false) const override
Returns an update containing the last known position, or a null update if none is available.
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void changeAuthorizationStatus(CLAuthorizationStatus status)
PositioningMethods supportedPositioningMethods() const override
Returns the positioning methods available to this source.
void stopUpdates() override
void setError(QGeoPositionInfoSource::Error positionError)
~QGeoPositionInfoSourceCL()
void positionUpdated(const QGeoPositionInfo &update)
If startUpdates() or requestUpdate() is called, this signal is emitted when an update becomes availab...
void errorOccurred(QGeoPositionInfoSource::Error)
This signal is emitted after an error occurred.
Error
The Error enumeration represents the errors which can occur.
virtual void setUpdateInterval(int msec)
Access the user's location.
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
void killTimer(int id)
Kills the timer with timer identifier, id.
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
qint64 qRound64(qfloat16 d) noexcept
#define MINIMUM_UPDATE_INTERVAL
GLbitfield GLuint64 timeout
[4]
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
QNetworkAccessManager manager
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent