gint count;
VikTrwLayer *vtl;
VikTrack *track;
- gchar *cmd_args;
+ gchar *babelargs;
gchar *window_title;
GtkWidget *dialog;
GtkWidget *status_label;
{
gint new_proto = 0;
// +1 for luck (i.e the NULL terminator)
- gchar **new_protocols = g_malloc(1 + g_list_length(a_babel_device_list)*sizeof(gpointer));
+ gchar **new_protocols = g_malloc_n(1 + g_list_length(a_babel_device_list), sizeof(gpointer));
GList *gl = g_list_first ( a_babel_device_list );
while ( gl ) {
static void gps_session_delete(GpsSession *sess)
{
vik_mutex_free(sess->mutex);
- g_free(sess->cmd_args);
+ g_free(sess->babelargs);
g_free(sess);
}
{
// Maybe a gpsbabel bug/feature (upto at least v1.4.3 or maybe my Garmin device) but the count always seems x2 too many for routepoints
gint mycnt = (cnt / 2) + 1;
- tmp_str = ngettext("Downloading %d routepoint...", "Downloading %d routepoints...", mycnt); break;
+ tmp_str = ngettext("Downloading %d routepoint...", "Downloading %d routepoints...", mycnt);
sess->total_count = mycnt;
+ break;
}
}
}
{
gboolean result;
- if (sess->direction == GPS_DOWN)
- result = a_babel_convert_from (sess->vtl, sess->cmd_args, sess->port,
- (BabelStatusFunc) gps_download_progress_func, sess, NULL);
+ if (sess->direction == GPS_DOWN) {
+ ProcessOptions po = { sess->babelargs, sess->port, NULL, NULL, NULL, NULL };
+ result = a_babel_convert_from (sess->vtl, &po, (BabelStatusFunc) gps_download_progress_func, sess, NULL);
+ }
else {
- result = a_babel_convert_to (sess->vtl, sess->track, sess->cmd_args, sess->port,
+ result = a_babel_convert_to (sess->vtl, sess->track, sess->babelargs, sess->port,
(BabelStatusFunc) gps_upload_progress_func, sess);
}
if (!sess->realtime_tracking)
#endif
{
- if ( sess->vvp && sess->direction == GPS_DOWN ) {
- /* View the data available */
- vik_trw_layer_auto_set_view ( sess->vtl, sess->vvp) ;
- vik_layer_emit_update ( VIK_LAYER(sess->vtl) ); // NB update from background thread
- }
+ if ( sess->vvp && sess->direction == GPS_DOWN ) {
+ vik_layer_post_read ( VIK_LAYER(sess->vtl), sess->vvp, TRUE );
+ /* View the data available */
+ vik_trw_layer_auto_set_view ( sess->vtl, sess->vvp ) ;
+ vik_layer_emit_update ( VIK_LAYER(sess->vtl) ); // NB update from background thread
+ }
}
} else {
/* canceled */
else
waypoints = "";
- sess->cmd_args = g_strdup_printf("-D 9 %s %s %s -%c %s",
+ sess->babelargs = g_strdup_printf("-D 9 %s %s %s -%c %s",
tracks, routes, waypoints, (dir == GPS_DOWN) ? 'i' : 'o', protocol);
tracks = NULL;
waypoints = NULL;
if ( turn_off ) {
// No need for thread for powering off device (should be quick operation...) - so use babel command directly:
gchar *device_off = g_strdup_printf("-i %s,%s", protocol, "power_off");
- gboolean result = a_babel_convert_from (NULL, (const char*)device_off, (const char*)port, NULL, NULL, NULL);
+ ProcessOptions po = { device_off, port, NULL, NULL, NULL, NULL };
+ gboolean result = a_babel_convert_from (NULL, &po, NULL, NULL, NULL);
if ( !result )
a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_LAYER(vtl), _("Could not turn off device.") );
g_free ( device_off );
if (condition == G_IO_IN) {
#if GPSD_API_MAJOR_VERSION == 3 || GPSD_API_MAJOR_VERSION == 4
if (!gps_poll(&vgl->vgpsd->gpsd)) {
-#elif GPSD_API_MAJOR_VERSION == 5
+#elif GPSD_API_MAJOR_VERSION == 5 || GPSD_API_MAJOR_VERSION == 6
if (gps_read(&vgl->vgpsd->gpsd) > -1) {
// Reuse old function to perform operations on the new GPS data
gpsd_raw_hook(vgl->vgpsd, NULL);
else {
g_warning("Disconnected from gpsd. Trying to reconnect");
rt_gpsd_disconnect(vgl);
- rt_gpsd_connect(vgl, FALSE);
+ (void)rt_gpsd_connect(vgl, FALSE);
}
}
return FALSE; /* no further calling */
vgl->vgpsd = g_malloc(sizeof(VglGpsd));
if (gps_open_r(vgl->gpsd_host, vgl->gpsd_port, /*(struct gps_data_t *)*/vgl->vgpsd) != 0) {
-#elif GPSD_API_MAJOR_VERSION == 5
+#elif GPSD_API_MAJOR_VERSION == 5 || GPSD_API_MAJOR_VERSION == 6
vgl->vgpsd = g_malloc(sizeof(VglGpsd));
if (gps_open(vgl->gpsd_host, vgl->gpsd_port, &vgl->vgpsd->gpsd) != 0) {
#else
#if GPSD_API_MAJOR_VERSION == 3
gps_query(&vgl->vgpsd->gpsd, "w+x");
#endif
-#if GPSD_API_MAJOR_VERSION == 4 || GPSD_API_MAJOR_VERSION == 5
- gps_stream(&vgl->vgpsd->gpsd, WATCH_ENABLE, NULL);
+#if GPSD_API_MAJOR_VERSION == 4 || GPSD_API_MAJOR_VERSION == 5 || GPSD_API_MAJOR_VERSION == 6
+ if ( gps_stream(&vgl->vgpsd->gpsd, WATCH_ENABLE, NULL) == -1 )
+ g_critical ( "gps_stream error" );
#endif
return FALSE; /* no longer called by timeout */
vgl->realtime_io_channel = NULL;
}
if (vgl->vgpsd) {
-#if GPSD_API_MAJOR_VERSION == 4 || GPSD_API_MAJOR_VERSION == 5
+#if GPSD_API_MAJOR_VERSION == 4 || GPSD_API_MAJOR_VERSION == 5 || GPSD_API_MAJOR_VERSION == 6
gps_stream(&vgl->vgpsd->gpsd, WATCH_DISABLE, NULL);
#endif
gps_close(&vgl->vgpsd->gpsd);
#if GPSD_API_MAJOR_VERSION == 3
free(vgl->vgpsd);
-#elif GPSD_API_MAJOR_VERSION == 4 || GPSD_API_MAJOR_VERSION == 5
+#elif GPSD_API_MAJOR_VERSION == 4 || GPSD_API_MAJOR_VERSION == 5 || GPSD_API_MAJOR_VERSION == 6
g_free(vgl->vgpsd);
#endif
vgl->vgpsd = NULL;