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/geocodingservice.h"
40 #include "routing/routingservice.h"
42 #include "network/networkaccessmanager.h"
43 #include "situareservice/situareservice.h"
44 #include "ui/mainwindow.h"
48 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED"; ///< GPS setting
49 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";///< Auto centering setting
50 const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12; ///< Default zoom level when GPS available
51 const qreal USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE = 0.003;///< Min value for user move latitude
52 const qreal USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE = 0.001;///< Min value for user move longitude
53 const int MIN_UPDATE_INTERVAL_MSECS = 5*60*1000;
55 SituareEngine::SituareEngine()
56 : m_autoCenteringEnabled(false),
57 m_automaticUpdateFirstStart(true),
58 m_automaticUpdateRequest(false),
60 m_automaticUpdateIntervalTimer(0),
61 m_lastUpdatedGPSPosition(GeoCoordinate())
63 qDebug() << __PRETTY_FUNCTION__;
65 m_ui = new MainWindow;
66 m_ui->updateItemVisibility();
69 m_app = static_cast<Application *>(qApp);
70 m_app->registerWindow(m_ui->winId());
72 connect(m_app, SIGNAL(topmostChanged(bool)),
73 this, SLOT(enablePowerSave(bool)));
76 m_networkAccessManager = new NetworkAccessManager(this);
79 m_mapEngine = new MapEngine(this);
80 m_ui->setMapViewScene(m_mapEngine->scene());
83 m_gps = new GPSPosition(this);
85 // build SituareService
86 m_situareService = new SituareService(this);
88 // build FacebookAuthenticator
89 m_facebookAuthenticator = new FacebookAuthentication(this);
91 // build routing service
92 m_routingService = new RoutingService(this); // create this when needed, not in constructor!
94 // build geocoding service
95 m_geocodingService = new GeocodingService(this);
98 signalsFromMapEngine();
99 signalsFromGeocodingService();
101 signalsFromRoutingService();
102 signalsFromSituareService();
103 signalsFromMainWindow();
104 signalsFromFacebookAuthenticator();
106 connect(this, SIGNAL(userLocationReady(User*)),
107 m_ui, SIGNAL(userLocationReady(User*)));
109 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
110 m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
112 connect(this, SIGNAL(userLocationReady(User*)),
113 m_mapEngine, SLOT(receiveOwnLocation(User*)));
115 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
116 m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
118 connect(this, SIGNAL(friendImageReady(User*)),
119 m_ui, SIGNAL(friendImageReady(User*)));
121 connect(this, SIGNAL(friendImageReady(User*)),
122 m_mapEngine, SIGNAL(friendImageReady(User*)));
124 m_automaticUpdateIntervalTimer = new QTimer(this);
125 connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
126 this, SLOT(startAutomaticUpdate()));
128 // signals connected, now it's time to show the main window
129 // but init the MapEngine before so starting location is set
133 m_facebookAuthenticator->start();
135 m_gps->setMode(GPSPosition::Default);
136 initializeGpsAndAutocentering();
138 m_mce = new MCE(this);
139 connect(m_mce, SIGNAL(displayOff(bool)), this, SLOT(enablePowerSave(bool)));
142 SituareEngine::~SituareEngine()
144 qDebug() << __PRETTY_FUNCTION__;
148 QSettings settings(DIRECTORY_NAME, FILE_NAME);
149 settings.setValue(SETTINGS_GPS_ENABLED, m_gps->isRunning());
150 settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
153 void SituareEngine::changeAutoCenteringSetting(bool enabled)
155 qDebug() << __PRETTY_FUNCTION__ << enabled;
157 m_autoCenteringEnabled = enabled;
158 setAutoCentering(enabled);
161 void SituareEngine::disableAutoCentering()
163 qDebug() << __PRETTY_FUNCTION__;
165 changeAutoCenteringSetting(false);
168 void SituareEngine::draggingModeTriggered()
170 qDebug() << __PRETTY_FUNCTION__;
173 m_mce->vibrationFeedback();
176 void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
178 qDebug() << __PRETTY_FUNCTION__;
180 //Show automatic update confirmation dialog
181 if (m_automaticUpdateFirstStart && m_gps->isRunning() && enabled) {
182 m_ui->showEnableAutomaticUpdateLocationDialog(
183 tr("Do you want to enable automatic location update with %1 min update interval?")
184 .arg(updateIntervalMsecs/1000/60));
185 m_automaticUpdateFirstStart = false;
187 if (enabled && m_gps->isRunning()) {
188 m_ui->buildInformationBox(tr("Automatic location update enabled"));
189 if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
190 m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
192 m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
194 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
195 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
197 m_automaticUpdateIntervalTimer->start();
200 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
201 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
203 m_automaticUpdateIntervalTimer->stop();
208 void SituareEngine::enablePowerSave(bool enabled)
210 qDebug() << __PRETTY_FUNCTION__ << enabled;
212 m_gps->enablePowerSave(enabled);
214 if(m_autoCenteringEnabled)
215 m_mapEngine->setAutoCentering(!enabled);
218 void SituareEngine::error(const int context, const int error)
220 qDebug() << __PRETTY_FUNCTION__;
224 case SituareError::ERROR_GENERAL:
225 if(context == ErrorContext::SITUARE) {
226 m_ui->toggleProgressIndicator(false);
227 m_ui->buildInformationBox(tr("Unknown server error"), true);
230 case 1: //errors: SituareError::ERROR_MISSING_ARGUMENT and QNetworkReply::ConnectionRefusedError
231 m_ui->toggleProgressIndicator(false);
232 if(context == ErrorContext::SITUARE) {
233 m_ui->buildInformationBox(tr("Missing parameter from request"), true);
234 } else if(context == ErrorContext::NETWORK) {
235 m_ui->buildInformationBox(tr("Connection refused by the server"), true);
238 case QNetworkReply::RemoteHostClosedError:
239 if(context == ErrorContext::NETWORK) {
240 m_ui->toggleProgressIndicator(false);
241 m_ui->buildInformationBox(tr("Connection closed by the server"), true);
244 case QNetworkReply::HostNotFoundError:
245 if(context == ErrorContext::NETWORK) {
246 m_ui->toggleProgressIndicator(false);
247 m_ui->buildInformationBox(tr("Remote server not found"), true);
250 case QNetworkReply::TimeoutError:
251 if(context == ErrorContext::NETWORK) {
252 m_ui->toggleProgressIndicator(false);
253 m_ui->buildInformationBox(tr("Connection timed out"), true);
256 case QNetworkReply::UnknownNetworkError:
257 if(context == ErrorContext::NETWORK) {
258 m_ui->toggleProgressIndicator(false);
259 m_ui->buildInformationBox(tr("No network connection"), true);
262 case SituareError::SESSION_EXPIRED:
263 m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
264 m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
265 m_situareService->clearUserData();
266 m_ui->loggedIn(false);
269 case SituareError::LOGIN_FAILED:
270 m_ui->toggleProgressIndicator(false);
271 m_ui->buildInformationBox(tr("Invalid E-mail address or password"), true);
274 case SituareError::UPDATE_FAILED:
275 m_ui->toggleProgressIndicator(false);
276 m_ui->buildInformationBox(tr("Update failed, please try again"), true);
278 case SituareError::DATA_RETRIEVAL_FAILED:
279 m_ui->toggleProgressIndicator(false);
280 m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
282 case SituareError::ADDRESS_RETRIEVAL_FAILED:
283 case SituareError::ERROR_GEOLOCATION_REQUEST_FAIL:
284 case SituareError::ERROR_GEOLOCATION_LONLAT_INVALID:
285 m_ui->toggleProgressIndicator(false);
286 m_ui->buildInformationBox(tr("Address retrieval failed"), true);
288 case SituareError::IMAGE_DOWNLOAD_FAILED:
289 m_ui->buildInformationBox(tr("Image download failed"), true);
291 case SituareError::MAP_IMAGE_DOWNLOAD_FAILED:
292 m_ui->buildInformationBox(tr("Map image download failed"), true);
294 case SituareError::GPS_INITIALIZATION_FAILED:
296 m_ui->buildInformationBox(tr("GPS initialization failed"), true);
298 case SituareError::INVALID_JSON:
299 m_ui->buildInformationBox(tr("Malformatted reply from server"), true);
300 m_ui->loggedIn(false);
301 m_facebookAuthenticator->clearAccountInformation(false); // clean all
303 case SituareError::ERROR_GEOLOCATION_SERVER_UNAVAILABLE:
304 m_ui->toggleProgressIndicator(false);
305 m_ui->buildInformationBox(tr("Address server not responding"), true);
308 m_ui->toggleProgressIndicator(false);
309 if(context == ErrorContext::NETWORK)
310 qCritical() << __PRETTY_FUNCTION__ << "QNetworkReply::NetworkError: " << error;
312 qCritical() << __PRETTY_FUNCTION__ << "Unknown error: " << error;
318 void SituareEngine::fetchUsernameFromSettings()
320 qDebug() << __PRETTY_FUNCTION__;
322 m_ui->setUsername(m_facebookAuthenticator->loadUsername());
325 void SituareEngine::imageReady(User *user)
327 qDebug() << __PRETTY_FUNCTION__;
330 emit userLocationReady(user);
332 emit friendImageReady(user);
335 void SituareEngine::initializeGpsAndAutocentering()
337 qDebug() << __PRETTY_FUNCTION__;
339 QSettings settings(DIRECTORY_NAME, FILE_NAME);
340 QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
341 QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
343 if (m_gps->isInitialized()) {
345 if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
347 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
348 this, SLOT(setFirstStartZoomLevel()));
350 changeAutoCenteringSetting(true);
353 m_ui->buildInformationBox(tr("GPS enabled"));
355 } else { // Normal start
356 changeAutoCenteringSetting(autoCenteringEnabled.toBool());
357 setGPS(gpsEnabled.toBool());
359 if (gpsEnabled.toBool())
360 m_ui->buildInformationBox(tr("GPS enabled"));
367 void SituareEngine::locationSearch(QString location)
369 qDebug() << __PRETTY_FUNCTION__;
371 if(!location.isEmpty())
372 m_geocodingService->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::routeParsed(Route &route)
495 qDebug() << __PRETTY_FUNCTION__;
499 m_ui->toggleProgressIndicator(false);
502 void SituareEngine::routeTo(const GeoCoordinate &endPointCoordinates)
504 qDebug() << __PRETTY_FUNCTION__;
506 m_ui->toggleProgressIndicator(true);
508 if (m_gps->isRunning())
509 m_routingService->requestRoute(m_gps->lastPosition(), endPointCoordinates);
511 m_routingService->requestRoute(m_mapEngine->centerGeoCoordinate(), endPointCoordinates);
514 void SituareEngine::setAutoCentering(bool enabled)
516 qDebug() << __PRETTY_FUNCTION__ << enabled;
518 m_ui->setIndicatorButtonEnabled(enabled);
519 m_mapEngine->setAutoCentering(enabled);
520 m_ui->setOwnLocationCrosshairVisibility(!enabled);
524 m_gps->requestLastPosition();
528 void SituareEngine::setFirstStartZoomLevel()
530 qDebug() << __PRETTY_FUNCTION__;
532 if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
533 m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
535 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
536 this, SLOT(setFirstStartZoomLevel()));
539 void SituareEngine::setGPS(bool enabled)
541 qDebug() << __PRETTY_FUNCTION__ << enabled;
543 if (m_gps->isInitialized()) {
544 m_ui->setGPSButtonEnabled(enabled);
545 m_mapEngine->setGPSEnabled(enabled);
547 if (enabled && !m_gps->isRunning()) {
549 m_gps->requestLastPosition();
551 if(m_ui->loginState())
552 m_ui->readAutomaticLocationUpdateSettings();
554 else if (!enabled && m_gps->isRunning()) {
556 changeAutoCenteringSetting(false);
557 enableAutomaticLocationUpdate(false);
562 m_ui->buildInformationBox(tr("Unable to start GPS"));
563 m_ui->setGPSButtonEnabled(false);
564 m_mapEngine->setGPSEnabled(false);
568 void SituareEngine::signalsFromFacebookAuthenticator()
570 qDebug() << __PRETTY_FUNCTION__;
572 connect(m_facebookAuthenticator, SIGNAL(error(int, int)),
573 this, SLOT(error(int, int)));
575 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
576 m_situareService, SLOT(credentialsReady(FacebookCredentials)));
578 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
579 this, SLOT(loginOk()));
581 connect(m_facebookAuthenticator, SIGNAL(newLoginRequest()),
582 m_ui, SLOT(startLoginProcess()));
584 connect(m_facebookAuthenticator, SIGNAL(saveCookiesRequest()),
585 m_ui, SLOT(saveCookies()));
587 connect(m_facebookAuthenticator, SIGNAL(loginUsingCookies()),
588 m_ui, SLOT(loginUsingCookies()));
591 void SituareEngine::signalsFromGeocodingService()
593 qDebug() << __PRETTY_FUNCTION__;
595 connect(m_geocodingService, SIGNAL(locationDataParsed(const QList<Location>&)),
596 m_ui, SIGNAL(locationDataParsed(const QList<Location>&)));
599 void SituareEngine::signalsFromGPS()
601 qDebug() << __PRETTY_FUNCTION__;
603 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
604 m_mapEngine, SLOT(gpsPositionUpdate(GeoCoordinate, qreal)));
606 connect(m_gps, SIGNAL(timeout()),
607 m_ui, SLOT(gpsTimeout()));
609 connect(m_gps, SIGNAL(error(int, int)),
610 this, SLOT(error(int, int)));
613 void SituareEngine::signalsFromMainWindow()
615 qDebug() << __PRETTY_FUNCTION__;
617 connect(m_ui, SIGNAL(error(int, int)),
618 this, SLOT(error(int, int)));
620 connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
621 this, SLOT(fetchUsernameFromSettings()));
623 connect(m_ui, SIGNAL(loginActionPressed()),
624 this, SLOT(loginActionPressed()));
626 connect(m_ui, SIGNAL(saveUsername(QString)),
627 m_facebookAuthenticator, SLOT(saveUsername(QString)));
629 connect(m_ui, SIGNAL(updateCredentials(QUrl)),
630 m_facebookAuthenticator, SLOT(updateCredentials(QUrl)));
632 // signals from map view
633 connect(m_ui, SIGNAL(mapViewScrolled(SceneCoordinate)),
634 m_mapEngine, SLOT(setCenterPosition(SceneCoordinate)));
636 connect(m_ui, SIGNAL(mapViewResized(QSize)),
637 m_mapEngine, SLOT(viewResized(QSize)));
639 connect(m_ui, SIGNAL(viewZoomFinished()),
640 m_mapEngine, SLOT(viewZoomFinished()));
642 // signals from zoom buttons (zoom panel and volume buttons)
643 connect(m_ui, SIGNAL(zoomIn()),
644 m_mapEngine, SLOT(zoomIn()));
646 connect(m_ui, SIGNAL(zoomOut()),
647 m_mapEngine, SLOT(zoomOut()));
649 // signals from menu buttons
650 connect(m_ui, SIGNAL(gpsTriggered(bool)),
651 this, SLOT(setGPS(bool)));
653 //signals from dialogs
654 connect(m_ui, SIGNAL(cancelLoginProcess()),
655 this, SLOT(loginProcessCancelled()));
657 connect(m_ui, SIGNAL(requestReverseGeo()),
658 this, SLOT(requestAddress()));
660 connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
661 this, SLOT(requestUpdateLocation(QString,bool)));
663 connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
664 this, SLOT(enableAutomaticLocationUpdate(bool, int)));
666 // signals from user info tab
667 connect(m_ui, SIGNAL(refreshUserData()),
668 this, SLOT(refreshUserData()));
670 connect(m_ui, SIGNAL(findUser(GeoCoordinate)),
671 m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
673 // signals from friend list tab
674 connect(m_ui, SIGNAL(findFriend(GeoCoordinate)),
675 m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
678 // signals from routing tab
680 SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
682 SLOT(showMapArea(const GeoCoordinate&, const GeoCoordinate&)));
684 // signals from distence indicator button
685 connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
686 this, SLOT(changeAutoCenteringSetting(bool)));
688 connect(m_ui, SIGNAL(searchForLocation(QString)),
689 this, SLOT(locationSearch(QString)));
691 connect(m_ui, SIGNAL(draggingModeTriggered()),
692 this, SLOT(draggingModeTriggered()));
694 connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
695 this, SLOT(routeTo(const GeoCoordinate&)));
698 void SituareEngine::signalsFromMapEngine()
700 qDebug() << __PRETTY_FUNCTION__;
702 connect(m_mapEngine, SIGNAL(error(int, int)),
703 this, SLOT(error(int, int)));
705 connect(m_mapEngine, SIGNAL(locationChanged(SceneCoordinate)),
706 m_ui, SIGNAL(centerToSceneCoordinates(SceneCoordinate)));
708 connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
709 m_ui, SIGNAL(zoomLevelChanged(int)));
711 connect(m_mapEngine, SIGNAL(mapScrolledManually()),
712 this, SLOT(disableAutoCentering()));
714 connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
715 m_ui, SIGNAL(maxZoomLevelReached()));
717 connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
718 m_ui, SIGNAL(minZoomLevelReached()));
720 connect(m_mapEngine, SIGNAL(locationItemClicked(QList<QString>)),
721 m_ui, SIGNAL(locationItemClicked(QList<QString>)));
723 connect(m_mapEngine, SIGNAL(newMapResolution(qreal)),
724 m_ui, SIGNAL(newMapResolution(qreal)));
726 connect(m_mapEngine, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
727 m_ui, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
730 void SituareEngine::signalsFromRoutingService()
732 qDebug() << __PRETTY_FUNCTION__;
734 connect(m_routingService, SIGNAL(routeParsed(Route&)),
735 this, SLOT(routeParsed(Route&)));
737 connect(m_routingService, SIGNAL(routeParsed(Route&)),
738 m_mapEngine, SLOT(setRoute(Route&)));
741 void SituareEngine::signalsFromSituareService()
743 qDebug() << __PRETTY_FUNCTION__;
745 connect(m_situareService, SIGNAL(error(int, int)),
746 this, SLOT(error(int, int)));
748 connect(m_situareService, SIGNAL(imageReady(User*)),
749 this, SLOT(imageReady(User*)));
751 connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
752 m_ui, SIGNAL(reverseGeoReady(QString)));
754 connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
755 this, SLOT(userDataChanged(User*, QList<User*>&)));
757 connect(m_situareService, SIGNAL(updateWasSuccessful()),
758 this, SLOT(updateWasSuccessful()));
760 connect(m_situareService, SIGNAL(updateWasSuccessful()),
761 m_ui, SIGNAL(clearUpdateLocationDialogData()));
764 void SituareEngine::startAutomaticUpdate()
766 qDebug() << __PRETTY_FUNCTION__;
768 m_gps->requestUpdate();
769 m_automaticUpdateRequest = true;
772 void SituareEngine::updateWasSuccessful()
774 qDebug() << __PRETTY_FUNCTION__;
776 if (m_networkAccessManager->isConnected())
777 m_situareService->fetchLocations();
779 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
782 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
784 qDebug() << __PRETTY_FUNCTION__;
786 m_ui->toggleProgressIndicator(false);
789 emit userLocationReady(user);
790 emit friendsLocationsReady(friendsList);