18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*
2635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Copyright (C) 2008 Holger Hans Peter Freyther
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is free software; you can redistribute it and/or
58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modify it under the terms of the GNU Library General Public
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * License as published by the Free Software Foundation; either
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * version 2 of the License, or (at your option) any later version.
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is distributed in the hope that it will be useful,
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * but WITHOUT ANY WARRANTY; without even the implied warranty of
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Library General Public License for more details.
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * You should have received a copy of the GNU Library General Public License
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * along with this library; see the file COPYING.LIB.  If not, write to
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Boston, MA 02110-1301, USA.
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
20635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#ifndef GeolocationServiceGtk_h
21635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#define GeolocationServiceGtk_h
22635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
23635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include "GeolocationService.h"
248f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "Geoposition.h"
258f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "PositionError.h"
268f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "RefPtr.h"
278f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian
288f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include <geoclue/geoclue-master.h>
298f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include <geoclue/geoclue-position.h>
308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore {
32635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project    class GeolocationServiceGtk : public GeolocationService {
33635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project    public:
34231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block        static GeolocationService* create(GeolocationServiceClient*);
358f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        ~GeolocationServiceGtk();
368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
37635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project        virtual bool startUpdating(PositionOptions*);
38635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project        virtual void stopUpdating();
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
40635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project        virtual void suspend();
41635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project        virtual void resume();
42635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
43635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project        Geoposition* lastPosition() const;
44635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project        PositionError* lastError() const;
458f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian
468f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian    private:
47231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block        GeolocationServiceGtk(GeolocationServiceClient*);
48231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block
498f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        void updateLocationInformation();
508f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        void setError(PositionError::ErrorCode, const char* message);
518f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        void updatePosition();
528f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian
538f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        static void position_changed(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GeolocationServiceGtk*);
548f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian
558f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian    private:
568f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        RefPtr<Geoposition> m_lastPosition;
578f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        RefPtr<PositionError> m_lastError;
588f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian
598f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        // state objects
608f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        GeoclueMasterClient* m_geoclueClient;
618f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        GeocluePosition* m_geocluePosition;
628f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian
638f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        // Error and Position state
648f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        double m_latitude;
658f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        double m_longitude;
668f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        double m_altitude;
678f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        double m_accuracy;
688f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        double m_altitudeAccuracy;
698f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian        int m_timestamp;
70635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project    };
718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}
72635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
73635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif
74