diff options
author | Alex <qt-info@nokia.com> | 2011-05-11 13:38:16 +1000 |
---|---|---|
committer | Alex <qt-info@nokia.com> | 2011-05-11 13:38:16 +1000 |
commit | 312dd340f91c1007379ddae47825ec0d4ddf5437 (patch) | |
tree | db2ef25d90e81e04a962b012a6c669db440e94fa | |
parent | e4a26fca13a12398ddf3e7d5da09852f2181357f (diff) | |
download | qtlocation-312dd340f91c1007379ddae47825ec0d4ddf5437.tar.gz |
Remove WinCE and Freemantle support
-rw-r--r-- | src/location/liblocationwrapper.cpp | 377 | ||||
-rw-r--r-- | src/location/liblocationwrapper_p.h | 121 | ||||
-rw-r--r-- | src/location/location.pro | 27 | ||||
-rw-r--r-- | src/location/qgeoinfothread_wince.cpp | 409 | ||||
-rw-r--r-- | src/location/qgeoinfothread_wince_p.h | 151 | ||||
-rw-r--r-- | src/location/qgeopositioninfosource_maemo5.cpp | 369 | ||||
-rw-r--r-- | src/location/qgeopositioninfosource_maemo5_p.h | 129 | ||||
-rw-r--r-- | src/location/qgeopositioninfosource_wince.cpp | 179 | ||||
-rw-r--r-- | src/location/qgeopositioninfosource_wince_p.h | 104 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_maemo5.cpp | 245 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_maemo5_p.h | 119 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_wince.cpp | 169 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_wince_p.h | 98 |
13 files changed, 1 insertions, 2496 deletions
diff --git a/src/location/liblocationwrapper.cpp b/src/location/liblocationwrapper.cpp deleted file mode 100644 index fbb4f9fc..00000000 --- a/src/location/liblocationwrapper.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "liblocationwrapper_p.h" - -#include <QDateTime> - -using namespace std; - -QTM_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(LiblocationWrapper, LocationEngine) - -LiblocationWrapper *LiblocationWrapper::instance() -{ - return LocationEngine(); -} - -LiblocationWrapper::LiblocationWrapper() - : file(NULL), - locationControl(NULL), - locationDevice(NULL), - errorHandlerId(0), - posChangedId(0), - origUpdateInterval(0), - startcounter(0), - validLastUpdate(false), - validLastSatUpdate(false), - locationState(LiblocationWrapper::Undefined) {} - -LiblocationWrapper::~LiblocationWrapper() -{ - if (locationDevice) - g_object_unref(locationDevice); - if (locationControl) - g_object_unref(locationControl); -} - -bool LiblocationWrapper::inited() -{ - int retval = false; - if (!(locationState & LiblocationWrapper::Inited)) { - g_type_init(); - - locationControl = location_gpsd_control_get_default(); - - if (locationControl) { - g_object_set(G_OBJECT(locationControl), - "preferred-method", LOCATION_METHOD_USER_SELECTED, - "preferred-interval", LOCATION_INTERVAL_1S, - NULL); - locationDevice = - (LocationGPSDevice*)g_object_new(LOCATION_TYPE_GPS_DEVICE, - NULL); - - if (locationDevice) { - errorHandlerId = - g_signal_connect(G_OBJECT(locationControl), "error-verbose", - G_CALLBACK(&locationError), - static_cast<void*>(this)); - posChangedId = - g_signal_connect(G_OBJECT(locationDevice), "changed", - G_CALLBACK(&locationChanged), - static_cast<void*>(this)); - locationState = LiblocationWrapper::Inited; - retval = true; - startcounter = 0; - } - } - } else { - retval = true; - } - return retval; -} - -void LiblocationWrapper::locationError(LocationGPSDevice *device, - gint errorCode, gpointer data) -{ - Q_UNUSED(device); - QString locationError; - - switch (errorCode) { - case LOCATION_ERROR_USER_REJECTED_DIALOG: - locationError = "User didn't enable requested methods"; - break; - case LOCATION_ERROR_USER_REJECTED_SETTINGS: - locationError = "User changed settings, which disabled location."; - break; - case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE: - locationError = "Problems with BT GPS"; - break; - case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE: - locationError = "Requested method is not allowed in offline mode"; - break; - case LOCATION_ERROR_SYSTEM: - locationError = "System error."; - break; - default: - locationError = "Unknown error."; - } - - qDebug() << "Location error:" << locationError; - - LiblocationWrapper *object; - object = (LiblocationWrapper *)data; - emit object->error(); -} - -void LiblocationWrapper::locationChanged(LocationGPSDevice *device, - gpointer data) -{ - QGeoPositionInfo posInfo; - QGeoCoordinate coordinate; - QGeoSatelliteInfo satInfo; - int satellitesInUseCount = 0; - LiblocationWrapper *object; - - if (!data || !device) { - return; - } - - object = (LiblocationWrapper *)data; - - if (device) { - if (device->fix) { - if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) { - posInfo.setTimestamp(QDateTime::fromTime_t(device->fix->time)); - } - - if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) { - coordinate.setLatitude(device->fix->latitude); - coordinate.setLongitude(device->fix->longitude); - posInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy, - device->fix->eph / 100.0); - posInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, - device->fix->epv); - } - - if (device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET) { - coordinate.setAltitude(device->fix->altitude); - } - - if (device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) { - posInfo.setAttribute(QGeoPositionInfo::GroundSpeed, - device->fix->speed / 3.6); - } - - if (device->fix->fields & LOCATION_GPS_DEVICE_CLIMB_SET) { - posInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, - device->fix->climb); - } - - if (device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET) { - posInfo.setAttribute(QGeoPositionInfo::Direction, - device->fix->track); - } - } - - if (device->satellites_in_view) { - QList<QGeoSatelliteInfo> satsInView; - QList<QGeoSatelliteInfo> satsInUse; - unsigned int i; - for (i = 0;i < device->satellites->len;i++) { - LocationGPSDeviceSatellite *satData = - (LocationGPSDeviceSatellite *)g_ptr_array_index(device->satellites, - i); - satInfo.setSignalStrength(satData->signal_strength); - satInfo.setPrnNumber(satData->prn); - satInfo.setAttribute(QGeoSatelliteInfo::Elevation, - satData->elevation); - satInfo.setAttribute(QGeoSatelliteInfo::Azimuth, - satData->azimuth); - - satsInView.append(satInfo); - if (satData->in_use) { - satellitesInUseCount++; - satsInUse.append(satInfo); - } - } - - if (!satsInView.isEmpty()) - object->satellitesInViewUpdated(satsInView); - - if (!satsInUse.isEmpty()) - object->satellitesInUseUpdated(satsInUse); - } - } - - posInfo.setCoordinate(coordinate); - - emit object->positionUpdated(posInfo); -} - -QGeoPositionInfo LiblocationWrapper::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const -{ - QGeoPositionInfo posInfo; - QGeoCoordinate coordinate; - double time; - double latitude; - double longitude; - double altitude; - double speed; - double track; - double climb; - - GConfItem lastKnownPositionTime("/system/nokia/location/lastknown/time"); - GConfItem lastKnownPositionLatitude("/system/nokia/location/lastknown/latitude"); - GConfItem lastKnownPositionLongitude("/system/nokia/location/lastknown/longitude"); - GConfItem lastKnownPositionAltitude("/system/nokia/location/lastknown/altitude"); - GConfItem lastKnownPositionSpeed("/system/nokia/location/lastknown/speed"); - GConfItem lastKnownPositionTrack("/system/nokia/location/lastknown/track"); - GConfItem lastKnownPositionClimb("/system/nokia/location/lastknown/climb"); - - if (validLastSatUpdate) - return lastSatUpdate; - - if (!fromSatellitePositioningMethodsOnly) - if (validLastUpdate) - return lastUpdate; - - time = lastKnownPositionTime.value().toDouble(); - latitude = lastKnownPositionLatitude.value().toDouble(); - longitude = lastKnownPositionLongitude.value().toDouble(); - altitude = lastKnownPositionAltitude.value().toDouble(); - speed = lastKnownPositionSpeed.value().toDouble(); - track = lastKnownPositionTrack.value().toDouble(); - climb = lastKnownPositionClimb.value().toDouble(); - - if (longitude && latitude) { - coordinate.setLongitude(longitude); - coordinate.setLatitude(latitude); - if (altitude) { - coordinate.setAltitude(altitude); - } - posInfo.setCoordinate(coordinate); - } - - if (speed) { - posInfo.setAttribute(QGeoPositionInfo::GroundSpeed, speed); - } - - if (track) { - posInfo.setAttribute(QGeoPositionInfo::Direction, track); - } - - if (climb) { - posInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, climb); - } - - // Only positions with time (3D) are provided. - if (time) { - posInfo.setTimestamp(QDateTime::fromTime_t(time)); - return posInfo; - } - - return QGeoPositionInfo(); -} - -void LiblocationWrapper::satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites) -{ - satsInView = satellites; -} - -void LiblocationWrapper::satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites) -{ - satsInUse = satellites; -} - -QList<QGeoSatelliteInfo> LiblocationWrapper::satellitesInView() -{ - return satsInView; -} - -QList<QGeoSatelliteInfo> LiblocationWrapper::satellitesInUse() -{ - return satsInUse; -} - -void LiblocationWrapper::start() { - startcounter++; - - if ((locationState & LiblocationWrapper::Inited) && - !(locationState & LiblocationWrapper::Started)) { - if (!errorHandlerId) { - errorHandlerId = - g_signal_connect(G_OBJECT(locationControl), "error-verbose", - G_CALLBACK(&locationError), - static_cast<void*>(this)); - } - - if (!posChangedId) { - posChangedId = - g_signal_connect(G_OBJECT(locationDevice), "changed", - G_CALLBACK(&locationChanged), - static_cast<void*>(this)); - } - - location_gpsd_control_start(locationControl); - - locationState |= LiblocationWrapper::Started; - locationState &= ~LiblocationWrapper::Stopped; - } -} - -void LiblocationWrapper::stop() { - startcounter--; - - if (startcounter > 0) - return; - - if ((locationState & (LiblocationWrapper::Started | - LiblocationWrapper::Inited)) && - !(locationState & LiblocationWrapper::Stopped)) { - if (errorHandlerId) - g_signal_handler_disconnect(G_OBJECT(locationControl), - errorHandlerId); - if (posChangedId) - g_signal_handler_disconnect(G_OBJECT(locationDevice), - posChangedId); - errorHandlerId = 0; - posChangedId = 0; - startcounter = 0; - location_gpsd_control_stop(locationControl); - - locationState &= ~LiblocationWrapper::Started; - locationState |= LiblocationWrapper::Stopped; - } -} - -bool LiblocationWrapper::isActive() { - if (locationState & LiblocationWrapper::Started) - return true; - else - return false; -} - -#include "moc_liblocationwrapper_p.cpp" -QTM_END_NAMESPACE - diff --git a/src/location/liblocationwrapper_p.h b/src/location/liblocationwrapper_p.h deleted file mode 100644 index e5d5d9c2..00000000 --- a/src/location/liblocationwrapper_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef LIBLOCATIONWRAPPER_H -#define LIBLOCATINWRAPPER_H - -// INCLUDES -#include <QDebug> -#include <QFile> - -#include "qgeocoordinate.h" -#include "qgeopositioninfo.h" -#include "qgeosatelliteinfo.h" - -#include "gconfitem_p.h" - -extern "C" { - #include <glib.h> - #include <location/location-gpsd-control.h> - #include <location/location-gps-device.h> - #include <location/location-misc.h> - #include <location/location-distance-utils.h> -} - -QTM_BEGIN_NAMESPACE - -class LiblocationWrapper : public QObject -{ - Q_OBJECT - -public: - static LiblocationWrapper *instance(); - LiblocationWrapper(); - ~LiblocationWrapper(); - - void start(); - void stop(); - QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const; - bool inited(); - bool isActive(); - QList<QGeoSatelliteInfo> satellitesInView(); - QList<QGeoSatelliteInfo> satellitesInUse(); - -private: - QFile *file; - LocationGPSDControl *locationControl; - LocationGPSDevice *locationDevice; - - static void locationError(LocationGPSDevice *device, gint code, gpointer data); - static void locationChanged(LocationGPSDevice *device, gpointer data); - - int errorHandlerId; - int posChangedId; - int origUpdateInterval; - int startcounter; - QGeoPositionInfo lastUpdate; - QGeoPositionInfo lastSatUpdate; - bool validLastUpdate; - bool validLastSatUpdate; - bool fromSatellite; - - void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites); - void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites); - QList<QGeoSatelliteInfo> satsInView; - QList<QGeoSatelliteInfo> satsInUse; - - enum LocationState { - Undefined = 0, - Inited = 1, - Started = 2, - Stopped = 4, - RequestActive = 8, - RequestSingleShot = 16 - }; - int locationState; - -signals: - void positionUpdated(const QGeoPositionInfo &position); - void error(); -}; - -QTM_END_NAMESPACE -#endif // LIBLOCATIONWRAPPER_H diff --git a/src/location/location.pro b/src/location/location.pro index ee53bdb8..b4aec374 100644 --- a/src/location/location.pro +++ b/src/location/location.pro @@ -12,9 +12,6 @@ DEFINES += QT_BUILD_LOCATION_LIB QT_MAKEDLL include($$QT_SOURCE_TREE/src/qbase.pri) -INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE -#INCLUDEPATH += . -#DEPENDPATH += . include(landmarks/landmarks.pri) include(maps/maps.pri) @@ -82,15 +79,6 @@ symbian { } } -wince* { - PRIVATE_HEADERS += qgeopositioninfosource_wince_p.h \ - qgeosatelliteinfosource_wince_p.h \ - qgeoinfothread_wince_p.h - SOURCES += qgeopositioninfosource_wince.cpp \ - qgeosatelliteinfosource_wince.cpp \ - qgeoinfothread_wince.cpp - LIBS += -lgpsapi -} maemo6|meego { CONFIG += qdbus link_pkgconfig @@ -104,20 +92,6 @@ maemo6|meego { dbusserver_maemo_p.h } -maemo5 { - CONFIG += qdbus link_pkgconfig - SOURCES += gconfitem.cpp \ - liblocationwrapper.cpp \ - qgeopositioninfosource_maemo5.cpp \ - qgeosatelliteinfosource_maemo5.cpp - HEADERS += gconfitem_p.h \ - liblocationwrapper_p.h \ - qgeopositioninfosource_maemo5_p.h \ - qgeosatelliteinfosource_maemo5_p.h - PKGCONFIG += glib-2.0 gconf-2.0 - LIBS += -llocation - QMAKE_PKGCONFIG_REQUIRES = glib-2.0 gconf-2.0 -} meego { contains (geoclue-master_enabled, yes) { @@ -168,6 +142,7 @@ SOURCES += \ qgeopositioninfosourcefactory.cpp symbian { + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE TARGET.CAPABILITY = ALL -TCB TARGET.UID3 = 0x2002AC83 diff --git a/src/location/qgeoinfothread_wince.cpp b/src/location/qgeoinfothread_wince.cpp deleted file mode 100644 index 84bf3ef2..00000000 --- a/src/location/qgeoinfothread_wince.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include <QMetaType> - -#include "qgeoinfothread_wince_p.h" - -Q_DECLARE_METATYPE(GPS_POSITION); - -QTM_BEGIN_NAMESPACE - -// ========== QGeoInfoValidator ========== - -QGeoInfoValidator::QGeoInfoValidator() {} - -QGeoInfoValidator::~QGeoInfoValidator() {} - -// ========== QGeoInfoThreadWinCE ========== - - -// This QGeoInfoThreadWinCE instance takes ownership of the validator, and must delete it before -// it is destructed. -QGeoInfoThreadWinCE::QGeoInfoThreadWinCE(QGeoInfoValidator *validator, bool timeoutsForPeriodicUpdates, QObject *parent) - : QThread(parent), - validator(validator), - timeoutsForPeriodicUpdates(timeoutsForPeriodicUpdates), - requestScheduled(false), - requestInterval(0), - updatesScheduled(false), - updatesInterval(0), - stopping(false), - hasLastPosition(false), - invalidDataReceived(false), - updateTimeoutTriggered(false) -{ - qRegisterMetaType<GPS_POSITION>(); - m_newDataEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - m_gpsStateChange = CreateEvent(NULL, FALSE, FALSE, NULL); - m_wakeUpEvent = CreateEvent(NULL, FALSE, FALSE, NULL); -} - -QGeoInfoThreadWinCE::~QGeoInfoThreadWinCE() -{ - // Let/make the thread finish... - - mutex.lock(); - - updatesScheduled = false; - requestScheduled = false; - stopping = true; - - mutex.unlock(); - - wakeUp(); - - wait(); - - // ...then clean up. - - delete validator; - - CloseHandle(m_newDataEvent); - CloseHandle(m_gpsStateChange); - CloseHandle(m_wakeUpEvent); -} - -// TODO - just need to add the WinCE line from QTime::currentTime to QDateTime::currentDateTime -// and we can scrap this method -QDateTime QGeoInfoThreadWinCE::currentDateTime() -{ - QDate d = QDate::currentDate(); - QTime t = QTime::currentTime(); - - // just in case we past midnight in between the last two calls - if (d != QDate::currentDate()) { - d = QDate::currentDate(); - t = QTime::currentTime(); - } - - return QDateTime(d, t); -} - -int QGeoInfoThreadWinCE::msecsTo(QDateTime from, QDateTime to) -{ - int MSECS_PER_DAY = 86400000; - return (from.date().daysTo(to.date()) * MSECS_PER_DAY) + from.time().msecsTo(to.time()); -} - -void QGeoInfoThreadWinCE::requestUpdate(int timeout) -{ - QMutexLocker locker(&mutex); - - if (!requestScheduled) { - requestScheduled = true; - - if (timeout == 0) - timeout = DefaultRequestTimeout; - - requestInterval = timeout; - requestNextTime = currentDateTime().addMSecs(requestInterval); - - locker.unlock(); - wakeUp(); - } -} - -void QGeoInfoThreadWinCE::startUpdates() -{ - QMutexLocker locker(&mutex); - if (!updatesScheduled) { - updatesScheduled = true; - updateTimeoutTriggered = false; - hasLastPosition = false; - - if (updatesInterval != 0) - updatesNextTime = currentDateTime().addMSecs(updatesInterval); - - locker.unlock(); - wakeUp(); - } -} - -void QGeoInfoThreadWinCE::stopUpdates() -{ - QMutexLocker locker(&mutex); - if (updatesScheduled) { - updatesScheduled = false; - locker.unlock(); - wakeUp(); - } -} - -void QGeoInfoThreadWinCE::setUpdateInterval(int interval) -{ - QMutexLocker locker(&mutex); - - if (interval == updatesInterval) - return; - - int oldInterval = updatesInterval; - updatesInterval = interval; - - if (updatesScheduled) { - QDateTime now = currentDateTime(); - - // The periodic update interval has been changed and updates are still ocurring. - - if (oldInterval != 0) { - if (updatesInterval != 0) { - // If we are changing fixed intervals we update the scheduled time for the next - // periodic update, making sure that it is scheduled in the future. - updatesNextTime = updatesNextTime.addMSecs(updatesInterval - oldInterval); - while (msecsTo(now, updatesNextTime) < 0) - updatesNextTime = updatesNextTime.addMSecs(updatesInterval); - } else { - // If we now want to emit updates as the data arrives we invalidate the scheduled - // time for the next update, just to be on the safe side. - updatesNextTime = now; - } - } else { - // If we were previously emitting updates as the data arrived we set the scheduled time - // for the next periodic update. - updatesNextTime = now.addMSecs(updatesInterval); - } - - locker.unlock(); - wakeUp(); - } -} - -void QGeoInfoThreadWinCE::wakeUp() -{ - SetEvent(m_wakeUpEvent); - statusUpdated.wakeAll(); -} - -// We try to keep the GPS turned off as much as we can to preserve battery life. -// When run() is called we turn on the GPS device and we leave it on -// until the request is satisfied or periodic updates are stopped. -// The methods requestUpdate() and startUpdates() will call start() if required. -void QGeoInfoThreadWinCE::run() -{ - mutex.lock(); - gpsReachedOnState = false; - m_gps = NULL; - - const int handleCount = 3; - HANDLE handles[handleCount] = { m_newDataEvent, m_gpsStateChange, m_wakeUpEvent }; - - if (updatesScheduled || requestScheduled) { - m_gps = GPSOpenDevice(m_newDataEvent, m_gpsStateChange, NULL, 0); - } - - while (true) { - - if (stopping) - break; - - if (!updatesScheduled && !requestScheduled) { - if (m_gps != NULL) { - GPSCloseDevice(m_gps); - m_gps = NULL; - } - statusUpdated.wait(&mutex); - if (updatesScheduled || requestScheduled) { - gpsReachedOnState = false; - m_gps = GPSOpenDevice(m_newDataEvent, m_gpsStateChange, NULL, 0); - } - } - - // If the periodic update is 0 then updates are returned as available. - // If this is not the case then the next timeout will be set for whichever of - // the request and periodic updates that is due next. - - // We cap the amount of time we spend waiting for updates. - DWORD timeout = MaximumMainLoopWaitTime; - - QDateTime now = currentDateTime(); - - if (requestScheduled) { - if (!updatesScheduled || (updatesInterval == 0) - || (msecsTo(requestNextTime, updatesNextTime) >= 0)) { - timeout = msecsTo(now, requestNextTime) + 100; - } else { - if (updatesInterval != 0) - timeout = msecsTo(now, updatesNextTime) + 100; - } - } else { - // updatesScheduled has to be true or we wouldn't still be in the larger while loop. - if (updatesInterval != 0) - timeout = msecsTo(now, updatesNextTime) + 100; - } - - if (timeout > MaximumMainLoopWaitTime) - timeout = MaximumMainLoopWaitTime; - - mutex.unlock(); - DWORD dwRet = WaitForMultipleObjects(handleCount, handles, FALSE, timeout); - mutex.lock(); - - // The GPS data has been updated. - if (dwRet == WAIT_OBJECT_0) { - // The other options are: - // dwRet == WAIT_OBJECT_0 + 1 - // => The GPS state has been updated. - // dwRet == WAIT_OBJECT_0 + 2 - // => We called QGeoInfoThreadWinCE::wakeUp(). - // dwRet == WAIT_TIMEOUT - // => WaitForMultipleObjects() timed out. - - GPS_POSITION posn; - posn.dwVersion = GPS_VERSION_1; - posn.dwSize = sizeof(posn); - - dwRet = GPSGetPosition(m_gps, &posn, timeout, 0); - - if (dwRet == ERROR_SUCCESS) { - if (!validator->valid(posn)) { - invalidDataReceived = true; - } else { - m_lastPosition = posn; - hasLastPosition = true; - updateTimeoutTriggered = false; - - // A request and a periodic update could both be satisfied at once. - // We use this flag to prevent a double update. - bool emitDataUpdated = false; - - // If a request is in process we emit the dataUpdated signal. - if (requestScheduled) { - emitDataUpdated = true; - requestScheduled = false; - } - - // If we are updating as data becomes available or if the update period has elapsed - // we emit the dataUpdated signal. - if (updatesScheduled) { - QDateTime now = currentDateTime(); - if (updatesInterval == 0) { - emitDataUpdated = true; - } else if (msecsTo(now, updatesNextTime) < 0) { - while (msecsTo(now, updatesNextTime) < 0) - updatesNextTime = updatesNextTime.addMSecs(updatesInterval); - emitDataUpdated = true; - } - } - - if (emitDataUpdated) { - hasLastPosition = false; - mutex.unlock(); - emit dataUpdated(m_lastPosition); - mutex.lock(); - } - } - } - } - if (dwRet != WAIT_OBJECT_0 || invalidDataReceived) { - invalidDataReceived = false; - - // Third party apps may have the ability to turn off the gps hardware independently of - // the Microsoft GPS API. - // This checks for an unexpected power down and turns the hardware back on. - - // The GPS state has been updated. - - if (dwRet == WAIT_OBJECT_0 + 1) { - GPS_DEVICE device; - device.dwVersion = GPS_VERSION_1; - device.dwSize = sizeof(device); - - dwRet = GPSGetDeviceState(&device); - - if (device.dwDeviceState == SERVICE_STATE_ON) { - gpsReachedOnState = true; - } else if ((device.dwDeviceState == SERVICE_STATE_OFF) && gpsReachedOnState) { - // We do not want to mess with devices that are slow starting up, so we only - // turn on devices that have previously reached the "On" state. - gpsReachedOnState = false; - m_gps = GPSOpenDevice(m_newDataEvent, m_gpsStateChange, NULL, 0); - } - } - - // We reach this point if the gps state has changed, if the wake up event has been - // triggered, if we received data we were not interested in from the GPS, - // or if a timeout occurred while waiting for gps data. - // - // In all of these cases we should check for request and periodic update timeouts. - - QDateTime now = currentDateTime(); - - bool emitUpdateTimeout = false; - - // Check for request timeouts. - if (requestScheduled && msecsTo(now, requestNextTime) < 0) { - requestScheduled = false; - emitUpdateTimeout = true; - } - - // Check to see if a periodic update is due. - if (updatesScheduled && updatesInterval != 0 && (msecsTo(now, updatesNextTime) < 0)) { - while (msecsTo(now, updatesNextTime) < 0) - updatesNextTime = updatesNextTime.addMSecs(updatesInterval); - if (hasLastPosition) { - hasLastPosition = false; - mutex.unlock(); - emit dataUpdated(m_lastPosition); - mutex.lock(); - } else { - if (timeoutsForPeriodicUpdates && !updateTimeoutTriggered) { - updateTimeoutTriggered = true; - emitUpdateTimeout = true; - } - } - } - - if (emitUpdateTimeout) { - mutex.unlock(); - emit updateTimeout(); - mutex.lock(); - } - } - } - - if (m_gps != NULL) - GPSCloseDevice(m_gps); - - mutex.unlock(); -} - -#include "moc_qgeoinfothread_wince_p.cpp" -QTM_END_NAMESPACE diff --git a/src/location/qgeoinfothread_wince_p.h b/src/location/qgeoinfothread_wince_p.h deleted file mode 100644 index 49f1b76b..00000000 --- a/src/location/qgeoinfothread_wince_p.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QGEOINFOTHREAD_WINCE_P_H -#define QGEOINFOTHREAD_WINCE_P_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 "qmobilityglobal.h" - -#include <QThread> -#include <QMutex> -#include <QWaitCondition> -#include <QDateTime> - -#include <windows.h> - -// including requires <windows.h> -#include <gpsapi.h> - -// including requires <windows.h> -// included here rather than in the cpp file to make sure it is included after <windows.h> -#include <service.h> // used for SERVICE_STATE_ constants - -QTM_BEGIN_NAMESPACE - -// Used to determine if the dataUpdated signal should be emitted by a QGeoInfoThreadWinCE instance. -// If valid() returns false the QGeoInfoThreadWinCE instance will ignore the data. -// This is subclassed in order to filter for valid position or satellite data in GPS_POSITION -// structs. -class QGeoInfoValidator -{ -public: - QGeoInfoValidator(); - virtual ~QGeoInfoValidator(); - virtual bool valid(const GPS_POSITION &data) const = 0; -}; - -class QGeoInfoThreadWinCE : public QThread -{ - Q_OBJECT - -public: - enum { - // The default timeout for requests if none is specified. - DefaultRequestTimeout = 10000, - // The maximum time to spend waiting for GPS events in the main loop of the thread. - MaximumMainLoopWaitTime = 5000 - }; - - QGeoInfoThreadWinCE(QGeoInfoValidator *validator, bool timeoutsForPeriodicUpdates, QObject *parent = 0); - ~QGeoInfoThreadWinCE(); - -//public slots: - void requestUpdate(int timeout = 5000); - void startUpdates(); - void stopUpdates(); - void setUpdateInterval(int updateInterval); - -signals: - void dataUpdated(GPS_POSITION data); - void updateTimeout(); - -protected: - void run(); - -private: - void wakeUp(); - - QDateTime currentDateTime(); - int msecsTo(QDateTime from, QDateTime to); - - QGeoInfoValidator *validator; - bool timeoutsForPeriodicUpdates; - - bool requestScheduled; - qint32 requestInterval; - QDateTime requestNextTime; - - bool updatesScheduled; - qint32 updatesInterval; - QDateTime updatesNextTime; - - bool stopping; - - bool gpsReachedOnState; - - bool hasLastPosition; - bool invalidDataReceived; - bool updateTimeoutTriggered; - GPS_POSITION m_lastPosition; - - QMutex mutex; - QWaitCondition statusUpdated; - - HANDLE m_gps; - HANDLE m_newDataEvent; - HANDLE m_gpsStateChange; - HANDLE m_wakeUpEvent; -}; - -QTM_END_NAMESPACE - -#endif //#ifndef QGEOINFOTHREAD_WINCE_P_H diff --git a/src/location/qgeopositioninfosource_maemo5.cpp b/src/location/qgeopositioninfosource_maemo5.cpp deleted file mode 100644 index d9227d31..00000000 --- a/src/location/qgeopositioninfosource_maemo5.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qgeopositioninfosource_maemo5_p.h" -#include "liblocationwrapper_p.h" -#include <qnumeric.h> - -using namespace std; - -QTM_BEGIN_NAMESPACE - -QGeoPositionInfoSourceMaemo::QGeoPositionInfoSourceMaemo(QObject *parent) - : QGeoPositionInfoSource(parent) -{ - // default values - timerInterval = DEFAULT_UPDATE_INTERVAL; - updateTimer = new QTimer(this); - updateTimer->setSingleShot(true); - connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTimeoutElapsed())); - - requestTimer = new QTimer(this); - requestTimer->setSingleShot(true); - connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimeoutElapsed())); - - connect(LiblocationWrapper::instance(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPositionUpdate(QGeoPositionInfo))); - - errorOccurred = false; - errorSent = false; - - positionInfoState = QGeoPositionInfoSourceMaemo::Undefined; -} - -int QGeoPositionInfoSourceMaemo::init() -{ - if (LiblocationWrapper::instance()->inited()) { - connect(LiblocationWrapper::instance(), SIGNAL(error()), this, SLOT(error())); - return INIT_OK; - } else { - return INIT_FAILED; - } -} - -QGeoPositionInfo QGeoPositionInfoSourceMaemo::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const -{ - return (LiblocationWrapper::instance()->lastKnownPosition(fromSatellitePositioningMethodsOnly)); -} - -QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceMaemo::supportedPositioningMethods() const -{ - QGeoPositionInfoSource::PositioningMethods methods; - - if (!GConfItem("/system/nokia/location/gps-disabled").value().toBool()) - methods |= SatellitePositioningMethods; - if (!GConfItem("/system/nokia/location/network-disabled").value().toBool()) - methods |= NonSatellitePositioningMethods; - if (methods.testFlag(SatellitePositioningMethods) && methods.testFlag(NonSatellitePositioningMethods)) - methods |= AllPositioningMethods; - - return methods; -} - -void QGeoPositionInfoSourceMaemo::setUpdateInterval(int msec) -{ - bool updateTimerInterval = false; - - if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) - if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) - updateTimerInterval = true; - - if (!msec) { - timerInterval = MINIMUM_UPDATE_INTERVAL; - QGeoPositionInfoSource::setUpdateInterval(0); - } else { - timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec; - QGeoPositionInfoSource::setUpdateInterval(timerInterval); - } - - if (timerInterval >= POWERSAVE_THRESHOLD) - positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive; - else - positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive; - - // If powersave has been active when new update interval has been set, - // ensure that timer is started. - if (updateTimerInterval) - startLocationDaemon(); - - // Ensure that new timer interval is taken into use immediately. - activateTimer(); -} - -void QGeoPositionInfoSourceMaemo::setPreferredPositioningMethods(PositioningMethods methods) -{ - QGeoPositionInfoSource::setPreferredPositioningMethods(methods); -} - -int QGeoPositionInfoSourceMaemo::minimumUpdateInterval() const -{ - return MINIMUM_UPDATE_INTERVAL; -} - -// public slots: -void QGeoPositionInfoSourceMaemo::startUpdates() -{ - startLocationDaemon(); - - // Ensure that powersave is selected, if stopUpdates() has been called, - // but selected update interval is still greater than POWERSAVE_THRESHOLD. - if (timerInterval >= POWERSAVE_THRESHOLD) - positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive; - - activateTimer(); -} - -void QGeoPositionInfoSourceMaemo::stopUpdates() -{ - positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive; - - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive)) { - updateTimer->stop(); - if (LiblocationWrapper::instance()->isActive()) - LiblocationWrapper::instance()->stop(); - } - - errorOccurred = false; - errorSent = false; - - positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started; - positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped; -} - -void QGeoPositionInfoSourceMaemo::requestUpdate(int timeout) -{ - int timeoutForRequest = 0; - - if (!timeout) { - if (LiblocationWrapper::instance()->isActive()) - // If GPS is active, assume quick fix. - timeoutForRequest = DEFAULT_UPDATE_INTERVAL; - else - // Otherwise reserve longer time to get a fix. - timeoutForRequest = POWERSAVE_POWERON_PERIOD; - } else if (timeout < MINIMUM_UPDATE_INTERVAL) { - if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) - return; - - emit updateTimeout(); - return; - } else { - timeoutForRequest = timeout; - } - - positionInfoState |= QGeoPositionInfoSourceMaemo::RequestActive; - - if (!(LiblocationWrapper::instance()->isActive())) - LiblocationWrapper::instance()->start(); - - activateTimer(); - requestTimer->start(timeoutForRequest); -} - -void QGeoPositionInfoSourceMaemo::newPositionUpdate(const QGeoPositionInfo &position) -{ - /* - Invalid fixes have NaN for horizontal accuracy regardless of - whether they come from satellite or non-satellite position methods. - - Satellite fixes always have LOCATION_GPS_DEVICE_TIME_SET. - If this is not set and we have a numeric value for horizontal - accuracy then we are dealing with a non-satellite based positioning - method. - - Since QGeoPositionInfo instances are only considered valid if - they have a valid coordinate and a valid timestamp, we use - the current date and time as the timestamp for the network based - positioning. This will help in the case where someone wants to - reply a journey from a log file. - - Based on some logging it looks like satellite and non-satellite - methods can be distinguished (after the initial fix) by whether - the time has been set and / or whether the horizontal accuracy - is above or below around 500 metres. Using the timestamp - appears to be more definitive than using the accuracy. - */ - - const bool horizontalAccuracyDefined = !qIsNaN(position.attribute(QGeoPositionInfo::HorizontalAccuracy)); - const bool hasTimeStamp = !position.timestamp().isNull(); - - if (horizontalAccuracyDefined) { - if (hasTimeStamp) { - //Valid satellite fix - lastUpdateFromSatellite = position; - } else { - //Valid non-satellite fix - QGeoPositionInfo networkPosition(position); - networkPosition.setTimestamp(QDateTime::currentDateTime()); - lastUpdateFromNetwork = networkPosition; - } - } else { - //Invalid position update - if (hasTimeStamp) { - lastUpdateFromSatellite = QGeoPositionInfo(); - } else { - lastUpdateFromNetwork = QGeoPositionInfo(); - } - } -} - -void QGeoPositionInfoSourceMaemo::updateTimeoutElapsed() -{ - QGeoPositionInfo position; - - QGeoPositionInfoSource::PositioningMethods methods = preferredPositioningMethods(); - - if (methods.testFlag(AllPositioningMethods)) { - methods |= SatellitePositioningMethods; - methods |= NonSatellitePositioningMethods; - } - - if (methods.testFlag(SatellitePositioningMethods) && !methods.testFlag(NonSatellitePositioningMethods)) { - //only SatellitePositioningMethods preferred - position = lastUpdateFromSatellite; - } else if (methods.testFlag(NonSatellitePositioningMethods) && !methods.testFlag(SatellitePositioningMethods)) { - //only NonSatellitePositioningMethods preferred - position = lastUpdateFromNetwork; - } else { - //AllPositioningMethods or none preferred - if (lastUpdateFromSatellite.isValid()) - position = lastUpdateFromSatellite; - else - position = lastUpdateFromNetwork; - } - - if (position.isValid()) { - errorOccurred = false; - errorSent = false; - - if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) { - positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive; - requestTimer->stop(); - - if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) - if (LiblocationWrapper::instance()->isActive()) - LiblocationWrapper::instance()->stop(); - - // Ensure that requested position fix is emitted even though - // powersave is active and GPS would normally be off. - if ((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) && - (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)) { - emit positionUpdated(position); - } - } - - // Make sure that if update is triggered when waking up, there - // is no false position update. - if (!((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) && - (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped))) - emit positionUpdated(position); - } else { - // if an error occurs when we are updating periodically and we haven't - // sent an error since the last fix... - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) && - errorOccurred && !errorSent) { - errorSent = true; - // we need to emit the updateTimeout signal - emit updateTimeout(); - } - } - activateTimer(); -} - -void QGeoPositionInfoSourceMaemo::requestTimeoutElapsed() -{ - updateTimer->stop(); - emit updateTimeout(); - - positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive; - - if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) - if (LiblocationWrapper::instance()->isActive()) - LiblocationWrapper::instance()->stop(); - - activateTimer(); -} - -void QGeoPositionInfoSourceMaemo::error() -{ - errorOccurred = true; -} - -void QGeoPositionInfoSourceMaemo::activateTimer() -{ - if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) { - updateTimer->start(MINIMUM_UPDATE_INTERVAL); - return; - } - - if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) { - if (positionInfoState & QGeoPositionInfoSourceMaemo::Started) { - // Cannot call stopUpdates() here since we want to keep powersave - // active. - if (LiblocationWrapper::instance()->isActive()) - LiblocationWrapper::instance()->stop(); - updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD); - errorOccurred = false; - errorSent = false; - - positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started; - positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped; - } else if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) { - startLocationDaemon(); - updateTimer->start(POWERSAVE_POWERON_PERIOD); - } - return; - } - - if (positionInfoState & QGeoPositionInfoSourceMaemo::Started) - updateTimer->start(timerInterval); -} - -void QGeoPositionInfoSourceMaemo::startLocationDaemon() -{ - if (!(LiblocationWrapper::instance()->isActive())) - LiblocationWrapper::instance()->start(); - positionInfoState |= QGeoPositionInfoSourceMaemo::Started; - positionInfoState &= ~QGeoPositionInfoSourceMaemo::Stopped; -} - -#include "moc_qgeopositioninfosource_maemo5_p.cpp" -QTM_END_NAMESPACE - diff --git a/src/location/qgeopositioninfosource_maemo5_p.h b/src/location/qgeopositioninfosource_maemo5_p.h deleted file mode 100644 index 0bbc8bc1..00000000 --- a/src/location/qgeopositioninfosource_maemo5_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QGEOPOSITIONINFOSOURCEMAEMO5_H -#define QGEOPOSITIONINFOSOURCEMAEMO5_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 <QTimer> -#include "qgeopositioninfosource.h" - -#define INIT_OK 0 -#define INIT_FAILED -1 -#define MINIMUM_UPDATE_INTERVAL 1000 -#define DEFAULT_UPDATE_INTERVAL 5000 -#define POWERSAVE_THRESHOLD 180000 -#define POWERSAVE_POWERON_PERIOD 120000 - -QTM_BEGIN_NAMESPACE - -class LiblocationWrapper; - -class QGeoPositionInfoSourceMaemo : public QGeoPositionInfoSource -{ - Q_OBJECT - -public: - - QGeoPositionInfoSourceMaemo(QObject *parent = 0); - - int init(); - - virtual void setUpdateInterval(int interval); - virtual void setPreferredPositioningMethods(PositioningMethods methods); - virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const; - virtual PositioningMethods supportedPositioningMethods() const; - virtual int minimumUpdateInterval() const; - -private: - bool positionInited; - QTimer *updateTimer; - QTimer *requestTimer; - int timerInterval; - bool errorOccurred; - bool errorSent; - - void activateTimer(); - void startLocationDaemon(); - - enum PositionInfoState { - Undefined = 0, - Started = 1, - Stopped = 2, - RequestActive = 4, - PowersaveActive = 8 - }; - int positionInfoState; - - QGeoPositionInfo lastUpdateFromSatellite; - QGeoPositionInfo lastUpdateFromNetwork; - -signals: - void positionUpdated(const QGeoPositionInfo &update); - -public slots: - void startUpdates(); - void stopUpdates(); - void requestUpdate(int timeout = DEFAULT_UPDATE_INTERVAL); - -private slots: - void requestTimeoutElapsed(); - void error(); - void newPositionUpdate(const QGeoPositionInfo &position); - void updateTimeoutElapsed(); - -private: - Q_DISABLE_COPY(QGeoPositionInfoSourceMaemo) -}; - -QTM_END_NAMESPACE - -#endif // QGEOPOSITIONINFOSOURCEMAEMO5_H diff --git a/src/location/qgeopositioninfosource_wince.cpp b/src/location/qgeopositioninfosource_wince.cpp deleted file mode 100644 index 19451e60..00000000 --- a/src/location/qgeopositioninfosource_wince.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include <windows.h> -#include <gpsapi.h> // including requires <windows.h> - -#include "qgeopositioninfosource_wince_p.h" -#include "qgeoinfothread_wince_p.h" - -QTM_BEGIN_NAMESPACE - -// ========== QGeoPositionInfoValidator ========== - -QGeoPositionInfoValidator::QGeoPositionInfoValidator() : QGeoInfoValidator() {} - -QGeoPositionInfoValidator::~QGeoPositionInfoValidator() {} - -// Returns true if data contains at least the minimal amount of data we need to produce the -// QGeoPositionInfoSource positionUpdated signal, otherwise returns false. -bool QGeoPositionInfoValidator::valid(const GPS_POSITION &data) const -{ - if (((data.dwValidFields & GPS_VALID_LATITUDE) == 0) - || ((data.dwValidFields & GPS_VALID_LONGITUDE) == 0) - || ((data.dwValidFields & GPS_VALID_UTC_TIME) == 0)) { - return false; - } - return true; -} - -// ========== QGeoPositionInfoSourceWinCE ========== - -QGeoPositionInfoSourceWinCE::QGeoPositionInfoSourceWinCE(QObject *parent) - : QGeoPositionInfoSource(parent) -{ - QGeoInfoValidator *validator = new QGeoPositionInfoValidator(); - - // The QGeoInfoThreadWinCE instance takes ownership of the validator. - infoThread = new QGeoInfoThreadWinCE(validator, true, this); - infoThread->start(); - // QGeoInfoThreadWinCE takes care of registering GPS_POSITION as a metatype. - connect(infoThread, SIGNAL(dataUpdated(GPS_POSITION)), this, SLOT(dataUpdated(GPS_POSITION))); - connect(infoThread, SIGNAL(updateTimeout()), this, SIGNAL(updateTimeout())); -} - -QGeoPositionInfoSourceWinCE::~QGeoPositionInfoSourceWinCE() -{ - delete infoThread; -} - -QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinCE::supportedPositioningMethods() const -{ - return QGeoPositionInfoSource::SatellitePositioningMethods; -} - -QGeoPositionInfo QGeoPositionInfoSourceWinCE::lastKnownPosition(bool) const -{ - return lastPosition; -} - -void QGeoPositionInfoSourceWinCE::setUpdateInterval(int msec) -{ - // If msec is 0 we send updates as data becomes available, otherwise we force msec to be equal - // to or larger than the minimum update interval. - if (msec != 0 && msec < MinimumUpdateInterval) - msec = MinimumUpdateInterval; - - infoThread->setUpdateInterval(msec); - QGeoPositionInfoSource::setUpdateInterval(msec); -} - -int QGeoPositionInfoSourceWinCE::minimumUpdateInterval() const -{ - return MinimumUpdateInterval; -} - -void QGeoPositionInfoSourceWinCE::startUpdates() -{ - infoThread->startUpdates(); -} - -void QGeoPositionInfoSourceWinCE::stopUpdates() -{ - infoThread->stopUpdates(); -} - -void QGeoPositionInfoSourceWinCE::requestUpdate(int timeout) -{ - // A timeout of 0 means to use the default timeout, which is handled by the QGeoInfoThreadWinCE - // instance, otherwise if timeout is less than the minimum update interval we emit a - // updateTimeout signal - if (timeout < minimumUpdateInterval() && timeout != 0) - emit updateTimeout(); - else - infoThread->requestUpdate(timeout); -} - -/* - This is _only_ called when QGeoPositionInfoValidator::valid() returns true for the position. - This means that it is implied that: - - (data.dwValidFields & GPS_VALID_LATITUDE) != 0 - - (data.dwValidFields & GPS_VALID_LONGITUDE) != 0 - - (data.dwValidFields & GPS_VALID_UTC_TIME) != 0 - - This guarantees that the newly created position will be valid. - If the code is changed such that this is no longer guaranteed then this method will need to be - updated to test for those conditions. -*/ -void QGeoPositionInfoSourceWinCE::dataUpdated(GPS_POSITION data) -{ - QGeoCoordinate coordinate(data.dblLatitude, data.dblLongitude); - - // The altitude is optional in QGeoCoordinate, so we do not strictly require that the - // GPS_POSITION structure has valid altitude data in order to trigger an update. - if ((data.dwValidFields & GPS_VALID_ALTITUDE_WRT_SEA_LEVEL) != 0) - coordinate.setAltitude(data.flAltitudeWRTSeaLevel); - - QDate date(data.stUTCTime.wYear, data.stUTCTime.wMonth, data.stUTCTime.wDay); - QTime time(data.stUTCTime.wHour, data.stUTCTime.wMinute, data.stUTCTime.wSecond, - data.stUTCTime.wMilliseconds); - - QDateTime dateTime(date, time, Qt::UTC); - - QGeoPositionInfo pos(coordinate, dateTime); - - // The following properties are optional, and so are set if the data is present and valid in - // the GPS_POSITION structure. - if ((data.dwValidFields & GPS_VALID_SPEED) != 0) - pos.setAttribute(QGeoPositionInfo::GroundSpeed, data.flSpeed); - - if ((data.dwValidFields & GPS_VALID_HEADING) != 0) - pos.setAttribute(QGeoPositionInfo::Direction, data.flHeading); - - if ((data.dwValidFields & GPS_VALID_MAGNETIC_VARIATION) != 0) - pos.setAttribute(QGeoPositionInfo::MagneticVariation, data.dblMagneticVariation); - - lastPosition = pos; - emit positionUpdated(pos); -} - -#include "moc_qgeopositioninfosource_wince_p.cpp" -QTM_END_NAMESPACE diff --git a/src/location/qgeopositioninfosource_wince_p.h b/src/location/qgeopositioninfosource_wince_p.h deleted file mode 100644 index c3da32a5..00000000 --- a/src/location/qgeopositioninfosource_wince_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QGEOPOSITIONINFOSOURCE_WINCE_P_H -#define QGEOPOSITIONINFOSOURCE_WINCE_P_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 <qgeopositioninfosource.h> - -#include "qgeoinfothread_wince_p.h" - -QTM_BEGIN_NAMESPACE - -class QGeoPositionInfoValidator : public QGeoInfoValidator -{ -public: - QGeoPositionInfoValidator(); - ~QGeoPositionInfoValidator(); - - bool valid(const GPS_POSITION &data) const; -}; - -class QGeoPositionInfoSourceWinCE : public QGeoPositionInfoSource -{ - Q_OBJECT - -public: - enum { - // The minimum acceptable interval for periodic updates. - MinimumUpdateInterval = 100 - }; - - explicit QGeoPositionInfoSourceWinCE(QObject *parent = 0); - ~QGeoPositionInfoSourceWinCE(); - - void setUpdateInterval(int msec); - QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const; - PositioningMethods supportedPositioningMethods() const; - int minimumUpdateInterval() const; - -public slots: - virtual void startUpdates(); - virtual void stopUpdates(); - virtual void requestUpdate(int timeout = 0); - -private slots: - void dataUpdated(GPS_POSITION data); - -private: - QGeoPositionInfo lastPosition; - QGeoInfoThreadWinCE *infoThread; -}; - -QTM_END_NAMESPACE - -#endif //#ifndef QGEOPOSITIONINFOSOURCE_WINCE_P_H diff --git a/src/location/qgeosatelliteinfosource_maemo5.cpp b/src/location/qgeosatelliteinfosource_maemo5.cpp deleted file mode 100644 index f0edb292..00000000 --- a/src/location/qgeosatelliteinfosource_maemo5.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qgeosatelliteinfosource_maemo5_p.h" -#include "liblocationwrapper_p.h" - -QTM_BEGIN_NAMESPACE - -QGeoSatelliteInfoSourceMaemo::QGeoSatelliteInfoSourceMaemo(QObject *parent) - : QGeoSatelliteInfoSource(parent) -{ - client_id_ = -1; - timerInterval = DEFAULT_UPDATE_INTERVAL; - updateTimer = new QTimer(this); - updateTimer->setSingleShot(true); - connect(updateTimer, SIGNAL(timeout()), this, SLOT(satelliteStatus())); - - requestTimer = new QTimer(this); - requestTimer->setSingleShot(true); - connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimeoutElapsed())); - - satelliteInfoState = QGeoSatelliteInfoSourceMaemo::Undefined; -} - -int QGeoSatelliteInfoSourceMaemo::init() -{ - if (LiblocationWrapper::instance()->inited()) - return INIT_OK; - else - return INIT_FAILED; -} - -void QGeoSatelliteInfoSourceMaemo::setUpdateInterval(int msec) -{ - bool updateTimerInterval = false; - - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) - updateTimerInterval = true; - - timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec; - - if (timerInterval >= POWERSAVE_THRESHOLD) - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive; - else - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive; - - // If powersave has been active when new update interval has been set, - // ensure that timer is started. - if (updateTimerInterval) - startLocationDaemon(); - - // Ensure that new timer interval is taken into use immediately. - activateTimer(); -} - -void QGeoSatelliteInfoSourceMaemo::startUpdates() -{ - startLocationDaemon(); - - // Ensure that powersave is selected, if stopUpdates() has been called, - // but selected update interval is still greater than POWERSAVE_THRESHOLD. - if (timerInterval >= POWERSAVE_THRESHOLD) - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive; - - activateTimer(); -} - -void QGeoSatelliteInfoSourceMaemo::stopUpdates() -{ - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive; - - if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive)) { - updateTimer->stop(); - if (LiblocationWrapper::instance()->isActive()) - LiblocationWrapper::instance()->stop(); - } - - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started; - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped; -} - -void QGeoSatelliteInfoSourceMaemo::requestUpdate(int timeout) -{ - int timeoutForRequest = 0; - - if (!timeout) { - if (LiblocationWrapper::instance()->isActive()) - // If GPS is active, assume quick fix. - timeoutForRequest = DEFAULT_UPDATE_INTERVAL; - else - // Otherwise reserve longer time to get a fix. - timeoutForRequest = POWERSAVE_POWERON_PERIOD; - } else if (timeout < MINIMUM_UPDATE_INTERVAL) { - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) - return; - - emit requestTimeout(); - return; - } else { - timeoutForRequest = timeout; - } - - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::RequestActive; - - if (!(LiblocationWrapper::instance()->isActive())) - LiblocationWrapper::instance()->start(); - - activateTimer(); - requestTimer->start(timeoutForRequest); -} - -void QGeoSatelliteInfoSourceMaemo::satelliteStatus() -{ - QList<QGeoSatelliteInfo> satellitesInView = - LiblocationWrapper::instance()->satellitesInView(); - QList<QGeoSatelliteInfo> satellitesInUse = - LiblocationWrapper::instance()->satellitesInUse(); - - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) { - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive; - - requestTimer->stop(); - - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) { - if (LiblocationWrapper::instance()->isActive()) { - LiblocationWrapper::instance()->stop(); - } - } - - // Ensure that requested satellite info is emitted even though - // powersave is active and GPS would normally be off. - if ((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) && - (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)) { - if (satellitesInView.length()) { - emit satellitesInViewUpdated(satellitesInView); - emit satellitesInUseUpdated(satellitesInUse); - } - } - } - - // Make sure that if update is triggered when waking up, there - // is no false position update. - if (!((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) && - (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped))) { - if (satellitesInView.length()) { - emit satellitesInViewUpdated(satellitesInView); - emit satellitesInUseUpdated(satellitesInUse); - } - } - - activateTimer(); -} - -void QGeoSatelliteInfoSourceMaemo::requestTimeoutElapsed() -{ - updateTimer->stop(); - emit requestTimeout(); - - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive; - - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) - if (LiblocationWrapper::instance()->isActive()) - LiblocationWrapper::instance()->stop(); - - activateTimer(); -} - -void QGeoSatelliteInfoSourceMaemo::activateTimer() -{ - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) { - updateTimer->start(MINIMUM_UPDATE_INTERVAL); - return; - } - - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) { - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started) { - // Cannot call stopUpdates() here since we want to keep powersave - // active. - if (LiblocationWrapper::instance()->isActive()) - LiblocationWrapper::instance()->stop(); - updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD); - - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started; - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped; - } else if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) { - startLocationDaemon(); - updateTimer->start(POWERSAVE_POWERON_PERIOD); - } - return; - } - - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started) - updateTimer->start(timerInterval); -} - -void QGeoSatelliteInfoSourceMaemo::startLocationDaemon() -{ - if (!(LiblocationWrapper::instance()->isActive())) - LiblocationWrapper::instance()->start(); - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Started; - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Stopped; -} - -#include "moc_qgeosatelliteinfosource_maemo5_p.cpp" -QTM_END_NAMESPACE - diff --git a/src/location/qgeosatelliteinfosource_maemo5_p.h b/src/location/qgeosatelliteinfosource_maemo5_p.h deleted file mode 100644 index 0cb8be4e..00000000 --- a/src/location/qgeosatelliteinfosource_maemo5_p.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QGEOSATELLITEINFOSOURCE_MAEMO5_H -#define QGEOSATELLITEINFOSOURCE_MAEMO5_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 <QTimer> -#include "qgeosatelliteinfosource.h" -#include "qgeosatelliteinfo.h" - -#define INIT_OK 0 -#define INIT_FAILED -1 -#define MINIMUM_UPDATE_INTERVAL 1000 -#define DEFAULT_UPDATE_INTERVAL 5000 -#define POWERSAVE_THRESHOLD 180000 -#define POWERSAVE_POWERON_PERIOD 120000 - -QTM_BEGIN_NAMESPACE - -class LiblocationWrapper; - -class QGeoSatelliteInfoSourceMaemo : public QGeoSatelliteInfoSource -{ - Q_OBJECT - -public: - explicit QGeoSatelliteInfoSourceMaemo(QObject *parent = 0); - - int init(); - -private: - int client_id_; - void setUpdateInterval(int interval); - QTimer *updateTimer; - QTimer *requestTimer; - int timerInterval; - void activateTimer(); - void startLocationDaemon(); - - enum SatelliteInfoState { - Undefined = 0, - Started = 1, - Stopped = 2, - RequestActive = 4, - PowersaveActive = 8 - }; - int satelliteInfoState; - -public slots: - virtual void startUpdates(); - void stopUpdates(); - void requestUpdate(int timeout = 5000); - void satelliteStatus(); - -signals: - void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites); - void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites); - void requestTimeout(); - -private slots: - void requestTimeoutElapsed(); - -private: - Q_DISABLE_COPY(QGeoSatelliteInfoSourceMaemo) -}; - -QTM_END_NAMESPACE - -#endif // QGEOSATELLITEINFOSOURCE_MAEMO5_H - diff --git a/src/location/qgeosatelliteinfosource_wince.cpp b/src/location/qgeosatelliteinfosource_wince.cpp deleted file mode 100644 index 5b5ae48c..00000000 --- a/src/location/qgeosatelliteinfosource_wince.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include <QList> -#include <QHash> - -#include <qgeosatelliteinfo.h> - -#include "qgeosatelliteinfosource_wince_p.h" -#include "qgeoinfothread_wince_p.h" - -QTM_BEGIN_NAMESPACE - -// ========== QGeoSatelliteInfoValidator ========== - -QGeoSatelliteInfoValidator::QGeoSatelliteInfoValidator() : QGeoInfoValidator() {} - -QGeoSatelliteInfoValidator::~QGeoSatelliteInfoValidator() {} - -// Returns true if data contains at least the minimal amount of data we need to produce one of the -// QGeoSatelliteInfoSource signals, otherwise returns false. -bool QGeoSatelliteInfoValidator::valid(const GPS_POSITION &data) const -{ - if (((data.dwValidFields & GPS_VALID_SATELLITE_COUNT) == 0) - || ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) == 0) - || ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_PRNS) == 0) - || ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_SIGNAL_TO_NOISE_RATIO) == 0)) { - return false; - } - return true; -} - -// ========== QGeoSatelliteInfoSourceWinCE ========== - -QGeoSatelliteInfoSourceWinCE::QGeoSatelliteInfoSourceWinCE(QObject *parent) : QGeoSatelliteInfoSource(parent) -{ - QGeoSatelliteInfoValidator *validator = new QGeoSatelliteInfoValidator(); - - // The QGeoInfoThreadWinCE instance takes ownership of the validator. - infoThread = new QGeoInfoThreadWinCE(validator, false, this); - infoThread->setUpdateInterval(DefaultUpdateInterval); - infoThread->start(); - - // QGeoInfoThreadWinCE takes care of registering GPS_POSITION as a metatype. - connect(infoThread, SIGNAL(dataUpdated(GPS_POSITION)), this, SLOT(dataUpdated(GPS_POSITION))); - connect(infoThread, SIGNAL(updateTimeout()), this, SIGNAL(requestTimeout())); -} - -QGeoSatelliteInfoSourceWinCE::~QGeoSatelliteInfoSourceWinCE() -{ - delete infoThread; -} - -void QGeoSatelliteInfoSourceWinCE::startUpdates() -{ - infoThread->startUpdates(); -} - -void QGeoSatelliteInfoSourceWinCE::stopUpdates() -{ - infoThread->stopUpdates(); -} - -void QGeoSatelliteInfoSourceWinCE::requestUpdate(int timeout) -{ - if (timeout < 0) - emit requestTimeout(); - else - infoThread->requestUpdate(timeout); -} - -/* - This is _only_ called when QGeoSatelliteInfoValidator::valid() returns true for the position. - This means that it is implied that: - - (data.dwValidFields & GPS_VALID_SATELLITE_COUNT) != 0 - - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) != 0 - - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_PRNS) != 0 - - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_SIGNAL_TO_NOISE_RATIO) != 0 - - This guarantees that the newly created position will be valid. - If the code is changed such that this is no longer guaranteed then this method will need to be - updated to test for those conditions. -*/ -void QGeoSatelliteInfoSourceWinCE::dataUpdated(GPS_POSITION data) -{ - // Satellites in view are hashed on the PRN values since the PRN value is how we - // determine which of the satellites are in use. - QHash<int, QGeoSatelliteInfo> satellitesInView; - - for (unsigned int i = 0; i < data.dwSatellitesInView; ++i) { - QGeoSatelliteInfo satellite; - - satellite.setPrnNumber(data.rgdwSatellitesInViewPRNs[i]); - satellite.setSignalStrength(data.rgdwSatellitesInViewSignalToNoiseRatio[i]); - - // The following properties are optional, and so are set if the data is present and valid - // in the GPS_POSITION structure. - if ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_AZIMUTH) != 0) { - satellite.setAttribute(QGeoSatelliteInfo::Azimuth, - data.rgdwSatellitesInViewAzimuth[i]); - } - - if ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_ELEVATION) != 0) { - satellite.setAttribute(QGeoSatelliteInfo::Elevation, - data.rgdwSatellitesInViewElevation[i]); - } - - satellitesInView.insert(satellite.prnNumber(), satellite); - } - - emit satellitesInViewUpdated(satellitesInView.values()); - - // If the PRN data for the satellites which were used is unavailable we are done... - if ((data.dwValidFields & GPS_VALID_SATELLITES_USED_PRNS) == 0) - return; - - // ...otherwise we construct the list of satellites which are in use and emit the appropriate - // signal - QList<QGeoSatelliteInfo> satellitesInUse; - - for (unsigned int i = 0; i < data.dwSatelliteCount; ++i) { - int inUsePRN = data.rgdwSatellitesUsedPRNs[i]; - if (satellitesInView.contains(inUsePRN)) - satellitesInUse << satellitesInView.value(inUsePRN); - } - - emit satellitesInUseUpdated(satellitesInUse); -} - -#include "moc_qgeosatelliteinfosource_wince_p.cpp" -QTM_END_NAMESPACE diff --git a/src/location/qgeosatelliteinfosource_wince_p.h b/src/location/qgeosatelliteinfosource_wince_p.h deleted file mode 100644 index 8fc1bd28..00000000 --- a/src/location/qgeosatelliteinfosource_wince_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QGEOSATELLITEINFOSOURCE_WINCE_P_H -#define QGEOSATELLITEINFOSOURCE_WINCE_P_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 <qgeosatelliteinfosource.h> - -#include "qgeoinfothread_wince_p.h" - -QTM_BEGIN_NAMESPACE - -class QGeoSatelliteInfoValidator : public QGeoInfoValidator -{ -public: - QGeoSatelliteInfoValidator(); - ~QGeoSatelliteInfoValidator(); - - bool valid(const GPS_POSITION &data) const; -}; - -class QGeoSatelliteInfoSourceWinCE : public QGeoSatelliteInfoSource -{ - Q_OBJECT - -public: - enum { - // The interval at which the periodic updates will occur. - DefaultUpdateInterval = 5000 - }; - - explicit QGeoSatelliteInfoSourceWinCE(QObject *parent = 0); - ~QGeoSatelliteInfoSourceWinCE(); - -public slots: - void startUpdates(); - void stopUpdates(); - void requestUpdate(int timeout = 0); - -private slots: - void dataUpdated(GPS_POSITION data); - -private: - QGeoInfoThreadWinCE *infoThread; -}; - -QTM_END_NAMESPACE - -#endif //#ifndef QGEOSATELLITEINFOSOURCE_WINCE_P_H |