Changeset 40441 in webkit
- Timestamp:
- Jan 30, 2009 7:51:00 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r39804 r40441 1 2009-01-30 Holger Hans Peter Freyther <zecke@selfish.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 [GTK] Implement GeolocationService using the Geoclue library 6 7 https://bugs.webkit.org/show_bug.cgi?id=22022 8 9 Untested implementation of the GeolocationService using the geoclue 10 library. Velocity handling is completely missing and the accuracy 11 handling might be wrong. 12 13 * GNUmakefile.am: 14 * configure.ac: 15 1 16 2009-01-11 Xan Lopez <xan@gnome.org> 2 17 -
trunk/GNUmakefile.am
r39421 r40441 182 182 $(LIBXSLT_CFLAGS) \ 183 183 $(COVERAGE_CFLAGS) \ 184 $(HILDON_CFLAGS) 184 $(HILDON_CFLAGS) \ 185 $(GEOCLUE_CFLAGS) 185 186 186 187 libWebCore_la_CPPFLAGS = \ … … 211 212 $(JPEG_LIBS) \ 212 213 $(PNG_LIBS) \ 214 $(GEOCLUE_LIBS) \ 213 215 -lpthread 214 216 -
trunk/WebCore/ChangeLog
r40440 r40441 1 2009-01-30 Holger Hans Peter Freyther <zecke@selfish.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 [GTK] Implement GeolocationService using the Geoclue library 6 7 https://bugs.webkit.org/show_bug.cgi?id=22022 8 9 Untested implementation of the GeolocationService using the geoclue 10 library. Velocity handling is completely missing and the accuracy 11 handling might be wrong. 12 13 * platform/gtk/GeolocationServiceGtk.cpp: 14 (WTF::GeoclueAccuracy): 15 (WebCore::GeolocationServiceGtk::GeolocationServiceGtk): 16 (WebCore::GeolocationServiceGtk::~GeolocationServiceGtk): 17 (WebCore::GeolocationServiceGtk::startUpdating): 18 (WebCore::GeolocationServiceGtk::stopUpdating): 19 (WebCore::GeolocationServiceGtk::suspend): 20 (WebCore::GeolocationServiceGtk::resume): 21 (WebCore::GeolocationServiceGtk::lastPosition): 22 (WebCore::GeolocationServiceGtk::lastError): 23 (WebCore::GeolocationServiceGtk::updateLocationInformation): 24 (WebCore::GeolocationServiceGtk::updatePosition): 25 (WebCore::GeolocationServiceGtk::position_changed): 26 (WebCore::GeolocationServiceGtk::setError): 27 * platform/gtk/GeolocationServiceGtk.h: 28 1 29 2009-01-30 Mark Rowe <mrowe@apple.com> 2 30 -
trunk/WebCore/platform/gtk/GeolocationServiceGtk.cpp
r38765 r40441 21 21 #include "GeolocationServiceGtk.h" 22 22 23 #include "CString.h" 24 #include "GOwnPtr.h" 25 #include "NotImplemented.h" 26 #include "PositionOptions.h" 27 28 namespace WTF { 29 template<> void freeOwnedGPtr<GeoclueAccuracy>(GeoclueAccuracy* accuracy) 30 { 31 if (!accuracy) 32 return; 33 34 geoclue_accuracy_free(accuracy); 35 } 36 } 37 23 38 namespace WebCore { 24 39 … … 30 45 GeolocationServiceGtk::GeolocationServiceGtk(GeolocationServiceClient* client) 31 46 : GeolocationService(client) 32 {} 33 34 bool GeolocationServiceGtk::startUpdating(PositionOptions*) 35 { 36 return false; 47 , m_geoclueClient(0) 48 , m_geocluePosition(0) 49 , m_latitude(0.0) 50 , m_longitude(0.0) 51 , m_altitude(0.0) 52 , m_altitudeAccuracy(0.0) 53 , m_timestamp(0) 54 { 55 } 56 57 GeolocationServiceGtk::~GeolocationServiceGtk() 58 { 59 if (m_geoclueClient) 60 g_object_unref(m_geoclueClient); 61 62 if (m_geocluePosition) 63 g_object_unref(m_geocluePosition); 64 } 65 66 // 67 // 1.) Initialize Geoclue with our requirements 68 // 2.) Try to get a GeocluePosition 69 // 3.) Update the Information and get the current position 70 // 71 // TODO: Also get GeoclueVelocity but there is no master client 72 // API for that. 73 // 74 bool GeolocationServiceGtk::startUpdating(PositionOptions* options) 75 { 76 ASSERT(!m_geoclueClient); 77 78 m_lastPosition = 0; 79 m_lastError = 0; 80 81 GOwnPtr<GError> error; 82 GeoclueMaster* master = geoclue_master_get_default(); 83 GeoclueMasterClient* client = geoclue_master_create_client(master, 0, 0); 84 g_object_unref(master); 85 86 if (!client) { 87 setError(PositionError::LOCATION_PROVIDER_ERROR, "Could not connect to location provider."); 88 return false; 89 } 90 91 GeoclueAccuracyLevel accuracyLevel = GEOCLUE_ACCURACY_LEVEL_LOCALITY; 92 int timeout = 0; 93 if (options) { 94 accuracyLevel = options->enableHighAccuracy() ? GEOCLUE_ACCURACY_LEVEL_DETAILED : GEOCLUE_ACCURACY_LEVEL_LOCALITY; 95 timeout = options->timeout(); 96 } 97 98 gboolean result = geoclue_master_client_set_requirements(client, accuracyLevel, timeout, 99 true, GEOCLUE_RESOURCE_ALL, &error.outPtr()); 100 101 if (!result) { 102 setError(PositionError::LOCATION_PROVIDER_ERROR, error->message); 103 g_object_unref(client); 104 return false; 105 } 106 107 m_geocluePosition = geoclue_master_client_create_position(client, &error.outPtr()); 108 if (!m_geocluePosition) { 109 setError(PositionError::LOCATION_PROVIDER_ERROR, error->message); 110 g_object_unref(client); 111 return false; 112 } 113 114 g_signal_connect(G_OBJECT(m_geocluePosition), "position-changed", 115 G_CALLBACK(position_changed), this); 116 117 m_geoclueClient = client; 118 updateLocationInformation(); 119 120 return result; 37 121 } 38 122 39 123 void GeolocationServiceGtk::stopUpdating() 40 124 { 125 if (!m_geoclueClient) 126 return; 127 128 g_object_unref(m_geocluePosition); 129 g_object_unref(m_geoclueClient); 130 131 m_geocluePosition = 0; 132 m_geoclueClient = 0; 41 133 } 42 134 43 135 void GeolocationServiceGtk::suspend() 44 136 { 137 // not available with geoclue 138 notImplemented(); 45 139 } 46 140 47 141 void GeolocationServiceGtk::resume() 48 142 { 143 // not available with geoclue 144 notImplemented(); 49 145 } 50 146 51 147 Geoposition* GeolocationServiceGtk::lastPosition() const 52 148 { 53 return 0;149 return m_lastPosition.get(); 54 150 } 55 151 56 152 PositionError* GeolocationServiceGtk::lastError() const 57 153 { 58 return 0; 59 } 60 61 } 154 return m_lastError.get(); 155 } 156 157 void GeolocationServiceGtk::updateLocationInformation() 158 { 159 ASSERT(m_geocluePosition); 160 161 GOwnPtr<GError> error; 162 GOwnPtr<GeoclueAccuracy> accuracy; 163 164 GeocluePositionFields fields = geoclue_position_get_position(m_geocluePosition, &m_timestamp, 165 &m_latitude, &m_longitude, 166 &m_altitude, &accuracy.outPtr(), 167 &error.outPtr()); 168 if (error) { 169 setError(PositionError::POSITION_NOT_FOUND_ERROR, error->message); 170 return; 171 } else if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { 172 setError(PositionError::POSITION_NOT_FOUND_ERROR, "Position could not be determined."); 173 return; 174 } 175 176 177 // The m_altitudeAccuracy accuracy is likely to be wrong 178 GeoclueAccuracyLevel level; 179 geoclue_accuracy_get_details(accuracy.get(), &level, &m_accuracy, &m_altitudeAccuracy); 180 updatePosition(); 181 } 182 183 void GeolocationServiceGtk::updatePosition() 184 { 185 m_lastError = 0; 186 m_lastPosition = Geoposition::create(m_latitude, m_longitude, m_altitude, 187 m_accuracy, m_altitudeAccuracy, 0.0, 188 0.0, m_timestamp*1000.0); 189 positionChanged(); 190 } 191 192 void GeolocationServiceGtk::position_changed(GeocluePosition*, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy, GeolocationServiceGtk* that) 193 { 194 if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { 195 that->setError(PositionError::POSITION_NOT_FOUND_ERROR, "Position could not be determined."); 196 return; 197 } 198 199 that->m_timestamp = timestamp; 200 that->m_latitude = latitude; 201 that->m_longitude = longitude; 202 that->m_altitude = altitude; 203 204 GeoclueAccuracyLevel level; 205 geoclue_accuracy_get_details(accuracy, &level, &that->m_accuracy, &that->m_altitudeAccuracy); 206 that->updatePosition(); 207 } 208 209 void GeolocationServiceGtk::setError(PositionError::ErrorCode errorCode, const char* message) 210 { 211 m_lastPosition = 0; 212 m_lastError = PositionError::create(errorCode, String::fromUTF8(message)); 213 } 214 215 } -
trunk/WebCore/platform/gtk/GeolocationServiceGtk.h
r38765 r40441 22 22 23 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> 24 30 25 31 namespace WebCore { … … 27 33 public: 28 34 GeolocationServiceGtk(GeolocationServiceClient*); 35 ~GeolocationServiceGtk(); 29 36 30 37 virtual bool startUpdating(PositionOptions*); … … 36 43 Geoposition* lastPosition() const; 37 44 PositionError* lastError() const; 45 46 private: 47 void updateLocationInformation(); 48 void setError(PositionError::ErrorCode, const char* message); 49 void updatePosition(); 50 51 static void position_changed(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, 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; 38 68 }; 39 69 } -
trunk/configure.ac
r39804 r40441 676 676 AC_SUBST([LIBXSLT_LIBS]) 677 677 fi 678 679 # check if geoclue is available 680 if test "$enable_geolocation" = "yes"; then 681 PKG_CHECK_MODULES([GEOCLUE], [geoclue]) 682 AC_SUBST([GEOCLUE_CFLAGS]) 683 AC_SUBST([GEOCLUE_LIBS]) 684 fi 685 678 686 679 687 # check if gstreamer is available
Note: See TracChangeset
for help on using the changeset viewer.