00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Jussi Laitinen - jussi.laitinen@ixonos.com 00006 00007 Situare is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 version 2 as published by the Free Software Foundation. 00010 00011 Situare is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Situare; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. 00020 */ 00021 00022 #ifndef LIBLOCATIONWRAPPER_H 00023 #define LIBLOCATIONWRAPPER_H 00024 00025 #include <QObject> 00026 #include "geopositioninfo.h" 00027 00028 extern "C" 00029 { 00030 #include <location/location-gps-device.h> 00031 #include <location/location-gpsd-control.h> 00032 } 00033 00037 class LiblocationWrapper : public QObject 00038 { 00039 Q_OBJECT 00040 00041 public: 00045 LiblocationWrapper(QObject *parent); 00046 00052 ~LiblocationWrapper(); 00053 00057 enum State {Undefined, Initialized, Running}; 00058 00059 /****************************************************************************** 00060 * MEMBER FUNCTIONS AND SLOTS 00061 ******************************************************************************/ 00067 bool isRunning(); 00068 00074 GeoPositionInfo lastKnownPosition() const; 00075 00079 void startUpdates(); 00080 00086 void setLastKnownPosition(const GeoPositionInfo &positionInfo); 00087 00093 void init(int updateInterval); 00094 00098 void stopUpdates(); 00099 00100 private: 00107 static void changed(LocationGPSDevice *device, gpointer data); 00108 00115 static void error(LocationGPSDevice *device, gpointer data); 00116 00122 void setState(int state); 00123 00129 int state(); 00130 00131 /****************************************************************************** 00132 * SIGNALS 00133 ******************************************************************************/ 00134 signals: 00140 void locationChanged(const GeoPositionInfo &positionInfo); 00141 00147 void errorMessage(const QString &message); 00148 00149 00150 /****************************************************************************** 00151 * DATA MEMBERS 00152 ******************************************************************************/ 00153 private: 00154 LocationGPSDControl *m_control; 00155 LocationGPSDevice *m_device; 00156 GeoPositionInfo m_lastKnownPosition; 00157 int m_state; 00158 }; 00159 00160 #endif // LIBLOCATIONWRAPPER_H