initial import
[vuplus_webkit] / Source / WebCore / platform / gtk / GeolocationServiceGtk.h
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 PassOwnPtr<GeolocationService> create(GeolocationServiceClient*);
36         ~GeolocationServiceGtk();
37
38         virtual bool startUpdating(PositionOptions*);
39         virtual void stopUpdating();
40
41         Geoposition* lastPosition() const;
42         PositionError* lastError() const;
43
44     private:
45         GeolocationServiceGtk(GeolocationServiceClient*);
46
47         void setError(PositionError::ErrorCode, const char* message);
48         void updatePosition();
49
50         static void position_changed(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GeolocationServiceGtk*);
51         static void getPositionCallback(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GError*, GeolocationServiceGtk*);
52
53     private:
54         RefPtr<Geoposition> m_lastPosition;
55         RefPtr<PositionError> m_lastError;
56
57         // state objects
58         GeoclueMasterClient* m_geoclueClient;
59         GeocluePosition* m_geocluePosition;
60
61         // Error and Position state
62         double m_latitude;
63         double m_longitude;
64         double m_altitude;
65         double m_accuracy;
66         double m_altitudeAccuracy;
67         int m_timestamp;
68     };
69 }
70
71 #endif // ENABLE(GEOLOCATION)
72 #endif