From: Kaj-Michael Lang Date: Mon, 28 Jan 2008 17:15:33 +0000 (+0200) Subject: Start to separate UI from GPS connection and parsing. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5ce56e821bdd93e5761c34806c1bcc342b239cb;p=mapper Start to separate UI from GPS connection and parsing. - Build a library for handling gps connection and NMEA parsing in preparation for the future home applet. - Use callback for interesting events. --- diff --git a/src/Makefile.am b/src/Makefile.am index 2c68ade..76d06cc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,15 +41,13 @@ mapper_LDADD = $(GLIBGTK_LIBS) $(GTKHTML_LIBS) \ $(SQLITE_LIBS) $(LIBCURL_LIBS) \ $(DBUS_GLIB_LIBS) $(BLUEZ_LIBS) \ $(GYPSY_LIBS) $(LIBGPSBT_LIBS) \ - -lm libgtkgps.la libosmdb.la + -lm libgtkgps.la libosmdb.la libmappergps.la mapper_SOURCES = utils.c \ file.c \ gpx.c \ filter.c \ - gps.c \ gps-browse.c \ - gps-nmea-parse.c \ gps-panels.c \ gps-conn.c \ cb.c \ @@ -77,27 +75,23 @@ mapper_SOURCES = utils.c \ search.c \ mapper.c +osm2db_CFLAGS = $(EXPAT_CFLAGS) $(SQLITE_CFLAGS) $(GLIBGTK_CFLAGS) +osm2db_LDADD = $(EXPAT_LIBS) $(SQLITE_LIBS) $(GLIBGTK_LIBS) $(BZ2_LIBS) -lm libosmdb.la +osm2db_SOURCES = osm.c + +lib_LTLIBRARIES = libgtkgps.la libosmdb.la libmappergps.la + +libmappergps_la_SOURCES = gps.c gps-nmea-parse.c if HAVE_BLUEZ_DBUS_BT -mapper_SOURCES+=gps-bluetooth-bluez.c gps-bluetooth-bluez-marshal.c +libmappergps_la_SOURCES+=gps-bluetooth-bluez.c gps-bluetooth-bluez-marshal.c endif if HAVE_HILDON_DBUS_BT -mapper_SOURCES+=gps-bluetooth-maemo.c gps-bluetooth-maemo-marshal.c +libmappergps_la_SOURCES+=gps-bluetooth-maemo.c gps-bluetooth-maemo-marshal.c endif - -#if HAVE_GPSD -#mapper_SOURCES+=gps-gpsd.c -#endif - -#if HAVE_GYPSY -#mapper_SOURCES+=gps-gypsy.c -#endif - -osm2db_CFLAGS = $(EXPAT_CFLAGS) $(SQLITE_CFLAGS) $(GLIBGTK_CFLAGS) -osm2db_LDADD = $(EXPAT_LIBS) $(SQLITE_LIBS) $(GLIBGTK_LIBS) $(BZ2_LIBS) -lm libosmdb.la -osm2db_SOURCES = osm.c - -lib_LTLIBRARIES = libgtkgps.la libosmdb.la +libmappergps_la_CFLAGS = $(GLIBGTK_CFLAGS) $(LIBGPSBT_CFLAGS) $(defines) +libmappergps_la_LIBADD = $(GLIBGTK_LIBS) $(LIBGPSBT_LIBS) +libmappergps_la_LDFLAGS = -lm -no-undefined libgtkgps_la_SOURCES = gtkgps.c gtkcompass.c libgtkgps_la_CFLAGS = $(GLIBGTK_CFLAGS) $(defines) diff --git a/src/config-gconf.c b/src/config-gconf.c index 64fc4f8..e90ae2f 100644 --- a/src/config-gconf.c +++ b/src/config-gconf.c @@ -442,6 +442,7 @@ if (value) { } else { _gps->io.type=GPS_IO_SIMULATION; } +g_debug("GPS Type: %d", _gps->io.type); /* Get Auto-Download. Default is FALSE. */ _auto_download = gconf_client_get_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, NULL); diff --git a/src/gps-bluetooth-bluez.c b/src/gps-bluetooth-bluez.c index ff03391..fee8da2 100644 --- a/src/gps-bluetooth-bluez.c +++ b/src/gps-bluetooth-bluez.c @@ -7,13 +7,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include @@ -22,13 +20,10 @@ #include #include "bluetooth-scan.h" -#include "gps.h" -#include "map.h" #include "utils.h" #include "mapper-types.h" #include "settings.h" #include "ui-common.h" -#include "gps-conn.h" gint scan_start_search(ScanInfo * scan_info) diff --git a/src/gps-conn.c b/src/gps-conn.c index 5aab930..a841f1c 100644 --- a/src/gps-conn.c +++ b/src/gps-conn.c @@ -57,7 +57,6 @@ gps_conn_set_state(Gps *gps, GpsConnState new_conn_state) { switch (gps->io.conn=new_conn_state) { case RCVR_OFF: - _enable_gps=FALSE; set_action_activate("gps_enabled", FALSE); case RCVR_FIXED: if (connect_banner) { diff --git a/src/gps-nmea-parse.c b/src/gps-nmea-parse.c index dee1673..810791a 100644 --- a/src/gps-nmea-parse.c +++ b/src/gps-nmea-parse.c @@ -34,25 +34,16 @@ #include #include #include -#include #include -#include #include "utils.h" #include "gps.h" -#include "mapper-types.h" -#include "ui-common.h" -#include "map.h" -#include "track.h" -#include "route.h" -#include "gps-panels.h" -#include "settings.h" -#include "gps-conn.h" -#include "gtkgps.h" -#include "gtkcompass.h" +#include "gps-nmea-parse.h" + +#define DELIM "," static void -gps_nmea_parse_rmc(Gps *gps, gchar * sentence) +gps_nmea_parse_rmc(Gps *gps, gchar *sentence) { /* Recommended Minimum Navigation Information C * 1) UTC Time @@ -73,9 +64,7 @@ gps_nmea_parse_rmc(Gps *gps, gchar * sentence) gdouble tmpd = 0.f; guint tmpi = 0; gboolean newly_fixed = FALSE; - vprintf("%s(): %s\n", __PRETTY_FUNCTION__, sentence); - -#define DELIM "," + g_debug("%s(): %s", __PRETTY_FUNCTION__, sentence); /* Parse time. */ token = strsep(&sentence, DELIM); @@ -94,7 +83,7 @@ gps_nmea_parse_rmc(Gps *gps, gchar * sentence) /* Data is invalid - not enough satellites?. */ if (gps->io.conn != RCVR_UP) { gps_conn_set_state(gps, RCVR_UP); - track_add(NULL, FALSE); + /* track_add(NULL, FALSE); */ } } @@ -155,20 +144,16 @@ gps_nmea_parse_rmc(Gps *gps, gchar * sentence) strcat(gpsdate, token); strptime(gpsdate, "%H%M%S%d%m%y", &time); gps->data.time = mktime(&time) + _gmtoffset; - } else + } else { gps->data.time = time(NULL); - - /* Add new data to track only if we have a fix */ - _track_store=TRUE; + } gps_data_integerize(&gps->data); - gps_display_data_speed(info_banner.speed, gps->data.speed); - if ((gps->io.conn==RCVR_FIXED) && (_track_store==TRUE) && filter_check(&filter, &gps->data, &map_loc)==TRUE) { - track_add(&_gps->data, newly_fixed); - gps->data.lheading=gps->data.heading; - map_refresh_mark(); + if ((gps->io.conn==RCVR_FIXED) && (gps->update_location!=NULL)) { + gps->update_location(gps, newly_fixed); } + gps->data.lheading=gps->data.heading; } static void @@ -201,9 +186,7 @@ gps_nmea_parse_gga(Gps *gps, gchar * sentence) 15. the checksum data */ gchar *token; - vprintf("%s(): %s\n", __PRETTY_FUNCTION__, sentence); - -#define DELIM "," + g_debug("%s(): %s", __PRETTY_FUNCTION__, sentence); /* Skip Fix time */ token = strsep(&sentence, DELIM); @@ -256,8 +239,6 @@ gps_nmea_parse_gsa(Gps *gps, gchar * sentence) g_debug("%s(): %s\n", __PRETTY_FUNCTION__, sentence); -#define DELIM "," - /* Skip Auto selection. */ token = strsep(&sentence, DELIM); @@ -372,40 +353,35 @@ gps_nmea_parse_gsv(Gps *gps, gchar * sentence) if (gps->io.conn==RCVR_UP) { gdouble fraction = running_total * sqrt(num_sats_used) / num_sats_used / 100.0; BOUND(fraction, 0.0, 1.0); - gps_conn_set_progress(gps, fraction); + if (gps->connection_progress!=NULL) + gps->connection_progress(gps, fraction); } running_total=0; num_sats_used=0; } satcnt = 0; - - /* Keep awake while they watch the progress bar. */ - KEEP_DISPLAY_ON(); } } gboolean -gps_nmea_parse(gchar *data) +gps_nmea_parse(Gps *gps) { -Gps *gps=_gps; - -if (!strncmp(data + 3, "GSV", 3)) { - if (gps->io.conn==RCVR_UP) - gps_nmea_parse_gsv(gps, data + 7); -} else if (!strncmp(data + 3, "RMC", 3)) - gps_nmea_parse_rmc(gps, data + 7); -else if (!strncmp(data + 3, "GGA", 3)) - gps_nmea_parse_gga(gps, data + 7); -else if (!strncmp(data + 3, "GSA", 3)) - gps_nmea_parse_gsa(gps, data + 7); -else g_debug("Unknown NMEA: [%s]\n", data); -g_free(data); - -if (_gps_info) - gps_display_data(&gps->data); - -if (_satdetails_on) - gps_display_details(&gps->data); +g_assert(gps); +g_assert(gps->io.nmea); + +g_debug("%s(): %s", __PRETTY_FUNCTION__, gps->io.nmea); + +if (!strncmp(gps->io.nmea + 3, "GSV", 3)) { + gps_nmea_parse_gsv(gps, gps->io.nmea + 7); +} else if (!strncmp(gps->io.nmea + 3, "RMC", 3)) + gps_nmea_parse_rmc(gps, gps->io.nmea + 7); +else if (!strncmp(gps->io.nmea + 3, "GGA", 3)) + gps_nmea_parse_gga(gps, gps->io.nmea + 7); +else if (!strncmp(gps->io.nmea + 3, "GSA", 3)) + gps_nmea_parse_gsa(gps, gps->io.nmea + 7); +else g_printerr("Unknown NMEA: [%s]\n", gps->io.nmea); +g_free(gps->io.nmea); +gps->io.nmea=NULL; return FALSE; } diff --git a/src/gps-nmea-parse.h b/src/gps-nmea-parse.h index 569ffae..fa21042 100644 --- a/src/gps-nmea-parse.h +++ b/src/gps-nmea-parse.h @@ -1,6 +1,8 @@ #ifndef _GPS_NMEA_PARSE_H #define _GPS_NMEA_PARSE_H -gboolean gps_nmea_parse(gchar *data); +#include "gps.h" + +gboolean gps_nmea_parse(Gps *gps); #endif diff --git a/src/gps.c b/src/gps.c index 227122e..08e3f31 100644 --- a/src/gps.c +++ b/src/gps.c @@ -43,9 +43,8 @@ #include "gps.h" #include "latlon.h" #include "map.h" -#include "gps-nmea-parse.h" #include "gps-conn.h" -#include "track.h" +#include "gps-nmea-parse.h" #ifdef WITH_HILDON_DBUS_BT #include @@ -66,18 +65,26 @@ static gboolean gps_connect_file(Gps *gps, gchar *file); #define GPSD_PORT (2947) const GpsTypes gps_types[] = { - { GPS_IO_RFCOMM, "Direct bluetooth connection", TRUE, TRUE}, - { GPS_IO_HILDON_DBUS, "Hildon D-Bus", TRUE, TRUE }, - { GPS_IO_BLUEZ_DBUS, "Blues D-Bus", TRUE, TRUE}, +#ifdef WITH_BLUEZ + { GPS_IO_RFCOMM, "Bluetooth connection (old)", TRUE, TRUE}, +#endif +#ifdef WITH_HILDON_DBUS_BT + { GPS_IO_HILDON_DBUS, "Bluetooth connection (btconn)", TRUE, TRUE }, +#endif +#ifdef WITH_BLUEZ_DBUS_BT + { GPS_IO_BLUEZ_DBUS, "Bluetooth connection (new)", TRUE, TRUE}, +#endif + { GPS_IO_GPSD, "GPSD Connection", FALSE, TRUE}, { GPS_IO_FILE, "File or device", FALSE, TRUE}, { GPS_IO_TCP, "TCP Connection", FALSE, TRUE}, - { GPS_IO_GPSD, "GPSD", FALSE, TRUE}, +#ifdef WITH_GYPSY { GPS_IO_GYPSY, "Gypsy", FALSE, TRUE}, - { GPS_IO_SIMULATION, "Simulation", FALSE, FALSE}, +#endif + { GPS_IO_SIMULATION, "Simulation (random)", FALSE, FALSE}, { 0 } }; -GpsTypes * +const GpsTypes * gps_get_supported_types(void) { return gps_types; @@ -97,10 +104,15 @@ gps->io.fd=-1; gps->io.address=NULL; gps->io.type=type; gps->io.conn=RCVR_OFF; +gps->io.nmea=NULL; gps->data.lat=60.20; gps->data.lon=22.20; gps->connection_error=NULL; gps->connection_retry=NULL; +gps->connection_progress=NULL; +gps->update_location=NULL; +gps->update_info=NULL; +gps->update_satellite=NULL; gps_data_integerize(&gps->data); return gps; } @@ -241,20 +253,25 @@ static gboolean gps_connect_socket(Gps *gps) { gint r, e; +g_assert(gps); + switch (gps->io.type) { -#ifdef WITH_BLUEZ case GPS_IO_RFCOMM: +#ifdef WITH_BLUEZ + g_debug("RFCOMM: %d", gps->io.fd); r=connect(gps->io.fd, (struct sockaddr *)&gps->io.rcvr_addr_rc, sizeof(gps->io.rcvr_addr_rc)); - break; #endif + break; case GPS_IO_TCP: case GPS_IO_GPSD: + g_debug("TCP: %d", gps->io.fd); r=connect(gps->io.fd, (struct sockaddr *)&gps->io.rcvr_addr_in, sizeof(gps->io.rcvr_addr_in)); break; default: return FALSE; } e=errno; +g_debug("GPS: Error %d", e); /* The socket is non blocking so handle it */ if (r != 0) { @@ -263,12 +280,12 @@ if (r != 0) { case EBUSY: case EINPROGRESS: case EALREADY: - g_printf("*** Connection in progress... %d %d\n", e, r); + g_printerr("*** Connection in progress... %d %d\n", e, r); perror("INFO: "); return TRUE; break; case EHOSTUNREACH: - g_printf("*** Bluetooth/GPS device not found.\n"); + g_printerr("*** Bluetooth/GPS device not found.\n"); gps_disconnect(gps); #if 0 set_action_activate("gps_enable", FALSE); @@ -278,7 +295,7 @@ if (r != 0) { break; default: /* Connection failed. Disconnect and try again later. */ - g_printf("### Connect failed, retrying... %d %d\n", e, r); + g_printerr("### Connect failed, retrying... %d %d\n", e, r); perror("ERROR: "); gps_disconnect(gps); gps_connect_later(gps); @@ -396,9 +413,10 @@ h=calculate_course(plat, plon, gps->data.lat, gps->data.lon); gps->data.heading=(h<0) ? 360+h : h; gps->data.time=time(NULL); gps_data_integerize(&gps->data); -track_add(&gps->data, FALSE); +if (gps->update_location!=NULL) { + gps->update_location(gps, FALSE); +} gps->data.lheading=gps->data.heading; -map_refresh_mark(); return gps->io.conn==RCVR_FIXED ? TRUE : FALSE; } @@ -423,8 +441,8 @@ gps_read_channel_connect(Gps *gps) gps->io.channel=g_io_channel_unix_new(gps->io.fd); g_io_channel_set_encoding(gps->io.channel, NULL, NULL); g_io_channel_set_flags(gps->io.channel, G_IO_FLAG_NONBLOCK, NULL); -gps->io.error_sid=g_io_add_watch_full(gps->io.channel, G_PRIORITY_HIGH_IDLE, G_IO_ERR | G_IO_HUP, gps_channel_cb_error, NULL, NULL); -gps->io.connect_sid=g_io_add_watch_full(gps->io.channel, G_PRIORITY_HIGH_IDLE, G_IO_OUT, gps_channel_cb_connect, NULL, NULL); +gps->io.error_sid=g_io_add_watch_full(gps->io.channel, G_PRIORITY_HIGH_IDLE, G_IO_ERR | G_IO_HUP, gps_channel_cb_error, gps, NULL); +gps->io.connect_sid=g_io_add_watch_full(gps->io.channel, G_PRIORITY_HIGH_IDLE, G_IO_OUT, gps_channel_cb_connect, gps, NULL); gps->io.clater_sid=0; } @@ -454,7 +472,7 @@ switch (gps->io.type) { break; case GPS_IO_TCP: case GPS_IO_GPSD: - if (gps->io.conn==RCVR_DOWN && gps->io.address) { + if (gps->io.conn<=RCVR_DOWN && gps->io.address) { gps->io.fd=socket(AF_INET, SOCK_STREAM, 0); if (gps->io.fd==-1) { g_debug("Failed to create socket\n"); @@ -479,8 +497,8 @@ switch (gps->io.type) { } #endif break; - case GPS_IO_HILDON_DBUS: #ifdef WITH_HILDON_DBUS_BT + case GPS_IO_HILDON_DBUS: if (NULL == (gps->io.dbus_conn=dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) { g_printerr("Failed to get D-Bus connection."); return FALSE; @@ -499,15 +517,14 @@ switch (gps->io.type) { G_TYPE_BOOLEAN, &mybool, G_TYPE_INVALID); } -#endif - return FALSE; break; - case GPS_IO_RFCOMM: +#endif #ifdef WITH_BLUEZ + case GPS_IO_RFCOMM: if (!gps->io.address) return FALSE; - if (gps->io.conn==RCVR_DOWN && gps->io.address) { + if (gps->io.conn<=RCVR_DOWN && gps->io.address) { gps->io.fd=socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); /* If file descriptor creation failed, try again later. Note that @@ -524,7 +541,6 @@ switch (gps->io.type) { str2ba(gps->io.address, &gps->io.rcvr_addr_rc.rc_bdaddr); } #endif - return FALSE; break; case GPS_IO_SIMULATION: /* Set a periodic cb to generate random movement */ @@ -533,6 +549,7 @@ switch (gps->io.type) { return FALSE; break; default: + g_printerr("Unknown GPS connection type\n"); return FALSE; break; } @@ -608,8 +625,9 @@ Gps *gps=(Gps *)data; g_assert(data); /* An error has occurred - re-connect(). */ gps_disconnect(gps); -track_add(NULL, FALSE); -/* _speed_excess = FALSE; */ + +if (gps->connection_error!=NULL) + gps->connection_error(gps, "GPS Connection error"); if (gps->io.conn > RCVR_OFF) { gps_conn_set_state(gps, RCVR_DOWN); @@ -651,8 +669,9 @@ switch (status) { if (*sptr) *sptr = '\0'; /* take checksum out of the buffer. */ - data=g_strdup(gps->io.buffer); - g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)gps_nmea_parse, data, NULL); + gps->io.nmea=g_strdup(gps->io.buffer); + g_assert(gps->io.nmea); + g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)gps_nmea_parse, gps, NULL); } else { /* There was a checksum, and it was bad. */ g_printerr("%s: Bad checksum in NMEA sentence:\n%s\n", __PRETTY_FUNCTION__, gps->io.buffer); @@ -671,15 +690,34 @@ switch (status) { gps->io.curr -= (eol - gps->io.buffer + 1); } } + gps->io.errors=0; + gps->io.again=0; break; case G_IO_STATUS_ERROR: case G_IO_STATUS_EOF: gps_disconnect(gps); gps_connect_later(gps); gps->io.errors++; + if (gps->io.errors>10) { + if (gps->connection_error==NULL) + return FALSE; + else { + gps->connection_error(gps, "GPS data read error."); + } + } return FALSE; break; case G_IO_STATUS_AGAIN: + gps->io.again++; + if (gps->io.again>20) { + gps_disconnect(gps); + gps_connect_later(gps); + if (gps->connection_error==NULL) + return FALSE; + else { + gps->connection_error(gps, "GPS connection deadlock."); + } + } return TRUE; break; default: diff --git a/src/gps.h b/src/gps.h index c4a4e02..fa7afda 100644 --- a/src/gps.h +++ b/src/gps.h @@ -90,11 +90,13 @@ struct _GpsIO { guint error_sid; guint input_sid; guint clater_sid; - guint errors; + guint errors; /* G_IO_STATUS_ERRROR counter */ + guint again; /* G_IO_STATUS_AGAIN counter */ /* Input buffer */ gchar buffer[GPS_READ_BUF_SIZE]; gchar *curr; gchar *last; + /* Latest NMEA line, ready for parsing */ gchar *nmea; }; @@ -107,16 +109,26 @@ struct _Gps { GpsIO io; GpsData data; /* Event callbacks */ + /* On errors */ gboolean(* connection_error) (Gps *gps, const gchar *error_str); + /* Connection retry */ gboolean(* connection_retry) (Gps *gps, const gchar *error_str); + + /* Connection progress */ + gboolean(* connection_progress)(Gps *gps, gdouble fix); + + /* New location */ + void(* update_location)(Gps *gps, gboolean newly_fixed); + void(* update_satellite)(Gps *gps); + void(* update_info)(Gps *gps); }; Gps *_gps; gint _gmtoffset; -GpsTypes *gps_get_supported_types(void); +const GpsTypes *gps_get_supported_types(void); Gps *gps_new(GpsIOSourceType type); void gps_set_address(Gps *gps, gchar *address, guint port); diff --git a/src/gpx.h b/src/gpx.h index 0a09812..febce87 100644 --- a/src/gpx.h +++ b/src/gpx.h @@ -2,6 +2,7 @@ #define _GPX_H #include +#include #include "path.h" void gpx_init(void); diff --git a/src/mapper.c b/src/mapper.c index 60374a7..bb51c85 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -58,6 +58,7 @@ #include "mapper-types.h" #include "settings.h" #include "gps.h" +#include "gps-conn.h" #include "map.h" #include "route.h" #include "track.h" @@ -287,6 +288,11 @@ switch (mis) { /* XXX: Load GPS configuration, then create gps */ _gps=gps_new(GPS_IO_SIMULATION); _gps->connection_retry=gps_retry_connection; + _gps->connection_error=NULL; + _gps->connection_progress=gps_conn_set_progress; + _gps->update_location=gps_location_update; + _gps->update_info=gps_info_update; + timezone_init(); gpx_init(); variables_init(); diff --git a/src/track.c b/src/track.c index 800cd0f..20f0eb8 100644 --- a/src/track.c +++ b/src/track.c @@ -1,5 +1,8 @@ #include +#include +#include + #include "utils.h" #include "gps.h" #include "map.h" @@ -193,7 +196,7 @@ if (gps && show_directions && _next_way_dist_squared < (announce_thres_unsquared KEEP_DISPLAY_ON(); } -void +gboolean track_insert_break(void) { if (_track.tail->unity) { @@ -215,9 +218,9 @@ if ((x1 < BUF_WIDTH_PIXELS) && ((unsigned)y1 < BUF_HEIGHT_PIXELS)) x1 - _draw_width, y1 - _draw_width, 2 * _draw_width, 2 * _draw_width, 0, 360 * 64); -} else { - MACRO_BANNER_SHOW_INFO(_window, _("Break already inserted.")); + return TRUE; } +return FALSE; } gboolean diff --git a/src/track.h b/src/track.h index 51f761a..9c4bd84 100644 --- a/src/track.h +++ b/src/track.h @@ -25,7 +25,7 @@ void track_init(void); void track_deinit(void); void track_add(GpsData *gps, gboolean newly_fixed); -void track_insert_break(void); +gboolean track_insert_break(void); gboolean track_insert_mark(void); gboolean track_save(void); gboolean track_open(void); diff --git a/src/ui-common.c b/src/ui-common.c index 9d14e13..1fe5f20 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -32,6 +32,7 @@ #include "db.h" #include "gps-panels.h" #include "gps-conn.h" +#include "filter.h" #include "settings-gui.h" /* Callbacks */ @@ -799,6 +800,32 @@ if (dialog) gtk_widget_destroy(dialog); } +gboolean +gps_info_update(Gps *gps) +{ +g_assert(gps); +if (_gps_info) + gps_display_data(&gps->data); + +if (_satdetails_on) + gps_display_details(&gps->data); + +gps_display_data_speed(info_banner.speed, gps->data.speed); + +return TRUE; +} + +gboolean +gps_location_update(Gps *gps, gboolean newly_fixed) +{ +g_assert(gps); +if (filter_check(&filter, &gps->data, &map_loc)==TRUE) { + track_add(&_gps->data, newly_fixed); + map_refresh_mark(); +} +return TRUE; +} + /** * Simple dialog to ask if we should try to reconnect to GPS * returns TRUE or FALSE @@ -809,6 +836,7 @@ gps_retry_connection(Gps *gps, const gchar *error) GtkWidget *confirm; gboolean r; +g_assert(gps); confirm=hildon_note_new_confirmation(GTK_WINDOW(_window), _("Failed to connect to GPS receiver. Retry?")); r=(GTK_RESPONSE_OK==gtk_dialog_run(GTK_DIALOG(confirm))) ? TRUE : FALSE; gtk_widget_destroy(confirm); diff --git a/src/ui-common.h b/src/ui-common.h index f4359ee..d3213e9 100644 --- a/src/ui-common.h +++ b/src/ui-common.h @@ -15,11 +15,6 @@ #include #include #include -#include -#include -#include -#include -#include #include "gps.h" #include "mapper-types.h" @@ -132,6 +127,9 @@ void set_action_activate(const char *name, gboolean active); GtkWidget *progress_dialog(const gchar *title, GtkWidget *progress); void progress_dialog_remove(GtkWidget *dialog); +/* XXX: Not the right place but.. */ +gboolean gps_info_update(Gps *gps); +gboolean gps_location_update(Gps *gps, gboolean newly_fixed); gboolean gps_retry_connection(Gps *gps, const gchar *error); #endif diff --git a/src/utils.h b/src/utils.h index a1e1467..53a6471 100644 --- a/src/utils.h +++ b/src/utils.h @@ -76,7 +76,6 @@ if(error_check == (str)) \ { \ g_printerr("Line %d: Failed to parse string as int: %s\n", __LINE__, str); \ - MACRO_BANNER_SHOW_INFO(_window, _("Invalid NMEA input from receiver!")); \ return; \ } \ } @@ -86,7 +85,6 @@ if(error_check == (str)) \ { \ g_printerr("Failed to parse string as float: %s\n", str); \ - MACRO_BANNER_SHOW_INFO(_window, _("Invalid NMEA input from receiver!")); \ return; \ } \ }