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>
30 #include "application.h"
33 #include "facebookservice/facebookauthentication.h"
34 #include "gps/gpsposition.h"
35 #include "map/mapengine.h"
36 #include "routing/geocodingservice.h"
37 #include "routing/routingservice.h"
39 #include "network/networkaccessmanager.h"
40 #include "situareservice/situareservice.h"
41 #include "ui/mainwindow.h"
45 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED"; ///< GPS setting
46 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";///< Auto centering setting
47 const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12; ///< Default zoom level when GPS available
48 const qreal USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE = 0.003;///< Min value for user move latitude
49 const qreal USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE = 0.001;///< Min value for user move longitude
50 const int MIN_UPDATE_INTERVAL_MSECS = 5*60*1000;
52 SituareEngine::SituareEngine()
53 : m_autoCenteringEnabled(false),
54 m_automaticUpdateFirstStart(true),
55 m_automaticUpdateRequest(false),
57 m_automaticUpdateIntervalTimer(0),
58 m_lastUpdatedGPSPosition(GeoCoordinate())
60 qDebug() << __PRETTY_FUNCTION__;
62 m_ui = new MainWindow;
63 m_ui->updateItemVisibility();
65 Application *application = static_cast<Application *>(qApp);
66 application->registerWindow(m_ui->winId());
68 connect(application, SIGNAL(topmostWindowChanged(bool)),
69 this, SLOT(topmostWindowChanged(bool)));
71 m_networkAccessManager = new NetworkAccessManager(this);
74 m_mapEngine = new MapEngine(this);
75 m_ui->setMapViewScene(m_mapEngine->scene());
78 m_gps = new GPSPosition(this);
80 // build SituareService
81 m_situareService = new SituareService(this);
83 // build FacebookAuthenticator
84 m_facebookAuthenticator = new FacebookAuthentication(this);
86 // build routing service
87 m_routingService = new RoutingService(this); // create this when needed, not in constructor!
89 // build geocoding service
90 m_geocodingService = new GeocodingService(this);
93 signalsFromMapEngine();
94 signalsFromGeocodingService();
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(setPowerSaving(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()
165 qDebug() << __PRETTY_FUNCTION__;
168 m_mce->vibrationFeedback();
171 void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
173 qDebug() << __PRETTY_FUNCTION__;
175 //Show automatic update confirmation dialog
176 if (m_automaticUpdateFirstStart && m_gps->isRunning() && enabled) {
177 m_ui->showEnableAutomaticUpdateLocationDialog(
178 tr("Do you want to enable automatic location update with %1 min update interval?")
179 .arg(updateIntervalMsecs/1000/60));
180 m_automaticUpdateFirstStart = false;
182 if (enabled && m_gps->isRunning()) {
183 m_ui->buildInformationBox(tr("Automatic location update enabled"));
184 if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
185 m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
187 m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
189 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
190 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
192 m_automaticUpdateIntervalTimer->start();
195 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
196 this, SLOT(requestAutomaticUpdateIfMoved(GeoCoordinate)));
198 m_automaticUpdateIntervalTimer->stop();
203 void SituareEngine::error(const int context, const int error)
205 qDebug() << __PRETTY_FUNCTION__;
209 case SituareError::ERROR_GENERAL:
210 if(context == ErrorContext::SITUARE) {
211 m_ui->toggleProgressIndicator(false);
212 m_ui->buildInformationBox(tr("Unknown server error"), true);
215 case 1: //errors: SituareError::ERROR_MISSING_ARGUMENT and QNetworkReply::ConnectionRefusedError
216 m_ui->toggleProgressIndicator(false);
217 if(context == ErrorContext::SITUARE) {
218 m_ui->buildInformationBox(tr("Missing parameter from request"), true);
219 } else if(context == ErrorContext::NETWORK) {
220 m_ui->buildInformationBox(tr("Connection refused by the server"), true);
223 case QNetworkReply::RemoteHostClosedError:
224 if(context == ErrorContext::NETWORK) {
225 m_ui->toggleProgressIndicator(false);
226 m_ui->buildInformationBox(tr("Connection closed by the server"), true);
229 case QNetworkReply::HostNotFoundError:
230 if(context == ErrorContext::NETWORK) {
231 m_ui->toggleProgressIndicator(false);
232 m_ui->buildInformationBox(tr("Remote server not found"), true);
235 case QNetworkReply::TimeoutError:
236 if(context == ErrorContext::NETWORK) {
237 m_ui->toggleProgressIndicator(false);
238 m_ui->buildInformationBox(tr("Connection timed out"), true);
241 case QNetworkReply::UnknownNetworkError:
242 if(context == ErrorContext::NETWORK) {
243 m_ui->toggleProgressIndicator(false);
244 m_ui->buildInformationBox(tr("No network connection"), true);
247 case SituareError::SESSION_EXPIRED:
248 m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
249 m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
250 m_situareService->clearUserData();
251 m_ui->loggedIn(false);
254 case SituareError::LOGIN_FAILED:
255 m_ui->toggleProgressIndicator(false);
256 m_ui->buildInformationBox(tr("Invalid E-mail address or password"), true);
259 case SituareError::UPDATE_FAILED:
260 m_ui->toggleProgressIndicator(false);
261 m_ui->buildInformationBox(tr("Update failed, please try again"), true);
263 case SituareError::DATA_RETRIEVAL_FAILED:
264 m_ui->toggleProgressIndicator(false);
265 m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
267 case SituareError::ADDRESS_RETRIEVAL_FAILED:
268 m_ui->toggleProgressIndicator(false);
269 m_ui->buildInformationBox(tr("Address retrieval failed"), true);
271 case SituareError::IMAGE_DOWNLOAD_FAILED:
272 m_ui->buildInformationBox(tr("Image download failed"), true);
274 case SituareError::MAP_IMAGE_DOWNLOAD_FAILED:
275 m_ui->buildInformationBox(tr("Map image download failed"), true);
277 case SituareError::GPS_INITIALIZATION_FAILED:
279 m_ui->buildInformationBox(tr("GPS initialization failed"), true);
281 case SituareError::INVALID_JSON:
282 m_ui->buildInformationBox(tr("Malformatted reply from server"), true);
283 m_ui->loggedIn(false);
284 m_facebookAuthenticator->clearAccountInformation(false); // clean all
286 case SituareError::ERROR_ROUTING_FAILED:
287 m_ui->toggleProgressIndicator(false);
288 m_ui->buildInformationBox(tr("Routing failed"), true);
290 case SituareError::ERROR_LOCATION_SEARCH_FAILED:
291 m_ui->buildInformationBox(tr("No results found"), true);
294 m_ui->toggleProgressIndicator(false);
295 if(context == ErrorContext::NETWORK)
296 qCritical() << __PRETTY_FUNCTION__ << "QNetworkReply::NetworkError: " << error;
298 qCritical() << __PRETTY_FUNCTION__ << "Unknown error: " << error;
303 void SituareEngine::fetchUsernameFromSettings()
305 qDebug() << __PRETTY_FUNCTION__;
307 m_ui->setUsername(m_facebookAuthenticator->loadUsername());
310 void SituareEngine::imageReady(User *user)
312 qDebug() << __PRETTY_FUNCTION__;
315 emit userLocationReady(user);
317 emit friendImageReady(user);
320 void SituareEngine::initializeGpsAndAutocentering()
322 qDebug() << __PRETTY_FUNCTION__;
324 QSettings settings(DIRECTORY_NAME, FILE_NAME);
325 QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
326 QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
328 if (m_gps->isInitialized()) {
330 if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
332 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
333 this, SLOT(setFirstStartZoomLevel()));
335 changeAutoCenteringSetting(true);
338 m_ui->buildInformationBox(tr("GPS enabled"));
340 } else { // Normal start
341 changeAutoCenteringSetting(autoCenteringEnabled.toBool());
342 setGPS(gpsEnabled.toBool());
344 if (gpsEnabled.toBool())
345 m_ui->buildInformationBox(tr("GPS enabled"));
352 void SituareEngine::locationSearch(QString location)
354 qDebug() << __PRETTY_FUNCTION__;
356 if(!location.isEmpty())
357 m_geocodingService->requestLocation(location);
360 void SituareEngine::loginActionPressed()
362 qDebug() << __PRETTY_FUNCTION__;
364 if (m_networkAccessManager->isConnected()) {
365 if(m_ui->loginState()) {
367 m_situareService->clearUserData();
369 m_facebookAuthenticator->start();
373 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
377 void SituareEngine::loginOk()
379 qDebug() << __PRETTY_FUNCTION__;
381 m_ui->loggedIn(true);
384 m_situareService->fetchLocations(); // request user locations
386 if (m_gps->isRunning())
387 m_ui->readAutomaticLocationUpdateSettings();
390 void SituareEngine::loginProcessCancelled()
392 qDebug() << __PRETTY_FUNCTION__;
394 m_ui->toggleProgressIndicator(false);
395 m_ui->updateItemVisibility();
398 void SituareEngine::logout()
400 qDebug() << __PRETTY_FUNCTION__;
402 m_ui->loggedIn(false);
404 // signal to clear locationUpdateDialog's data
405 connect(this, SIGNAL(clearUpdateLocationDialogData()),
406 m_ui, SIGNAL(clearUpdateLocationDialogData()));
407 emit clearUpdateLocationDialogData();
409 m_facebookAuthenticator->clearAccountInformation(); // clear all
410 m_automaticUpdateFirstStart = true;
413 void SituareEngine::refreshUserData()
415 qDebug() << __PRETTY_FUNCTION__;
417 if (m_networkAccessManager->isConnected()) {
418 m_ui->toggleProgressIndicator(true);
419 m_situareService->fetchLocations();
422 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
426 void SituareEngine::requestAddress()
428 qDebug() << __PRETTY_FUNCTION__;
430 if (m_networkAccessManager->isConnected()) {
431 if (m_gps->isRunning())
432 m_situareService->reverseGeo(m_gps->lastPosition());
434 m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
437 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
441 void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
443 qDebug() << __PRETTY_FUNCTION__;
445 if (m_networkAccessManager->isConnected()) {
446 m_ui->toggleProgressIndicator(true);
448 if (m_gps->isRunning())
449 m_situareService->updateLocation(m_gps->lastPosition(), status, publish);
451 m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
454 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
458 void SituareEngine::requestAutomaticUpdateIfMoved(GeoCoordinate position)
460 qDebug() << __PRETTY_FUNCTION__;
462 if ((fabs(m_lastUpdatedGPSPosition.longitude() - position.longitude()) >
463 USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE) ||
464 (fabs(m_lastUpdatedGPSPosition.latitude() - position.latitude()) >
465 USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE)) {
467 m_lastUpdatedGPSPosition = position;
471 if (m_automaticUpdateRequest && m_userMoved) {
472 requestUpdateLocation(tr("Automatic location update"));
473 m_automaticUpdateRequest = false;
478 void SituareEngine::routeParsed(Route &route)
480 qDebug() << __PRETTY_FUNCTION__;
484 m_ui->toggleProgressIndicator(false);
487 void SituareEngine::routeTo(const GeoCoordinate &endPointCoordinates)
489 qDebug() << __PRETTY_FUNCTION__;
491 m_ui->toggleProgressIndicator(true);
493 if (m_gps->isRunning())
494 m_routingService->requestRoute(m_gps->lastPosition(), endPointCoordinates);
496 m_routingService->requestRoute(m_mapEngine->centerGeoCoordinate(), endPointCoordinates);
499 void SituareEngine::routeToCursor()
501 qDebug() << __PRETTY_FUNCTION__;
503 routeTo(m_mapEngine->centerGeoCoordinate());
506 void SituareEngine::setAutoCentering(bool enabled)
508 qDebug() << __PRETTY_FUNCTION__ << enabled;
510 m_ui->setIndicatorButtonEnabled(enabled);
511 m_mapEngine->setAutoCentering(enabled);
512 m_ui->setCrosshairVisibility(!enabled);
516 m_gps->requestLastPosition();
520 void SituareEngine::setFirstStartZoomLevel()
522 qDebug() << __PRETTY_FUNCTION__;
524 if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
525 m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
527 disconnect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
528 this, SLOT(setFirstStartZoomLevel()));
531 void SituareEngine::setGPS(bool enabled)
533 qDebug() << __PRETTY_FUNCTION__ << enabled;
535 if (m_gps->isInitialized()) {
536 m_ui->setGPSButtonEnabled(enabled);
537 m_mapEngine->setGPSEnabled(enabled);
539 if (enabled && !m_gps->isRunning()) {
541 m_gps->requestLastPosition();
543 if(m_ui->loginState())
544 m_ui->readAutomaticLocationUpdateSettings();
546 else if (!enabled && m_gps->isRunning()) {
548 changeAutoCenteringSetting(false);
549 enableAutomaticLocationUpdate(false);
554 m_ui->buildInformationBox(tr("Unable to start GPS"));
555 m_ui->setGPSButtonEnabled(false);
556 m_mapEngine->setGPSEnabled(false);
560 void SituareEngine::setPowerSaving(bool enabled)
562 qDebug() << __PRETTY_FUNCTION__ << enabled;
564 m_gps->enablePowerSave(enabled);
566 if(m_autoCenteringEnabled)
567 m_mapEngine->setAutoCentering(!enabled);
570 void SituareEngine::signalsFromFacebookAuthenticator()
572 qDebug() << __PRETTY_FUNCTION__;
574 connect(m_facebookAuthenticator, SIGNAL(error(int, int)),
575 this, SLOT(error(int, int)));
577 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
578 m_situareService, SLOT(credentialsReady(FacebookCredentials)));
580 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
581 this, SLOT(loginOk()));
583 connect(m_facebookAuthenticator, SIGNAL(newLoginRequest()),
584 m_ui, SLOT(startLoginProcess()));
586 connect(m_facebookAuthenticator, SIGNAL(saveCookiesRequest()),
587 m_ui, SLOT(saveCookies()));
589 connect(m_facebookAuthenticator, SIGNAL(loginUsingCookies()),
590 m_ui, SLOT(loginUsingCookies()));
593 void SituareEngine::signalsFromGeocodingService()
595 qDebug() << __PRETTY_FUNCTION__;
597 connect(m_geocodingService, SIGNAL(locationDataParsed(const QList<Location>&)),
598 m_ui, SIGNAL(locationDataParsed(const QList<Location>&)));
600 connect(m_geocodingService, SIGNAL(error(int, int)),
601 this, SLOT(error(int, int)));
604 void SituareEngine::signalsFromGPS()
606 qDebug() << __PRETTY_FUNCTION__;
608 connect(m_gps, SIGNAL(position(GeoCoordinate, qreal)),
609 m_mapEngine, SLOT(gpsPositionUpdate(GeoCoordinate, qreal)));
611 connect(m_gps, SIGNAL(timeout()),
612 m_ui, SLOT(gpsTimeout()));
614 connect(m_gps, SIGNAL(error(int, int)),
615 this, SLOT(error(int, int)));
618 void SituareEngine::signalsFromMainWindow()
620 qDebug() << __PRETTY_FUNCTION__;
622 connect(m_ui, SIGNAL(error(int, int)),
623 this, SLOT(error(int, int)));
625 connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
626 this, SLOT(fetchUsernameFromSettings()));
628 connect(m_ui, SIGNAL(loginActionPressed()),
629 this, SLOT(loginActionPressed()));
631 connect(m_ui, SIGNAL(saveUsername(QString)),
632 m_facebookAuthenticator, SLOT(saveUsername(QString)));
634 connect(m_ui, SIGNAL(updateCredentials(QUrl)),
635 m_facebookAuthenticator, SLOT(updateCredentials(QUrl)));
637 // signals from map view
638 connect(m_ui, SIGNAL(mapViewScrolled(SceneCoordinate)),
639 m_mapEngine, SLOT(setCenterPosition(SceneCoordinate)));
641 connect(m_ui, SIGNAL(mapViewResized(QSize)),
642 m_mapEngine, SLOT(viewResized(QSize)));
644 connect(m_ui, SIGNAL(viewZoomFinished()),
645 m_mapEngine, SLOT(viewZoomFinished()));
647 // signals from zoom buttons (zoom panel and volume buttons)
648 connect(m_ui, SIGNAL(zoomIn()),
649 m_mapEngine, SLOT(zoomIn()));
651 connect(m_ui, SIGNAL(zoomOut()),
652 m_mapEngine, SLOT(zoomOut()));
654 // signals from menu buttons
655 connect(m_ui, SIGNAL(gpsTriggered(bool)),
656 this, SLOT(setGPS(bool)));
658 //signals from dialogs
659 connect(m_ui, SIGNAL(cancelLoginProcess()),
660 this, SLOT(loginProcessCancelled()));
662 connect(m_ui, SIGNAL(requestReverseGeo()),
663 this, SLOT(requestAddress()));
665 connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
666 this, SLOT(requestUpdateLocation(QString,bool)));
668 connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
669 this, SLOT(enableAutomaticLocationUpdate(bool, int)));
671 // signals from user info tab
672 connect(m_ui, SIGNAL(refreshUserData()),
673 this, SLOT(refreshUserData()));
675 connect(m_ui, SIGNAL(centerToCoordinates(GeoCoordinate)),
676 m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
678 // routing signal from friend list tab & search location tab
679 connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
680 this, SLOT(routeTo(const GeoCoordinate&)));
682 // signals from location search panel
684 SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
686 SLOT(showMapArea(const GeoCoordinate&, const GeoCoordinate&)));
688 connect(m_ui, SIGNAL(searchHistoryItemClicked(QString)),
689 this, SLOT(locationSearch(QString)));
691 // signals from routing tab
692 connect(m_ui, SIGNAL(clearRoute()),
693 m_mapEngine, SLOT(clearRoute()));
695 connect(m_ui, SIGNAL(routeToCursor()),
696 this, SLOT(routeToCursor()));
698 // signals from distance indicator button
699 connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
700 this, SLOT(changeAutoCenteringSetting(bool)));
702 connect(m_ui, SIGNAL(draggingModeTriggered()),
703 this, SLOT(draggingModeTriggered()));
705 // signal from search location dialog
706 connect(m_ui, SIGNAL(searchForLocation(QString)),
707 this, SLOT(locationSearch(QString)));
710 void SituareEngine::signalsFromMapEngine()
712 qDebug() << __PRETTY_FUNCTION__;
714 connect(m_mapEngine, SIGNAL(error(int, int)),
715 this, SLOT(error(int, int)));
717 connect(m_mapEngine, SIGNAL(locationChanged(SceneCoordinate)),
718 m_ui, SIGNAL(centerToSceneCoordinates(SceneCoordinate)));
720 connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
721 m_ui, SIGNAL(zoomLevelChanged(int)));
723 connect(m_mapEngine, SIGNAL(mapScrolledManually()),
724 this, SLOT(disableAutoCentering()));
726 connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
727 m_ui, SIGNAL(maxZoomLevelReached()));
729 connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
730 m_ui, SIGNAL(minZoomLevelReached()));
732 connect(m_mapEngine, SIGNAL(locationItemClicked(QList<QString>)),
733 m_ui, SIGNAL(locationItemClicked(QList<QString>)));
735 connect(m_mapEngine, SIGNAL(newMapResolution(qreal)),
736 m_ui, SIGNAL(newMapResolution(qreal)));
738 connect(m_mapEngine, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
739 m_ui, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
742 void SituareEngine::signalsFromRoutingService()
744 qDebug() << __PRETTY_FUNCTION__;
746 connect(m_routingService, SIGNAL(routeParsed(Route&)),
747 this, SLOT(routeParsed(Route&)));
749 connect(m_routingService, SIGNAL(routeParsed(Route&)),
750 m_mapEngine, SLOT(setRoute(Route&)));
752 connect(m_routingService, SIGNAL(routeParsed(Route&)),
753 m_ui, SIGNAL(routeParsed(Route&)));
755 connect(m_routingService, SIGNAL(error(int, int)),
756 this, SLOT(error(int, int)));
759 void SituareEngine::signalsFromSituareService()
761 qDebug() << __PRETTY_FUNCTION__;
763 connect(m_situareService, SIGNAL(error(int, int)),
764 this, SLOT(error(int, int)));
766 connect(m_situareService, SIGNAL(imageReady(User*)),
767 this, SLOT(imageReady(User*)));
769 connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
770 m_ui, SIGNAL(reverseGeoReady(QString)));
772 connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
773 this, SLOT(userDataChanged(User*, QList<User*>&)));
775 connect(m_situareService, SIGNAL(updateWasSuccessful()),
776 this, SLOT(updateWasSuccessful()));
778 connect(m_situareService, SIGNAL(updateWasSuccessful()),
779 m_ui, SIGNAL(clearUpdateLocationDialogData()));
782 void SituareEngine::startAutomaticUpdate()
784 qDebug() << __PRETTY_FUNCTION__;
786 m_gps->requestUpdate();
787 m_automaticUpdateRequest = true;
790 void SituareEngine::topmostWindowChanged(bool isMainWindow)
792 qDebug() << __PRETTY_FUNCTION__;
794 setPowerSaving(!isMainWindow);
797 void SituareEngine::updateWasSuccessful()
799 qDebug() << __PRETTY_FUNCTION__;
801 if (m_networkAccessManager->isConnected())
802 m_situareService->fetchLocations();
804 error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
807 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
809 qDebug() << __PRETTY_FUNCTION__;
811 m_ui->toggleProgressIndicator(false);
813 emit userLocationReady(user);
814 emit friendsLocationsReady(friendsList);