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"
35 #include "facebookservice/facebookauthentication.h"
36 #include "gps/gpsposition.h"
37 #include "map/mapengine.h"
38 #include "routing/routingservice.h"
40 #include "network/networkaccessmanager.h"
41 #include "situareservice/situareservice.h"
42 #include "ui/mainwindow.h"
46 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED"; ///< GPS setting
47 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";///< Auto centering setting
48 const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12; ///< Default zoom level when GPS available
49 const qreal USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE = 0.003;///< Min value for user move latitude
50 const qreal USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE = 0.001;///< Min value for user move longitude
51 const int MIN_UPDATE_INTERVAL_MSECS = 5*60*1000;
53 SituareEngine::SituareEngine()
54 : m_autoCenteringEnabled(false),
55 m_automaticUpdateFirstStart(true),
56 m_automaticUpdateRequest(false),
58 m_automaticUpdateIntervalTimer(0),
59 m_lastUpdatedGPSPosition(GeoCoordinate())
61 qDebug() << __PRETTY_FUNCTION__;
63 m_ui = new MainWindow;
64 m_ui->updateItemVisibility();
67 m_app = static_cast<Application *>(qApp);
68 m_app->registerWindow(m_ui->winId());
70 connect(m_app, SIGNAL(topmostChanged(bool)),
71 this, SLOT(enablePowerSave(bool)));
74 m_networkAccessManager = new NetworkAccessManager(this);
77 m_mapEngine = new MapEngine(this);
78 m_ui->setMapViewScene(m_mapEngine->scene());
81 m_gps = new GPSPosition(this);
83 // build SituareService
84 m_situareService = new SituareService(this);
86 // build FacebookAuthenticator
87 m_facebookAuthenticator = new FacebookAuthentication(this);
89 // build routing service
90 m_routingService = new RoutingService(this); // create this when needed, not in constructor!
93 signalsFromMapEngine();
95 signalsFromRoutingService();
96 signalsFromSituareService();
97 signalsFromMainWindow();
98 signalsFromFacebookAuthenticator();
100 connect(this, SIGNAL(userLocationReady(User*)),
101 m_ui, SIGNAL(userLocationReady(User*)));
103 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
104 m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
106 connect(this, SIGNAL(userLocationReady(User*)),
107 m_mapEngine, SLOT(receiveOwnLocation(User*)));
109 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
110 m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
112 connect(this, SIGNAL(friendImageReady(User*)),
113 m_ui, SIGNAL(friendImageReady(User*)));
115 connect(this, SIGNAL(friendImageReady(User*)),
116 m_mapEngine, SIGNAL(friendImageReady(User*)));
118 m_automaticUpdateIntervalTimer = new QTimer(this);
119 connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
120 this, SLOT(startAutomaticUpdate()));
122 // signals connected, now it's time to show the main window
123 // but init the MapEngine before so starting location is set
127 m_facebookAuthenticator->start();
129 m_gps->setMode(GPSPosition::Default);
130 initializeGpsAndAutocentering();
132 m_mce = new MCE(this);
133 connect(m_mce, SIGNAL(displayOff(bool)), this, SLOT(enablePowerSave(bool)));
136 SituareEngine::~SituareEngine()
138 qDebug() << __PRETTY_FUNCTION__;
142 QSettings settings(DIRECTORY_NAME, FILE_NAME);
143 settings.setValue(SETTINGS_GPS_ENABLED, m_gps->isRunning());
144 settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
147 void SituareEngine::changeAutoCenteringSetting(bool enabled)
149 qDebug() << __PRETTY_FUNCTION__ << enabled;
151 m_autoCenteringEnabled = enabled;
152 setAutoCentering(enabled);
155 void SituareEngine::disableAutoCentering()
157 qDebug() << __PRETTY_FUNCTION__;
159 changeAutoCenteringSetting(false);
162 void SituareEngine::draggingModeTriggered()
165 m_mce->vibrationFeedback();
168 void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
170 qDebug() << __PRETTY_FUNCTION__;
172 //Show automatic update confirmation dialog
173 if (m_automaticUpdateFirstStart && m_gps->isRunning() && enabled) {
174 m_ui->showEnableAutomaticUpdateLocationDialog(
175 tr("Do you want to enable automatic location update with %1 min update interval?")
176 .arg(updateIntervalMsecs/1000/60));
177 m_automaticUpdateFirstStart = false;
179 if (enabled && m_gps->isRunning()) {
180 m_ui->buildInformationBox(tr("Automatic location update enabled"));
181 if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
182 m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
184 m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
186 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
187 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
189 m_automaticUpdateIntervalTimer->start();
192 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
193 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
195 m_automaticUpdateIntervalTimer->stop();
200 void SituareEngine::enablePowerSave(bool enabled)
202 qDebug() << __PRETTY_FUNCTION__ << enabled;
204 m_gps->enablePowerSave(enabled);
206 if(m_autoCenteringEnabled)
207 m_mapEngine->setAutoCentering(!enabled);
210 void SituareEngine::error(const int context, const int error)
212 qDebug() << __PRETTY_FUNCTION__;
216 case SituareError::ERROR_GENERAL:
217 if(context == ErrorContext::SITUARE) {
218 m_ui->toggleProgressIndicator(false);
219 m_ui->buildInformationBox(tr("Unknown server error"), true);
222 case 1: //errors: SituareError::ERROR_MISSING_ARGUMENT and QNetworkReply::ConnectionRefusedError
223 m_ui->toggleProgressIndicator(false);
224 if(context == ErrorContext::SITUARE) {
225 m_ui->buildInformationBox(tr("Missing parameter from request"), true);
226 } else if(context == ErrorContext::NETWORK) {
227 m_ui->buildInformationBox(tr("Connection refused by the server"), true);
230 case QNetworkReply::RemoteHostClosedError:
231 if(context == ErrorContext::NETWORK) {
232 m_ui->toggleProgressIndicator(false);
233 m_ui->buildInformationBox(tr("Connection closed by the server"), true);
236 case QNetworkReply::HostNotFoundError:
237 if(context == ErrorContext::NETWORK) {
238 m_ui->toggleProgressIndicator(false);
239 m_ui->buildInformationBox(tr("Remote server not found"), true);
242 case QNetworkReply::TimeoutError:
243 if(context == ErrorContext::NETWORK) {
244 m_ui->toggleProgressIndicator(false);
245 m_ui->buildInformationBox(tr("Connection timed out"), true);
248 case QNetworkReply::UnknownNetworkError:
249 if(context == ErrorContext::NETWORK) {
250 m_ui->toggleProgressIndicator(false);
251 m_ui->buildInformationBox(tr("No network connection"), true);
254 case SituareError::SESSION_EXPIRED:
255 m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
256 m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
257 m_situareService->clearUserData();
258 m_ui->loggedIn(false);
261 case SituareError::LOGIN_FAILED:
262 m_ui->toggleProgressIndicator(false);
263 m_ui->buildInformationBox(tr("Invalid E-mail address or password"), true);
266 case SituareError::UPDATE_FAILED:
267 m_ui->toggleProgressIndicator(false);
268 m_ui->buildInformationBox(tr("Update failed, please try again"), true);
270 case SituareError::DATA_RETRIEVAL_FAILED:
271 m_ui->toggleProgressIndicator(false);
272 m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
274 case SituareError::ADDRESS_RETRIEVAL_FAILED:
275 case SituareError::ERROR_GEOLOCATION_REQUEST_FAIL:
276 case SituareError::ERROR_GEOLOCATION_LONLAT_INVALID:
277 m_ui->toggleProgressIndicator(false);
278 m_ui->buildInformationBox(tr("Address retrieval failed"), true);
280 case SituareError::IMAGE_DOWNLOAD_FAILED:
281 m_ui->buildInformationBox(tr("Image download failed"), true);
283 case SituareError::MAP_IMAGE_DOWNLOAD_FAILED:
284 m_ui->buildInformationBox(tr("Map image download failed"), true);
286 case SituareError::GPS_INITIALIZATION_FAILED:
288 m_ui->buildInformationBox(tr("GPS initialization failed"), true);
290 case SituareError::INVALID_JSON:
291 m_ui->buildInformationBox(tr("Malformatted reply from server"), true);
292 m_ui->loggedIn(false);
293 m_facebookAuthenticator->clearAccountInformation(false); // clean all
295 case SituareError::ERROR_GEOLOCATION_SERVER_UNAVAILABLE:
296 m_ui->toggleProgressIndicator(false);
297 m_ui->buildInformationBox(tr("Address server not responding"), true);
300 m_ui->toggleProgressIndicator(false);
301 if(context == ErrorContext::NETWORK)
302 qCritical() << "QNetworkReply::NetworkError: " << error;
304 qCritical() << "Unknown error: " << error;
310 void SituareEngine::fetchUsernameFromSettings()
312 qDebug() << __PRETTY_FUNCTION__;
314 m_ui->setUsername(m_facebookAuthenticator->loadUsername());
317 void SituareEngine::imageReady(User *user)
319 qDebug() << __PRETTY_FUNCTION__;
322 emit userLocationReady(user);
324 emit friendImageReady(user);
327 void SituareEngine::initializeGpsAndAutocentering()
329 qDebug() << __PRETTY_FUNCTION__;
331 QSettings settings(DIRECTORY_NAME, FILE_NAME);
332 QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
333 QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
335 if (m_gps->isInitialized()) {
337 if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
339 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
340 this, SLOT(setFirstStartZoomLevel()));
342 changeAutoCenteringSetting(true);
345 m_ui->buildInformationBox(tr("GPS enabled"));
347 } else { // Normal start
348 changeAutoCenteringSetting(autoCenteringEnabled.toBool());
349 setGPS(gpsEnabled.toBool());
351 if (gpsEnabled.toBool())
352 m_ui->buildInformationBox(tr("GPS enabled"));
359 void SituareEngine::locationDataReady(QList<Location> &result)
361 qDebug() << __PRETTY_FUNCTION__;
363 Q_UNUSED(result) /// @todo remove Q_UNUSED
366 void SituareEngine::locationSearch(QString location)
368 qDebug() << __PRETTY_FUNCTION__;
370 if(!location.isEmpty())
371 m_routingService->requestLocation(location);
374 void SituareEngine::loginActionPressed()
376 qDebug() << __PRETTY_FUNCTION__;
378 if (m_networkAccessManager->isConnected()) {
379 if(m_ui->loginState()) {
381 m_situareService->clearUserData();
383 m_facebookAuthenticator->start();
387 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
391 void SituareEngine::loginOk()
393 qDebug() << __PRETTY_FUNCTION__;
395 m_ui->loggedIn(true);
398 m_situareService->fetchLocations(); // request user locations
400 if (m_gps->isRunning())
401 m_ui->readAutomaticLocationUpdateSettings();
404 void SituareEngine::loginProcessCancelled()
406 qDebug() << __PRETTY_FUNCTION__;
408 m_ui->toggleProgressIndicator(false);
409 m_ui->updateItemVisibility();
412 void SituareEngine::logout()
414 qDebug() << __PRETTY_FUNCTION__;
416 m_ui->loggedIn(false);
418 // signal to clear locationUpdateDialog's data
419 connect(this, SIGNAL(clearUpdateLocationDialogData()),
420 m_ui, SIGNAL(clearUpdateLocationDialogData()));
421 emit clearUpdateLocationDialogData();
423 m_facebookAuthenticator->clearAccountInformation(); // clear all
424 m_automaticUpdateFirstStart = true;
427 void SituareEngine::refreshUserData()
429 qDebug() << __PRETTY_FUNCTION__;
431 if (m_networkAccessManager->isConnected()) {
432 m_ui->toggleProgressIndicator(true);
433 m_situareService->fetchLocations();
436 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
440 void SituareEngine::requestAddress()
442 qDebug() << __PRETTY_FUNCTION__;
444 if (m_networkAccessManager->isConnected()) {
445 if (m_gps->isRunning())
446 m_situareService->reverseGeo(m_gps->lastPosition());
448 m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
451 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
455 void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
457 qDebug() << __PRETTY_FUNCTION__;
459 if (m_networkAccessManager->isConnected()) {
460 m_ui->toggleProgressIndicator(true);
462 if (m_gps->isRunning())
463 m_situareService->updateLocation(m_gps->lastPosition(), status, publish);
465 m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
468 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
472 void SituareEngine::requestAutomaticUpdateIfMoved(GeoCoordinate position)
474 qDebug() << __PRETTY_FUNCTION__;
476 if ((fabs(m_lastUpdatedGPSPosition.longitude() - position.longitude()) >
477 USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE) ||
478 (fabs(m_lastUpdatedGPSPosition.latitude() - position.latitude()) >
479 USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE)) {
481 m_lastUpdatedGPSPosition = position;
485 if (m_automaticUpdateRequest && m_userMoved) {
486 requestUpdateLocation(tr("Automatic location update"));
487 m_automaticUpdateRequest = false;
492 void SituareEngine::setAutoCentering(bool enabled)
494 qDebug() << __PRETTY_FUNCTION__ << enabled;
496 m_ui->setIndicatorButtonEnabled(enabled);
497 m_mapEngine->setAutoCentering(enabled);
498 m_ui->setOwnLocationCrosshairVisibility(!enabled);
502 m_gps->requestLastPosition();
506 void SituareEngine::setFirstStartZoomLevel()
508 qDebug() << __PRETTY_FUNCTION__;
510 if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
511 m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
513 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
514 this, SLOT(setFirstStartZoomLevel()));
517 void SituareEngine::setGPS(bool enabled)
519 qDebug() << __PRETTY_FUNCTION__ << enabled;
521 if (m_gps->isInitialized()) {
522 m_ui->setGPSButtonEnabled(enabled);
523 m_mapEngine->setGPSEnabled(enabled);
525 if (enabled && !m_gps->isRunning()) {
527 m_gps->requestLastPosition();
529 if(m_ui->loginState())
530 m_ui->readAutomaticLocationUpdateSettings();
532 else if (!enabled && m_gps->isRunning()) {
534 changeAutoCenteringSetting(false);
535 enableAutomaticLocationUpdate(false);
540 m_ui->buildInformationBox(tr("Unable to start GPS"));
541 m_ui->setGPSButtonEnabled(false);
542 m_mapEngine->setGPSEnabled(false);
546 void SituareEngine::signalsFromFacebookAuthenticator()
548 qDebug() << __PRETTY_FUNCTION__;
550 connect(m_facebookAuthenticator, SIGNAL(error(int, int)),
551 this, SLOT(error(int, int)));
553 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
554 m_situareService, SLOT(credentialsReady(FacebookCredentials)));
556 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
557 this, SLOT(loginOk()));
559 connect(m_facebookAuthenticator, SIGNAL(newLoginRequest()),
560 m_ui, SLOT(startLoginProcess()));
562 connect(m_facebookAuthenticator, SIGNAL(saveCookiesRequest()),
563 m_ui, SLOT(saveCookies()));
565 connect(m_facebookAuthenticator, SIGNAL(loginUsingCookies()),
566 m_ui, SLOT(loginUsingCookies()));
569 void SituareEngine::signalsFromGPS()
571 qDebug() << __PRETTY_FUNCTION__;
573 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
574 m_mapEngine, SLOT(gpsPositionUpdate(GeoCoordinate, qreal)));
576 connect(m_gps, SIGNAL(timeout()),
577 m_ui, SLOT(gpsTimeout()));
579 connect(m_gps, SIGNAL(error(int, int)),
580 this, SLOT(error(int, int)));
583 void SituareEngine::signalsFromMainWindow()
585 qDebug() << __PRETTY_FUNCTION__;
587 connect(m_ui, SIGNAL(error(int, int)),
588 this, SLOT(error(int, int)));
590 connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
591 this, SLOT(fetchUsernameFromSettings()));
593 connect(m_ui, SIGNAL(loginActionPressed()),
594 this, SLOT(loginActionPressed()));
596 connect(m_ui, SIGNAL(saveUsername(QString)),
597 m_facebookAuthenticator, SLOT(saveUsername(QString)));
599 connect(m_ui, SIGNAL(updateCredentials(QUrl)),
600 m_facebookAuthenticator, SLOT(updateCredentials(QUrl)));
602 // signals from map view
603 connect(m_ui, SIGNAL(mapViewScrolled(SceneCoordinate)),
604 m_mapEngine, SLOT(setCenterPosition(SceneCoordinate)));
606 connect(m_ui, SIGNAL(mapViewResized(QSize)),
607 m_mapEngine, SLOT(viewResized(QSize)));
609 connect(m_ui, SIGNAL(viewZoomFinished()),
610 m_mapEngine, SLOT(viewZoomFinished()));
612 // signals from zoom buttons (zoom panel and volume buttons)
613 connect(m_ui, SIGNAL(zoomIn()),
614 m_mapEngine, SLOT(zoomIn()));
616 connect(m_ui, SIGNAL(zoomOut()),
617 m_mapEngine, SLOT(zoomOut()));
619 // signals from menu buttons
620 connect(m_ui, SIGNAL(gpsTriggered(bool)),
621 this, SLOT(setGPS(bool)));
623 //signals from dialogs
624 connect(m_ui, SIGNAL(cancelLoginProcess()),
625 this, SLOT(loginProcessCancelled()));
627 connect(m_ui, SIGNAL(requestReverseGeo()),
628 this, SLOT(requestAddress()));
630 connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
631 this, SLOT(requestUpdateLocation(QString,bool)));
633 connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
634 this, SLOT(enableAutomaticLocationUpdate(bool, int)));
636 // signals from user info tab
637 connect(m_ui, SIGNAL(refreshUserData()),
638 this, SLOT(refreshUserData()));
640 connect(m_ui, SIGNAL(findUser(GeoCoordinate)),
641 m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
643 // signals from friend list tab
644 connect(m_ui, SIGNAL(findFriend(GeoCoordinate)),
645 m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
647 connect(m_ui, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
648 m_mapEngine, SLOT(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
650 // signals from distence indicator button
651 connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
652 this, SLOT(changeAutoCenteringSetting(bool)));
654 connect(m_ui, SIGNAL(searchForLocation(QString)),
655 this, SLOT(locationSearch(QString)));
657 connect(m_ui, SIGNAL(draggingModeTriggered()),
658 this, SLOT(draggingModeTriggered()));
661 void SituareEngine::signalsFromMapEngine()
663 qDebug() << __PRETTY_FUNCTION__;
665 connect(m_mapEngine, SIGNAL(error(int, int)),
666 this, SLOT(error(int, int)));
668 connect(m_mapEngine, SIGNAL(locationChanged(SceneCoordinate)),
669 m_ui, SIGNAL(centerToSceneCoordinates(SceneCoordinate)));
671 connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
672 m_ui, SIGNAL(zoomLevelChanged(int)));
674 connect(m_mapEngine, SIGNAL(mapScrolledManually()),
675 this, SLOT(disableAutoCentering()));
677 connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
678 m_ui, SIGNAL(maxZoomLevelReached()));
680 connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
681 m_ui, SIGNAL(minZoomLevelReached()));
683 connect(m_mapEngine, SIGNAL(locationItemClicked(QList<QString>)),
684 m_ui, SIGNAL(locationItemClicked(QList<QString>)));
686 connect(m_mapEngine, SIGNAL(newMapResolution(qreal)),
687 m_ui, SIGNAL(newMapResolution(qreal)));
690 void SituareEngine::signalsFromRoutingService()
692 qDebug() << __PRETTY_FUNCTION__;
694 connect(m_routingService, SIGNAL(locationDataParsed(QList<Location>&)),
695 this, SLOT(locationDataReady(QList<Location>&)));
697 connect(m_routingService, SIGNAL(routeParsed(Route&)),
698 m_mapEngine, SLOT(setRoute(Route&)));
700 connect(m_routingService, SIGNAL(locationDataParsed(QList<Location>&)),
701 m_ui, SIGNAL(locationDataParsed(QList<Location>&)));
704 void SituareEngine::signalsFromSituareService()
706 qDebug() << __PRETTY_FUNCTION__;
708 connect(m_situareService, SIGNAL(error(int, int)),
709 this, SLOT(error(int, int)));
711 connect(m_situareService, SIGNAL(imageReady(User*)),
712 this, SLOT(imageReady(User*)));
714 connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
715 m_ui, SIGNAL(reverseGeoReady(QString)));
717 connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
718 this, SLOT(userDataChanged(User*, QList<User*>&)));
720 connect(m_situareService, SIGNAL(updateWasSuccessful()),
721 this, SLOT(updateWasSuccessful()));
723 connect(m_situareService, SIGNAL(updateWasSuccessful()),
724 m_ui, SIGNAL(clearUpdateLocationDialogData()));
727 void SituareEngine::startAutomaticUpdate()
729 qDebug() << __PRETTY_FUNCTION__;
731 m_gps->requestUpdate();
732 m_automaticUpdateRequest = true;
735 void SituareEngine::updateWasSuccessful()
737 qDebug() << __PRETTY_FUNCTION__;
739 if (m_networkAccessManager->isConnected())
740 m_situareService->fetchLocations();
742 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
745 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
747 qDebug() << __PRETTY_FUNCTION__;
749 m_ui->toggleProgressIndicator(false);
752 emit userLocationReady(user);
753 emit friendsLocationsReady(friendsList);