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())); }
void TestQGeoPositionInfoSource::removeSlotForRequestTimeout() { CHECK_SOURCE_VALID; bool i = connect(m_source, SIGNAL(updateTimeout()), this, SLOT(test_slot1())); QVERIFY(i == true); i = connect(m_source, SIGNAL(updateTimeout()), this, SLOT(test_slot2())); QVERIFY(i == true); i = disconnect(m_source, SIGNAL(updateTimeout()), this, SLOT(test_slot1())); QVERIFY(i == true); m_source->requestUpdate(-1); QTRY_VERIFY_WITH_TIMEOUT((m_testSlot2Called == true), 1000); }
void tst_QNmeaPositionInfoSource::requestUpdate_after_start() { QNmeaPositionInfoSource source(m_mode); QNmeaPositionInfoSourceProxyFactory factory; QNmeaPositionInfoSourceProxy *proxy = static_cast<QNmeaPositionInfoSourceProxy*>(factory.createProxy(&source)); QSignalSpy spyUpdate(proxy->source(), SIGNAL(positionUpdated(QGeoPositionInfo))); QSignalSpy spyTimeout(proxy->source(), SIGNAL(updateTimeout())); // Start updates with 500ms interval and requestUpdate() with 100ms // timeout. Feed an update, and it should be emitted immediately due to // the requestUpdate(). The update should not be emitted again after that // (i.e. the startUpdates() interval should not cause it to be re-emitted). QDateTime dt = QDateTime::currentDateTime().toUTC(); proxy->source()->setUpdateInterval(500); proxy->source()->startUpdates(); proxy->source()->requestUpdate(100); proxy->feedUpdate(dt); QTRY_COMPARE(spyUpdate.count(), 1); QCOMPARE(spyUpdate[0][0].value<QGeoPositionInfo>().timestamp(), dt); QCOMPARE(spyTimeout.count(), 0); spyUpdate.clear(); // Update has been emitted for requestUpdate(), shouldn't be emitted for startUpdates() QTRY_COMPARE_WITH_TIMEOUT(spyUpdate.count(), 0, 1000); }
void tst_QNmeaPositionInfoSource::lastKnownPosition() { QNmeaPositionInfoSource source(m_mode); QNmeaPositionInfoSourceProxyFactory factory; QNmeaPositionInfoSourceProxy *proxy = static_cast<QNmeaPositionInfoSourceProxy*>(factory.createProxy(&source)); QCOMPARE(proxy->source()->lastKnownPosition(), QGeoPositionInfo()); // source may need requestUpdate() or startUpdates() to be called to // trigger reading of data channel QSignalSpy spyTimeout(proxy->source(), SIGNAL(updateTimeout())); proxy->source()->requestUpdate(proxy->source()->minimumUpdateInterval()); QTRY_COMPARE(spyTimeout.count(), 1); // If an update is received and startUpdates() or requestUpdate() hasn't // been called, it should still be available through lastKnownPosition() QDateTime dt = QDateTime::currentDateTime().toUTC(); proxy->feedUpdate(dt); QTRY_COMPARE(proxy->source()->lastKnownPosition().timestamp(), dt); QList<QDateTime> dateTimes = createDateTimes(5); for (int i=0; i<dateTimes.count(); i++) { proxy->source()->requestUpdate(); proxy->feedUpdate(dateTimes[i]); QTRY_COMPARE(proxy->source()->lastKnownPosition().timestamp(), dateTimes[i]); } proxy->source()->startUpdates(); dateTimes = createDateTimes(5); for (int i=0; i<dateTimes.count(); i++) { proxy->feedUpdate(dateTimes[i]); QTRY_COMPARE(proxy->source()->lastKnownPosition().timestamp(), dateTimes[i]); } }
/*! \internal */ void QDeclarativePositionSource::socketConnected() { #ifdef QDECLARATIVE_POSITION_DEBUG qDebug() << "Socket connected: " << m_nmeaSocket->peerName(); #endif PositioningMethods previousPositioningMethods = supportedPositioningMethods(); // The current position source needs to be deleted // because QNmeaPositionInfoSource can be bound only to a one file. delete m_nmeaFile; m_nmeaFile = 0; delete m_positionSource; m_positionSource = new QNmeaPositionInfoSource(QNmeaPositionInfoSource::RealTimeMode); (qobject_cast<QNmeaPositionInfoSource *>(m_positionSource))->setDevice(m_nmeaSocket); connect(m_positionSource, &QNmeaPositionInfoSource::positionUpdated, this, &QDeclarativePositionSource::positionUpdateReceived); connect(m_positionSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); connect(m_positionSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeoutReceived())); setPosition(m_positionSource->lastKnownPosition()); if (m_active && !m_singleUpdate) { // Keep on updating even though source changed QTimer::singleShot(0, this, SLOT(start())); } if (previousPositioningMethods != supportedPositioningMethods()) emit supportedPositioningMethodsChanged(); }
FoursquareVenueSelectionPage::FoursquareVenueSelectionPage(QGraphicsItem *parent) : SelectionPage(parent), m_geosource(QGeoPositionInfoSource::createDefaultSource(this)), m_model(new FoursquareVenueSelectionPageListModel(this)), m_storage(FoursquareAuthStorage::storage()) { if (m_geosource == NULL) { mDebug(__func__) << "Cannot set up geoposition source. "; } else { mDebug(__func__) << "Starting geoposition lookup. "; connect(m_geosource, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this, SLOT(positionUpdated(const QGeoPositionInfo &))); connect(m_geosource, SIGNAL(updateTimeout()), this, SLOT(positionUpdateTimeout())); m_geosource->startUpdates(); } connect(m_model, SIGNAL(ready(enum FoursquareVenueSearch::SearchStatus)), this, SLOT(itemsReady(enum FoursquareVenueSearch::SearchStatus))); connect(this, SIGNAL(created()), this, SLOT(activate()), Qt::QueuedConnection); }
static void submitSACK(Connection *conn, const uint32_t ackn) { SgmBuffElem *ackedelem = NULL; Segment sgm; long double sampleRTT; if ((ackedelem = findSgmBuffAckn(&(conn->sndsgmbuff), ackn))) { setSgmBuffElemStatus(ackedelem, RUSP_YACK); sgm = ackedelem->segment; DBGPRINT(RUSP_DEBUG, "SACKED: %u", sgm.hdr.seqn); if (sgm.hdr.seqn == getWindowBase(&(conn->sndwnd))) { sampleRTT = getSgmBuffElemElapsed(ackedelem); while (conn->sndsgmbuff.head) { if (getSgmBuffElemStatus(conn->sndsgmbuff.head) != RUSP_YACK) break; sgm = conn->sndsgmbuff.head->segment; removeSgmBuff(&(conn->sndsgmbuff), conn->sndsgmbuff.head); slideWindow(&(conn->sndwnd), (sgm.hdr.ctrl & RUSP_FIN)?1:sgm.hdr.plds); DBGPRINT(RUSP_DEBUG, "SND (WND): base:%u nxt:%u end:%u SNDUSRBUFF:%zu SNDSGMBUFF:%ld", getWindowBase(&(conn->sndwnd)), getWindowNext(&(conn->sndwnd)), getWindowEnd(&(conn->sndwnd)), getStrBuffSize(&(conn->sndusrbuff)), getSgmBuffSize(&(conn->sndsgmbuff))); } updateTimeout(&(conn->timeout), sampleRTT); } } }
LocationTracker::LocationTracker() : m_latitude(0) , m_longitude(0) { //Creo la source para geoposici—n src = QGeoPositionInfoSource::createDefaultSource(this); if (src){ src->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods); src->setUpdateInterval(15000); //15 segundos de update // Connect the positionUpdated() signal to a // slot that handles position updates. connect(src, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this, SLOT(positionUpdated(const QGeoPositionInfo &))); connect(src, SIGNAL(updateTimeout()), this, SLOT(positionUpdateTimeout())); } }
KnotsPlayer::KnotsPlayer( QObject *parent ) : QObject( parent ) , _status( Stopped ) , _tickPeriod( KOneSecond ) , _tickCount( 0 ) , _properties( 0 ) { _properties = new KnotsPlayerProperties; _propertiesUpdateTimer = new QTimer(); _backlightTimer = new QTimer(); Knots::instance().setPlayer( this ); _propertiesUpdateTimer->setSingleShot(false); connect(_propertiesUpdateTimer, SIGNAL(timeout()), this, SLOT( updateTimeout())); connect(_backlightTimer, SIGNAL(timeout()), this, SLOT(onBacklightTimer())); connect( _properties, SIGNAL(propertiesUpdated()), this, SLOT(networkPropertiesUpdated())); connect( &Knots::instance().serverConnection(), SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*))); connect( this, SIGNAL(stateChanged(KnotsPlayer::PlayingState)), Knots::instance().mainWindow(), SLOT(onPlayerStateChange(KnotsPlayer::PlayingState))); #if defined(Q_WS_MAEMO_5) _ossoContext = osso_initialize("QtKnots","1.0",true, 0); #endif }
//TC_ID_3_x_1 void TestQGeoPositionInfoSource::stopUpdates() { CHECK_SOURCE_VALID; #if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) QSKIP("Real GPS not suitable for autotesting, skipping the test.", SkipAll); #endif QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&))); QSignalSpy timeout(m_source, SIGNAL(updateTimeout())); m_source->setUpdateInterval(7000); m_source->startUpdates(); for (int i = 0; i < 2; i++) { EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spy.count() > 0) && (timeout.count() == 0), 9500); spy.clear(); } m_source->stopUpdates(); QTest::qWait(9500); QCOMPARE(spy.count(), 0); spy.clear(); m_source->setUpdateInterval(0); m_source->startUpdates(); m_source->stopUpdates(); QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 0, 9500); }
void ProjectsView::initialUpdate() { m_list->sortByColumn( 0, Qt::AscendingOrder ); m_model = new ProjectsModel( this ); m_list->setModel( m_model ); TreeViewHelper helper( m_list ); helper.loadColumnWidths( "ProjectsViewWidths", QList<int>() << 150 << 150 ); helper.loadExpandedNodes( "ExpandedProjects" ); setCaption( dataManager->serverName() ); connect( m_list->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateSelection() ) ); connect( m_model, SIGNAL( layoutChanged() ), this, SLOT( updateActions() ) ); updateActions(); initialUpdateData(); m_timer = new QTimer( this ); connect( m_timer, SIGNAL( timeout() ), this, SLOT( updateTimeout() ) ); m_timer->start( 60 * 1000 ); setAccess( checkDataAccess(), true ); }
void QGeoPositionInfoSourceAndroid::updateTimeoutElapsed() { QGeoPositionInfo position; position=m_lastUpdate; if (position.isValid()) { if (m_positionInfoState & QGeoPositionInfoSourceAndroid::RequestActive) { m_requestTimer->stop(); m_positionInfoState &= ~QGeoPositionInfoSourceAndroid::RequestActive; if (m_positionInfoState & QGeoPositionInfoSourceAndroid::Stopped ||!(m_positionInfoState & QGeoPositionInfoSourceAndroid::StartUpdateActive)) { QtLocationJni::disableUpdates(this); } } emit positionUpdated(position); } else { emit updateTimeout(); } activateTimer(); }
void TestQGeoPositionInfoSource::requestUpdateBeforeStartUpdates_ZeroInterval() { CHECK_SOURCE_VALID; QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&))); QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout())); m_source->requestUpdate(7000); m_source->setUpdateInterval(0); m_source->startUpdates(); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() >= 2) && (spyTimeout.count() == 0), 14000); spyUpdate.clear(); QTest::qWait(7000); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QCOMPARE(spyTimeout.count(), 0); m_source->stopUpdates(); }
void TestQGeoPositionInfoSource::requestUpdateAfterStartUpdates_SmallInterval() { CHECK_SOURCE_VALID; QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&))); QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout())); m_source->setUpdateInterval(10000); m_source->startUpdates(); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() == 1) && (spyTimeout.count() == 0), 20000); spyUpdate.clear(); m_source->requestUpdate(7000); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() == 1) && (spyTimeout.count() == 0), 7000); spyUpdate.clear(); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() == 1) && (spyTimeout.count() == 0), 20000); m_source->stopUpdates(); }
void TestQGeoPositionInfoSource::requestUpdateBeforeStartUpdates_SmallInterval() { CHECK_SOURCE_VALID; #if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) QSKIP("Real GPS not suitable for autotesting, skipping the test.", SkipAll); #endif QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&))); QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout())); m_source->requestUpdate(7000); m_source->setUpdateInterval(10000); m_source->startUpdates(); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000); spyUpdate.clear(); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 20000); m_source->stopUpdates(); }
void QGeoPositionInfoSourceAndroid::requestUpdate(int timeout) { if (m_requestTimer.isActive()) return; if (timeout != 0 && timeout < minimumUpdateInterval()) { emit updateTimeout(); return; } if (timeout == 0) timeout = UPDATE_FROM_COLD_START; m_requestTimer.start(timeout); // if updates already running with interval equal to timeout // then we wait for next update coming through // assume that a single update will not be quicker than regular updates anyway if (updatesRunning && updateInterval() <= timeout) return; QGeoPositionInfoSource::Error error = AndroidPositioning::requestUpdate(androidClassKeyForSingleRequest); //if (error != QGeoPositionInfoSource::NoError) { //TODO if (error != 3) { m_requestTimer.stop(); m_error = error; emit QGeoPositionInfoSource::error(m_error); } }
void TestQGeoPositionInfoSource::removeSlotForRequestTimeout() { CHECK_SOURCE_VALID; #if defined(Q_WS_MAEMO_6) QSKIP("Real GPS not suitable for autotesting, skipping the test.", SkipAll); #endif bool i = connect(m_source, SIGNAL(updateTimeout()), this, SLOT(test_slot1())); QVERIFY(i == true); i = connect(m_source, SIGNAL(updateTimeout()), this, SLOT(test_slot2())); QVERIFY(i == true); i = disconnect(m_source, SIGNAL(updateTimeout()), this, SLOT(test_slot1())); QVERIFY(i == true); m_source->requestUpdate(-1); QTRY_VERIFY_WITH_TIMEOUT((m_testSlot2Called == true), 1000); }
GPSTracker::GPSTracker(QObject *parent) : QObject(parent) { geoPositionInfoSource = QGeoPositionInfoSource::createDefaultSource(this); // emit funktioniert erst nach dem Konstruktor if(geoPositionInfoSource) { connect(geoPositionInfoSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); connect(geoPositionInfoSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); changeGPSStatus(INACTIVE); } else { changeGPSStatus(ERROR); } trackingInterval = 500; tracking = false; }
void QGeoPositionInfoSourceSimulator::updatePosition() { if (qtPositionInfo()->enabled) { lastPosition = Simulator::toPositionInfo(*qtPositionInfo()); emit positionUpdated(lastPosition); } else { emit updateTimeout(); } }
void LogFilePositionSource::requestUpdate(int /*timeout*/) { // For simplicity, ignore timeout - assume that if data is not available // now, no data will be added to the file later if (logFile->canReadLine()) readNextPosition(); else emit updateTimeout(); }
void TestQGeoPositionInfoSource::requestUpdate() { CHECK_SOURCE_VALID; QFETCH(int, timeout); QSignalSpy spy(m_source, SIGNAL(updateTimeout())); m_source->requestUpdate(timeout); QTRY_COMPARE(spy.count(), 1); }
void CLbsPositionLogger::requestUpdate(int timeout) { Q_UNUSED(timeout); // For simplicity, ignore timeout - assume that if data is not available // now, no data will be added to the file later if (m_logFile.canReadLine()) readNextPosition(); else emit updateTimeout(); }
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); }
void QGeoPositionInfoSourceSimulator::requestUpdate(int timeout) { if (!requestTimer->isActive()) { // Get a single update within timeframe if (timeout < minimumUpdateInterval() && timeout != 0) emit updateTimeout(); else { requestTimer->start(timeout * qreal(0.75)); } } }
void TestQGeoPositionInfoSource::requestUpdate() { CHECK_SOURCE_VALID; #if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) QSKIP("Real GPS not suitable for autotesting, skipping the test.", SkipAll); #endif QFETCH(int, timeout); QSignalSpy spy(m_source, SIGNAL(updateTimeout())); m_source->requestUpdate(timeout); QTRY_COMPARE(spy.count(), 1); }
// TC_ID_3_x_2 : Create position source and call requestUpdate with a timeout less than // minimumupdateInterval void TestQGeoPositionInfoSource::requestUpdate_timeoutLessThanMinimumInterval() { CHECK_SOURCE_VALID; QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout())); m_source->requestUpdate(1); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_COMPARE_WITH_TIMEOUT(spyTimeout.count(), 1, 1000); }
QGeoPositionInfoSource *GpsLocation::getGpsSource() { if (haveSource == NOGPS) return 0; if (!m_GpsSource) { m_GpsSource = QGeoPositionInfoSource::createDefaultSource(this); if (m_GpsSource != 0) { #if defined(Q_OS_IOS) // at least Qt 5.6.0 isn't doing things right on iOS - it MUST check for permission before // accessing the position source // I have a hacked version of Qt 5.6.0 that I will build the iOS binaries with for now; // this test below righ after creating the source checks if the location service is disabled // and set's an error right when the position source is created to indicate this if (m_GpsSource->error() == QGeoPositionInfoSource::AccessError) { haveSource = NOGPS; emit haveSourceChanged(); m_GpsSource = NULL; return NULL; } #endif haveSource = (m_GpsSource->supportedPositioningMethods() & QGeoPositionInfoSource::SatellitePositioningMethods) ? HAVEGPS : NOGPS; emit haveSourceChanged(); #ifndef SUBSURFACE_MOBILE if (verbose) #endif status(QString("Created position source %1").arg(m_GpsSource->sourceName())); connect(m_GpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo))); connect(m_GpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); connect(m_GpsSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(positionSourceError(QGeoPositionInfoSource::Error))); setGpsTimeThreshold(prefs.time_threshold); } else { #ifdef SUBSURFACE_MOBILE status("don't have GPS source"); #endif haveSource = NOGPS; emit haveSourceChanged(); } } return m_GpsSource; }
GpsLocation::GpsLocation(QObject *parent) : QObject(parent), Location("0", "0", "GPS", "GPS"), m_gps(QGeoPositionInfoSource::createDefaultSource(this)), m_active(false), latitude(0), longitude(0) { m_valid = false; m_gps->setUpdateInterval(20000); connect(m_gps, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(updateLocation(QGeoPositionInfo))); connect(m_gps, SIGNAL(updateTimeout()), this, SLOT(timeout())); }
void Daemon::createGPS() { if (!m_location) { m_location = QGeoPositionInfoSource::createDefaultSource(this); m_location->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods); m_location->setUpdateInterval(10*1000); // System has some positioning source found if (m_location) { QObject::connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); QObject::connect(m_location, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); } else { // System has not any positioning source log("Device has not any positioning source. WhoWhereDaemon is exiting"); // Exit application QCoreApplication::exit(); } } }
// TC_ID_3_x_1 : Create position source and call requestUpdate with valid timeout value void TestQGeoPositionInfoSource::requestUpdate_validTimeout() { CHECK_SOURCE_VALID; QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&))); QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout())); m_source->requestUpdate(7000); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000); }