/*
* viking -- GPS Data and Topo Analyzer, Explorer, and Manager
*
- * Copyright (C) 2012, Rob Norris <rw_norris@hotmail.com>
+ * Copyright (C) 2012-2015, Rob Norris <rw_norris@hotmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static gpointer datasource_osm_my_traces_init ( acq_vik_t *avt );
static void datasource_osm_my_traces_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
-static void datasource_osm_my_traces_get_cmd_string ( gpointer user_data, gchar **args, gchar **extra, DownloadMapOptions *options );
-static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, DownloadMapOptions *options_unused );
+static void datasource_osm_my_traces_get_process_options ( gpointer user_data, ProcessOptions *po, DownloadFileOptions *options, const gchar *notused1, const gchar *notused2 );
+static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, ProcessOptions *process_options, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, DownloadFileOptions *options_unused );
static void datasource_osm_my_traces_cleanup ( gpointer data );
VikDataSourceInterface vik_datasource_osm_my_traces_interface = {
(VikDataSourceInitFunc) datasource_osm_my_traces_init,
(VikDataSourceCheckExistenceFunc) NULL,
(VikDataSourceAddSetupWidgetsFunc)datasource_osm_my_traces_add_setup_widgets,
- (VikDataSourceGetCmdStringFunc) datasource_osm_my_traces_get_cmd_string,
- (VikDataSourceProcessFunc) datasource_osm_my_traces_process,
+ (VikDataSourceGetProcessOptionsFunc) datasource_osm_my_traces_get_process_options,
+ (VikDataSourceProcessFunc) datasource_osm_my_traces_process,
(VikDataSourceProgressFunc) NULL,
(VikDataSourceAddProgressWidgetsFunc) NULL,
(VikDataSourceCleanupFunc) datasource_osm_my_traces_cleanup,
data->vvp = vvp;
}
-static void datasource_osm_my_traces_get_cmd_string ( gpointer user_data, gchar **args, gchar **extra, DownloadMapOptions *options )
+static void datasource_osm_my_traces_get_process_options ( gpointer user_data, ProcessOptions *po, DownloadFileOptions *options, const gchar *notused1, const gchar *notused2 )
{
datasource_osm_my_traces_t *data = (datasource_osm_my_traces_t*) user_data;
osm_set_login ( gtk_entry_get_text ( GTK_ENTRY(data->user_entry) ),
gtk_entry_get_text ( GTK_ENTRY(data->password_entry) ) );
- // If going to use the values passed back into the process function parameters then these need to be set.
+ // If going to use the values passed back into the process function parameters then they need to be set.
// But ATM we aren't
- *args = NULL;
- *extra = NULL;
options = NULL;
}
}
}
-static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, DownloadMapOptions *options_unused )
+static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, ProcessOptions *process_options, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, DownloadFileOptions *options_unused )
{
//datasource_osm_my_traces_t *data = (datasource_osm_my_traces_t *)adw->user_data;
gchar *user_pass = osm_get_login();
// Support .zip + bzip2 files directly
- DownloadMapOptions options = { FALSE, FALSE, NULL, 2, NULL, user_pass, a_try_decompress_file }; // Allow a couple of redirects
+ DownloadFileOptions options = { FALSE, FALSE, NULL, 2, NULL, user_pass, a_try_decompress_file }; // Allow a couple of redirects
+
+ gchar *tmpname = a_download_uri_to_tmp_file ( DS_OSM_TRACES_GPX_FILES, &options );
+ if ( !tmpname )
+ return FALSE;
xml_data *xd = g_malloc ( sizeof (xml_data) );
//xd->xpath = g_string_new ( "" );
xd->current_gpx_meta_data = new_gpx_meta_data_t();
xd->list_of_gpx_meta_data = NULL;
- gchar *tmpname = a_download_uri_to_tmp_file ( DS_OSM_TRACES_GPX_FILES, &options );
result = read_gpx_files_metadata_xml ( tmpname, xd );
// Test already downloaded metadata file: eg:
//result = read_gpx_files_metadata_xml ( "/tmp/viking-download.GI47PW", xd );
if ( tmpname ) {
- g_remove ( tmpname );
+ (void)util_remove ( tmpname );
g_free ( tmpname );
}
- if ( ! result )
+ if ( ! result ) {
+ g_free ( xd );
return FALSE;
+ }
if ( g_list_length ( xd->list_of_gpx_meta_data ) == 0 ) {
if (!vik_datasource_osm_my_traces_interface.is_thread)
none_found ( GTK_WINDOW(adw->vw) );
+ g_free ( xd );
return FALSE;
}
if ( gpx_id ) {
gchar *url = g_strdup_printf ( DS_OSM_TRACES_GPX_URL_FMT, gpx_id );
- result = a_babel_convert_from_url ( vtlX, url, "gpx", status_cb, adw, &options );
+ // NB download type is GPX (or a compressed version)
+ ProcessOptions my_po = *process_options;
+ my_po.url = url;
+ result = a_babel_convert_from ( vtlX, &my_po, status_cb, adw, &options );
// TODO investigate using a progress bar:
// http://developer.gnome.org/gtk/2.24/GtkProgressBar.html
got_something = got_something || result;
- // TODO feedback to UI to inform which traces failed
- if ( !result )
- g_warning ( _("Unable to get trace: %s"), url );
+ if ( !result ) {
+ // Report errors to the status bar
+ gchar* msg = g_strdup_printf ( _("Unable to get trace: %s"), url );
+ vik_window_statusbar_update ( adw->vw, msg, VIK_STATUSBAR_INFO );
+ g_free (msg);
+ }
g_free ( url );
}