2010-02-26 Arno Renevier <arno@renevier.net>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Feb 2010 01:00:00 +0000 (01:00 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Feb 2010 01:00:00 +0000 (01:00 +0000)
        Reviewed by Gustavo Noronha Silva.

        [Gtk] use geoclue_position_get_position_async to get geolocation position.
        https://bugs.webkit.org/show_bug.cgi?id=35355

        No new tests, behaviour depends on system.

        * platform/gtk/GeolocationServiceGtk.cpp:
        (WebCore::GeolocationServiceGtk::startUpdating):
        (WebCore::GeolocationServiceGtk::get_position):
        * platform/gtk/GeolocationServiceGtk.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55325 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/gtk/GeolocationServiceGtk.cpp
WebCore/platform/gtk/GeolocationServiceGtk.h

index 334e25b5008554ade97b7364b5d08239f6e46176..1c837a3d2a8ed10b7e4ee476d38e907cb3d6a2c7 100644 (file)
@@ -1,3 +1,17 @@
+2010-02-26  Arno Renevier  <arno@renevier.net>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [Gtk] use geoclue_position_get_position_async to get geolocation position.
+        https://bugs.webkit.org/show_bug.cgi?id=35355
+
+        No new tests, behaviour depends on system.
+
+        * platform/gtk/GeolocationServiceGtk.cpp:
+        (WebCore::GeolocationServiceGtk::startUpdating):
+        (WebCore::GeolocationServiceGtk::get_position):
+        * platform/gtk/GeolocationServiceGtk.h:
+
 2010-02-26  Yaar Schnitman  <yaar@chromium.org>
 
         Chromium Win build fix.
index edb8d1037869281edf44c3f867a3c60ae724bc85..f961ebb142ce1ef306320ef8b98beac3c06bbca1 100644 (file)
@@ -113,12 +113,13 @@ bool GeolocationServiceGtk::startUpdating(PositionOptions* options)
         return false;
     }
 
+    m_geoclueClient = client;
+
+    geoclue_position_get_position_async(m_geocluePosition, (GeocluePositionCallback)getPositionCallback, this);
+
     g_signal_connect(G_OBJECT(m_geocluePosition), "position-changed",
                      G_CALLBACK(position_changed), this);
 
-    m_geoclueClient = client;
-    updateLocationInformation();
-
     return true;
 }
 
@@ -156,28 +157,6 @@ PositionError* GeolocationServiceGtk::lastError() const
     return m_lastError.get();
 }
 
-void GeolocationServiceGtk::updateLocationInformation()
-{
-    ASSERT(m_geocluePosition);
-
-    GOwnPtr<GError> error;
-    GOwnPtr<GeoclueAccuracy> accuracy;
-
-    GeocluePositionFields fields = geoclue_position_get_position(m_geocluePosition, &m_timestamp,
-                                                                 &m_latitude, &m_longitude,
-                                                                 &m_altitude, &accuracy.outPtr(),
-                                                                 &error.outPtr());
-    if (error) {
-        setError(PositionError::POSITION_UNAVAILABLE, error->message);
-        return;
-    } else if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) {
-        setError(PositionError::POSITION_UNAVAILABLE, "Position could not be determined.");
-        return;
-    }
-
-
-}
-
 void GeolocationServiceGtk::updatePosition()
 {
     m_lastError = 0;
@@ -189,6 +168,24 @@ void GeolocationServiceGtk::updatePosition()
     positionChanged();
 }
 
+void GeolocationServiceGtk::getPositionCallback(GeocluePosition *position,
+                                                GeocluePositionFields fields,
+                                                int timestamp,
+                                                double latitude,
+                                                double longitude,
+                                                double altitude,
+                                                GeoclueAccuracy* accuracy,
+                                                GError* error,
+                                                GeolocationServiceGtk* that)
+{
+    if (error) {
+        that->setError(PositionError::POSITION_UNAVAILABLE, error->message);
+        g_error_free(error);
+        return;
+    }
+    position_changed(position, fields, timestamp, latitude, longitude, altitude, accuracy, that);
+}
+
 void GeolocationServiceGtk::position_changed(GeocluePosition*, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy, GeolocationServiceGtk* that)
 {
     if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) {
index a198dc0e46dec7de02864f3de6bfd819cac81815..c12301768048d3bfa1daa6a5dc03cb5ec0b14e1d 100644 (file)
@@ -46,11 +46,11 @@ namespace WebCore {
     private:
         GeolocationServiceGtk(GeolocationServiceClient*);
 
-        void updateLocationInformation();
         void setError(PositionError::ErrorCode, const char* message);
         void updatePosition();
 
         static void position_changed(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GeolocationServiceGtk*);
+        static void getPositionCallback(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GError*, GeolocationServiceGtk*);
 
     private:
         RefPtr<Geoposition> m_lastPosition;