00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Kaj Wallin - kaj.wallin@ixonos.com 00006 Henri Lampela - henri.lampela@ixonos.com 00007 Jussi Laitinen - jussi.laitinen@ixonos.com 00008 Sami Rämö - sami.ramo@ixonos.com 00009 00010 Situare is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 version 2 as published by the Free Software Foundation. 00013 00014 Situare is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with Situare; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00022 USA. 00023 */ 00024 00025 00026 #ifndef ENGINE_H 00027 #define ENGINE_H 00028 00029 #include <QObject> 00030 #include <QTime> 00031 00032 #include "coordinates/geocoordinate.h" 00033 00034 class QTimer; 00035 00036 class Application; 00037 class ContactManager; 00038 class FacebookAuthentication; 00039 class FacebookCredentials; 00040 class GeocodingService; 00041 class GPSPosition; 00042 class Location; 00043 class MainWindow; 00044 class MapEngine; 00045 class MCE; 00046 class NetworkAccessManager; 00047 class Route; 00048 class RoutingService; 00049 class SituareService; 00050 class User; 00051 00058 class SituareEngine : public QObject 00059 { 00060 Q_OBJECT 00061 public: 00066 SituareEngine(); 00067 00071 ~SituareEngine(); 00072 00073 /******************************************************************************* 00074 * MEMBER FUNCTIONS AND SLOTS 00075 ******************************************************************************/ 00076 public slots: 00083 void error(const int context, const int error); 00084 00089 void fetchUsernameFromSettings(); 00090 00096 void locationSearch(QString location); 00097 00102 void loginActionPressed(); 00103 00108 void loginOk(); 00109 00113 void loginProcessCancelled(); 00114 00119 void logout(); 00120 00125 void requestAddress(); 00126 00134 void requestUpdateLocation(const QString &status = QString(), bool publish = false); 00135 00139 void refreshUserData(); 00140 00145 void updateWasSuccessful(); 00146 00154 void userDataChanged(User *user, QList<User *> &friendsList); 00155 00156 private: 00161 void initializeGpsAndAutocentering(); 00162 00166 void signalsFromFacebookAuthenticator(); 00167 00171 void signalsFromGeocodingService(); 00172 00176 void signalsFromGPS(); 00177 00181 void signalsFromMainWindow(); 00182 00186 void signalsFromMapEngine(); 00187 00191 void signalsFromMapView(); 00192 00196 void signalsFromRoutingService(); 00197 00201 void signalsFromSituareService(); 00202 00203 private slots: 00209 void changeAutoCenteringSetting(bool enabled); 00210 00214 void disableAutoCentering(); 00215 00219 void draggingModeTriggered(); 00220 00227 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0); 00228 00234 void imageReady(User *user); 00235 00243 void requestAutomaticUpdateIfMoved(GeoCoordinate position); 00244 00250 void routeParsed(Route &route); 00251 00258 void routeTo(const GeoCoordinate &endPointCoordinates); 00259 00263 void routeToCursor(); 00264 00272 void setAutoCentering(bool enabled); 00273 00278 void setFirstStartZoomLevel(); 00279 00285 void setGPS(bool enabled); 00286 00292 void setPowerSaving(bool enabled); 00293 00300 void showContactDialog(const QString &facebookId); 00301 00307 void startAutomaticUpdate(); 00308 00316 void topmostWindowChanged(bool isMainWindow); 00317 00318 /******************************************************************************* 00319 * SIGNALS 00320 ******************************************************************************/ 00321 signals: 00327 void automaticLocationUpdateEnabled(bool enabled); 00328 00333 void clearUpdateLocationDialogData(); 00334 00343 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw); 00344 00350 void friendsLocationsReady(QList<User *> &friendList); 00351 00357 void friendImageReady(User *user); 00358 00364 void locationDataParsed(QList<Location> &result); 00365 00371 void userLocationReady(User *user); 00372 00373 /******************************************************************************* 00374 * DATA MEMBERS 00375 ******************************************************************************/ 00376 private: 00377 bool m_autoCenteringEnabled; 00378 bool m_automaticUpdateFirstStart; 00379 bool m_automaticUpdateRequest; 00380 bool m_userMoved; 00381 00382 QTimer *m_automaticUpdateIntervalTimer; 00383 00384 ContactManager *m_contactManager; 00385 FacebookAuthentication *m_facebookAuthenticator; 00386 GeocodingService *m_geocodingService; 00387 GeoCoordinate m_lastUpdatedGPSPosition; 00388 GPSPosition *m_gps; 00389 MainWindow *m_ui; 00390 MapEngine *m_mapEngine; 00391 NetworkAccessManager *m_networkAccessManager; 00392 RoutingService *m_routingService; 00393 SituareService *m_situareService; 00394 MCE *m_mce; 00395 }; 00396 00397 #endif // ENGINE_H