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 #include <QPointF> 00032 00033 class QMainWindow; 00034 00035 class FacebookAuthentication; 00036 class FacebookCredentials; 00037 class GPSPosition; 00038 class MainWindow; 00039 class MapEngine; 00040 class SituareService; 00041 class User; 00042 00043 class QTimer; 00044 00051 class SituareEngine : public QObject 00052 { 00053 Q_OBJECT 00054 public: 00060 SituareEngine(QMainWindow *parent = 0); 00061 00065 ~SituareEngine(); 00066 00067 /******************************************************************************* 00068 * MEMBER FUNCTIONS AND SLOTS 00069 ******************************************************************************/ 00070 public slots: 00076 void error(const QString &error); 00077 00082 void fetchUsernameFromSettings(); 00083 00088 void loginActionPressed(); 00089 00094 void loginOk(); 00095 00099 void loginProcessCancelled(); 00100 00105 void logout(); 00106 00111 void requestAddress(); 00112 00120 void requestUpdateLocation(const QString &status = QString(), bool publish = false); 00121 00125 void refreshUserData(); 00126 00131 void updateWasSuccessful(); 00132 00140 void userDataChanged(User *user, QList<User *> &friendsList); 00141 00142 private: 00148 bool isUserMoved(); 00149 00154 void initializeGpsAndAutocentering(); 00155 00159 void signalsFromFacebookAuthenticator(); 00160 00164 void signalsFromGPS(); 00165 00169 void signalsFromMainWindow(); 00170 00174 void signalsFromMapEngine(); 00175 00179 void signalsFromMapView(); 00180 00184 void signalsFromSituareService(); 00185 00186 private slots: 00192 void automaticUpdateIntervalTimerTimeout(); 00193 00199 void changeAutoCenteringSetting(bool enabled); 00200 00204 void disableAutoCentering(); 00205 00213 void enableAutoCentering(bool enabled); 00214 00220 void enableGPS(bool enabled); 00221 00228 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0); 00229 00237 void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy); 00238 00246 void saveGPSPosition(QPointF position); 00247 00248 /******************************************************************************* 00249 * SIGNALS 00250 ******************************************************************************/ 00251 signals: 00257 void automaticLocationUpdateEnabled(bool enabled); 00258 00264 void friendsLocationsReady(QList<User *> &friendList); 00265 00271 void userLocationReady(User *user); 00272 00273 /******************************************************************************* 00274 * DATA MEMBERS 00275 ******************************************************************************/ 00276 private: 00277 bool m_autoCenteringEnabled; 00278 bool m_automaticUpdateFirstStart; 00279 bool m_loggedIn; 00280 bool m_userMoved; 00281 bool m_automaticUpdateEnabled; 00282 00283 FacebookAuthentication *m_facebookAuthenticator; 00284 GPSPosition *m_gps; 00285 MainWindow *m_ui; 00286 MapEngine *m_mapEngine; 00287 SituareService *m_situareService; 00288 00289 QTimer *m_automaticUpdateIntervalTimer; 00290 QPointF m_lastUpdatedGPSPosition; 00291 }; 00292 00293 #endif // ENGINE_H