--- providers/gpsd/geoclue-gpsd.c.bak	2011-11-06 00:43:28.832224036 +0100
+++ providers/gpsd/geoclue-gpsd.c	2011-11-06 01:59:54.512878539 +0100
@@ -40,7 +40,6 @@
 #include <geoclue/gc-iface-position.h>
 #include <geoclue/gc-iface-velocity.h>
 
-typedef struct gps_data_t gps_data;
 typedef struct gps_fix_t gps_fix;
 
 /* only listing used tags */
@@ -59,7 +58,7 @@
 	char *host;
 	char *port;
 	
-	gps_data *gpsdata;
+	struct gps_data_t gpsdata;
 	
 	gps_fix *last_fix;
 	
@@ -152,6 +151,10 @@
 		port = DEFAULT_GPSD_PORT;
 	}
 	
+	if (host == NULL) {
+		host = "localhost";
+	}
+	
 	/* new values? */
 	if (g_strcmp0 (host, gpsd->host) != 0 ||
 	    g_strcmp0 (port, gpsd->port) != 0) {
@@ -228,16 +231,16 @@
 static void
 geoclue_gpsd_update_position (GeoclueGpsd *gpsd, NmeaTag nmea_tag)
 {
-	gps_fix *fix = &gpsd->gpsdata->fix;
+	gps_fix *fix = &gpsd->gpsdata.fix;
 	gps_fix *last_fix = gpsd->last_fix;
 	
 	last_fix->time = fix->time;
 	
 	/* If a flag is not set, bail out.*/
-	if (!((gpsd->gpsdata->set & LATLON_SET) || (gpsd->gpsdata->set & ALTITUDE_SET))) {
+	if (!((gpsd->gpsdata.set & LATLON_SET) || (gpsd->gpsdata.set & ALTITUDE_SET))) {
 		return;
 	}
-	gpsd->gpsdata->set &= ~(LATLON_SET | ALTITUDE_SET);
+	gpsd->gpsdata.set &= ~(LATLON_SET | ALTITUDE_SET);
 	
 	if (equal_or_nan (fix->latitude, last_fix->latitude) &&
 	    equal_or_nan (fix->longitude, last_fix->longitude) &&
@@ -279,7 +282,7 @@
 static void
 geoclue_gpsd_update_velocity (GeoclueGpsd *gpsd, NmeaTag nmea_tag)
 {
-	gps_fix *fix = &gpsd->gpsdata->fix;
+	gps_fix *fix = &gpsd->gpsdata.fix;
 	gps_fix *last_fix = gpsd->last_fix;
 	gboolean changed = FALSE;
 	
@@ -290,10 +293,10 @@
 	 * couldn't think of an smart way to handle this, I don't think there is one
 	 */
 	
-	if (((gpsd->gpsdata->set & TRACK_SET) || (gpsd->gpsdata->set & SPEED_SET)) &&
+	if (((gpsd->gpsdata.set & TRACK_SET) || (gpsd->gpsdata.set & SPEED_SET)) &&
 	    nmea_tag == NMEA_RMC) {
 		
-		gpsd->gpsdata->set &= ~(TRACK_SET | SPEED_SET);
+		gpsd->gpsdata.set &= ~(TRACK_SET | SPEED_SET);
 		
 		last_fix->time = fix->time;
 		
@@ -305,12 +308,12 @@
 			last_fix->track = fix->track;
 			last_fix->speed = fix->speed;
 		}
-	} else if ((gpsd->gpsdata->set & CLIMB_SET) &&
+	} else if ((gpsd->gpsdata.set & CLIMB_SET) &&
 	           (nmea_tag == NMEA_GGA || 
 	            nmea_tag == NMEA_GSA || 
 	            nmea_tag == NMEA_GSV)) {
 		
-		gpsd->gpsdata->set &= ~(CLIMB_SET);
+		gpsd->gpsdata.set &= ~(CLIMB_SET);
 		
 		last_fix->time = fix->time;
 		
@@ -344,12 +347,12 @@
 	GeoclueStatus status;
 	
 	/* gpsdata->online is supposedly always up-to-date */
-	if (gpsd->gpsdata->online <= 0) {
+	if (gpsd->gpsdata.online <= 0) {
 		status = GEOCLUE_STATUS_UNAVAILABLE;
-	} else if (gpsd->gpsdata->set & STATUS_SET) {
-		gpsd->gpsdata->set &= ~(STATUS_SET);
+	} else if (gpsd->gpsdata.set & STATUS_SET) {
+		gpsd->gpsdata.set &= ~(STATUS_SET);
 		
-		if (gpsd->gpsdata->status > 0) {
+		if (gpsd->gpsdata.status > 0) {
 			status = GEOCLUE_STATUS_AVAILABLE;
 		} else {
 			status = GEOCLUE_STATUS_ACQUIRING;
@@ -362,9 +365,9 @@
 }
 
 static void 
-gpsd_raw_hook (struct gps_data_t *gpsdata, char *message, size_t len)
+gpsd_raw_hook (struct gps_data_t gpsdata)
 {
-	char *tag_str = gpsd->gpsdata->tag;
+	char *tag_str = gpsd->gpsdata.tag;
 	NmeaTag nmea_tag = NMEA_NONE;
 	
 	if (tag_str[0] == 'G' && tag_str[1] == 'S' && tag_str[2] == 'A') {
@@ -385,23 +388,22 @@
 static void
 geoclue_gpsd_stop_gpsd (GeoclueGpsd *self)
 {
-	if (self->gpsdata) {
-		gps_close (self->gpsdata);
-		self->gpsdata = NULL;
+	struct gps_data_t *gpsdata = &self->gpsdata; 
+	if (gpsdata) {
+		gps_close (gpsdata);
+		gpsdata = NULL;
 	}
 }
 
 static gboolean
 geoclue_gpsd_start_gpsd (GeoclueGpsd *self)
 {
-	self->gpsdata = gps_open (self->host, self->port);
-	if (self->gpsdata) {
-		gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NMEA | POLL_NONBLOCK, NULL);
-		gps_set_raw_hook (self->gpsdata, gpsd_raw_hook);
-		return TRUE;
-	} else {
+	if (gps_open(self->host, self->port, &self->gpsdata) != 0) {
 		g_warning ("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port);
 		return FALSE;
+	} else {
+		gps_stream(&self->gpsdata, WATCH_ENABLE | WATCH_NMEA, NULL);
+		return TRUE;
 	}
 }
 
@@ -409,12 +411,13 @@
 gpsd_poll(gpointer data)
 {
 	GeoclueGpsd *self = (GeoclueGpsd*)data;
-	if (self->gpsdata) {
-		if (gps_poll(self->gpsdata) < 0) {
+	if (&self->gpsdata) {
+		if (gps_read(&self->gpsdata) < 0) {
 			geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR);
 			geoclue_gpsd_stop_gpsd(self);
 			return FALSE;
 		}
+		gpsd_raw_hook(self->gpsdata);
 	}
 	return TRUE;
 }
@@ -422,7 +425,6 @@
 static void
 geoclue_gpsd_init (GeoclueGpsd *self)
 {
-	self->gpsdata = NULL;
 	self->last_fix = g_new0 (gps_fix, 1);
 	
 	self->last_pos_fields = GEOCLUE_POSITION_FIELDS_NONE;
@@ -435,7 +437,7 @@
 				 "Gpsd", "Gpsd provider");
 	
 	self->port = g_strdup (DEFAULT_GPSD_PORT);
-	self->host = NULL;
+	self->host = "localhost";
 	geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ACQUIRING);
 	if (!geoclue_gpsd_start_gpsd (self)) {
 		geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR);