2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Henri Lampela - henri.lampela@ixonos.com
7 Jussi Laitinen - jussi.laitinen@ixonos.com
8 Sami Rämö - sami.ramo@ixonos.com
10 Situare is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 version 2 as published by the Free Software Foundation.
14 Situare is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Situare; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
27 #include <QMessageBox>
28 #include <QNetworkReply>
31 #include "application.h"
36 #include "facebookservice/facebookauthentication.h"
37 #include "gps/gpsposition.h"
38 #include "map/mapengine.h"
39 #include "routing/routingservice.h"
41 #include "network/networkaccessmanager.h"
42 #include "situareservice/situareservice.h"
43 #include "ui/mainwindow.h"
47 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED"; ///< GPS setting
48 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";///< Auto centering setting
49 const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12; ///< Default zoom level when GPS available
50 const qreal USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE = 0.003;///< Min value for user move latitude
51 const qreal USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE = 0.001;///< Min value for user move longitude
52 const int MIN_UPDATE_INTERVAL_MSECS = 5*60*1000;
54 SituareEngine::SituareEngine()
55 : m_autoCenteringEnabled(false),
56 m_automaticUpdateFirstStart(true),
57 m_automaticUpdateRequest(false),
59 m_automaticUpdateIntervalTimer(0),
60 m_lastUpdatedGPSPosition(GeoCoordinate())
62 qDebug() << __PRETTY_FUNCTION__;
64 m_ui = new MainWindow;
65 m_ui->updateItemVisibility();
68 m_app = static_cast<Application *>(qApp);
69 m_app->registerWindow(m_ui->winId());
71 connect(m_app, SIGNAL(topmostChanged(bool)),
72 this, SLOT(enablePowerSave(bool)));
75 m_networkAccessManager = new NetworkAccessManager(this);
78 m_mapEngine = new MapEngine(this);
79 m_ui->setMapViewScene(m_mapEngine->scene());
82 m_gps = new GPSPosition(this);
84 // build SituareService
85 m_situareService = new SituareService(this);
87 // build FacebookAuthenticator
88 m_facebookAuthenticator = new FacebookAuthentication(this);
90 // build routing service
91 m_routingService = new RoutingService(this); // create this when needed, not in constructor!
94 signalsFromMapEngine();
96 signalsFromRoutingService();
97 signalsFromSituareService();
98 signalsFromMainWindow();
99 signalsFromFacebookAuthenticator();
101 connect(this, SIGNAL(userLocationReady(User*)),
102 m_ui, SIGNAL(userLocationReady(User*)));
104 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
105 m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
107 connect(this, SIGNAL(userLocationReady(User*)),
108 m_mapEngine, SLOT(receiveOwnLocation(User*)));
110 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
111 m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
113 connect(this, SIGNAL(friendImageReady(User*)),
114 m_ui, SIGNAL(friendImageReady(User*)));
116 connect(this, SIGNAL(friendImageReady(User*)),
117 m_mapEngine, SIGNAL(friendImageReady(User*)));
119 m_automaticUpdateIntervalTimer = new QTimer(this);
120 connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
121 this, SLOT(startAutomaticUpdate()));
123 // signals connected, now it's time to show the main window
124 // but init the MapEngine before so starting location is set
128 m_facebookAuthenticator->start();
130 m_gps->setMode(GPSPosition::Default);
131 initializeGpsAndAutocentering();
133 m_mce = new MCE(this);
134 connect(m_mce, SIGNAL(displayOff(bool)), this, SLOT(enablePowerSave(bool)));
137 SituareEngine::~SituareEngine()
139 qDebug() << __PRETTY_FUNCTION__;
143 QSettings settings(DIRECTORY_NAME, FILE_NAME);
144 settings.setValue(SETTINGS_GPS_ENABLED, m_gps->isRunning());
145 settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
148 void SituareEngine::changeAutoCenteringSetting(bool enabled)
150 qDebug() << __PRETTY_FUNCTION__ << enabled;
152 m_autoCenteringEnabled = enabled;
153 setAutoCentering(enabled);
156 void SituareEngine::disableAutoCentering()
158 qDebug() << __PRETTY_FUNCTION__;
160 changeAutoCenteringSetting(false);
163 void SituareEngine::draggingModeTriggered()
166 m_mce->vibrationFeedback();
169 void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
171 qDebug() << __PRETTY_FUNCTION__;
173 //Show automatic update confirmation dialog
174 if (m_automaticUpdateFirstStart && m_gps->isRunning() && enabled) {
175 m_ui->showEnableAutomaticUpdateLocationDialog(
176 tr("Do you want to enable automatic location update with %1 min update interval?")
177 .arg(updateIntervalMsecs/1000/60));
178 m_automaticUpdateFirstStart = false;
180 if (enabled && m_gps->isRunning()) {
181 m_ui->buildInformationBox(tr("Automatic location update enabled"));
182 if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
183 m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
185 m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
187 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
188 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
190 m_automaticUpdateIntervalTimer->start();
193 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
194 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
196 m_automaticUpdateIntervalTimer->stop();
201 void SituareEngine::enablePowerSave(bool enabled)
203 qDebug() << __PRETTY_FUNCTION__ << enabled;
205 m_gps->enablePowerSave(enabled);
207 if(m_autoCenteringEnabled)
208 m_mapEngine->setAutoCentering(!enabled);
211 void SituareEngine::error(const int context, const int error)
213 qDebug() << __PRETTY_FUNCTION__;
217 case SituareError::ERROR_GENERAL:
218 if(context == ErrorContext::SITUARE) {
219 m_ui->toggleProgressIndicator(false);
220 m_ui->buildInformationBox(tr("Unknown server error"), true);
223 case 1: //errors: SituareError::ERROR_MISSING_ARGUMENT and QNetworkReply::ConnectionRefusedError
224 m_ui->toggleProgressIndicator(false);
225 if(context == ErrorContext::SITUARE) {
226 m_ui->buildInformationBox(tr("Missing parameter from request"), true);
227 } else if(context == ErrorContext::NETWORK) {
228 m_ui->buildInformationBox(tr("Connection refused by the server"), true);
231 case QNetworkReply::RemoteHostClosedError:
232 if(context == ErrorContext::NETWORK) {
233 m_ui->toggleProgressIndicator(false);
234 m_ui->buildInformationBox(tr("Connection closed by the server"), true);
237 case QNetworkReply::HostNotFoundError:
238 if(context == ErrorContext::NETWORK) {
239 m_ui->toggleProgressIndicator(false);
240 m_ui->buildInformationBox(tr("Remote server not found"), true);
243 case QNetworkReply::TimeoutError:
244 if(context == ErrorContext::NETWORK) {
245 m_ui->toggleProgressIndicator(false);
246 m_ui->buildInformationBox(tr("Connection timed out"), true);
249 case QNetworkReply::UnknownNetworkError:
250 if(context == ErrorContext::NETWORK) {
251 m_ui->toggleProgressIndicator(false);
252 m_ui->buildInformationBox(tr("No network connection"), true);
255 case SituareError::SESSION_EXPIRED:
256 m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
257 m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
258 m_situareService->clearUserData();
259 m_ui->loggedIn(false);
262 case SituareError::LOGIN_FAILED:
263 m_ui->toggleProgressIndicator(false);
264 m_ui->buildInformationBox(tr("Invalid E-mail address or password"), true);
267 case SituareError::UPDATE_FAILED:
268 m_ui->toggleProgressIndicator(false);
269 m_ui->buildInformationBox(tr("Update failed, please try again"), true);
271 case SituareError::DATA_RETRIEVAL_FAILED:
272 m_ui->toggleProgressIndicator(false);
273 m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
275 case SituareError::ADDRESS_RETRIEVAL_FAILED:
276 case SituareError::ERROR_GEOLOCATION_REQUEST_FAIL:
277 case SituareError::ERROR_GEOLOCATION_LONLAT_INVALID:
278 m_ui->toggleProgressIndicator(false);
279 m_ui->buildInformationBox(tr("Address retrieval failed"), true);
281 case SituareError::IMAGE_DOWNLOAD_FAILED:
282 m_ui->buildInformationBox(tr("Image download failed"), true);
284 case SituareError::MAP_IMAGE_DOWNLOAD_FAILED:
285 m_ui->buildInformationBox(tr("Map image download failed"), true);
287 case SituareError::GPS_INITIALIZATION_FAILED:
289 m_ui->buildInformationBox(tr("GPS initialization failed"), true);
291 case SituareError::INVALID_JSON:
292 m_ui->buildInformationBox(tr("Malformatted reply from server"), true);
293 m_ui->loggedIn(false);
294 m_facebookAuthenticator->clearAccountInformation(false); // clean all
296 case SituareError::ERROR_GEOLOCATION_SERVER_UNAVAILABLE:
297 m_ui->toggleProgressIndicator(false);
298 m_ui->buildInformationBox(tr("Address server not responding"), true);
301 m_ui->toggleProgressIndicator(false);
302 if(context == ErrorContext::NETWORK)
303 qCritical() << __PRETTY_FUNCTION__ << "QNetworkReply::NetworkError: " << error;
305 qCritical() << __PRETTY_FUNCTION__ << "Unknown error: " << error;
311 void SituareEngine::fetchUsernameFromSettings()
313 qDebug() << __PRETTY_FUNCTION__;
315 m_ui->setUsername(m_facebookAuthenticator->loadUsername());
318 void SituareEngine::imageReady(User *user)
320 qDebug() << __PRETTY_FUNCTION__;
323 emit userLocationReady(user);
325 emit friendImageReady(user);
328 void SituareEngine::initializeGpsAndAutocentering()
330 qDebug() << __PRETTY_FUNCTION__;
332 QSettings settings(DIRECTORY_NAME, FILE_NAME);
333 QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
334 QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
336 if (m_gps->isInitialized()) {
338 if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
340 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
341 this, SLOT(setFirstStartZoomLevel()));
343 changeAutoCenteringSetting(true);
346 m_ui->buildInformationBox(tr("GPS enabled"));
348 } else { // Normal start
349 changeAutoCenteringSetting(autoCenteringEnabled.toBool());
350 setGPS(gpsEnabled.toBool());
352 if (gpsEnabled.toBool())
353 m_ui->buildInformationBox(tr("GPS enabled"));
360 void SituareEngine::locationDataReady(QList<Location> &result)
362 qDebug() << __PRETTY_FUNCTION__;
364 Q_UNUSED(result) /// @todo remove Q_UNUSED
367 void SituareEngine::locationSearch(QString location)
369 qDebug() << __PRETTY_FUNCTION__;
371 if(!location.isEmpty())
372 m_routingService->requestLocation(location);
375 void SituareEngine::loginActionPressed()
377 qDebug() << __PRETTY_FUNCTION__;
379 if (m_networkAccessManager->isConnected()) {
380 if(m_ui->loginState()) {
382 m_situareService->clearUserData();
384 m_facebookAuthenticator->start();
388 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
392 void SituareEngine::loginOk()
394 qDebug() << __PRETTY_FUNCTION__;
396 m_ui->loggedIn(true);
399 m_situareService->fetchLocations(); // request user locations
401 if (m_gps->isRunning())
402 m_ui->readAutomaticLocationUpdateSettings();
405 void SituareEngine::loginProcessCancelled()
407 qDebug() << __PRETTY_FUNCTION__;
409 m_ui->toggleProgressIndicator(false);
410 m_ui->updateItemVisibility();
413 void SituareEngine::logout()
415 qDebug() << __PRETTY_FUNCTION__;
417 m_ui->loggedIn(false);
419 // signal to clear locationUpdateDialog's data
420 connect(this, SIGNAL(clearUpdateLocationDialogData()),
421 m_ui, SIGNAL(clearUpdateLocationDialogData()));
422 emit clearUpdateLocationDialogData();
424 m_facebookAuthenticator->clearAccountInformation(); // clear all
425 m_automaticUpdateFirstStart = true;
428 void SituareEngine::refreshUserData()
430 qDebug() << __PRETTY_FUNCTION__;
432 if (m_networkAccessManager->isConnected()) {
433 m_ui->toggleProgressIndicator(true);
434 m_situareService->fetchLocations();
437 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
441 void SituareEngine::requestAddress()
443 qDebug() << __PRETTY_FUNCTION__;
445 if (m_networkAccessManager->isConnected()) {
446 if (m_gps->isRunning())
447 m_situareService->reverseGeo(m_gps->lastPosition());
449 m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
452 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
456 void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
458 qDebug() << __PRETTY_FUNCTION__;
460 if (m_networkAccessManager->isConnected()) {
461 m_ui->toggleProgressIndicator(true);
463 if (m_gps->isRunning())
464 m_situareService->updateLocation(m_gps->lastPosition(), status, publish);
466 m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
469 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
473 void SituareEngine::requestAutomaticUpdateIfMoved(GeoCoordinate position)
475 qDebug() << __PRETTY_FUNCTION__;
477 if ((fabs(m_lastUpdatedGPSPosition.longitude() - position.longitude()) >
478 USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE) ||
479 (fabs(m_lastUpdatedGPSPosition.latitude() - position.latitude()) >
480 USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE)) {
482 m_lastUpdatedGPSPosition = position;
486 if (m_automaticUpdateRequest && m_userMoved) {
487 requestUpdateLocation(tr("Automatic location update"));
488 m_automaticUpdateRequest = false;
493 void SituareEngine::setAutoCentering(bool enabled)
495 qDebug() << __PRETTY_FUNCTION__ << enabled;
497 m_ui->setIndicatorButtonEnabled(enabled);
498 m_mapEngine->setAutoCentering(enabled);
499 m_ui->setOwnLocationCrosshairVisibility(!enabled);
503 m_gps->requestLastPosition();
507 void SituareEngine::setFirstStartZoomLevel()
509 qDebug() << __PRETTY_FUNCTION__;
511 if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
512 m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
514 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
515 this, SLOT(setFirstStartZoomLevel()));
518 void SituareEngine::setGPS(bool enabled)
520 qDebug() << __PRETTY_FUNCTION__ << enabled;
522 if (m_gps->isInitialized()) {
523 m_ui->setGPSButtonEnabled(enabled);
524 m_mapEngine->setGPSEnabled(enabled);
526 if (enabled && !m_gps->isRunning()) {
528 m_gps->requestLastPosition();
530 if(m_ui->loginState())
531 m_ui->readAutomaticLocationUpdateSettings();
533 else if (!enabled && m_gps->isRunning()) {
535 changeAutoCenteringSetting(false);
536 enableAutomaticLocationUpdate(false);
541 m_ui->buildInformationBox(tr("Unable to start GPS"));
542 m_ui->setGPSButtonEnabled(false);
543 m_mapEngine->setGPSEnabled(false);
547 void SituareEngine::signalsFromFacebookAuthenticator()
549 qDebug() << __PRETTY_FUNCTION__;
551 connect(m_facebookAuthenticator, SIGNAL(error(int, int)),
552 this, SLOT(error(int, int)));
554 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
555 m_situareService, SLOT(credentialsReady(FacebookCredentials)));
557 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
558 this, SLOT(loginOk()));
560 connect(m_facebookAuthenticator, SIGNAL(newLoginRequest()),
561 m_ui, SLOT(startLoginProcess()));
563 connect(m_facebookAuthenticator, SIGNAL(saveCookiesRequest()),
564 m_ui, SLOT(saveCookies()));
566 connect(m_facebookAuthenticator, SIGNAL(loginUsingCookies()),
567 m_ui, SLOT(loginUsingCookies()));
570 void SituareEngine::signalsFromGPS()
572 qDebug() << __PRETTY_FUNCTION__;
574 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
575 m_mapEngine, SLOT(gpsPositionUpdate(GeoCoordinate, qreal)));
577 connect(m_gps, SIGNAL(timeout()),
578 m_ui, SLOT(gpsTimeout()));
580 connect(m_gps, SIGNAL(error(int, int)),
581 this, SLOT(error(int, int)));
584 void SituareEngine::signalsFromMainWindow()
586 qDebug() << __PRETTY_FUNCTION__;
588 connect(m_ui, SIGNAL(error(int, int)),
589 this, SLOT(error(int, int)));
591 connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
592 this, SLOT(fetchUsernameFromSettings()));
594 connect(m_ui, SIGNAL(loginActionPressed()),
595 this, SLOT(loginActionPressed()));
597 connect(m_ui, SIGNAL(saveUsername(QString)),
598 m_facebookAuthenticator, SLOT(saveUsername(QString)));
600 connect(m_ui, SIGNAL(updateCredentials(QUrl)),
601 m_facebookAuthenticator, SLOT(updateCredentials(QUrl)));
603 // signals from map view
604 connect(m_ui, SIGNAL(mapViewScrolled(SceneCoordinate)),
605 m_mapEngine, SLOT(setCenterPosition(SceneCoordinate)));
607 connect(m_ui, SIGNAL(mapViewResized(QSize)),
608 m_mapEngine, SLOT(viewResized(QSize)));
610 connect(m_ui, SIGNAL(viewZoomFinished()),
611 m_mapEngine, SLOT(viewZoomFinished()));
613 // signals from zoom buttons (zoom panel and volume buttons)
614 connect(m_ui, SIGNAL(zoomIn()),
615 m_mapEngine, SLOT(zoomIn()));
617 connect(m_ui, SIGNAL(zoomOut()),
618 m_mapEngine, SLOT(zoomOut()));
620 // signals from menu buttons
621 connect(m_ui, SIGNAL(gpsTriggered(bool)),
622 this, SLOT(setGPS(bool)));
624 //signals from dialogs
625 connect(m_ui, SIGNAL(cancelLoginProcess()),
626 this, SLOT(loginProcessCancelled()));
628 connect(m_ui, SIGNAL(requestReverseGeo()),
629 this, SLOT(requestAddress()));
631 connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
632 this, SLOT(requestUpdateLocation(QString,bool)));
634 connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
635 this, SLOT(enableAutomaticLocationUpdate(bool, int)));
637 // signals from user info tab
638 connect(m_ui, SIGNAL(refreshUserData()),
639 this, SLOT(refreshUserData()));
641 connect(m_ui, SIGNAL(findUser(GeoCoordinate)),
642 m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
644 // signals from friend list tab
645 connect(m_ui, SIGNAL(findFriend(GeoCoordinate)),
646 m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
648 // signals from distence indicator button
649 connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
650 this, SLOT(changeAutoCenteringSetting(bool)));
652 connect(m_ui, SIGNAL(searchForLocation(QString)),
653 this, SLOT(locationSearch(QString)));
655 connect(m_ui, SIGNAL(draggingModeTriggered()),
656 this, SLOT(draggingModeTriggered()));
659 void SituareEngine::signalsFromMapEngine()
661 qDebug() << __PRETTY_FUNCTION__;
663 connect(m_mapEngine, SIGNAL(error(int, int)),
664 this, SLOT(error(int, int)));
666 connect(m_mapEngine, SIGNAL(locationChanged(SceneCoordinate)),
667 m_ui, SIGNAL(centerToSceneCoordinates(SceneCoordinate)));
669 connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
670 m_ui, SIGNAL(zoomLevelChanged(int)));
672 connect(m_mapEngine, SIGNAL(mapScrolledManually()),
673 this, SLOT(disableAutoCentering()));
675 connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
676 m_ui, SIGNAL(maxZoomLevelReached()));
678 connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
679 m_ui, SIGNAL(minZoomLevelReached()));
681 connect(m_mapEngine, SIGNAL(locationItemClicked(QList<QString>)),
682 m_ui, SIGNAL(locationItemClicked(QList<QString>)));
684 connect(m_mapEngine, SIGNAL(newMapResolution(qreal)),
685 m_ui, SIGNAL(newMapResolution(qreal)));
688 void SituareEngine::signalsFromRoutingService()
690 qDebug() << __PRETTY_FUNCTION__;
692 connect(m_routingService, SIGNAL(locationDataParsed(QList<Location>&)),
693 this, SLOT(locationDataReady(QList<Location>&)));
695 connect(m_routingService, SIGNAL(routeParsed(Route&)),
696 m_mapEngine, SLOT(setRoute(Route&)));
700 void SituareEngine::signalsFromSituareService()
702 qDebug() << __PRETTY_FUNCTION__;
704 connect(m_situareService, SIGNAL(error(int, int)),
705 this, SLOT(error(int, int)));
707 connect(m_situareService, SIGNAL(imageReady(User*)),
708 this, SLOT(imageReady(User*)));
710 connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
711 m_ui, SIGNAL(reverseGeoReady(QString)));
713 connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
714 this, SLOT(userDataChanged(User*, QList<User*>&)));
716 connect(m_situareService, SIGNAL(updateWasSuccessful()),
717 this, SLOT(updateWasSuccessful()));
719 connect(m_situareService, SIGNAL(updateWasSuccessful()),
720 m_ui, SIGNAL(clearUpdateLocationDialogData()));
723 void SituareEngine::startAutomaticUpdate()
725 qDebug() << __PRETTY_FUNCTION__;
727 m_gps->requestUpdate();
728 m_automaticUpdateRequest = true;
731 void SituareEngine::updateWasSuccessful()
733 qDebug() << __PRETTY_FUNCTION__;
735 if (m_networkAccessManager->isConnected())
736 m_situareService->fetchLocations();
738 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
741 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
743 qDebug() << __PRETTY_FUNCTION__;
745 m_ui->toggleProgressIndicator(false);
748 emit userLocationReady(user);
749 emit friendsLocationsReady(friendsList);