1 /* 2 * Copyright (C) 2008 Holger Hans Peter Freyther 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef GeolocationServiceGtk_h 21 #define GeolocationServiceGtk_h 22 #if ENABLE(GEOLOCATION) 23 24 #include "GeolocationService.h" 25 #include "Geoposition.h" 26 #include "PositionError.h" 27 #include "RefPtr.h" 28 29 #include <geoclue/geoclue-master.h> 30 #include <geoclue/geoclue-position.h> 31 32 namespace WebCore { 33 class GeolocationServiceGtk : public GeolocationService { 34 public: 35 static GeolocationService* create(GeolocationServiceClient*); 36 ~GeolocationServiceGtk(); 37 38 virtual bool startUpdating(PositionOptions*); 39 virtual void stopUpdating(); 40 41 virtual void suspend(); 42 virtual void resume(); 43 44 Geoposition* lastPosition() const; 45 PositionError* lastError() const; 46 47 private: 48 GeolocationServiceGtk(GeolocationServiceClient*); 49 50 void setError(PositionError::ErrorCode, const char* message); 51 void updatePosition(); 52 53 static void position_changed(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GeolocationServiceGtk*); 54 static void getPositionCallback(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GError*, GeolocationServiceGtk*); 55 56 private: 57 RefPtr<Geoposition> m_lastPosition; 58 RefPtr<PositionError> m_lastError; 59 60 // state objects 61 GeoclueMasterClient* m_geoclueClient; 62 GeocluePosition* m_geocluePosition; 63 64 // Error and Position state 65 double m_latitude; 66 double m_longitude; 67 double m_altitude; 68 double m_accuracy; 69 double m_altitudeAccuracy; 70 int m_timestamp; 71 }; 72 } 73 74 #endif // ENABLE(GEOLOCATION) 75 #endif 76