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 23 #include "GeolocationService.h" 24 #include "Geoposition.h" 25 #include "PositionError.h" 26 #include "RefPtr.h" 27 28 #include <geoclue/geoclue-master.h> 29 #include <geoclue/geoclue-position.h> 30 31 namespace WebCore { 32 class GeolocationServiceGtk : public GeolocationService { 33 public: 34 static GeolocationService* create(GeolocationServiceClient*); 35 ~GeolocationServiceGtk(); 36 37 virtual bool startUpdating(PositionOptions*); 38 virtual void stopUpdating(); 39 40 virtual void suspend(); 41 virtual void resume(); 42 43 Geoposition* lastPosition() const; 44 PositionError* lastError() const; 45 46 private: 47 GeolocationServiceGtk(GeolocationServiceClient*); 48 49 void updateLocationInformation(); 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 55 private: 56 RefPtr<Geoposition> m_lastPosition; 57 RefPtr<PositionError> m_lastError; 58 59 // state objects 60 GeoclueMasterClient* m_geoclueClient; 61 GeocluePosition* m_geocluePosition; 62 63 // Error and Position state 64 double m_latitude; 65 double m_longitude; 66 double m_altitude; 67 double m_accuracy; 68 double m_altitudeAccuracy; 69 int m_timestamp; 70 }; 71 } 72 73 #endif 74