~ubuntu-branches/ubuntu/saucy/geoclue-providers/saucy-proposed

« back to all changes in this revision

Viewing changes to providers/gpsd/geoclue-gpsd.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-07-05 10:56:26 UTC
  • Revision ID: package-import@ubuntu.com-20130705105626-hywod41wasnytrjr
Tags: 0.12.99-2ubuntu1
* Sync with geoclue packaging. Remaining changes:
  - debian/control:
    + Build-depend on autotools-dev, libgeoclue-dev, libgps-dev and
      libgypsy-dev
  - debian/rules:
    + Enable gpsd and gypsy providers
    + Fix handling of config.sub 
  - Install only the gpsd and gypsy providers

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include <geoclue/gc-iface-position.h>
41
41
#include <geoclue/gc-iface-velocity.h>
42
42
 
 
43
#if GPSD_API_MAJOR_VERSION >= 5
 
44
/* gps_data conflicts with gps_data function */
 
45
typedef struct gps_data_t gps_data_l;
 
46
#else
43
47
typedef struct gps_data_t gps_data;
 
48
#endif
44
49
typedef struct gps_fix_t gps_fix;
45
50
 
46
51
/* only listing used tags */
59
64
        char *host;
60
65
        char *port;
61
66
        
 
67
#if GPSD_API_MAJOR_VERSION >= 5
 
68
        gps_data_l *gpsdata;
 
69
#else
62
70
        gps_data *gpsdata;
 
71
#endif
63
72
        
64
73
        gps_fix *last_fix;
65
74
        
397
406
static gboolean
398
407
geoclue_gpsd_start_gpsd (GeoclueGpsd *self)
399
408
{
 
409
#if GPSD_API_MAJOR_VERSION >= 5
 
410
        int status = gps_open (self->host, self->port, self->gpsdata);
 
411
        if (status == 0) {
 
412
                gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NMEA, NULL);
 
413
#else
400
414
        self->gpsdata = gps_open (self->host, self->port);
401
415
        if (self->gpsdata) {
402
416
                gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NMEA | POLL_NONBLOCK, NULL);
403
417
                gps_set_raw_hook (self->gpsdata, gpsd_raw_hook);
 
418
#endif
404
419
                return TRUE;
405
420
        } else {
406
421
                g_warning ("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port);
413
428
{
414
429
        GeoclueGpsd *self = (GeoclueGpsd*)data;
415
430
        if (self->gpsdata) {
 
431
#if GPSD_API_MAJOR_VERSION >= 5 
 
432
                /* gps_poll and gps_set_raw_hook no longer present in this API version */
 
433
                if (gps_waiting(self->gpsdata, 500)) {
 
434
                        if (gps_read(self->gpsdata) == -1) {
 
435
                                geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR);
 
436
                                geoclue_gpsd_stop_gpsd(self);
 
437
                                return FALSE;
 
438
                        } else {          
 
439
                                /* Call existing raw_hook to process the data */
 
440
                                gpsd_raw_hook(self->gpsdata, NULL, 0);    
 
441
                        }
 
442
#else
416
443
                if (gps_poll(self->gpsdata) < 0) {
417
444
                        geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR);
418
445
                        geoclue_gpsd_stop_gpsd(self);
419
446
                        return FALSE;
 
447
#endif
420
448
                }
421
449
        }
422
450
        return TRUE;